Starting with a Solid Foundation (Coding Habits)

mycodinghabits
4 min readApr 30, 2020

--

Learning to program requires a mix of some theory and a lot of practice, and today instead of introducing you to programming via a language I would like to start with what all or most programming languages have in common.

Before we proceed I would like to debunk one of the most often brought up misconceptions of becoming a programmer; No, you don’t have to be a mathematician to be a programmer. Math skills can be helpful, but they’re not necessary, and it really is dependent on what you would like to apply your skills in, instead you should be more focused on improving your problem solving skills. This skill is at the very core of being a good programmer.

With that being said let us look at what programming is; programming is essentially about data analysis, using data to output a certain result or generating data based on input given to the program you are building. How the program is written is depending on what language the programmer uses, but there are some basic fundamentals that are similar with most programming languages, these are

  1. Data Types
  2. Variables
  3. Logic and Arithmetic operators
  4. Branching(If else conditions, switch statements)
  5. Loops( for , while)
  6. Functions ( programmer defined statements of code)

Lets look at these in more detail

Data Types

There are 4 major data types which include numbers(integers, decimals etc), strings(a sequence of characters), booleans(true or false, 0 or 1), collections(can be made up of other data types or collections of collections e.g arrays and objects)

Variables

In our program we would like to store values in memory, these are what variables are used for. Normally we would give the variable a data type and then assign the value we want to store in that variable e.g int variableName = 5; If the variable is assigned another integer some place else in our code the previous data stored will no longer be there so if variableName = 10, the data stored in that variable is now 10 and no longer 5.

Logical and Arithmetic operations

This are mostly built in operations that come with the programming language and allow programmers to perform operations for basic arithmetic like addition, subtraction, multiplication, division, the modulo operator which returns the remainder of two numbers e.g ( 4%2 = 0), and the double equal sign which checks if two values are the same etc. For the Logical Operators the AND (&) returns false if at-least one value is false, the OR (||) returns true if at-least of value is true and the NOT(!) flips true to false likewise.

Branching(If else conditions, switch statements)

This allows a body of instructions to be executed once a condition is true! If it is not true an alternative instruction could be executed and the body of code is skipped over. This can be done using an if statement or a switch statement.

Loops( for , while)

A loop is like an if statement but only defers because the condition body is executed more than one time if the condition is still true. The most popular loops used are the for and while loops. The for loops are used when the end of the loop is known, and a while loop is used instead when the condition for executing the body is unknown for example, the picture on the left is an example of a for loop, the body between the braces will continue executing until the variable i is no longer less than 10. The image of the right on the other hand will keep executing until the variable value becomes false. Easy to have an infinite loop when executing the image on the right so therefore the variable codingIsFun will need to become false to break out of the while loop.

Functions ( programmer defined statements of code)

A function is a body of code that can be executed once called in a software. It normally has a descriptive name that tells what the function does and can take zero or more arguments to help the function execute the instructions written by the programmer. The function can also return a value from where it was called for example the image below shows a function being declared and called/invoked.

A program is essentially a set of functions, no code exist outside a function and any function can call any function unless the programme is written to disallow this. Furthermore variables created in a function only exist within that function and not at a global scope.

So now that we have covered the basics of all programming languages at a very basic level, you can decide to pick a language to deeper your understanding of how to utilise these fundamentals. It is generally advised to pick a language that is user friendly like Javascript, Python or Java. These are all great choices to start with. I will leave links below for resources that can help you get started.

Learn Python — Full Course for Beginners [Tutorial]

https://www.youtube.com/watch?v=rfscVS0vtbw

Javascript Crash Course For Beginners

https://www.youtube.com/watch?v=hdI2bqOjy3c

Java Tutorial for Beginners

https://www.youtube.com/watch?v=eIrMbAQSU34

--

--

mycodinghabits

Software Engineer, Content Creator and Technical Writer using this medium to write away my invasive thoughts on technology and programming. Enjoy