UX matters, and it is not easy

In my last practice session, I had trouble using toggling behavior in a button. I knew my if statements were correct, my gut told me there was something wrong with how I was storing the data in my variable. I watched the next lecture video on variables, and I realized why: I had been using ‘var’ each time I was calling the variable. What that did was it just kept initializing the variable instead of updating its value. Next, I realized that when the else statement triggered, it would not set the value back to the original value. So, I changed from this:

first_swift_app

To this:

first_swift_app_breakthrough

That was cool. Finally, my app had a single press button that did everything I wanted it to do. Hooray, UX.

I realized this was an old lesson I learned; it was great to remember this again.

I moved on to the next app, which was a simple game that made you guess the number of fingers. By default, it would mean having a few text labels, and a TextInput field where users can input a number using the keyboard.

This is what version 1 looked like:

app_version01

Now, of course, my beta version was terrible. It had no checks for nil input (which I already learned would cause crashes, so, bad me). What I made sure of, though was that users were limited to input within 0-5, because there were only 5 fingers in 1 hand.

As I was playing it, I realized, what a terrible way to play. I had to keep hitting a number, and hitting the Guess button. I just wanted to hit buttons and keep winning. So I decided why not make buttons that gave a specific input?

And this is where UX comes in again. Welcome to version 2:

getting_to_v2_02

No wonder some of my programmer colleagues hated me for always thinking of things that would make things easier for the user; it’s not easy to do things like these. This is a simple game; I can only imagine how it can be for bigger games. Still, I know it’s right, so I’ll always go for this.

I learned a lot while improving this app.

1. There really is a gap between writing code just to see if it works, and actually getting it to display what you want. I wrote the original logic for this app in Playground in less than 10 minutes. I realized I needed to make it a real app, and that took me around 30-40 minutes because of all the UI stuff.

2. In the Fingers app, I still had an issue with resetting the variable, but I realized, adding the variable you want to reset WITHIN the function is clean and probably the most efficient way to do it. When the function is done, the variable is done, no need to add code to reset it. In my previous app, the variable was global so it stayed no matter what. In the Fingers app, I had to place the variable in each function for each button. That way, I could really play with just one button press.

3. One more improvement is to add a winning streak and high score. That would complement the one button to win idea, and will add a hook to using it.

4. Originally, because I wanted to keep both versions of the project without having to use version control (it’s not worth the effort), I duplicated version 1’s XCode files and edited and tried to compile. XCode wasn’t happy.  I just redid things from scratch – thank God this was a small project.

5. Finally, again, UX isn’t easy. Changing controls isn’t easy. No one said designing properly for the user was easy, but now I understand better how much harder it is to think of users when you design products. Like I said above, it’s still the right way to design things.  Not because you get designer brownie points or what, but because it just makes the user happier to use what you made.

Swiftly jumping in!

I decided to start on Swift; I didn’t see the need to head on deeper into Obj-C esp in tweaking UI, etc. At this point, the sooner I can get my hands deep into something, the better.

So I switched courses to this Swift course on Udemy – it’s pretty neat, there is an active community checking each others errors and bugs.

The first app I did was a simple button and text app – similar to the last app I did on Obj-C. It had a label display and 2 buttons. Pressing button 1 placed some text on the screen, and pressing button 2 reset the text on the screen. I tried making just 1 button, where if there was text on the screen and button 1 was pressed, the button would reset, but I couldn’t figure out how to make a new property for this object I made in Swift. (Thanks to all my friends who helped walk me through this – I think I asked for help from around 4 people that morning.) It’s still a bit different for me. (the other things in the simulator, I just added to play around with)

first_swift_app

So I moved on, and saw that the next project was making a Cat Age calculator app. Quite nice – I was able to go through it and make it, but not without setbacks.

Now, all over the app it says ‘Cat’, because the app was for cat years. Just before I finished tinkering around, I decided to make it a dog app, because my wife likes dogs.

cat_years

Things I learned:

    1. Changing the project name, etc, isn’t simple. I was able to change images, variable names (only because I wanted to keep it consistent), but not the filenames, etc. I was too scared of having big bugs.

    2. Perhaps the real lesson there is to not get too caught up in the project name.

    3. I had an issue with some breakpoint that suddenly appeared. I talked to a programmer friend and learned a bit more about breakpoints, but I still don’t understand why it suddenly appeared in my code as it was running. Does it mean I had a bug in there somewhere? That part still isn’t clear to me; I’m sure I had no bug.

    I decided to stop getting frustrated and stop the practice session, so I asked the question on the forum. Two days later, I got an answer and the answer was just to take out the breakpoint. The biggest question that eludes me now is why they appear on their own. I’m sure they’re useful for when you need to debug and see things at a certain point in code — we had a similar thing in our Python course, but I’m not deep enough into this yet to know how to use it.

    4. There’s a thing in Swift, “!”, which unwraps the variable. If you use that, you have to be careful that there is no nil value passed on, or a crash will happen. That’s the first lesson we had on this, hence we added the if statement.

    Screen Shot 2015-02-14 at 10.16.24 PM

    (see line 25 – for a better, longer, more technical explanation I cannot understand yet, go here)

    5. I just took a quick tour of Playground, and it looks like working on Python!

    playground
Next things up for me:
  1. 1. Learn more about Swift and how to really do things in it
  2. 2. Read up more on breakpoints. I did a quick google on breakpoints, and found this: http://jeffreysambells.com/2014/01/14/using-breakpoints-in-xcode
  3. 3. Find out how to do toggle behavior in Swift! Or, just to add my own property in a class. I bet I’ll learn this in the next few lectures.

Recent coding learnings, and my sort of first iPhone app (I co-made)

As I kept fiddling around with Obj-C, I kept having more questions. If I asked my programmer friends all my questions, by the time I’m done learning this, I won’t have any programmer friends left.

Screen Shot 2015-02-07 at 11.56.35 PM

What is @autoreleasepool? Does that mean if I instantiate an object in it, it will get destroyed after the code block ends? What if I make an object outside? I started looking for a method I could call to count objects before the block ended. I kept thinking, and then I found a hack.

I tried printing the object created in the @autoreleasepool block — outside of the block, and it didn’t exist. Aha! I stumbled on to something. Experience points + 10. It’s not a direct way to do it… but well, I hacked it. I’m officially a hacker.

Screen Shot 2015-02-07 at 11.57.06 PM

I was so confused between dot syntax and [ ] syntax, I wasn’t sure why I had to add ‘set’ when using a setter in [ ], but I didn’t need to use ‘set’ when using dot. (i.e. [Part setName:”testPart”] vs Part.name = “testPart”) In Python and JavaScript I see dot syntax, so I really want to differentiate them from each other.

I was also confused why there was no getName method! I thought there were always setters and getters? What was a getter and how was it used, anyway?

Then I read up a bit more and it hit me – ‘set’ is a standard for setters but getters are just called by the property name. (i.e. No need for getName, just use name) I’ve been using getters all along! I felt so smart and accomplished.

So, once I learned and understood Obj-C a bit more, I felt I should move on and head on into iOS coding. On to the next section of the lecture – app making!

I took the app from the lecture and as usual, did a bit of exploring. I still don’t completely understand the Model-View-Controller design pattern, the different classes like AppDelegate, ViewController, properties like IBOutlet, IBAction – I just know they need to be there. Nevertheless, that didn’t stop me from making (well, co-making) the world’s next biggest app since Snapchat, Instagram and Facebook.

The lecture app was a simple app that had a Say Hello button that displayed, “Hello, iPhone” on the screen when you pressed on it, with a turquoise screen. Who needs that kind of app, right? So I made it the best app ever.

yo_01

I changed the color to violet (very important visuals are important). And then, I added another button for you to answer back, as the iPhone – a button that answered “Yo” back. Absolutely game-changing. Your phone can answer back to you, when you want it to.

yo_02

Of course I got a bug! At first, pressing the Say Yo button kept saying “Hello, iPhone!” Weird. Then I decided to unsynthesize the display property, to see if Yo worked properly on its own. I got a bug – which pointed me to why it wasn’t working. I was calling the wrong property. After adjusting it properly, the app worked as intended. This is the backstory of this Facebook post:

Screen Shot 2015-02-08 at 12.22.13 AM

While I was considering other features, I thought of clearing out the UILabel with a Clear button, so you can talk to your phone again, and make it answer back to you when you want it (still a very mind-blowing concept – AI on a leash).

At this point, I got stuck. I’m unsure whether clearing out a UILabel is actually doable; so far searches have suggested using UITextField instead. Well, sad to say, folks, the best app ever isn’t quite ready yet. More to come, hopefully, as I learn new things.

Thanks for reading through this mess.

Credits to this course on Udemy for what I’m studying now: https://www.udemy.com/learn-ios-programming-the-basics/

First breakthrough in Objective-C

Yesterday, while tinkering around, I had my first breakthrough.

The tutorial I’m watching was talking about overriding init – 24 hours in, I still don’t know what this is for.

I had a few basic questions about why some lines were written in a certain way, and why certain things were being called. Frankly, I was getting confused – since there were talks of the super class (NSObject), the class (Part), and the object (myPart). Plus in some parts of the code, self was used.

I decided to reduce the confusion for myself, and thought of just adding a method to report on the properties of the object. I figured if there was a method, it would be much easier to keep naming standard (I wanted self to be used consistently in a section of the code, so I don’t get confused). And what if I wanted to tinker more and make other objects aside from myPart? I didn’t want to have to keep copy pasting that line.

So, I looked back at an older lecture where there was a ‘report’ method – and repurposed it for the current lecture.

I changed the printf line,  Here’s what it originally looked like.

original_print

 

Voila – it became this. So elegant.

 

report_method_print

 

Some takeaways for me yesterday:

1. I got a better grasp at what a void type is. I keep seeing this in code but it just doesn’t make sense to me.

2. I think I know what %s and %d is now (though if I recall correctly, NSLog does most of the print heavy-lifting for me). (Update: I did some tweaking today, 2015/02/04, and learned I was wrong about this. More on this in another post)

3. Another review of the difference between .h and .m files. (in Python, we were taught to write functions in their own .py file, so the concept of headers and implementations are new to me)

This is the header file now!
report_header

And how it was implemented. (Just today, I’ve changed this to use NSLog instead)
report_implementation

4. How to properly call a method in Obj-C. [ObjectName method]; At first, I made a mistake and did [method ObjectName]; then I learned the proper way to do it.

Yay, small victories.

What am I learning now?

I’ve been learning to code for the past few years, and it’s been a bunch of here-and-there “oh I will watch and do this tutorial” efforts.

Screen Shot 2015-02-03 at 9.49.31 AM

I’ve taken a Python course on Coursera that I didn’t finish, even though it was a great course (at the time, object oriented programming really screwed up my brain – the course was following an event-driven paradigm and I really couldn’t rewire my brain). We made a few games in the course (here’s my Pongclone) to practice. I’ve taken a HTML and CSS course on Codecademy and even finished the guided project to make a site that looked like Airbnb. I also tried doing front-end coding for a side project I eventually got too busy to pursue.

Knowing those stuff helped me communicate better at work, sometimes even fix basic things. But aside from those things, I never really got to do much with the things I learned. It may have been because I really didn’t know what I wanted to do.

I’ve always wanted to make mobile apps on iOS though – so now I’m finally learning Objective-C. I’m taking this free course on Udemy, and I have another paid course lined up when I’m done.

I plan to blog about things I learn and how I’m going about coding, primarily because it’s easier for me to think things through when I’ve written them down. If this helps anyone else in any other way, then great! I’d also be happy for any words of advice from more senior coders, in case this reaches any of you.

Are You Waiting or Just Scared?

Sometimes we receive word from God to wait. Like when Jesus told His disciples not to leave Jerusalem until they receive the gift the Father promised.

Once when he was eating with them, he commanded them, “Do not leave Jerusalem until the Father sends you the gift he promised, as I told you before. (Acts 1:4 NLT)

Some of us are good at waiting, some of us are terrible at it (I’m the latter). But the reality here is sometimes most of us get stuck in the waiting and get scared.

Continue reading Are You Waiting or Just Scared?

Priority vs Attention

I just learned the difference between a priority and attention.

A priority is something that is regarded as more important than others. Attention is the action of dealing with or taking special care of something or someone. A priority is something permanent, long-term; something that requires attention is temporary, and once you’ve taken care of it, your attention shifts to something else.

Continue reading Priority vs Attention