DD1
DD1
Comment
The image above shows us an example of a comment that was typed in Visual Basic.
Comments in the Visual Basic programming language are always highlighted in green. In
front of the comment is the comment symbol which is in this case here the apostrophe (‘).
That symbol must always be added before the programmer starts typing a comment or
otherwise will the program breaks down, as the Visual Basic compiler thinks that the text
does belong to a code, which doesn’t even exist. In the image above can we also see that
the comment doesn’t fit on a single line and does therefore goes into second line. So if the
comment requires more than one line is it very essential that the user use the comment
symbol on each line.
An advantage of using comments is that it helps other programmers to understand the
code much better, that the previous programmer has left them behind.
A disadvantage of using comments is that they are time consuming as a programmer have
to use appropriate comments that are detailed enough for another person to understand.
Appropriate names for variables:
One of the factors that improves the readability of code is appropriate names for
variables which basically means that the programmers need to make sure that they use
appropriate names for the variables and not any random ones. So if the programmers do
use random variable names such as “FN”, “MN” or “LS” can that affect other programmers
understanding of the code as they probably not know what the purpose of the variable is
and that will eventually make it harder for them to edit the code. Using appropriate
variable names is useful when the programmers wants to improve the readability of the
code as they make the understanding the purpose of a variable much simpler. In addition
to that does it also make it for programmers much easier to recognise the variables role in
the program. A variable name can also include the datatype of the variable that can
minimise the chances of the variable being assigned the
wrong data type.
In the example above can we see two statements that were typed in Visual Basic. The first
statement (“Dim variable 1 as string”) is an example where the programmer has use a
random name for the variable. So that eventually make it harder for the other
programmers to understand that code, as they probably have no idea what the purpose of
the variable could be and that make eventually for them harder to edit to code. So that’s
why it is really important to use appropriate names for the variables. The second example
(Dim firstName as string) does show us a statement where an appropriate name has been
given to the variable. That is quite beneficial for other programmers as that will give them
a better idea of what they will be used for or what data will be stored in that.
A benefit of using appropriate names for variable is that programmers can edit the code
much easily and relate the code with appropriate variables. Another advantage of using
appropriate names for variable is that less errors will be made when referring back to the
variables later on in the code. On the other hand, can using appropriate names for
variable also be a bad thing; then sometimes can be very difficult for a programmer to
think of appropriate names for variables that all programmers can understand in a large
program that uses lots of variables.
Indentation:
One of the factors that improves the readability of code is Indentation. Indentation is
basically when the programmer breaks down each section of the source code to make it
for them easier to understand and read the code much better. Indentation can also be
used to separate blocks of code such as selection statements (also known as If/else
statements that cause the program to be transferred to a specific flow based upon
whether a certain condition is true or not) and loops (do carry out instructions for a
certain amount of times until a certain condition is reached.) Nesting is a technique that
basically improve the code by showing a chunk of codes is “nested” within another chunk
of code, and that does allow the reader to simply follow that nesting pattern. When the
code has been improved does the code go into the testing stage of the software
development cycle, where developers and IT users need to test the code first before they
released it. In this stage are the developers required to improve the code by making it
easier to read.
The image above shows us an example of how programmers have indented that code. We
can see that the programmer has used appropriate spaces between all the variables which
were First name, Middle name and Last name to create space in the program to make it
easier to read. Other programmers who never came in touch with that code, would be
able to understand each of the procedures, as the code has been indented properly. If
that wouldn’t be the case would it firstly be very difficult to read the code and secondly it
would take a lot of time to revisit the code and use it.
An advantage of having all your coded indented is that makes the code looks very neat,
which means that the readability of the code will improve. In addition to that will it be
very easy for the programmer to read, to understand, to maintain and to maintain the
code. Another reason why indentation is quite advantageous for programmers is that it
saves their time. Programmers can see where the end of a code block is, rather than
having to read each line until they find it. So that’s why is it quite important to have codes
indented.
On the other hand, can indentation in the wrong places be even more confusing when the
programmer reads the code, this can even then lead to the program code not working.
Another drawback of Indentation is that it is very time consuming to indent code properly,
however indent properly makes therefore the code much easier to read.
Syntax Highlighting:
There are several programming languages such as Visual Basic or C++ which offer a feature
that is called Syntax Highlighting. Syntax Highlighting basically allows key parts of the code to
be displayed in different colours and fonts depending on their purpose. For instance, in the
Visual Basic programming language is the default colour for variables blue, comments are
coloured green and variable names are highlighted in black. However some of these programs
allow the user to customize, so that means that they can change the colour of each code part
within the application, this is generally a great and standard colour scheme for manipulating
code. Syntax highlighting does improve the readability of code; colour coding the code which
the programmers has written allows others viewers to identify particular elements of the
code and it also allows user to promptly tell the purpose of particular statements within the
code. That makes it much easier for developers to read, understand and modify the code.
The image above shows us an example of how syntax highlighting has been used in a program.
We can clearly see use of different colours here, which makes if for the programmers much
easier to read the code and understand. From just reading the code can programmers clearly
identify the comments which are highlighted in green, these has been added to understand
the purpose of each line much better. The text in the example that is highlighted in pink is the
text that gets displayed on the screen as notification and the variables in that example are
coloured in blue and violet. If everything would have the same colour then would
programmers find it very difficult to read the code. That why is it very essential to use
different colours for different parts of the code to avoid confusion. Colour and Font can be
changed within the application.
Syntax highlighting offers several advantages including that it helps programmers to detect
errors much faster in the program. As different parts of the codes are coloured in different
colours will it be very easy for programmers to find the mistake. Programmers can see where
the error was made, instead of having to go through each single line until they find it. Another
reason why syntax highlighting is quite advantageous for the user is that it tells programmers
and developers straightforwardly what the purpose of particular statements within the code
is, without confusing them. On the other hand does syntax highlighting also offer several
disadvantages such as that different programming languages such as Visual Basic, C++ or
Python do have different colours for their codes. For instance, in Visual Basic are variables
coloured in blue, but in another program might variables be purple. The programmers can get
confuse with all these colours.
Line Breaks:
Line Breaks or New Lines helps the programmers to structure and organise the code much
better. They are used to separate long lines of code into smaller sections so that each line
of the code is on a new line. This will help to define different areas of code which will
make it for the programmers easier to follow the code. Also, having more space can make
it easier when viewing and trying to read the code.
In the example above can we clearly see a Line Break that a programmer has added into
that program. The reason why the programmer has added that line is that it helps the
programmers to structure and organise the code much better. In the image can I see that
the long lines of code were separated into smaller sections so that each line of the code is
on a new line. This will make it easier for programmers to follow the code.
Line Breaks offer several advantages such as that