The 5 Concepts Every Programmer Must Understand
Tags: html, css, javascript, algorithms
Published: 2021-01-31 02:15:40

Back in freshman year, My professor wrote down five things onto the whiteboard and told us that we needed to understand these concepts. These were the fundamentals of computer programming. No matter which language you learn first, or decide to migrate to, you will be able to solve any programming problem by simply implementing these fundamentals.

-__Take input__
-__Allocate memory__
-__Give output__
-__Make decisions__
-__Loop__

__Take input__ is often the first fundamental taught when teaching students. This could be something as simple as creating a console application and prompting the user for a number as input. Many languages have different ways of taking input. With Java, you can use System.in.read() (don't forget to flush the keyboard buffer) or the scanner class. In C#, when dealing with console applications, you'll most likely start out using console.ReadLine(). Different methods, same concept. 

__Allocating memory__ is usually the next step when it comes to taking user input. After a user enters input, depending on the type of input it is, the program may need that user's input in order to process it later on. For starters, the user input will most likely be stored into a primitive type such as an integer. Later, user input can be stored into objects such as strings. Once programmers become more advanced, they can then start to allocate user input into more complex data structures such as Trees or Lists.

__Giving output__ is simply displaying information to the user that is easily digestible. Maybe you are building a calculator application and need to display the results. Maybe you've created a complex algorithm for your fortune 500 employer and need to display the results into a data table so non-technical folks can easily digest it.


In programming, there are a lot of decisions needed to be made by the developer. When a developer wants the program to make a decision, they will need to incorporate if-else statements that will allow the proper decision to be made. Senior developers tend to use ternary operators and nested complex statements that tend to obscure the logic for the juniors, but that's what comments are for. At the end of the day, fundamentally, these statements come down to basic if-else statements.

__Looping__ is one of the most essential concepts juniors should familiarize themselves with. Need to access data of an array? For loop. Need to create a chessboard? Two for loops. Need simple input validation?

                 While( input != null ){
                 }

__Looping__ can be simply taught, however, when complex problems start to arise, that's when certain loops become harder for juniors to understand. Don't fret, in order to run you must crawl. If you can understand how a for loop allows the program to access all elements inside an array, you'll be able to understand how a *foreach* loop can allow the program to access all items inside a Model inside an MVC application. 

In Coder Foundry, we were tasked with creating minisites that will allow us to complete coding challenges and display results to the user. In order to complete the FizzBuzz mini-site, I needed to revert back to the 5 concepts. The program will __take two inputs__ from the user and __allocate them as integer data__. Next, __loop__ through all numbers between 1 and 100.  Print "Fizz" if the first user input is divisible by the number that is currently in the iteration, or "Buzz" if the second number is divisible by the number inside the iteration.  Otherwise, just print the number itself. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/pf5qnzh59qhk8rsk0s8j.PNG)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/8tv8dvxgfbfmts4wqm3u.PNG)


 __Making decisions__ is usually the hardest part for students to understand because it involves algorithmic thinking. The FizzBuzz application makes decisions based on the else if statements. 

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/1f6kcle7bztgz8cfl9jf.PNG)  

Lastly comes __Giving output__. The programmer will need to give output in a way that is easily digestible for other programmers and non-technical clients viewing the program. For this specific project, I created a table class in markup, and then manipulated the data (__Making Decision__ and __looping__) in order to display the results properly to users.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/l5b3o5zqtj5hmoxp2ym1.PNG)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/zb80ph35cj7jhrcdz1qm.PNG)


From personal experience, I've gone from Java, to C++, to C, and now C#. Syntax differences will sometimes get in the way of things, however, strong programming fundamentals will always allow developers to keep a level head and understand complex problems by analyzing which of the 5 concepts need to be implemented and at what point in the program. 

Click the link to view the project:
https://zacharyhadjahfizzbuzz.netlify.app