Showing posts with label segues. Show all posts
Showing posts with label segues. Show all posts

Thursday, March 19, 2015

Delegates make me all philosophical. also shawls.

Even though I should be super frustrated, I am still super enamored with Mobile Makers. They've been giving us harder and harder projects and I'm still understanding. Which go me.

Anyways, remember how I was all like, "oh yea, segues are so easy, I am the best at them." I may have to amend that statement. I do get the general concept of them, but those paired with delegation make me a little iffy.

Delegation you ask? Yup. It's just like it sounds. It's when something makes something else do a task.... well sort of. It's actually super complicated and I'm just starting to wrap my head around. I'll probably post a clearer example once I start fully grasping it, but for now let me just give it my college try.

You have to use delegation when you are doing something in a different view  (or a different file) and want to know about it outside of that view (/file). I think it's a way to add more methods (making objects do things) that is cleaner and easier to break down. Some of the common objects we use all the time (view controller, table views, text fields) have delegates. These are already defined but generally I think of them as access to a level/power up. So with the objects 'built in' to objective c we can already do a  lot of stuff, but if we access their delegate we get to do ALL of their stuff.

Like Popeye. He is already a pretty good... sailor? Not really sure what he is. But then he eats spinach and he can do so much more stuff! Like knock people out... and other stuff. I'm not really up on my Popeye it would appear. But delegates are like spinach. We call them on a class and BOOM we can do way more.

From what I can tell, delegates are usually used when something is clicked or pushed and you want it to do something.

Phew. Right? That was all yesterday. We learned about delegates last week but yesterday we had to really learn them to build an app that basically just shows a different collection of tigers and lions when a corresponding button is clicked. WHICH IS SO MUCH HARDER THAN IT SOUNDS.

I think that's the main thing I've learned is that things that seem really easy are actually super complicated. I guess it makes sense because we think swiping to go to a new page makes sense, but we first had to learn how to see, how to make our finger move, and associate certain movements with certain results.

Think about being a baby. You didn't know anything as a baby (contrary to the movie Baby Geniuses). I was blown away a couple weeks ago when I learned that babies can't even recognize shapes until a couple months old. I mean that's why it takes so long to walk. Think about how complicated that is. But you don't even have to because your brain does it automatically.

Programming is making a brain. 

Ok.... you can tell I'm excited and into this right? So i'm going to be even nerdier right here. Because you know writing about knitting isn't nerdy enough.

I've always been fascinated by the brain. I've always been fascinated by philosophy and why things are how they are. And it turns out the programming is literally both of those.

Let me explain about the philosophy thing. (because the brain thing is explained up above sort of)

Philosophy takes abstract things and tries to make them concrete to be able to manipulate or solve problems. (I just blew my own brain writing that. I sound so deep and insightful)

Programming is wanting a computer or phone to do something. In order to do that, you have to conceptualize a lot of stuff. You have to break down the task into different actions and parts. You have to translate that into words (the programming language). And the programming language is telling the computer what ones and zeros and numbers to fire in order for it to accomplish things.

Why yes I am a little iffy on how programming languages and computers interact. However did you guess?

I realize there is no knitting here... but I am on the death marathon part of the shawl. For those of you unfamiliar with knitting, it's when you literally have a row that is 300 stitches and you have to add four stitches every other row in order to get to 400 stitches. You don't get a lot knit vertically and so your brain is like, "UGHHHH I just did one row and it took fifteen minutes and I have so many more of these".

Speaking of knitting... it might be time to switch to a sock as my portable project.

Sunday, March 15, 2015

Spring Love and what object oriented programming means

I have a confession. I thought that Mobile Makers was full of shit.

You know that saying, if it sounds too good to be true than it probably is? I thought that applied. What are the reasons I was skeptical about Mobile Makers?

1. They say, anyone can learn it (even people who haven't programmed before)
2. They say, people will want to hire you after the class if you work hard (I've been working hard my entire life and no one has jumped at the chance to hire me.)
3. They say, Mobile Makers has a network of peers and mentors that want to help you.
4. They say, Mobile Makers teaches you things that you can't learn on your own.

I don't want to sound like an advertisement for them... but I know for a fact that 3/4 of those things are true (since I haven't completed the class, I don't know if people will want to hire me).

Here is my second confession: I'm in love with Mobile Makers.

Also, I'm in love with life at the moment because it's SPRING and SUNNY.


Yes that is what I'm currently knitting. If you're patient I'll show you what I'm knitting at the end of this. and YES I am doing this class in downtown Chicago. No more suburbs for this girl, I'm an official big city person. I'm probably also loving life because I started taking anti-depressants again. Huzzah mental health.

But back to my undying love for Mobile Makers. I've spent ten hours for the past six days (well... only eight yesterday) dedicating myself to learning objective c. AND IT'S WORKING!!!

I've always known that I pick things up fast, but I didn't realize how fast I can pick things up if I can ask why things happen. One thing I've learned from the past week is that once I know the reason you do something or the reason something works... then I understand it.

Case in point. Segues. What is a Segue in objective c? GOOD QUESTION LET ME ANSWER.

(I'll try to tone it down... sorry just got excited that I TOTALLY KNOW HOW TO CODE)
(I know I just used parenthesis above but I have a funny story about the word segue. Up until a couple years ago, I spelled it segueway because I didn't realize that segue is pronounced seg-way. Thanks sister and Bekky for making me not look like an idiot! Oh english.)

A segue is a way to go from one screen to another and pass along information when you do it. Two points I'd like to make about this. First, this is the entire point of object oriented programming. Programming is basically turning computer language into words so we can modify it. Object oriented programming's strength is that you can break a complicated idea into smaller parts, create a thing or an action (method/function), and use those smaller parts to make a giant thing.

Example (because that was super vague): I want to tell a computer/robot to make a peanut butter and jelly sandwich. I could write it this way:

  1. open bread bag
  2. take two pieces of bread out of bad
  3. place slice of bread on the table
  4. open jar of peanut butter
  5. pick up knife
  6. put knife in open jar of peanut butter
  7. put peanut butter on knife
  8. take knife out of jar
  9. rub peanut butter on one side of the bread until evenly coated.
  10. put down knife
  11. open jar of raspberry jam (the best)
  12. pick up knife
  13. put knife in open jar of jam
  14. put jam on knife
  15. take knife out of jar
  16. rub jam on one side of the bread until evenly coated
  17. put down knife
  18. put the two pieces of bread together with the peanut buttered side and jam side touching each other.
That was a lot longer than you thought it would be, but not unbearable. The trouble with this comes when you want to make the ULTIMATE peanut butter and jam sandwich with multiple layers. You would have to repeat 7 steps just to tell the person to do the same thing as before (lines 4-10 are essentially the same as 11-17). And what would happen if you forgot to say to open the jar? then you'd have to go through a huge list of steps to find out where you missed something.

With objective C, you can turn an action into something that's repeatable.

I can hear your attention waning so I'll make this quick.

Instead of having one list, you would have a couple. the first list would turn the 7 lines of code into one method that you would call on whatever property(peanut butter or jam) you want.

prepare bread for sandwich:(topping added)
  1. open jar of (topping added)
  2. pick up knife
  3. put knife in jar of (topping added)
  4. put (topping added) on knife
  5. take knife out of jar of (topping added)
  6. rub (topping added) on one side of the bread.
  7. put down knife
Make Sandwich

  1. open bread bag
  2. take two pieces of bread out of bad
  3. place slice of bread on the table
  4. prepare bread for sandwich: peanut butter
  5. prepare bread for sandwich: jam
  6. put the two pieces of bread together with the peanut buttered side and jam side touching each other.
MUCH SIMPLER IN THE LONG RUN. Which is the point of coding. Yes you can do something the long way, but if you want to create something automated that does the same action over and over... why not be lazy about it?

Ok. I was going to talk about segues but that'll have to wait for tomorrow. Because it's time to figure out how to make a tic tac toe game.

PS. I'm making a shawl.