Week 5 – Mobile Engineering

Weekend Project – Spotifiron

The weekend project was creating an app that pulls data from the Spotify API, parse it into the data needed (basically specific artist and album IDs) and then using that information to display artists as the user searches by artist name in a text box at the top of the first screen.   For anyone out there thinking about saying, “Hey, I have a simple app idea…” let me sober you up to something; even simple app ideas take more than an hour to complete.   Last weekend I had a 6 screen application and I spent over 30 hours working on it.  At an hourly rate of $65 per hour, that app would cost almost $2000 to develop.  (most experienced developers charge over $100 per hour).

The assignment this weekend is a partner project.  We’re working to learn how to use Github more so that we can share the same project, work on it asynchronously, and not overwrite the work done by the other.  Github plays a massive role in keeping track of changes, and not “nuking” all the work the other has done.

Our app, so far, has two screens.  The tasks are tasks we’ve done before, but not in Swift.  The delegate methods are the same, but the syntax is different.  If you’re semi-fluent in Spanish, and I give you a newspaper article to translate for me that is in French, you’ll probably be able to do it, but it’ll take awhile.  A similar comparison exists with what we’re doing.

I don’t brag on myself much, but today I encountered an issue.  Normally I try not to bother my instructor on the weekends, but if I have an issue, I typically ask for some guidance.  I had an issue this morning.  I did text, but didn’t hear back.  So I took a couple hours off, washed my truck, went to Starbucks and tackled the issue again.  I figured it out!  Whether it was intentional or not on his part, I didn’t have to rely on my instructor to help me fix an issue (Although I did have him help with a separate non code-related issue later with Github!).   I think that is growth!  I was quite proud of myself that I faced an ambiguous problem where I wasn’t exactly sure what was wrong and managed to backtrack and walk my way through the problem….and fix it.   I even managed to add an extra feature that I had been thinking about but hadn’t exactly mapped out how to do it.

I pushed the committed code to Github up so my partner can look at it and see what I did.  He’ll tackle the same issue on the other screen later this evening and push it back to me to see if we can get it to work.  The final piece to the assignment will be to “beautify” the app and make the interface easy to the eyes and easy to use as well.

Partner projects do present challenges.  Who works on what?  When?  How do I know when they’ve made a change?  Joe, my partner, and I started by creating a list of tasks on paper and basically using a ping pong method approach.  You tackle this and then I’ll tackle that.  With the assignment relatively short, I think this tag-teaming of tasks will work.  If the project were bigger, I’m not so sure.

The other challenge is what if their part of the code doesn’t work?  Thankfully we haven’t encountered this yet.  I’m not sure how we would tackle this if it arises.

Monday – Day 21 – Separating Tasks, JSON Cleanup, & Singletons

The weekend project went quite well with few hiccups.  Joe and I used the ping-pong approach well with each taking a View Controller and working on it.  By Sunday evening, to give myself more practice parsing JSON, I added a 3rd view controller that will display the tracks for any given album chosen on the previous screen.  It wasn’t anything new compared to the other two screens, it was just more of the same.  Repetition, I’ve found though, reinforces what I’m learning.  I didn’t put in the effort on the design side of things for the screen, just making sure the data parsed and populated correctly.  After two beginner mistakes, I finished and decided my brain was done for the day.   My reward was watching the “Battle of the Bastards” episode of Game of Thrones.  It did not disappoint!

One of my biggest complaints about the parsing we’ve done in Swift is the “pyramid of doom” we create when trying to go multiple levels into the data.  Our screen looks something like this:

{ if let some code

{ if let some code

{ if let some more code

{ if let still more code to complete

{ if let still more code, nowhere near close

{ if let when will this stop?

{

if let finally to the middle, now to work our way out

} else

} else

} else

} else

} else

} else

} else

I’m really not exaggerating.  I’ve had several programs look like that.  It’s called nested conditionals.  An if statement inside of another if statement.  It’d easy to screw something up and then harder to find which nest the error lies so you can fix it. However, for the last week or so, it was all we knew.  You know that moment where you are taught a better way to do something that makes more sense, but you realize you had to do it the long way first?  That happened today.

We created functions that did some of the code.  Kept it short, clean, and accessible to the rest of the program.  The number of lines of code aren’t any less, but it’s better organized and reduces nesting by more than half.  After complaining about Swift syntax for a week, I think maybe a compromise can be reached.  I can live with it!

There was a two step process.  In the past, we’ve run all code through the ViewController.  This is the primary file we’ve played with the past few weeks.  All code went into and out of here.  Unfortunately, that meant sometimes 2oo-300 lines of code.  Today, we decided to make functions to break down the task and keep them in separate files.  One file would find and parse the information.  The other file would store the information.  By introducing this concept called a “singleton”, we can let the data be accessed by any ViewController.  Again, the amount of code hasn’t been reduced, but it’s better organized–much like my daughters’ playroom after my wife has gone in there to clean (short-lived though the organization may be).  We haven’t reduced the clutter, we’ve just put in nice, simple, easy to understand locations

I don’t know enough about Singletons to properly describe them, so that’s my nighttime reading today.  Hopefully I’ll have a better understanding tomorrow.

Tuesday – Day 22 – Writing our own Delegates

It’s late and I don’t feel like blogging.  I spent most of the afternoon trying to fix an issue with my Mac.  After reinstalling the operating system, I didn’t get started on my homework until after 8pm this evening.  It’s currently 1am and although my date doesn’t work (at least it parsed correctly), everything else works fine.

Today we created our first delegate.  Delegates assign responsibility to others in the program and allow them to use the delegate’s specific functions.  Imagine if I gave someone the key to my home and said, use what you need in the home, but make sure you use it correctly.  Technically they could use my truck, my motorcycle, my bed, my rifle, whatever.  I’ve delegated responsibility to maintain my home to them and they can use all the benefits that pertain to using my home.

We wrote a delegate that allowed us to send data from one part of the program to another. We’ve done this before, but never this way.  There are several steps to wrap my head around and I don’t have it straight yet, but I was able to re-create a delegate this evening for my homework app.  Hopefully as I do it more, I’ll understand it better.

Crossfire went really well tonight.  I  PR’ed on strict presses.  It was a tough weight intensive workout–I’ve really missed those!

I’m off to bed…hopefully.  I imagine I’ll stew for awhile trying to figure out that date format issue.

Wednesday – Day 23

Today we learned about creating & customizing alert messages in Swift.  These message pop-up on your phone to either ask you what you want to do, or inform you that something is not valid.

IMG_0044
Alert Messages

While this isn’t a glamorous part of programming, it did help to solidify some concepts we’ve learned about UITableViews, specifically adding some user functionality when they select a restaurant or movie from a list.

I want to take a line of code that I used and explain it as I didn’t really understand what was going on when I wrote/copied it.

var restaurantIsVisted = [Bool](count: 21, repeatedValue: false)

This is an array(list) of Boolean values.  Boolean means True or False.  In this line of code, I’ve declared 21 items to go in the list and all of them are set to False.  It is a shorthand method of writing this:

var restaurantIsVisited = [false, false, false, false, false, false, false,
false, false, false, false, false, false, false, false, false, false, false,
false, false, false]

What this allows me to do is go ahead and set the values to false. In my case, I had a list of restaurants.  I have an option of selecting that restaurant and marking it as whether I’ve visited it before.  If I mark it as visited, a check mark is placed and the position of that item is the array I created above is changed from false to true.  The reason for this is beyond what any of y’all want to hear so just trust me that this piece of code, while by itself is not all that useful, is incredibly useful within the scope of my project.

We also explored the concept of closures.  I admit, this isn’t something that is clicking with me.  I’ve written a couple but they are pretty much replicas of what Phil has written and I’m trusting it will work for me.  My hope is that the more I do them, the more they’ll make sense.

CrossFit went well tonight.  I performed my first ever Toes to Bar…which is exactly what it sounds like.  Hang from a bar, and raise your lower body up and touch the bar with your toes.  It’s a pretty big accomplishment for me and one movement that I’ve been trying for for awhile.

Thursday, Day 24 – WeatherWasp

Today I’m flying home for the weekend.  I haven’t seen my family in 5 weeks.  As such, concentration is hard to come by today.  Still, our weekend project starts and there are quite a few pieces to it, so I’ve done my diligence and made sure that I was able to ask the necessary questions I had and outlined a path to follow to get the project complete.  We’re building a weather app that ask the user to type in their zip code.  We then convert, behind the scenes, the zip code to latitude and longitude which we can then use to pull weather-related JSON data from the web.  It’s an intriguing project–a lot of new concepts, and almost all the old ones.  I like it! (Of course, I say this at the beginning of the project.  I may feel differently by Sunday evening.)

Friday, Day 25 – Back in Georgia

Travel via Frontier Airlines was not enjoyable.  They were cheaper by about $200 from any other carrier, but they certainly did not make my trip pleasant and stress free.  Our flight was supposed to leave at 6:10pm (Mountain Time) and arrive at 11:50pm (Eastern Time).  I booked a Groome bus trip back to Athens–the last one of the day that departed at 12:40 am.  50 minutes is plenty of time to de-board the plane and walk the miles of terminal that is Hartsfield-Jackson Int’l Airport.  Frontier, apparently, had problems and we did not leave until 7pm.  We encountered some weather in Denver and Kansas which made the ride bumpy, but we landed in Atlanta at 12:15am.  Okay, I’m starting to panic as I know the next Groome shuttle after the 12:40am is 5:40am.  I’m thinking if we get to the terminal and I’m off the plane by 12:30 I should make it.  I called Groome and they said they could hold the bus for 5 minutes.  Well, we were so late that our gate already had someone else in it and we couldn’t do anything until they left.  I got off the plane at 12:41.  I called Groome as I’m running through the airport and the lady was nice enough to check with the driver.  He relayed to me that if  could get there by 12:55, I’d still have a ride.  I walked off in the D terminal.  I had roughly 2 miles of terminal to get through and then through baggage claim to get to the bus in time.  Long story short, I made it to baggage with 3 minutes left and sprinted the 1/4 mile from one end to the other.  He was closing the doors to the van as I arrived.  I made it back home at 2am.

Today was spent doing nothing code-related until this evening.  Breakfast at Waffle House with the family, running errands, and getting to spend time with them.  It was exactly what I needed after 5 weeks of coding and basically spending most of the time alone.  I do feel for my fellow classmates that have families and are going through this.  Families are not a burden, they’re enjoyable and I love spending time with them.  However, it is exceedingly difficult to motivate myself to work when I know my wife and daughters are downstairs and would love nothing more than for me to spend time with them.  I appreciate the solitude a little more now because it makes it easier for me to focus on coding.  It is now 11pm and I’ve spent the last hour working on my project.  After weeks of living and breathing most every waking minute of the day in code, 1 hour of work is laughable.

Tomorrow will be spent at Starbucks so I can focus and work during the morning and early afternoon.  Given my outline and schedule for the outline, that should get me close to finished.  Tomorrow evening will be spent at the pool before I head out Sunday morning back to Salt Lake City.  Even if I’m 90% done by Sunday, I’ll arrive back in Utah in late afternoon and can easily spend the evening finalizing the project.  I’m certainly not off track or behind by any means, but it feels strange to spend a whole day doing stuff other than code–almost like I’m being lazy.

Nevertheless, I’m home.  My family is happy.  My dog, Ben, is beyond happy & I’ve spent a relaxing day doing what we were meant to do–be with family.

Advertisements

Week 4 – Mobile Engineering

#fiyf

Monday – Day 16 – Moving from Objective-C to Swift

For the past three weeks, we’ve been using Objective-C to code our apps.  It’s an odd language.  However, I’ve really taken to it.  It’s long, clunky, and confusing, but it has made me slow down and focus on what my task is, ask myself questions about what this piece of code is going to do, and generally made me a better problem solver.  Granted, i could never have learned any of this without Phil guiding us along.  One look at the documentation, even now, and I leave more confused than before.  But for what we’ve been shown how to do, I think I’ve learned a great deal.

I was trying to come up with a decent comparison for the migration to Swift from Objective-C.  I have two.  Objective-C is like that really heavy coat you wear. It’s big, it’s warm, it can hold a lot of stuff, and all the stuff is useful….if needed.  However, much of the time, it’s not alway necessary and weighs you down. Swift is light, fast, streamlined, and very easy to read.  I do wonder if that easier to read might prove to make it harder to understand.  That may not make sense when writing it, but given my growth as a problem solver the last 3 weeks, it makes sense to me.

The other is likening Objective-C to an old Volvo station wagon.  It performs admirably, does the job, is reliable, and perfectly functional–but it’s old.  Swift is the new, sexier, sports sedan that is fun to drive, has some new features that makes learning syntax easier, and will serve well in the future.  Right now, as Apple is slowly phasing Objective-C out, they’re having to share the road together.

volvo-240-20
I kind of like the old boxy cars.

I completed 98% of my weekend project.  There was one task I couldn’t get to work.  3 lines of code fixed this issue (2 of which I would probably have never figured out!).  I was the only one of the group to accomplish this much over the weekend.  I’m glad I was able to complete almost all of the assignment.  At the same time, I hate that the other guys struggled so much.  Three of us were at the school together on Saturday and I thought when we left we were all at about the same place.  While I miss my family terribly (and I do mean terribly.  I’m quite homesick and lonely.), I appreciate that I am free from the distractions to focus solely on code.  I spent all day Saturday & more time on Sunday at the school working on my project.   It was a long weekend, and a long project.  I think at last estimate I had over 500 lines of code.

Which  leads me to dispel some of the ideas about coding.  Regardless of what you see in the movies, nobody is typing nonstop for 9 straight hours.  In reality, I have a list of about 20 tasks.  I’ll tackle the first one.  Type in a few lines of code, test it, debug it, spend 20 minutes trying to figure out what went wrong and exactly how I fixed it, and then move onto the next task.  Some tasks take me minutes.  Others take days.   In my weekend project I had 6 major tasks.  I did the first 3 in about 45 minutes.  I spent the next 48 hours working on task 4 & 5.  Task 6 took an hour.  The actual typing of code was probably 25% of the time.  The other 75% was spent sketching out smaller steps, reading documentation to see how to do those steps, going back and refining my list of smaller steps, looking at sample programs that used some of the code I intend to use to make sure I understand both the differences between their project and mine and refining my list again based on what I’ve learned about the sample app.  Only then will I start typing in code–and still, its a few lines at a time.  This program has really taught me to slow down and break my project up into really small tasks.  The old adage about how to eat an elephant really is true.

While everyone else was refining their weekend projects, I spent the time today watching the Worldwide Developers Conference that Apple held.  For a developer, this is a big deal.  Everyone gets excited in the Fall when Apple releases new products, but for us, in June, the new developer tools are released in beta for us to play with and give feedback for.  It was 2 hours long and was chock full of developer goodness.  Regardless of your opinion on Apple products, they are really thoughtful about the developer tools they pass out.

The afternoon was spent taking our very first app we wrote 3 weeks ago in Objective-C and redoing it in Swift.  I admit I stumbled here and there.  After using big clunky code, I struggled transitioning to more Python-style code with Swift.  I left school with the program working, but not working correctly.  I fixed it in about 5 minutes after I got home from CrossFit.  Breaks are good!  The evening has been spent reading up on Swift as we transition.  Phil gifted each of us with a Swift Developer’s book on iBooks.  It’s a great beginner guide to Swift.

I look forward to another week of programming, even if I am going to have to take off the big coat of Objective-C.  I hope my transition to Swift is….well….swift.

Tuesday – Day 17 – Optionals, Delegates, Protocols, Properties

I already know that I’m going to mess up the definitions of those four items.  I also know that Optionals are going to frustrate me for several weeks until I learn to eventually accept them.  Delegates are actually coming together for me well.  However, I use protocols, properties, methods, and functions interchangeably and they’re not interchangeable.  I’m working on trying to keep it all together.

Optionals, though, are the computer science equivalent to Schrödinger’s Cat.  I create a variable.  That variable may hold a value such as an integer, a string, an image, a dictionary, etc…. Or it may hold nothing, known as nil in programming parlance.  Think of nil as a really pretty Christmas present.  You open it up, and it’s empty.  That’s nil.

The problem though is that Xcode, and eventually your iDevice, doesn’t know if there is a value in the box.  It could have one, or it couldn’t.  We won’t know until our program tries to “unwrap the box” to see what’s inside.  Optionals check to see if a value exists, and if it’s of the correct type before it completely unwraps the present.  It’s similar to an if statement that says “hey, if there is a value in here and it’s the right value, run the code.  If there isn’t a value or it’s not the right type, do nothing, but don’t let the program crash.”  It’s a safety mechanism.

I understand all this.  Swift is basically converting it’s code to Objective-C and then to the compiler.  Sometimes when casting an entire code over to another there is bound to be some bugs.  My issue is that I can’t figure out when to use them and where to put the correct symbol that says, “Hey this is an optional.  Check it out.”  Earlier today I created a variable.  It had the value I wanted.  However, Xcode kept giving me an error saying it was an optional.  Why?  I had a value there.  I had the value I wanted!  Run my damn code!

Ever the sage, Phil told me, “You’re going to have to get used to it.  You can kick and scream and fight it, but it will still be there.”   I’ve decide to kick and scream this week to get it out of my system.  Next week I’ll grow back up.

As I said yesterday, we’ve started using Swift.  Part of our learning is take existing apps we created in Objective-C and see if we can replicate it in Swift.  Today we took our very first weekend project (a project that took me two days to complete) and recreated it in about 4 hours.  The four of us decided to tackle it together since Swift is unfamiliar to all of us.  As it happens, my programming teacher background took over and I went to the front of the room and hooked my laptop up to the projector.  They were curious as to how I would attack the problem, so I broke down my steps.

  1. write a list of steps the program is supposed to do
  2. break those steps into smaller steps (no more than 4 outlined steps per task is my goal)
  3. Look at my old project to see how I began
  4. Look at the Apple documentation to see the code that was used in Objective-C and see if it has a Swift counterpart
  5. Test out the code and see what happens.

That’s it.  I don’t have a magic formula for success, I just break things down and start at the beginning.  Once I got a few steps under my belt, my confidence increases and the project starts to develop faster.

During this time, the other three had questions so I slowed down my process and told them what I wanted to do.  I showed them my Objective-C code for the task and asked if they could reproduce it in Swift without watching me do it.  My functions were small and contained maybe 4-5 tasks, so it wasn’t terribly long or confusing.

My next step, to make sure they understood what they and I did, was have them tell me what each line was doing.  This is something I started doing when teaching myself Python several years ago.  I spoke out loud and talked my way through each line to see how it was connected.  I still do this.  It helps me process everything.  Confidence grows when you can look at a line of code and say aloud exactly what it is doing or supposed to do.  By the end of the day, the app was finished and the tasks I had outlined went much faster for all of us.

I’m not doing so well at CrossFit the past couple days.  I’m trying to figure out why.  My only explanation may be that our WODs have been 40+ minutes long each day.  We had a couple more long WODs last week.  Back home, I’m generally used to the first 30 minutes being strength training (weights) and the last 30 minutes prep and ready for a WOD that lasts up to 20 minutes but usually 12 or 15.  I’m good at pacing myself for those, I am not that good at pacing myself for the longer ones.  I’ve started slowing way down to the point I think I’m frustrating the coach.  She wants me to move faster.  I don’t know my pace for a longer WOD and don’t want to pass out, so I’m being cautious.  It’s frustrating for all parties involved.  I usually take Wednesday off, but I’m going back tomorrow to battle through it.

Wednesday, Day 18 – Parsing JSON in Swift

After the relatively small assignment for yesterday, Wednesday is fast becoming overload day!  Not that it’s a bad thing.  Monday is starting to feel like a recap of the week before, Tuesday adding some new features and Wednesday is the bridge between what we can do and what we will be learning to do.  Tonight we had three separate assignments.  The first one was building custom table view cells (which was part of our weekend assignment).  It took a few Star Wars characters and a poster of each character and populate it into a list.  Pretty straight forward and it took me about 90 minutes to complete.  The goal of the app was to make sure out Views worked correctly, were linked up in the Controller correctly, and have a simple, finished product to see what it should look like.

The problem with this is that I must fill in all the data and import images.  6 characters and their images doesn’t take too much time, but if it were say, 1000 images and characters, the app would run slow (or more likely crash). The solution is to pull information from the web and let those files sit elsewhere and allow me to use them.

The trick with this is that in order to display a movie title, Swift needs it in string format.  My title or average movie rating may be an integer.  I need to change the type.  Sometimes this is easy, other times not.

Today I couldn’t get my data to parse.  My code looked right, everything was connected correctly, or so I thought.  I forgot to assign the correct Controller to the storyboard (app screen).  Once it’s fixed, it worked like a charm.

I’m really struggling embracing the syntax of Swift.  This notion of optionals is supposed to safeguard us.  All I’ve seen thus far is that it requires me to write if let statement after if let statement, nested inside each other.  It makes following the steps necessary to make my table views load exceedingly difficult.  I know what is required, but having to start and stop so often makes me lose my train of thought.  Despite getting my project completed, I’m stumbling more over the tasks.

Thursday, Day 19 – Spotify and Parsing

Today was a pretty intense day of lecture.  So far my apps have worked,  but any time they had to load images, it was slow to load.    Part of the morning lecture was on threading.  Threading is where processing happens.  There is the primary thread, known as the main thread, and secondary threads.  If the primary thread is overloaded, it slows down.  Various tasks are sent to secondary threads to take the load off the main thread.  When this happens, as long as those secondary threads know when to send the information back, the app runs much faster and loads data faster.   I still haven’t worked out everything in code, but the logic makes sense.

We spent most of the day making sure we could parse data from the internet.  We’ve done this before in Objective-C and it made sense to me after a couple attempts.  Swift is not clicking as well.  The notion of optionals just makes it more challenging for me to see the linkages.  When something is nested seven or eight times it makes keeping track of all the opening and closing braces nearly impossible.  I used sample code from today’s lecture to help me with tonight’s homework but I don’t know if I could follow it.   I keep hoping for a better way, but right now, this slow, brute-force method is taking a toll on my patience.  When it comes to apps, everything is driven by data so I have to learn how to do this, but I’m quite slow at it right now.

Tonight’s app I couldn’t complete.  I’m not sure what the problem is.  I have no bugs in my code.  I don’t know where to place my parsing function, and my text field is not grabbing the data I need.  It’s maddening to get 95% of the project done and not have a clue how to fix the final 5% (especially when you’ve used those methods before…and they worked before).  Normally I’d keep trying to power through, but mind and body are tired.  I know there is a solution so I’m going to hope for inspiration in the morning.

CrossFit went well tonight.  It was a different coach, more laid-back, more my style.  I enjoyed the break from code and left feeling recharged from the physical demands.  Of course, that was four hours ago, my batteries are now empty.  Tomorrow will be spent trying to figure what I did wrong tonight, plus adding to the project.  It’s a big one.  Hopefully I won’t dream about parsing tonight!

Friday – Day 20 – Delegates, Epiphanies, & Remembering Code

Several times during this course, Phil has talked about waking up in the middle of the night with an idea of how to solve a problem.  A moment of epiphany.  That happened to me last night.  2:30am I bolt up out of bed from a dead sleep because I realized that there was something I needed to do to get my app working.  I opened my laptop, double-checked the change I wanted to make with another program I had written that had used something similar, made the change…..AND……….nothing happened.

Frustrated, I tossed and turned and eventually got back to sleep thinking my program wasn’t anywhere near being done, and really upset about turning in an incomplete assignment.

As it turns out, i was really close.  One more function call would have fixed the entire program.  I didn’t know about the function call and Phil purposely didn’t tell us about it–for a very specific reason.  By letting us spend an evening not getting something to work, and then showing us the next morning how close we are, we’d never forget that method.  He’s right.  It happened earlier this month with UIImages vs UIImageViews for me.  I’ve never forgotten it.  I’ve also never forgotten not having the correct ViewController hooked up to my Storyboard object.  That was a mistake I made a couple weeks ago.

I probably would not have found the function on my own.  Now that I know how close I was, I’ll certainly remember how to better self diagnose what I need the program to do.

Despite all my complaints about parsing, I did get that function to work correctly.  I’m going to complain about it for one more day, and then begin this process of acceptance.  Contempt does not breed good coding habits

This morning, we had a guest speaker, Mark Anthony, come talk to us about branding and using LinkedIn to leverage ourselves when we graduate.  He was enthusiastic and really passionate about helping us get our dev careers started.  If there is one thing I struggle with (and there is more than one), its selling myself.  I don’t want to feel like an imposter when I write that I’m an iOS developer.  I don’t want to fully endorse myself unless I feel like I’m truly good at it.

Mark said that I may not be an expert, but I am coding apps, creating more advanced apps, and will continue to make even more complicated apps.  “You are a developer. Embrace it.  Grow with it.”   I’ll work on that.

Our weekend project is in full swing.  We’re building an app that pulls artist and album data from Spotify’s API.  However, instead of us picking the artist ahead of time like we did a couple weeks ago, we’ve created a text field that allows the user to type in a name and the program pulls all the artists with that name.  Afterwards, they can click on the artist and bring up all their album data.  The functionality of the app isn’t the most important point of the app, it’s being able to gather data, sift it for what we need and then send it to the Storyboard for the user to interact with.  Data drives the app.

The weekend will be spent getting the rest of the data parsed.  We’re now moving into external storyboarding.  Our apps are complex enough that we need sketch out the layout and interface on paper versions of an iOS screen before we try to do it on the computer.

As I realize today marks the 1/3 way through the program, I no longer have the fear of “Can I do this?” any more.  I’ve been coding apps for 4 weeks.  Now my focus is “Can I learn enough?”.  I’m certainly working at it.  Outside of my hourly CrossFit workouts and an episode of Game of Thrones here or there (I’m finally caught up!), I spend as much time as possible in code, reading other code, or look at documentation.  Full immersion, to me, is the way to go.  Dive in and get going.

Tomorrow will be spent coding, parsing, and beautifying our app.

Week 3 – Mobile Engineering

#fiyf

Monday – Day 11 – Parsing JSON data, UITableViews, Epic Pong

My wife came out to visit me on Friday afternoon. She’s staying through Thursday. (Our kids are with my sister at Disney World.  Bless her heart.)  We tried to see as much of Southern Idaho, Northern Nevada, and some of Northwestern Utah over the weekend–all while making sure my weekend project was completed.  Mission accomplished!

This morning was a review of the project and an explanation as to why our apps are taking awhile to load.  Patience grasshopper–you’ll learn a better way soon.  In Phil I trust.

Over the weekend we were given a function that allowed us to extract data from a JSON file.  JSON stands for JavaScript Object Notation.  It is basically large quantities of data in string format (a string is anything inside quotation marks) all set inside of dictionaries, or lists (aka arrays), or both.  You can have a dictionary with a list inside and inside that list another dictionary.  The idea is that by parsing, you can take the pertinent data you need from the file and use it in your app.  Over the weekend, we took information about popular movies at the end of 2015, complete with title of movie and an image of the respective movie poster.  Our task was to put this into a table where each movie sat next to its corresponding poster.  Out of graciousness or pity (I’m not sure which!), Phil, our instructor, wrote a method (aka function) that did that work for us.  It’s a long method involving all manner of dictionaries, arrays, loops, conditionals, and appending.  All we had to do was fill in the necessary parameters to grab the data and voila!, we have our information.

Guess what we got to do today?!

We went over the function in detail, going over the steps so we could then learn to build a similar one.  Our assignment tonight was not only replicate the function, tailored to our needs, but to create our own JSON file for the function to use.   I divided the function into two sections.

Aside from the mental gymnastics today, lunch time held an epic ping pong battle.  Doubles.  Garret, our campus director, and I were once team.  Mike, the JavaScript instructor, and Taylor, a fellow classmate, the other.   We went down early in the first game, but battled back from being down in both the second and third to earn the victory.  Emotions ran high, barbs were traded, and a curse word or two may have escaped our lips.  It was a great lunch time release!  I think more offices should have ping pong tables!

Tonight has been spent, not only replicating, but understanding all the steps necessary.  It is long, slow, and methodical.  It’s also a must if I’m to be any sort of competent developer!

CrossFit was a saving grace for me.  I missed Friday, ate whatever I wanted over the weekend, and generally felt sluggish today.  Split jerks, deadlifts, wall balls, kettle bell swings, box jumps, and pull ups will rid that feeling in a hurry.  At CrossFit Sandy, this workout is a once per month performance check up to see your progression.  I completed 102 reps in 12 minutes–scaled.   My goal for next month is to do 150.  Anyway, I needed the physical exertion to let my mind wander in and out of code as I process the day.  Tonight’s physical exhaustion feels great!

Tuesday – Day 12 – JSON, Spotify JSON, HARD mode, and a lonely Dane

Today was spent parsing data.  Rather than make up data again like yesterday, where parsing was rather straightforward, we went to Spotify’s developer site to pull some data from their hundreds of thousands of records.  Parsing data is not mind-blowingly difficult.  However, it does take a keen eye for detail and, for me, developing a rough scratch road map for me to follow as I search the levels upon levels  of mostly superfluous data to extract only what I need for my app.  Sketching out on a sheet of paper only the braces ( { } ) and brackets ( [ ] ) helps me so that I see only the levels, and not so much the data.

From there it was a matter of writing a parsing method in Objective-C to take the one big dictionary of information, and separate into smaller dictionaries and arrays as the levels dictate. We were given the option of picking an artist and finding all the albums by that artist to display in our app.  If we were feeling up to it, we could tackle HARD mode–a more rigorous version of the homework assignment where the albums artwork was displayed next to the album title in our tableView.  Feeling pretty confident, I decided to tackle HARD mode.   My artist of choice: Sturgill Simpson.  Here is one of my favorite songs of his:

With a rough roadmap, I quickly ran into trouble.  There are three images inside of a dictionary.  How do I tell Objective-C to use the correct size?  I consulted with my instructor, Phil, throughout the day and hashed out a roadmap to follow.   I didn’t complete hard mode on my own, as I had a fair amount of help, but I tackled it, asked questions, used what resources I had, and finished it.  I think that’s probably what being a programmer is truly about.  No man is an island.

sturgill
My completed app…we’ll deal with repeating information later this week…

I left school to run some errands and received a phone call from a close friend of the family.  Her daughter is taking care of our dogs while my wife is visiting me and my daughters are in Florida for the week with my sister.  Ben, my 160 lb Great Dane, is bored…and lonely.  He’s gone through the house at night and opened all the doors, opened filing cabinet drawers, rifled through the recycling bin, somehow got the attic door open, which in turn, allowed our smaller dog to run across the sheetrock and create some rather large holes in the ceiling below (our garage).  Today, he apparently chewed up a door knob.   So much so that it is broken and the back door must be locked by deadbolt only.  I love that dog to death, so I can’ be mad, but I also understand he’s confused.  He’s a rescue dog who had 3 previous owners.  This is our first time away from him for more than one night.  He’s just looking for his family.  Libby leaves on Thursday and the girls are back this weekend, so he’ll be reunited soon.   If you’ve never had a Great Dane, they’re comical–without trying to be.  They don’t know their size, and they’re easily embarrassed.  He just makes me laugh.

13350335_1797451580489052_3744449701495808746_o
Ben, my 160 lb. Great Dane

CrossFit went well tonight.  I think the thrusters I did tonight may be the first since the end of March.  I could mention 16.5 of the CrossFit open, but those that did it would run away screaming and possibly damage their computers trying to flee the memories of that awful workout.  Some thing just scar a person for life.

Wednesday – Day 13 – MapKit & CoreLocation

I created a new rule for our lunch time ping pong battles.  If you break a paddle, you buy two new ones.   I broke a paddle last week.  I’d been playing with it for several days, which only made it worse.  So yesterday I finally went and replaced the paddle.  I bought an extra because I may very well break another one.  I don’t have a temper, unless its competitive games.  I got carried away with how bad I am at ping pong last week, hence the broken paddle.

Today we began exploring the concept of CoreLocation & MapKit.  I’ve been excited about this one for awhile.  Using GPS, for some reason, just fascinates me.  I will say that by this evening, I’m starting to understand the relationship of delegates for framework properties a little more, but I am really going to have to dive deeper into MapKit to get it.  It’s just not clicking like some of the other concepts have.

Today is my wife’s last day here before she heads back to Athens, GA so I completed the necessary requirements for the homework but didn’t put as much effort into it as I have some other projects.  Instead we took a mountain drive through Big Cottonwood Canyon and ended up in Park City, Utah.  We enjoyed a quiet, leisurely dinner and drove back to the house I’m staying at.  I took tonight off from CrossFit so maybe my brain needs a night off too.

Thursday – Day 14 

Today began our weekend project.  It is massive!  Part of it requires us to create our own JSON data and then parse it.  Given the size and scope, the four of us decided to share one JSON data file that we all created.  As a former economics teacher, I’m all for division of labor.

We attended a lunch meeting at the Salt Mine, a collaborative workspace for tech startups. Among free brisket sandwiches and tacos, Tesla was there to discuss trends in the tech industry as well as show off their current models of cars.  I didn’t have time to ride in one, but I did get to look.  Nice, elegant, but still, I prefer my truck.

I am slowly beginning to understand the nuances of the Apple Development Library.  Objects, functions, properties, delegates–all have special do’s and don’t’s.  I am trying to learn how to use all of them on my own.  Being such a massive library, it is slow going.  I may not know when to use them, but I am beginning to understand how to use them.  Progress!

Tonight at CrossFit was a partner WOD.  We split the workout in half and only one can work at a time.  There were only two of us so finding a partner was easy.  The WOD wasn’t. Calorie row, toes to bar, hang cleans, and push presses.  75 for each round.   We finished in just under 22 minutes.

Having had to get my wife to airport at 5:30 this morning to fly back to Atlanta, I’m not doing any more work tonight.  It’s 8:15 and I’m off to bed.

Friday – Day 15

I have finished 25% of the program.  It has flown by!  It is easy to dwell on what I can’t do, but looking back, I’ve learned a ton of code, in a language I didn’t know before.  We’ve basically created an app a day for the past 14 days.  I look at the first app we created and am amazed at how I struggled with it.  Now, it looks so easy!

Today, a recruiter from Robert Half came by to discuss the role of recruiters in the tech industry.  Basically, we are not at an experience level where we will be hunted by recruiters, but he said after about a year, expect lots of calls.  He had some good information and brought doughnuts.  A warm doughnut is a comforting experience.   Being out of my element for the past few weeks, it was glorious.  A few moments where I forgot how isolated I am.

The remainder of the day was spent creating and parsing JSON data.  At 5pm, I had almost all of it working.  There is a bug somewhere in my code but I was too tired to figure it out.  The rest of the data parsed correctly, so I’ll have a look in the morning.  Oh, and there were several ping-pong battles throughout the day to break up the hours spent staring at a screen.

We are probably finishing up with Objective-C this week and moving on into Swift, the new Apple language.  Everyone seems excited about it. I guess I’m feeling somewhat nostalgic about Obj-C though.  I know it’s on its way out, but I’ve enjoyed trying to decipher the syntax.  Fortunately, we are told that our first jobs as developers will probably be to maintain an existing app, most likely written in Objective-C, so I’ll see it again.

I think most of us are coming up to school tomorrow to work on the project, so I’m taking this evening off.  After a long  weekend of driving last weekend and not sleeping enough this weekend, I’m going to enjoy myself, watch Game of Thrones, and sleep in.  Tomorrow will be a long workday.

 

Week 2 – Mobile Engineering

#fiyf

Monday – Day 6 –  no class, Memorial Day

I spent the day hiking.

Tuesday – Day 7 – Table Views

Today was an introduction to delegates, Table Views and more Objective-C.  I’m not actually memorizing a ton of code.  Rather I’m learning how to use already written code effectively to make the app do what I want.  Apple has done a wonderful job creating functions and classes that could be useful to us, but the documentation is enormous.  Reading through is daunting.  I do add my own code here and there, and I’m certain that I’ll add more as we progress through the class, but for now, I’m learning how to use existing code and get an idea of what good, clean code should look like and how to create references and pointers  to the objects I create.

Table views remind me of Excel spreadsheets.  A cell exists, and more can be added as needed.  A good example of an app that uses table views (and most of them do) is Instagram.  Each picture on your Instagram feed is a cell.  In the cell exists the picture as well as buttons to like, respond to the user you’re following, or share the picture with someone else.  All in one cell.  You can scroll through the cells to see time-stamped pictures from the people you follow.  Creating one has quite a few steps, especially if you want to interact with the table.  Our app today consisted of doing that.  I’ve gone through the code several times and made a lot of notes.  I’m starting to see how it relates, but if asked to recreate it right now, I’m not sure I could.  I just need practice.

I realized today that right now, I’m copying someone else’s code.  For a long time, this would have bothered me, but I’m an infant programmer.  My task right now is to mimic what more mature programmers are doing so I can “grow up” to be one–learn best practices.  So rather than spending the class time trying to decipher the code, I’ve decided to copy what we’re shown, trust the code works, and then go back at night to sift my way through understanding it.  “Okay.  We used this method today.  Why?  What did it do?  Why do we use it?  Where might I need to use it again?  How do I correctly call it? ”  These are the questions I’m asking myself at night.  For the most part I am understanding it.  I just need to re-use the code more to remember all the steps involved.

CrossFit was a nice surprise tonight.  We did snatches.  It’s not a movement I particularly enjoy, but Lindsey, my CrossFit coach back home loves them, so we do them quite often.  Apparently more than the CrossFit box here.  I was complimented several times on my technique.  After spending the first week feeling like I didn’t fit in (which isn’t true. I’m just new), it felt good to do something well.  I’m still sucking down water as much as I can, but at least breathing isn’t a problem.

Despite all the knowledge I’m digesting, I truly enjoy class and my classmates.  We’ve settled into a nice  rapport and are beginning to joke around with each other…and help each other..which probably builds the camaraderie faster.  Anyway, I look forward to another day.

Wednesday – Day 8 – TableViews and TableViewControllers

Today is a long day.  I’m taking a break from working on the app because I’ve been at it for 4 straight hours, and roughly 9 total.  Today was a continuation of yesterday regarding TableViews in Xcode but we also added TableViewControllers to the mix.  The upside to TVC is many of the methods and constraints are already done for you, so there is less to mess up with some of the code already there.  The downside is that ViewControllers can be painfully tricky and you can mess them up easily if you’re not careful.  TVC also doesn’t allow much customization as working with a normal TableView.  Being a newbie, I’m not particularly worried about that part.

Objective-C methods are not easy to read.  For example, this little gem.

-(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component

That’s just the method name and accompanying parameters/arguments.  I haven’t included the body of it that tells it what to do when its run.

Because of this, reading documentation is difficult and slow.  The examples from class help, stackoverflow.com helps, sometimes the Apple documentation helps, but the resources are all over the place, so it takes time to find the right one, read through it, try out the code, pray it works, curse when it doesn’t, and then breathe and try again.  I’m certain this app could probably be completed in about an hour by someone more experienced.   Which gives me a goal; to be more experienced than I am now!

My biggest gripe of tonight is that I couldn’t write a loop to do what I wanted.  In Python, for-loops are dead simple–regardless of data type.  Objective-C?  Not so much.  I needed a list (array) of 53 numbers.  I tried write a loop that would count up to 53 and add the number to the array.  Unfortunately, the array has to be a string data type and my counter variable is an integer.  Try as I might, i could not successfully cast it to the necessary data type.  In the end, it wasn’t worth spending hours on, so I just typed out the 53 numbers necessary to get my spinning wheel to work.

Truthfully, I’m probably 85-90% done with the project.  The last few details are tricky and I want to take it slow as I pass data from one view controller to another and then use that data.

The app assignment prevented me from going to CrossFit, but I couldn’t gauge how long it would take me, so I opted to stay home and work.  I believe it was the smarter decision.  I’ll be back tomorrow!

For now, it’s back in to the code.  Once more into the breach…!

Thursday – Day 9 – TableViews, ImageViews

It finally happened.  I had to leave a project unfinished.  Tonight’s project wasn’t entirely difficult.  It was some new material but I encountered the same issue as the previous night.  I flew through most of it, and then the last task, passing an image from one screen (aka ViewController) to another screen.  I had the code on the first file seemingly working correctly.  However, when I ran the app, the image on the first screen did not appear on the second screen.  I fiddled with this for two hours and couldn’t get it to work.  That feeling of inadequacy begin creeping up so I shut down the computer, turned on “Deadpool”, and tried to suppress the OCD side of me that hates leaving something unfinished when I know the deadline is soon.

Class spent most of the day making sure we have TableViews, PickerViews (grrrrr….) and Image Views down.  The code on all three is very similar.  Each have, at minimum, three functions that must be called to work properly. Individually, I was baffled, but after seeing and using all three, the pattern is starting to make sense.  I will say that if not for sites like StackOverflow, I’d be lost.  I look at the Apple Documentation and they go into great detail on what the functions do, but I wouldn’t have known to use those three specific ones just off the documentation.   I do hope it gets easier to decipher what is needed and what isn’t. When I see tutorials, I can’t help but wonder, how did these guys figure this out?!

We did a hero WOD at CrossFit tonight.  Hero WODs are special, incredibly difficult WODs to honor soldiers who heroically passed in battle.  The most famous, Murph, is performed every Memorial Day in memory of Michael Murphy.  If you saw Lone Survivor, he was part of that group.  I wasn’t able to do Murph on Monday, but I did “Nate” last night.  Even modified, it was intense.  After missing Wednesday night’s workout, it felt good to get the physical exercise necessary to battle the mental exercise I’m receiving all day long.

Friday – Day 10 – ImageViews, Parsing & Loading JSON files

Today I learned the difference between trying to pass storyboard objects versus trying to pass data.  All of my difficulties from last night were the result of mixing these two up.  My code ran, did not produce any errors, but my second screen was blank.  Turns out I wasn’t sending the image to the second screen, I was sending the box that held the image.  The box is just a place holder.  It’s empty.  I’d liken it to getting a bunch of film developed and all you get back is the yellow envelope that holds the pictures.  Fortunately, my instructor, Phil, knew exactly what my mistake was (without even looking at it!) and made a suggestion.  Voila.  Worked like a charm.  Passing data is a concept that has taken me longer to grasp than some of the other things I’ve done here.  Fortunately, I’m persistent and Phil has promised us plenty of practice over the coming weeks!

The morning ended with a guest speaker.  Justin is a TIY graduate in Houston who just happens to have moved back to SLC.  He came to talk about the job hunting process after graduation as well as tips and tricks we may want to implement to make our hunt more successful.

Lunch was an epic ping-pong battle between Jason, a fellow classmate, and myself.  Jason is good.  Quite good.  He beat me 4 games to 0, and has all week.  However, I’ve started scoring a few more points than before, so I’d say that’s progress.   Both of us relish these battles as it takes our minds off code for a few precious moments and allows us to get out of our respective heads.

I spent the afternoon beginning the homework project.  We are parsing JSON files to have data to load into our app.  JSON is universal for allowing apps and websites to access data of all types.  In our case, popular movies and their respective posters will be loaded into a table and allow the user to click on the cell to access more information about the movie.  It is a culmination of all we have learned about UITableViews, UITableViewControllers, passing data between View Controllers, and now, using other people’s data.  I wanted to get a head start because my wife arrived Friday afternoon to visit for the next few days.  We are getting out of town and enjoying our weekend together so I wanted to make as much progress on the app as possible so I can enjoy the weekend.

Addendum

Below are some of the sites we saw as we spent the weekend in Idaho.