Basic Concepts of Programming

Wanna learn a programming language?Java? Perhaps you’ll go with C, or you’ll go with .NET? No you may enjoy more Python? No matter what language you learn these are your personnel preferences , there are some concepts that are universal in any programming language you use, that’s why today we present five basic concepts of programming you will find in any programming language that you choose : variables, control structures, data structures, syntax, etc.

learn to codeI recommend following article to force a solid programming foundation, go read now!

 

  1. Variables
  2. Control Structures
  3. Data Structures
  4. Syntax
  5. Tools
  6. READ ON MOTIVATION!

Variables

What is a variable?  We can define a variable as an identifier pointing to a place where certain information is kept strictly a variable is defined by the following:

A variable consists of a space in the storage system (main memory of a computer) and a symbolic name (identifier) ​​that is associated with that space.

Let’s say that a variable is a string for example:

  • name
  • price

These two above words can be used as variables, these variables can be assigned a value considering that every variable is assigned a value:

Identifier = Value

For example, in the above example we can assign a value to each of these variables,

  • name = “Bike”
  • price = 1300.78

So now our identifier is equal to a value, or in other words, our identifiers pointing to a space occupied by a value memory.

In many programming languages ​​you must specify which type of information suggests this variable, it can be an int, float, string, etc … but, what are these data types?

Most programming languages ​​should know what type of data in each variable shalt observe to treat it so special and better. Therefore most of the time will need to first specify first variable, for example in java you define a variable like this:

the simply

string my_variable;

then tell him you to keep

and we can do with these variables?

Through these variables can perform basic operations of information as well as keeping organized code more correctly, is only a matter of time before you start with any programming language and see the importance of the variables in any programming language, all the basics of programming we’ll see this is without doubt the most important.

Control Structure

What is a control structure? Another basic concept more Wikipedia defines a control structure as follows,

Control structures allow you to change the flow of execution of program instructions.

This gives us a clue but we will explain it a little easier. Control structures are a set of lines of code that can control a decision to be taken by the program, for example, your to read a particular book you find some text that says “if you want to know what happened to X character sees the Page X of the book, if you want to know the full story of X position X go to the page of the book. “In this situation the reader takes the” decision “they should do, though programming, the program should make that decision based on certain” rules “that the programmer wrote. In many programming decisions are made, if satisfied that sees this line of code but go to these other lines of code, for example:

in this example we use variables as you can see, tells us that if the variable price (the value where points) is less than 500 then programming sequence jumps at a given location code (in this case a method, a set of lines of code we can send for) RemoveProduct (); but is grater than 500 then will go to another location code to run another method called ContinueProduct (); this is a control structure, in specific, is a control structure called if – else.

There are other control structures, such as while.

in this example, while the condition is met, age variable is less than 18, the same code between the braces is executed once not satisfy the condition then proceed to the next line of code after this control structure (after the stopcock).

Other examples of control structures would, do – while

where a cycle of code is from 0 (age = 0) to 18 (age <18) with an increment of 1 (age ++) according to the conditions set and a message is displayed on each repetition, also this structure switch / Control case

were based on the value of the variable age is showing a message or another.

Data Structures

Another basic programming concepts are fundamental data structures, Wikipedia defines the data structure as well.

A data structure is a way of organizing a set of basic data in order to facilitate handling.

Let’s explain a little more depth, suppose you need to keep information from contacts in your address book in a program, what would you do? I probably would happen to create some variables to store this information, something like

Perfect! Right? sorry this has two drawbacks:

  • Amount of code

It’s okay if they are 10 or maybe 20 contacts / variables but how about your book has over 500 contacts ?, or if you want to save contacts but are not records of students from a university with thousands of records! This is not right or for the programmer who has to write or for the program.

  • Flexibility

If we add another contact we can not do it without necessarily modifying the source code, which must always avoid this simply something serious nuisance.

Solution.

The use of data structures greatly facilitate this task. In java there is a data structure called List , looks like this.

List contacts = new ArrayList()

Forgetting some technical issues a List allows us to store a set of data within a single variable, we can add contacts in the following manner.

You may be saying that looks the same way that using variables and true, with a couple of differences, using this data structure you are only creating one single variable unlike the thousands who would have to be created using variables, also is more flexible the Using these data structures because we can easily insert or delete records without touching anything in your code.

In short a data structure allows us to organize information optimally and avoid creating countless variables.

There are other control structures as hashmaps, which store information in the form key -> value, but the work completed to finish today, I think you’ve learned what a data structure.

Syntax

Again we will review the definition in Wikipedia for this basic concept of programming,

Set of formal rules for a programming language determine whether a sequence of source code is a program well-trained in this language.

Take a simple example, suppose that these checking your email and you find a line of text as well,

[email protected]

Then you can tell immediately that this is an email address and not a web address, why? Because we know the “rules” an email is formed by a set of letters and symbols (plus the underscore) followed by the @ (at sign) and ending with web domain address such as gmail.com. This e-mail format is recognized by everyone and can not do otherwise, is exactly the same in programming and this is the syntax.

So with this we can say that a programming language has a “syntax”, i.e a set of rules that define how to write code so that this programming language can understand us, we see an example of what the syntax java.

The above line represents how a variable in Java is defined.

The syntax is:

  1. First write the data type of the variable.
  2. After the variable name (which must follow a set of rules that we will not see today) is written.
  3. Then follows the equal sign (=) representing allocation.
  4. Subsequently the value of the variable is written (in this case as we speak of a String variable type must be in quotes).
  5. Finally semicolons are written to finish line (;).

You see you have to follow a set of rules for our line of code is correctly interpreted and taken into account, ie syntax.

As you can imagine learning the syntax is often the hardest part of any programming language you are to learn but do not worry as there are some tools that will help us a lot, one of these tools are IDEs (Integrated Development Environment) which will help us to correct our mistakes and show us suggestions and support afforded us much easier.

Tools

Do not think you need to go to Wikipedia to show the definition of tool, just like in the real world, is an aid that will allow us to complete our program more quickly and efficiently. There are hundreds or maybe thousands of tools for programmers, but certainly the most important are the IDEs, I leave a list of the best IDEs for most programming languages.

I know we are missing several but since this is an introduction to basic concepts of programming and not know what language you’re about to learn these leave you alone.

More than any other thing the most important tool to learn programming is to have the will and desire to learn, not only to program because you must, you must find the taste and passion for this but just be one more of the pile so never let your curiosity to learn over.

So far we leave this Introduction to Basic Concepts of Programming, if this article served you something then I ask that you follow this blog,like us on Facebook, tweet or +1.

You can also leave me a comment if you have a question or comment about this topic or any other, we are all here to learn.

Greetings!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top