Hey you, yes you! You are awesome and let’s get started! Firstly, I am writing these introductory posts in a format that I assume you have very little knowledge about programming. The goal is to make this content accessible and understandable to the “general populace”.
So, let’s get straight into it. 5 basic programming concepts you need to know first in any programming language. You might be asking “But Chris, why are you talking in general terms, I thought you specialize in Android Development?” To start off, from personal experience, it is extremely important to understand the basics of any programming language.
“What separates the good coders from the not-so good coders, is that the good coders have an advanced understanding of the basics” – Stefan Mischook
What he is saying is that it’s not just one thing to know basic concepts such as functions, objects and arrays. But knowing how to use these concepts in sophisticated ways is another. To fundamentally understand when to use functions to lower the amount of code, or to use an array to solve that complex multiplication problem you have.
It is highly recommended that once you have learned the basic concepts, to take the time out of your schedule to “peel the onion“. To dig deeper into things that you think you know already. For example, if you know and understand arrays then you can move advanced concepts like two-dimensional arrays. Understanding why you would use a one-dimensional array over a multi-dimensional array. What are the performance differences in each type of array for a particular circumstance? Concepts can get deep very quickly, and that’s a great thing.
Here are 5 basic Concepts of any programming language:
If you are a complete beginner, I understand these words might seem foreign to you, that’s the nature of the learning process, I will do my absolute best to help you understand their meaning. Each concept can go into depth, but I will only talk about #1 Variables.
What is a Variable?
A variable, in the context of programming, is a symbolic name given to an unknown quantity that permits the name to be used independent of the information it represents.
Well that’s very abstract. To me, a variable is simply a location where we can store information of our choice to use later, and we can retrieve this information by assigning a “word” to describe this information.
For example, let’s say you want to visit my website “www.actualizedprogrammer.com” and I ask for your first name (To customize the experience for your next visit). I would create a pop-up screen that asks what your name is…this pop-up represents the variable! Let’s say we called this text box ‘YourName’, this would be the symbolic name for your variable.
So when you type in your name into the ‘YourName’ Text box, the data/information that you enter will be stored into the variable called ‘YourName’. Fast forward 24 hours and we ask “What value does the ‘YourName’ contain?”, and the program would display the data you physically typed into the text box.
How common are variables in programming?
They are everywhere! I almost guarantee every program that 99% of all programs that you interact with will have a variable somewhere. Big companies such as Google and Amazon use variables in their code. It’s part of a network of code that allows you to make a purchase on Amazon, or to withdraw cash from the cash machine. Ask any programmer and ask them how often do they use variables, you will get a positive response on the importance of them!
Strings, Integers and Doubles in Java
Now we’ve covered where they can be used, let’s dive into the meat of Java. In Java, this programming language wants to know the specific type of information you are storing inside a variable. Be it a decimal number, word or whole number. There are a number of reasons why types are important in Java, let’s find out.
So Chris, what would happen if I tried to store something that is not a string into a String variable, let’s say the value “28.55”? Simply, your program would be screaming at you asking you to fix it! The value “28.55” is a number with two decimal digits. In Java, when you specify that a variable is of the type String, you can only store characters, no numbers of any kind.
A String is simply a list of characters in a specific order, the computer does not understand the variable is a “word”, it only understands the characters individually, and so when these characters are placed in a specific order it creates different circumstances.
Defining what type of data that the program is dealing with will allow the programming language to manipulate the data in certain ways. Again, when I say “defining what type of data” I am referring to the type of data.
What Can You Do With Data Types?
Here’s a simple example.
You have the goal of adding two numbers together, let’s say the number 7 and the number 44. Java will behave differently depending on the type of variable that these pieces of data are assigned to.
Let’s see what I mean:
If you have defined your variables to be the type String, then “7” and “44” are stored in two separate variables.
A string has a different nature to Integers, and these behave differently because it is a different data type.
If we were to add these two variables together, each defined as Strings, what do you think the result is?
The resulting String would be: “744”
You might wonder, why is this confusing, but it makes more sense when you look past the illusion.
Now let’s say, both variables: “7” and “44” are the variable type Integer, and now we want to add the together, what do you think the result would be?
That’s right, we would get “51”.
In another example, let’s assume that we are storing 2 list of characters and number.Variable 1 is “Hello” and variable 2 is “World”.
With this in mind, can you work out the final result?
I’m confident in you and i’m sure you came to the result “Hello World”. If not, that’s okay this content will take time to digest, just keep consistent at the study and you will progress.
The exact same behaviour is occurring with the Strings “7” and “44”, remember Java behaves different depending on the initialised data type.
In Java, the String “7” is the same data type as the String “seven” as they are both a specific order of characters.
To summarise, we talked about what a variable is and how you can store information and then manipulate the data in a specific way.
All in all, I hope you can become aware what the benefits are of learning a programming language! The desire for a company to hire employees capable of learning new programming languages is a crucial skill, and many companies are hiring people to build new applications such as mobile applications. Let’s continue the journey of learning a programming language and come back for section two – Assignment.
References Stefan Mischook – https://www.youtube.com/channel/UCyUBW72KU30dfAYWLVNZO8Q