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:
To this:
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:
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:
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.