If you’ve never programmed (coded) before, you may feel anxious, especially after you see what raw programming actually looks like. Although most modern Software Development Kits (SDKs) that create modern apps offer drag-and-drop technologies to make it seem easy-to-use, you’re still going to have to get your hands dirty. That is; you’re still going to have to understand how programming works, and eventually type it out. Calling computer programming a “language” is somewhat of a misnomer. English, Spanish, and Portuguese are languages, whereas computer programming is more like a set of instructions and constructs. Someone may speak in broken English and still get their point across, whereas broken programming never works, which can add to coding anxiety. You can ask around to find out whether coding is hard or easy, or somewhere in between, but ultimately, it comes down to what you think. It actually comes down to your attitude.

Click here for xCode/Swift Software Development Kit Download

Click here for Android Studio Software Development Kit 

Try to keep an even temperament when you’re coding which will keep frustration to a minimum. There are no such things as “bugs” or “anomalies” in coding; if something doesn’t work, it’s because you did something wrong. Coding is the ultimate “learn from failure” environment. However, coding is also one of the most inventive, gratifying endeavors in business. Your business mobile app will be completely yours, from start to finish; something very few can claim.

Computer programming languages, like the ones used to develop mobile applications, are all generally the same. Although there are different Software Development Kits (SDKs) with very different GUIs and features, they essentially arrive at the same point with the same types of logic. (GUI is an acronym for Graphical User Interface that lets a user interact with a computer.) For instance, every modern coding language has an "IF" statement, which is a construct that can determine the direction a program will take based on a condition. The IF statement below wants to know Sarah's condition; whether she is hungry or not.

IF Statement

 

IF Sarah is hungry

THEN eat lunch

ELSE do homework

END IF

 

The "IF" statement simply checks Sarah's condition, in this case whether she is hungry, THEN if it's TRUE, tells her to eat lunch, or ELSE do her homework. The IF statement is part of many common constructs programming languages offer. The IF statement above is written in Pseudo Code that is designed to resemble generic and simplified programming languages for teaching and development purposes. Pseudo Code is an informal high-level depiction of the operations of a computer program. It uses the structural constructs and conventions of standard programming languages. Pseudo Code is like two attorneys informally agreeing to a contract during a spoken conversation. Writing "real" programming for an actual computer program is like when the attorneys have the actual contract committed to paper. The point of Pseudo Code is that a human can read, learn, and understand a program before it is committed to actual coding in a specific language like xCode/Swift for a computer or mobile device.

 

A more realistic Pseudo Code example of an IF statement was in the Alphabet Mobile App Game where users navigated through the alphabet and arrived at "Z" which was represented by its corresponding number of 26, that was represented by a variable called alphabetLetterNum. The Alphabet Mobile App Game would have thrown an error if value of alphabetLetterNum got higher than 26. To avoid an error, the following Pseudo Code, IF statement would be used.

IF Statement (cont.)

 

alphabetLetterNum = 12

RIGHT ARROW ADVANCE

IF alphabetLetterNum > 26

THEN alphabetLetterNum = 1

ELSE alphabetLetterNum = alphabetLetterNum + 1

END IF

 

Before the IF statement starts, alphabetLetterNum has a value of 12. The Alphabet Mobile App Game user sees the letter "L," (the 12th letter of the alphabet), a leaf in the background, and has access to the 12th WAV file. Then the mobile app detects that the user has touched the right arrow represented by the RIGHT ARROW ADVANCE Pseudo Code. The IF statement checks to see if alphabetLetterNum is greater than the value of 26, and if so, THEN resets it to "1", which represents the letter "A." If alphabetLetterNum is not greater than 26, the ELSE advances its value by 1. In this case, alphabetLetterNum has a value of 12; so adding 1 assigns alphabetLetterNum a new value of 13, which advances the Alphabet Mobile App Game to the letter "M," the thirteenth letter in the alphabet.

Sometimes you already have an expected condition. For example, your mobile app asks a user to pick 1 or 2. Depending on the number chosen, you want your program to do two separate things. You may be tempted to use a "nested" IF statement; essentially an IF statement inside another IF statement like the following Pseudo Code:

Nested IF Statement 

IF chosenValue = 1 THEN DISPLAY "One"

ELSEIF chosenValue = 2 THEN DISPLAY "Two"

ENDIF ENDIF

Nested IF Statements have their place, but when your code is trying to capture multiple cases, they can get very messy and convoluted. (Notice ENDIF appears twice at the end of the code because IF appeared twice.) Imagine the nested IF Statement above if you let the user choose a number between 1 and 10! A better idea is a construct called a "Switch." Now imagine prompting your user to choose a number between 1 and 5. The following is how a switch would handle it:

Switch

SWITCH

CASE chosenValue = 1 DISPLAY "One"

CASE chosenValue = 2 DISPLAY "Two"

CASE chosenValue = 3 DISPLAY "Three"

CASE chosenValue = 4 DISPLAY "Four"

CASE chosenValue = 5 DISPLAY "Five"

END SWITCH

Have you ever wondered what "getting caught in the loop" means? It's actually an old computer programming term that refers to something called a conditional loop. Conditional loops are a way programs can repeat one or more steps depending on a condition. All modern computer-programming languages support conditional loops of one kind or another in their own specific nomenclatures. Most coders agree that there are three or four types of conditional loops starting with the While loop. A basic definition of a While loop is that it waits for a condition to be true. For instance, when someone has a job, they might get off work at 5:00 PM. In Pseudo Code, the While loop looks like the following:

While Loop

WHILE currentTime < 5:00 PM

Keep working!

END WHILE

Go home!

The While loop above constantly checks to see if its quitting time, in this case, 5:00 PM. It is waiting for a condition to be met, waiting for the current time (currentTime variable) to be greater than 5:00 PM. If currentTime, say 4:30 PM is less than 5:00 PM, the While loop keeps looping back to the WHILE keyword and keeps checking currentTime relentlessly. Once the condition is met, say currentTime = 5:01 PM (no longer less than 5:00 PM), the program exits out and performs the next task after END WHILE and tells the employee to go home. What if the first line of the While loop above said "WHILE currentTime = 0"? Time will never equal 0, therefor; you are stuck in an infinite loop toiling forever. Now you know.

Another type of loop is a Do-while loop that wants something to be done until a condition is met. In Pseudo Code, it looks like the following:

Do While Loop

DO your homework WHILE currentTime > 3:00 PM AND currentTime < 5:00 PM

Go out and play!

The Do-while loop works almost exactly like the While loop but eliminates the END WHILE statement. In the above example, if it's after 3:00 PM AND before 5:00 PM, keep doing your homework. Notice the use of the keyword AND in the Pseudo Code. Had the coder used the keyword OR instead of the keyword AND, the loop would have been infinite. Once the condition is met in the Do-while loop, it simply goes to the next command, in this case, "Go out and play!"

A For loop is especially useful when you want a loop to do something for a specific amount of times. What if you wanted to make a timer that displays the numbers 1 through 10 on a screen, and each number would display for exactly 1 second? The following Pseudo Code does just that:

For Loop

 

FOR clockTick FROM 1 TO 10

DISPLAY clockTick WAIT 1 second

END FOR

The first line of the For loop Pseudo Code above assigns the value of 1 to a variable called clockTick. The second line displays clockTick (in this case, a 1) on the user's screen for 1 second. When the second is over, the code goes back to the first line and assigns clockTick as a 2, goes to the second line and displays it on the user's screen for 1 second. The For loop will continue through to 10, and once it is done counting, will exit out the END FOR statement.

An important aspect of programming a mobile app, or any other app for that matter, is the ability to reuse chunks of code that you know already work. Consider the For loop code above that counted to 10. What if you needed a piece of code to count down from 10 after every completed level of a game? For instance, the user completes the game's first level and then you want the game to display a "count down" screen, and then resume with the second level. Consider the following Pseudo Code:

For Loop (cont.)

MY NAME IS "CountDownCode"

FOR clockTick FROM 10 TO 1

DISPLAY clockTick WAIT 1 second

END FOR

END NAME

You could repeat this code every time a user completed a new level. As a matter of fact, you could simply copy and paste it after every level completion, but there may be a better idea. The Pseudo Code MY NAME IS "CountDownCode" surrounds the For Loop, and then ends with END NAME. That means that any code surrounded can now be run by simply typing whatever you named it, in this case, CountDownCode. It is as if you created your own programming word. Now instead of typing, or copy and pasting all the For loop code after every level completion, you simply call for the new CountDownCode. This is typically referred to as calling a Function; in this case, the function you made was CountDownCode.

Now consider something really interesting. What if there were 50 levels in your game, and you copy and pasted the For loop code instead of making a Function. Imagine if you decide it would be a better game if it counted down from 20? That means you get to find the 50 places in your code that have the same For loop, and change the 10 to a 20 fifty times. Had you made a Function like CountDownCodein the first place, all you would have to do is change the 10 to a 20 once within the CountDownCode Function.

Object-Oriented Programming

Making constructs are a big deal in coding with Object Oriented Programming(OOP). All modern computing languages are Object-Oriented. The Alphabet Mobile App Game used aspects of OOP, specifically by re-using arrows, sound icons, and code that could change the background by only changing a variable, and not the program. Too understand coding concepts, it's important to understand what OOP does, and how it does it.

In the past, non-Object-Oriented Programs like Cobol, Fortran, and Pascal focused on commands like "Go here," or "Do this, do that." With an Object-Oriented Language, organization comes first, and then commands come later.

 

In OOP, objects and classes are used for organizing your stuff. For example, you're programming an app to keep track of cars your business manufactures. Every car manufactured is pretty much alike. In OOP, each car is an object. Even though all of the cars manufactured are slightly different from each other, they all share the same overall list of characteristics. Basically, every car manufactured shares one blueprint that identifies every possible characteristic a car has. All of the cars have a characteristic identified as color, interior style, etc. In object-oriented programming, you need a master list (blueprint) containing all the characteristics that a car object can have. This master list of characteristics is called a class. Old-timey languages would make a brand new blueprint for every car manufactured whereas Object-Oriented Programming makes a singular (class) blueprint for all cars manufactured.

By using Object-Oriented Programming, you saved your business millions of dollars in blueprint costs. Now you can manufacture from one class (blueprint) and makes many objects (cars), but that's not the end of the story. What happens if your business wants to make trucks, does it require a new class (blueprint)? Do the trucks require their own set of blueprints? The answer is "maybe." Cars and trucks share a lot of characteristics, they have colors, wheels, interiors, but are they alike enough to share the same blueprint (class)? Maybe cars and trucks aren't really alike at all. Trucks have things like beds and tow packages that cars don't.

If you decide that cars and trucks are "alike" enough, you can make a subclass for trucks. The subclass is a new "sub-blueprint" with characteristics specific only to trucks. Go ahead and manufacture the truck with the new blueprints (subclass) and everything else you need to complete the vehicle inherits the original car blueprints (now called a superclass). Subclasses basically extend what the original class was intending to do.

Some refer to the superclass/subclass relationship as a parent/child relationship where the superclass is the parent and the subclass is the child of that parent. Will you make a new subclass (sub-blueprint) if your business decides to build sub-compact cars? The parent will now have two children. Once again the idea is that you can build many objects from the same class (cars), and somewhat different vehicle objects (trucks, sub-compacts) with subclasses. What if your business decides to make boats? Should you make a new subclass? The real question is, "Can I extend the original car blueprints (superclass) by adding a new "boat" blueprints (subclass) with "boat" characteristics? The answer is "probably not."

Object-Oriented Languages (OOL) was a paradigm shift in programming. It didn't particularly make programming easier, just way more efficient. Classes and objects that could be repurposed and reused replaced millions of lines of older, arcane code. Unfortunately, those who developed OOL seem to have made it difficult to understand with terminologies and poorly explained concepts that only serve to confuse. But there is hope. Think of OOP and OOL as a spoken language like Spanish. It just takes attention and practice. You can do this.