Understanding the Fundamentals of Programming Terms

Understanding the Fundamentals of Programming Terms

There's an old adage that goes, "Learn to walk before you run," which means you should know or have the fundamental skills before diving into something more complex. Fundamentals are referred to as "building blocks" in programming. It is said that without a better understanding of the fundamental topics in programming, there is a high likelihood of giving up. As you read this article, keep in mind that "Rome wasn't built in a day," and I know you'll be glad you did.

Variable And Datatype

Variables differ in today's programming languages. A variable is a reserved keyword or datatype container that is used to store values that can be referenced elsewhere in a program (often more than once). It aids in the assignment of a labeled descriptive name to a value.

Let's look at some variable examples in both a strongly (static) and loosely (dynamic) type programming language. Static programming languages, such as Java, have a specific method for assigning values to variables because there are different types of variables, such as int (which can only hold integer values), string (which can only hold a string), and boolean (which can hold either true or false).

However, in a loosely/dynamic language such as JavaScript, var is used to hold a variety of data types such as numbers, strings, booleans, and so on. In all programming languages, we have a constant value.

Every programming language has an exceptional variable that serves as a container for fixed values; this variable is known as a constant. A constant is a variable whose value cannot be changed anywhere in a program.

Datatypes A data type is an identification in programming that specifies the type of value a variable has and the types of operations that can be performed on it. Datatypes include

  • String: Characters embedded or quoted in a quotation are identified as a string, e.g

    WAGMI//this is a string
    
  • Integers: They are basically natural numbers in a dynamic programming language, but in a dynamic language, they are both decimals and natural numbers. -Boolean: These are true or false values and can also be represented with 1 and 0 -Double/float: It basically stands for decimal numbers and so on. -Object: This is used in conjunction with a class attribute in Object programming language.

AreYouWithMeBillMurrayGIF.gif

Data Structure

It is defined as the process of handling and modifying a collection of data in order to efficiently and effectively organize, retrieve, manage, and store it. Let's take a look at some data structure examples one by one.

  • Array: This is a collection of data that is mostly used to handle large amounts of data. The array is always formatted as [4,3,7,2,8,5]. The numbers contained within the arrays are referred to as elements, and the array starts at 0. An array can be identified by its index, for example. The index [0] is noted as the array's first number, which is 4. Arrays are associated with numerous methods, such as push, pop, shift, unshift, length and so on. Note that all of these methods are only applied to JavaScript. I've attached some simple code that explains all of the array methods to help you understand them better.
var naturalNumbers = [1,2,4]
Push
naturalNumbers.push(7); //this will add element(7) to the end of the array and the output will be [1,2,4,7].

pop
naturalNumbers.pop(); //this will remove the last element of the array and the output will be [1,2,4,].

shift
naturalNumber.shift() //this will remove the first element of the array and the output is [2,4,]

unShift
naturalNumber.unShift(9) //this will add element to the start of the array and the output will be [9,2,4,7]

length
naturalNumber.length. //the output will be 4,length is used to check the length of an array

In the meantime, the array is more than what we just explained above. I will urge you to stick to the fundamentals that were explained above. In the near future, hopefully we will deep dive into the complex parts of arrays.

  • Stack: This is the act of carrying out actions in accordance with the LIFO process. LIFO stands for Last In, First Out. Using a stack of bread slices as an example, the last bread added to the stack will be the first bread to be removed.

A stack is a linear data collection that allows for the addition and removal of items using the LIFO operation. The stack has two methods: PUSH and POP. The push method adds elements to the stack, while POP removes (pops out) elements from the stack. The diagrammatic representation of the illustration and implementation is shown below.

stack comb.jpg

  • Queue: The name "Queue" should give you an idea of where we're heading. A queue is the inverse of a stack, which implies a linear collection of data that allows for the addition and removal of items using the FIFO (First In First Out) operation. The queue data structure is modeled after an ATM queue, which means that the first person to enter the queue will also be the first person to exit it. The queue has two methods which are ENQUEUE and DEQUEUE.

Enqueue is used to add elements or items to the queue, while dequeue is used to remove them. The illustration and implementation are depicted in diagram form below.

queuecomb.jpg

We have a lot more data structures examples like trees, linked lists, graphs,heaps and so on. But for now, let's stick to these.

Control Flow

The order in which the computer executes the program is referred to as control flow. A program that lacks a conditional statement, loops, and any asynchronous declaration runs sequentially from top to bottom with no interruptions. It runs based on the program structure. Three types of control flows are:

  • Sequential
  • Conditional
  • Loop

The default flow in which a computer executes a program without interruption is sequential flow. It executes it in the order in which you have written it, i.e. from the first to the last line.

Conditional: In real life, a conditional statement or expression is the same as a conditional statement/expression in programming. When a conditional statement is true, it executes an expression and ignores it when it is false. A Boolean is commonly used to determine whether or not to execute a statement based on its truth or false value.

Loops: In real life, loops can be represented by Muslims fasting during the month of Ramadan. Loops are defined as the act of repeatedly or continuously executing a command until it reaches a certain condition. Loops adhere to three structures: initialization, condition, and increment/decrement. Initialization is the beginning of the loop, condition is the end, and incrementation or decrementation is the process of adding or subtracting values until the condition is met.

Returning to Muslim fasting, Ramadan repeats itself for 30 days, which means the initialization begins on day 1, the condition is Ramadan less than or equal to 30, and the incrementation is +1.

Below is a simple code to understand conditionals and loops

// |initialization|  |condition|   |increment|
for( let ramadan=1; ramadan <= 30; ramadan++){

//conditonal statement that check if ramadan is 
//less or equals to one then print singular day
       if(ramadan <= 1){

//output
        console.log("Day " + ramadan)
         }                                   
//else, if ramadan greater than one print plural day 
               else {
                   console.log("Days"+ ramadan)
                   }
            }

I hope you enjoy this important chapter of the series. If so, try to leave a comment and likes. Don't keep it to yourself instead, share it with others as we move on to the next part of the series. Thanks for always been awesome.

YellowCabYellowCabPizzaGIF.gif