Learning To Code

Since posting the article Making A Puzzle App With Unity, I've fielded a few questions about the C# language (pronounced "C-Sharp"), and the time it takes to learn computer programming. Learning C# isn't particularly difficult, but it probably takes more time to master than Adobe Photoshop or Microsoft Word. If you're looking for general information about the language, head over to Microsoft's C# pages.

While reviewing the code in my ChemSim-VR Web Demo, I identified two lines of C# using Unity's Input Class that do something specific with immediate, visual feedback. Pressing the shift key at any time while navigating the world-space with WASD keys causes the player's speed to triple. Release the shift key and no matter the direction of travel, the player's speed instantly returns to normal. To guarantee that the player's speed returns to and remains normal regardless of any other key presses, I added this to the main loop of the state engine:

if (!(Input.GetKey (KeyCode.LeftShift)) || (Input.GetKey (KeyCode.LeftControl)) && (!(moveSpeed == 3f)))

moveSpeed = 3f;

How programmers achieve their objectives has a lot to do with how they learned programming in the first place. Early in my career I worked with accomplished programmers and software developers. When I asked for their feedback I wasn't satisfied with answers like, "Yes, we can do that" or, "No, we can't". I wanted to know why an idea for a GUI component was feasible or not. Later when I directed teams of developers, I encouraged them to pursue a working knowledge of each other's specialties.

Today it's understood programmers benefit from the type of on-the-job training and mentoring I had even though I didn't learn programming until years later. It's also understood that, regardless of their formal education, programmers are largely self-taught. They're driven to master computers and coding the way musicians master instruments and expression. Accomplished programmers seek out new challenges and experiences to test their skills, overcoming frustration in pursuit of their objectives.

For a short introduction to programming through a simple exercise with the Unity game engine and C#, have a look at the two lines of code, above. Use Unity's on-line Scripting Reference and other resources to figure out what's happening. Describe the meaning of each word and symbol. Don't waste time guessing. If you plan to code your own apps, then expect this kind of research on an ongoing basis. If it seems overly complex or difficult, then learning to code might not be for you.

T.M.Wilcox, April, 2017

WILCOXMEDIA.COM