Learn by doing—basic concepts for writing code
I’m not a developer—I don’t need to understand code!
Engineers have a solid reputation as organisms that consume coffee and generate code.
Though engineering does require a special interest in working late hours to make a box move three pixels to the left, simply having a high level understanding of how application development works across your company can build a lot of trust and respect for your developers.
Outside of that, programming concepts and basic computer science principles are inherent in many applications you may purchase.
For example, if you know how to build conditional statements, it will be a breeze to understand how to set up complex logic in your company’s third party applications.
Programming languages vs. scripting languages
It is important to know the difference between a programming language and a scripting language when speaking to technical business partners. There is a wealth of content on the internet, but here are some key concepts to remember.
A programming language generally follows strict guidelines.
Code written in these languages must be compiled into machine code before it can be executed.
These languages are also strongly-typed, meaning that the declaration of specific data types is required during development to ensure the compiler generates the correct instructions for runtime use.
Examples of programming languages you will see in the wild include Java, C++, C#, Objective C, Salesforce Apex, and plenty more.
Scripting languages provide developers with a dynamic arsenal with which to build their applications.
These enable developers to be more creative in how they solve problems, though this flexibility can lead to confusing situations if care is not taken.
These languages are loosely-typed, meaning your data types are not committed until evaluated at runtime.
Runtime evaluation of code is similar to an actor jumping on stage assuming a fresh script each time the playwright makes an edit.
Basic concepts for writing code
Earlier we talked about the differences between programming languages and scripting languages. When using either of these, it is understood that you are “writing code.”
Many of the concepts we will cover are synonymous in both types of languages, as well as declarative automation solutions—the details of doing so may differ slightly, but the ideas are the same.
Once you have the concepts, translating them into new scenarios is a breeze, and you’ll feel really cool about it, too.
When someone refers to the “syntax” of a language, you can think of this just like the written English language. There are rules that you need to follow to ensure another person understands what you are saying, otherwise you risk scaring your loved ones and strangers alike.
Writing code has similar requirements.
Syntax differs across languages for various reasons. Programming languages prevent you from even attempting to run the code if your syntax is invalid somewhere, whereas scripting languages will fail at runtime when the invalid syntax is detected.
All you really need to know for now is that there are certain patterns you must follow when writing commands so that the computer knows what you want it to do.
Ahh, yes. The underdog of the development world.
Comments provide a way for you to leave notes in your code.
These have no effect on how your program operates—they are simply there to ensure you or those maintaining your code understand what is going on.
Another use for comments is to “comment-out” parts of code that you want to remove from execution.
This allows you to keep the code in the file without it actually running. This can be very helpful during debugging.
Always comment your code.
Variables are critical in application development. Variables hold data when your code is running.
They can hold literal data, such as the name “John” or the number 125, complex data, like a key-value store, or referential data, which is a reference to a location on the computer where your program will go find the data.
These make it very easy to simplify your code and make it easier to follow.
For an everyday example, you could tell your friends “Let’s go to the really fancy restaurant at 1200 East Avenue, Building 4, Floor 1,” but it is equivalent to saying “Let’s go to Taco Bell.”
Think of variables as labels that represent something you need to use in your code.
In most languages, the case of letters in your variables is important: mynumber is entirely different than myNumber.
It is imperative to understand data types as they are used when writing code.
This is not a rigorous concept, but you can find yourself stirring for too long on an error related to data types if you’re not well-versed with the data types available in your language of choice.
Both programming and scripting languages have limitations, or behave differently, depending on the data type on which it is operating.
Scripting languages are guilty of making it really easy to run into issues with conflicting data types because of their loosely-typed design.
For example, trying to do something with text data where your code is expecting a number could cause it to break during runtime.
It could even cause your application to behave oddly without an obvious error.
Control structures allow you to build conditional routing to different behaviors in your application based on a test of data values you specify to interpret either true or false.
Tests that return true give the code a green-light to continue.
Common types of control structures include “if-then-else,” error detection and handling, and loops.
“If-then-else” structures let you specify “IF condition is true, THEN do this, ELSE do this instead”. These can be as simple as a single “IF condition is true, THEN do this,” but they can be as long as needed to check a variety of conditions and execute different code as a result.
Error detection and handling
Error detection and handling control structures let you gracefully handle any unexpected behavior in your application. If you know code you are writing could be risky, you need error detection and handling.
It is usually provided in the form of, “TRY to do these risky commands, but CATCH any errors. FINALLY, run these commands.”
You may want to reach a website for some data, but you cannot guarantee if the website will be available all of the time. You can try to access it, then if it is down you will catch the error and do whatever you need with it. Finally, you can do something else related to the risky behavior.
Ever find yourself talking about something, and then you accidentally go back to the first thing you were talking about, and then you remember you already talked about it, so you try to quickly finish the thought about something, and then you accidentally go back to the first thing you were talking about, and then you remember you already talked about it so…
Loops are great. To construct a loop, you need to know just a few things:
- Data or iterations: What determines how many times your loop will run?
- End case: What is the condition for which the loop terminates?
- Base case: How does my loop need to begin to facilitate the previous two needs?
It is often that you build a loop that does something based on every element in a list of data or runs only a certain number of times.
Loops provide a way for you to write a set of operations once and then run those commands a number of times.
Make sure your loop is guaranteed to end.
A loop that runs non-stop is called an “infinite loop.” These can lock up your machine while scaring and discouraging you from becoming the best version of you.
Keep your chin up, and reach for the stars.
There are other types of control structures, but they are usually variants of the ones above.
Functions allow you to write shortcuts that refer to one or more lines of code that you will likely want to repeat in your application, or they can simply be written to improve the readability of your application.
In some languages, they are called “methods” or “subroutines.”
Functions can be invoked to run as-is, or they can accept input parameters that specify the context of values on which to operate. Functions can also return results of their commands back to the application, allowing you to define complex calculations elsewhere while keeping the rest of your application legible.
You can think of a function as a command you may give someone. We prefer to ask someone to “stand up” instead of “Lean forward slightly, extend your legs, engage your core muscles, raise your head, balance, and remain balanced.”
If you prefer the latter, I’m calling the police.
Namespaces help you guarantee that your variable and function names do not conflict with any other code with which yours may interact.
Conflicting variable names during runtime can present odd behavior or cause total failure in your application.
One way to think of namespaces is with cities.
If I say “She’s from Rome”, you may think of Rome, Italy by default. You later find out I’m referring to the city of Rome, Georgia in the United States.
To translate this example back to coding concepts, “Rome” is the variable name, while “Italy” and “Georgia” are the namespaces that give you context to resolve the true location of “Rome.”
Scope refers to the availability of a given variable, function, or other entity in certain places in your code. There are a variety of ways the scope of your variables could be limited.
Entities declared within a control structure are often only available within that block of code. Trying to access a value outside the control structure later in the code usually presents an error. A variable may not exist if the contents of the control structure were not visited unless you explicitly declared it earlier.
Within functions, entities are not accessible from the outside unless values are returned. Functions can, however, access entities outside of themselves with a higher scope to which they have access.
Entities within namespaces are only accessible to code within that same namespace unless explicitly called upon. You may have access to more than one namespace in your code, and to access other variables or functions, you need to specify in which namespace you need the entity so the code knows where to look (if it has access).
Speed up the process of writing code.
This modest list only scratches the surface of all the features of a programming language, and each language has its own unique aspects. Application development is no easy task and it takes a lot of effort to ensure things are done correctly and reliably. Your engineers are vital to ensuring the success of your business applications. No-code and low-code application development solutions allow your engineers to accelerate their development and circumvent much of the tedium in building the critical functions your business needs to thrive in the digital world.