SlideShare a Scribd company logo
1 of 14
IT Level 3
Software development
Assignment 1 - Unit 6
Brandon Skerritt
11/04/2016
Peter Gibbins
1
Table of Contents
Introduction ................................................................................................................................. 2
Task 1 – Programming Paradigms ........................................................................................ 3
Task 2 – Programming languages......................................................................................... 4
Task 3 – Data types ................................................................................................................... 7
Task 4 – Software design......................................................................................................... 8
Task 5 – Quality & Readability of Cod................................................................................ 10
Conclusion................................................................................................................................. 12
References................................................................................................................................. 13
2
Introduction
In this assignment I shall take on the persona of a programmer in a software house
specializing in varied and diverse projects, I will produce guidance that emphasizes that
paradigms and languages should be selected to suit the individual project rather than
the programmers favorite or most familiar language.
In this assignment I shall talk about the different programming paradigms and the key
advantages and features. I shall be talking about why readable code is good and the
uses for different languages along with a few data types and their uses.
3
Task 1 – Programming Paradigms
Procedural programming is programming which follows a linear fashion. The code is
executed from top to bottom, unlike other languages where functions can be run in any
order.
Scripting languages such as Shell, Bash or Dash benefit greatly from the procedural
programming paradigm. Because scripting languages often don't need functions and
are in themselves a form of function, they can benefit from the linear readability and
execution.
The idea of the code being linear allows bugs and problems to be spotted more easily
as you don't have to jump down a rabbit hole of functions and loops to find a problem.
Procedural programming is appropriate for mathematic based programs, where each
mathematical step is carried out in a linear fashion to produce the result the
mathematician wants.
Procedural programming is inappropriate for game creation and development. Since
many games have multiple objects such as the player sprite, the players weapon, and
the player’s attributes; Procedural Programming cannot compute the abstract thought of
Object Orientated Design and thus is unsuited for game development or any programs
where objects are used.
Event driven programming is software that only runs when an event happens. An event
can be anything, from the temperature rising to a certain degree, to the system reporting
errors, and even an RSS feed updating.
Event Driven Programs live in an event loop. This is a constant, semi-infinite loop that
repeatedly sends a request to the appropriate system to see if the information has
changed. A program may also run on events passed to the program, a program which
involves the system passing events to the program is the Blue Screen of Death.
Windows will crash and pass the error to the Blue Screen of Death program which will
take then necessary precautions to fix the system and recover.
Event Driven Programming is highly suitable for critical systems such as Centrifuges. A
centrifuge is the control system that puts in orbit a piece of material around another
material. This is used to mix and cause controlled reactions with Uranium in Nuclear
Power plants.
Back in 2014, Stuxnet, the computer virus, attacked centrifuges directly. Because the
centrifuge started to heat up, the control system in place, created by Siemens, detected
this event and took the appropriate measures to cool down the system. Stuxnet directly
attacked the event handler which stopped the system from detecting any problem,
however, this is not a programming paradigm problem but more of a problem with not
encrypting the data.
4
Event Driven Programming would not be appropriate for math programs, such as the
program which calculates Prime Numbers. Because this program uses the
mathematical formula N^2-1, this is not an event or a loop. It would only stunt and slow
down the calculations made by this program.
Object orientated programming is software based upon the principality of objects. An
object can be defined as anything, from a bike to the nuts holding the bike together.
Object Orientated Programming is essential in Computer Science as it's based around
Abstraction, and in the words of most computer science textbooks, "Computer Science
is the art of abstraction".
Abstraction means to take an object or function which is extremely complicated and to
allow it to run in parallel with other code which doesn't need to know how complicated
the abstraction is. An example of this is the transistors on a Central processing unit, we
don't have to know exactly how the electricity flows through the transistors for a
computer to work, but we can abstract this idea and call them Logic Gates instead.
Object Orientated programming is good for computational thinking, where problems are
solved using objects. It's a very natural way for computer science students to think, so
it's naturally the most favorable programming paradigm. As such, Object Orientated
Programming is also good for game design and development where each player has a
sprite, multiple attributes and possibly objects they can interact with in the world.
Object Orientated Programming is not suitable for mathematical based programming or
small scripts. Since most Object Orientated Programs force the paradigm on you (Java)
creating a small script to check to see if your internet connection is working may require
you making multiple objects and classes to check, this is not suitable as you can easily
perform the same task in 1 line of code in a scripting language.
Task 2 – Programming languages
5 factors that would influence the selection of a programming language used are:
The team’s knowledge – The team may already be proficient in a programming
language and may choose to use it due to experience. A team would rather use a
programming language they are already efficient in and know, then to learn another
programming language for a project unless that programming language was essential
for the project, such as using SQL to create a database as a database cannot be easily
made or operated on in conventional languages.
Platform – The platform you want to develop on will alter the language you use as
languages are normally platform specific with a few exceptions. Shell will not run on
Windows as it's a Unix specific scripting language, and likewise, Windows PowerShell
will not work on Unix-based operating systems such as Mac OSX or Linux.
5
Specific uses of programming languages – Some programming languages are created
for a specific use and thus are used for that use. Examples of this is SQL which is made
only for databasing applications, you cannot use SQL for a web scraper and you cannot
use Hadoop for a databasing solution.
Need for speed – Some programming languages, due to being classed as level 3 or
higher programming languages are slow. Because of this, we may choose to use a
faster programming language such as Assembly or C to perform mathematical
calculations such as vector graphic calculation for games or calculating prime numbers.
Reliability – The language being chosen for the project must be a reliable programming
language with a lot of bugs and flaws fixed. NASA uses Pascal to program their rocket
ships and Mars rovers because the language has been tried and tested over time by
many users and is considered one of the most reliable programming languages today.
SQL – SQL is most appropriately used for, according to the ANSI standard, databasing
solutions as it can only be used to interact with a database. SQL cannot be used to
create fully blown systems with event handling and error correction facilities as it was
created to interact with relational databases.
HTML- HTML is most appropriately used to create the documents that appear on the
web that the user downloads when they want to visit a website. This is HTML’s only use
but it is used everywhere to create web-pages.
C, C++ - C and C++ are two different languages. C++ is a multi-paradigm programming
language which involves Procedural programming and Object orientated programming
and is mainly used for Game development and development of platform specific
programs such as Google Chrome. C is a procedural based programming language
used mainly for control systems or operating systems due to it’s fast operational
speeds.
Visual Basic – Visual basic is most appropriately used within Microsoft Office
applications such as Excel, as it’s the language Excel uses to create queries, variables
and other spreadsheet functions.
Sequence – A simple definition of a sequence is that it is a set of instructions to follow to
complete a
task. This is
often done in
a linear
fashion, one
after another.
Sequencing is
important in
algorithmic
structures as it
defines the right steps to take to complete an algorithm. An example of this in C can be
seen in the picture above, although the program converts 165 Fahrenheit into Celsius,
the actual algorithm “Celsius = (5/9) * (Fahrenheit-32)” uses sequencing to make sure
6
the algorithm is correct. If we were to mess up the order the algorithm would not be the
same and thus the program will be void for it does not work.
Selection – Selection statements are used in programming to allow users to have an
option and the ability to make a choice within the program which is allows for non-linear
code. An example of this is the If, If else, and Else statements in C. This allows the user
to make a selection
about the code they
want to run, however
due to the abstract
nature of selection
statements the user
may not even know
the selection
statement is running.
An example of
selections statements
can be seen on the left
hand side. The user
will input an integer
and the program will
use comparison
statements to check
the integer the user
has inputted. If the
number is bigger than
10, use augmented assignments to add 1 to it. If the number is less than 10, add 10 to
it. If the number is neither, tell the user their input isn’t valid for this program.
Iteration – Iteration statements
are statements which allow code
to be repeated several times for
it to meet a certain criterion, a
certain amount of time or an
infinite amount. There are many
variations on the Iteration
statements, but on the left hand
side are two examples of
iteration statements. The first
statement is a for loop, this will
loop repeatedly until the
condition “y = 300” is true. We
create a variable called y and set
it to 0, and then every iteration we add n(10) to it.
The second loop is an infinite loop, it will iterate everything while true is true, but since
true is always true it’ll iterate infinitely.
7
Task 3 - Data types
Type Range of Values Memory
Required
Purpose/Use
Byte 0-255 1 byte
Binary
Integer -32,768 to 32,767 or -2,147,483,648 to
2,147,483,647
4 bytes
Whole Number
under 2^32
Longint -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807 4 bytes or 8
bytes
Whole number
under 2^64
Array
Infinite, limited by size of hard drive or architecture of
CPU.
16 bytes +
items in
array
Storing values in
organized list
Single
1.401298E-45 to
3.4028235E+38
4 bytes
Small numbers
Double -1.79769313486231570E+308 to -
4.94065645841246544E-324 and
4.94065645841246544E-324 to
1.79769313486231570E+308
8 bytes
Big numbers
Decimal
0 to +/-79,228,162,514,264,337
16 bytes
Decimal numbers
Boolean
True / False, 0/1, Yes/No
2 byes
True/False, 0/1,
Yes/No
String
0 to approximately 2 billion Unicode characters 10 bytes +
string length
Text
String(Fixed
Length)
1 to approximately 65,400 Length of
string Text
Unix Time
stamp
2^64 16 bytes Time since 1st
January, midnight
1970
Date
0:00:00 AM on January 1, 0001 to 11:59:59 PM on
December 31, 9999
8 bytes Day, Month, Year,
Time
8
We have multiple data types for various reasons. One of these reasons is saving space.
When you define a variable with the data type Double, it will always use 8 bytes. When
you define a variable with data type Single, it will always use 4 bytes. This may not
seem like a lot but on microcontroller systems where memory is limited this is a lot. The
main reason we have data types is Abstraction. There are many different objects in the
world, so we need many different data types to define these objects. We could define a
Unix Timestamp as an integer, however, programmers may be confused by this as a
timestamp should be a timestamp object. We use abstraction and multiple datatypes to
help programmers understand the objects they are manipulating. In Python, all user
input, by default, is a string. If a programmer can’t see this clearly defined they may
think it is an integer.
Task 4 – Software design
Need
The system life cycle starts with an individual or organization needing an upgrade or
new software, and this creates the need for the new software. Without a need, there
isn’t a reason to create new software. In the words of many wise men “Don’t fix what
isn’t broken”.
Scope
The scope is the general outline of the idea that the developer has of what they are
planning to build. This includes detailing estimates on how long it might take for the
project to be completed, the expected amount of money that will be required to
complete the project, the amount of developers needed for this project, the software
which may be needed in order to aid creation of this system and perhaps the training
that the staff will have to undergo to use the new software.
Requirement analysis
The requirement analysis is where the programmers look at all the requirements of the
program and then determine how they are going to complete the project. This will
usually involve asking members of staff who have used the software for a long time their
opinions on the current software and how it could be improved upon.
Specification
This is the specific details of al the requirements that the program has to do and the
amount of time that the programmers will have to complete the program in. This is a
document that is agreed with both programmers and company.
9
Design stage
The design stage is when the programmers prepare a design on how the program will
work, all of the programmers will have their own input on how each part of the program
should work. Once all the programmers have reached an agreement on how the
program will work they will put this into a document for future reference.
The design stage may also involve creating pseudocode for the project to help properly
visualize how it’s going to work.
Code development
The code development stage is when the programmers begin to create the code. Once
each programmer has created each of their individual parts and performed unit tests,
they will put all their code together normally using source control such as GitHub and
will compile the code.
Testing
The testing stage is when the programmers test the code as a whole program instead of
individual unit tests. This is one of the most important stages as it makes sure that it
can’t be broken by simple user input or other bugs which may annoy users to the extent
where they refuse to use the software.
Implementation
Implementation is the stage where you roll out the working and bug tested program
either to a small amount of chosen people, for example, one department or team to test
for any bugs or inconsistencies in the program, or to the whole organization if you are
confident in the code.
The implementation process also involves training all members of staff who need to use
the new software. Also, you could directly change over to the system which is
dangerous, may cause mass confusion amongst users and cause them to not want to
use the software. A better option is to parallel run the software next to the current
software and have the users slowly transition into using the new software by offering
greater functionality and ease of use.
Maintenance
Maintenance is the process in which the programmers constantly check for errors in the
program, and fix these errors and bugs as users report them. This is known as proactive
maintenance since the programmers don't stop looking for bugs until they are sure all
bugs are gone, after all bugs have dispersed the programmers may perform reactive
maintenance where maintenance is only performed when serious bugs occur. The
programmers will often create updates using the software life cycle described in this
document.
A top-down design chart is a way to plan a program by creating a chart and looking at it
from a top-down perspective, this is like pseudocode except you can visually see
selection statements in action.
10
Pseudo-code meaning “False code” Is a type of design plan for a program written in
Plain English and doesn’t follow a specific language. This often uses words such as
“Load file” instead of “with open(file, “w”);”. These words are laid out in a similar way to
program code to help understand the flow of a program.
Flow charts show the process of what is happening in a program in a visual way. It
allows the programmer to design their program as a rough sketch, not pseudocode but
a more abstract way of thinking about code.
Task 5 – Quality & Readability of Cod
Quality of Code is how good looking, understandable, and maintainable code is. If code
is easily maintainable and follows a strict guide on how the code is to be written and
created, then it is considered good quality code.
Code should be easily readable as it allows for easier monkey patching, fixing bugs and
finding potential problems and security issues in the code. Many programmers, when
they come back to their own code find it confusing and hard to pick up again. If they
would have followed a “grammar” guide on code, it would be easier to pick up and
maintain again. The advantages of having a good grammar guide on code is that you
can understand other peoples code and they can understand yours more easily.
An example of a grammar guide is Python’s PEP8 which is universally used at Google
and Facebook.
In this definition, we have good variable names such as “user_input”. This follows 2
coding standards, snake case where you have a “_” between every word and no capital
letters. Capital letters are reserved for constant variables.
Here are ways you can make your code more readable.
Indentation – Indent your code so code that only runs after
selection statements is indented below the selection
statement, this makes it easier to read.
Indentation is important as it separates code which runs when
a selection statement is activated and code that’s run in a
procedural style.
Look at example 1, an example of well indented code. Each
selection statement is preceded with a tab character which
puts the next statement on the line below, this is nesting the
code.
11
Example 2 is an example of how the code will look if
it’s not indented, you can’t read the code properly and
you’re not sure what statement is being run after the
selection statement runs.
Having a lot of white space around your code is
important as it makes code more readable. We use
whitespace in English as a rule to make our language
more readable, so it makes perfect sense to use it in
code to make it readable. In English, we can use
"Hello!How are you?I'm glad to see you!" as an
example. Here, the words "Hello!" and "How" look conjoined because there is no
whitespace, but once we add whitespace it should look cleaner and more readable;
"Hello! How are you? I'm glad to see you!".
In code the same rules apply, the code "3*6/4!==3||>50" looks extremely confusing and
unreadable. We can put whitespace before and after every operation which occurs,
which make the code read like this "3 * 6 / 4! == 3 || > 50". Notice also how we use a
factorial with a comparison operator, however in code with no-whitespace this can
become "!==" which means "Not equals to" but we wanted it to be "! ==" which means
"factorial comparison operator". White space is just as important for human readability
as it is for computer readability.
Variables should be aptly named using a naming convention such as snake case or
Pascal Case. By not having appropriately named variables you will become
discombobulated when you try to figure out what each variable stores and what it's for
when other people try to read your code or you read your code in a couple of months’
time. An example of this is using the variables "x, y, p, I, s". These variables are often
used as temporary storage in functions such as Bubble Sort. However, these variables
should never be used for actual variables because their names aren't clear and they are
relatively short variables which can get lost in the code. A good variable name for a
variable holding the sum of X + Y is "sum_x_y". In this, we implement snake casing and
naming the variable after what it stored inside it.
Useless comments are apparent in new coders’ code. Coders often feel like they have
to write pseudocode parallel to the code they have written
such can be seen in the example to the right. When the code
always says “return true” why explain it in a pseudo-code
format? It makes code messy and unreadable. You shouldn’t have to comment every
single line, just the things that may be confusing such as the algorithm for converting
Celsius to Fahrenheit, you could comment this with “Algorithm for converting Celsius to
Fahrenheit” to make it more readable.
12
Conclusion
In this assignment I haven taken on the persona of a programmer in a software house specializing
in varied and diverse projects, I have produce guidance that emphasizes that paradigms and
languages should be selected to suit the individual project rather than the programmers favorite
or most familiar language.
In this assignment I have talk about the different programming paradigms and the key
advantages and features. I shall be talking about why readable code is good and the uses for
different languages along with a few data types and their uses.
I have come to the conclusion that programming languages should be selected based on the
suitability for the job and not on the programmers’ preference, however a programmer’s
preference should still have a say on what languages are used.
13
References
1. Webopedia.com, (2015). What is Referential Integrity? Webopedia. [online]
Available at: http://www.webopedia.com/TERM/R/referential_integrity.html
[Accessed 26 Nov. 2015].
2. Chapple, M. (2015). Here's What 'Referential Integrity' Is in a Database. [online]
About.com Tech. Available at:
http://databases.about.com/cs/administration/g/refintegrity.htm [Accessed 26
Nov. 2015].
3. Bbc.co.uk. (2016). BBC Bitesize - KS3 Computer Science - Selection in
programming - Revision 1. [online] Available at:
http://www.bbc.co.uk/education/guides/z2p9kqt/revision [Accessed 7 Apr. 2016].
4. C++?, I. (2016). Is there a max array length limit in C++?. [online]
Stackoverflow.com. Available at: http://stackoverflow.com/questions/216259/is-
there-a-max-array-length-limit-in-c [Accessed 7 Apr. 2016].
5. Codingforums.com. (2010). number of digits in timestamp. [online] Available at:
http://www.codingforums.com/php/200420-number-digits-timestamp.html
[Accessed 7 Apr. 2016].
6. Why are there so many numeric types (bit, l. (2016). Why are there so many
numeric types (bit, int, float, double, long)?. [online]
Programmers.stackexchange.com. Available at:
http://programmers.stackexchange.com/questions/199388/why-are-there-so-
many-numeric-types-bit-int-float-double-long [Accessed 7 Apr. 2016].
7. Guzel, B. (2011). Top 15+ Best Practices for Writing Super Readable Code.
[online] Code Envato Tuts+. Available at: http://code.tutsplus.com/tutorials/top-
15-best-practices-for-writing-super-readable-code--net-8118 [Accessed 11 Apr.
2016].
8. Double Data Type (Visual Basic). (2016). [online] Msdn.microsoft.com. Available at:
https://msdn.microsoft.com/en-gb/library/x99xtshc.aspx [Accessed 20 Apr. 2016].
9. Data Type Summary. (2016). [online] Msdn.microsoft.com. Available at:
https://msdn.microsoft.com/en-us/library/aa263420(v=vs.60).aspx [Accessed 20 Apr. 2016].

More Related Content

Viewers also liked (10)

Acompanhe as últimas horas da polícia militar de pitanga
Acompanhe as últimas horas da polícia militar de pitangaAcompanhe as últimas horas da polícia militar de pitanga
Acompanhe as últimas horas da polícia militar de pitanga
 
vu2015konf_Zaromskiene
vu2015konf_Zaromskienevu2015konf_Zaromskiene
vu2015konf_Zaromskiene
 
Portada revista-estrada-12°b
Portada revista-estrada-12°bPortada revista-estrada-12°b
Portada revista-estrada-12°b
 
Refamilia107
Refamilia107Refamilia107
Refamilia107
 
Apresentaçãoinem
ApresentaçãoinemApresentaçãoinem
Apresentaçãoinem
 
Rx ps
Rx psRx ps
Rx ps
 
Fotos 2012
Fotos 2012Fotos 2012
Fotos 2012
 
Refamilia004
Refamilia004Refamilia004
Refamilia004
 
E-SHARP- SOLAR PCU
E-SHARP- SOLAR PCUE-SHARP- SOLAR PCU
E-SHARP- SOLAR PCU
 
Questão 85
Questão 85Questão 85
Questão 85
 

Similar to peter_proramming_1 (Repaired)

Introduction to Computer Programming
Introduction to Computer ProgrammingIntroduction to Computer Programming
Introduction to Computer Programming
Prof. Erwin Globio
 
Introduction to object oriented language
Introduction to object oriented languageIntroduction to object oriented language
Introduction to object oriented language
farhan amjad
 
Annotated Bibliography On Unreliable Software
Annotated Bibliography On Unreliable SoftwareAnnotated Bibliography On Unreliable Software
Annotated Bibliography On Unreliable Software
Mary Brown
 

Similar to peter_proramming_1 (Repaired) (20)

Beekman5 std ppt_13
Beekman5 std ppt_13Beekman5 std ppt_13
Beekman5 std ppt_13
 
Stnotes doc 5
Stnotes doc 5Stnotes doc 5
Stnotes doc 5
 
Vedic Calculator
Vedic CalculatorVedic Calculator
Vedic Calculator
 
SPCC:System programming and compiler construction
SPCC:System programming and compiler constructionSPCC:System programming and compiler construction
SPCC:System programming and compiler construction
 
Required computer skills program devlopment
Required computer skills program devlopmentRequired computer skills program devlopment
Required computer skills program devlopment
 
Introduction to Computer Programming
Introduction to Computer ProgrammingIntroduction to Computer Programming
Introduction to Computer Programming
 
SE.pdf
SE.pdfSE.pdf
SE.pdf
 
SULTHAN's - C Programming Language notes
SULTHAN's - C Programming Language notesSULTHAN's - C Programming Language notes
SULTHAN's - C Programming Language notes
 
Software ppt
Software pptSoftware ppt
Software ppt
 
software development and programming languages
software development and programming languages software development and programming languages
software development and programming languages
 
Crime file
Crime fileCrime file
Crime file
 
Unit 1
Unit 1Unit 1
Unit 1
 
JAVA
JAVAJAVA
JAVA
 
Introduction to object oriented language
Introduction to object oriented languageIntroduction to object oriented language
Introduction to object oriented language
 
Automatic Graphical Design Generator
Automatic Graphical Design GeneratorAutomatic Graphical Design Generator
Automatic Graphical Design Generator
 
LKGtoPG - Basics of C Language
LKGtoPG - Basics of  C LanguageLKGtoPG - Basics of  C Language
LKGtoPG - Basics of C Language
 
UNIT 2 ECSE-2.pptx
UNIT 2 ECSE-2.pptxUNIT 2 ECSE-2.pptx
UNIT 2 ECSE-2.pptx
 
Annotated Bibliography On Unreliable Software
Annotated Bibliography On Unreliable SoftwareAnnotated Bibliography On Unreliable Software
Annotated Bibliography On Unreliable Software
 
Chapter no 1
Chapter no 1Chapter no 1
Chapter no 1
 
Programming
ProgrammingProgramming
Programming
 

peter_proramming_1 (Repaired)

  • 1. IT Level 3 Software development Assignment 1 - Unit 6 Brandon Skerritt 11/04/2016 Peter Gibbins
  • 2. 1 Table of Contents Introduction ................................................................................................................................. 2 Task 1 – Programming Paradigms ........................................................................................ 3 Task 2 – Programming languages......................................................................................... 4 Task 3 – Data types ................................................................................................................... 7 Task 4 – Software design......................................................................................................... 8 Task 5 – Quality & Readability of Cod................................................................................ 10 Conclusion................................................................................................................................. 12 References................................................................................................................................. 13
  • 3. 2 Introduction In this assignment I shall take on the persona of a programmer in a software house specializing in varied and diverse projects, I will produce guidance that emphasizes that paradigms and languages should be selected to suit the individual project rather than the programmers favorite or most familiar language. In this assignment I shall talk about the different programming paradigms and the key advantages and features. I shall be talking about why readable code is good and the uses for different languages along with a few data types and their uses.
  • 4. 3 Task 1 – Programming Paradigms Procedural programming is programming which follows a linear fashion. The code is executed from top to bottom, unlike other languages where functions can be run in any order. Scripting languages such as Shell, Bash or Dash benefit greatly from the procedural programming paradigm. Because scripting languages often don't need functions and are in themselves a form of function, they can benefit from the linear readability and execution. The idea of the code being linear allows bugs and problems to be spotted more easily as you don't have to jump down a rabbit hole of functions and loops to find a problem. Procedural programming is appropriate for mathematic based programs, where each mathematical step is carried out in a linear fashion to produce the result the mathematician wants. Procedural programming is inappropriate for game creation and development. Since many games have multiple objects such as the player sprite, the players weapon, and the player’s attributes; Procedural Programming cannot compute the abstract thought of Object Orientated Design and thus is unsuited for game development or any programs where objects are used. Event driven programming is software that only runs when an event happens. An event can be anything, from the temperature rising to a certain degree, to the system reporting errors, and even an RSS feed updating. Event Driven Programs live in an event loop. This is a constant, semi-infinite loop that repeatedly sends a request to the appropriate system to see if the information has changed. A program may also run on events passed to the program, a program which involves the system passing events to the program is the Blue Screen of Death. Windows will crash and pass the error to the Blue Screen of Death program which will take then necessary precautions to fix the system and recover. Event Driven Programming is highly suitable for critical systems such as Centrifuges. A centrifuge is the control system that puts in orbit a piece of material around another material. This is used to mix and cause controlled reactions with Uranium in Nuclear Power plants. Back in 2014, Stuxnet, the computer virus, attacked centrifuges directly. Because the centrifuge started to heat up, the control system in place, created by Siemens, detected this event and took the appropriate measures to cool down the system. Stuxnet directly attacked the event handler which stopped the system from detecting any problem, however, this is not a programming paradigm problem but more of a problem with not encrypting the data.
  • 5. 4 Event Driven Programming would not be appropriate for math programs, such as the program which calculates Prime Numbers. Because this program uses the mathematical formula N^2-1, this is not an event or a loop. It would only stunt and slow down the calculations made by this program. Object orientated programming is software based upon the principality of objects. An object can be defined as anything, from a bike to the nuts holding the bike together. Object Orientated Programming is essential in Computer Science as it's based around Abstraction, and in the words of most computer science textbooks, "Computer Science is the art of abstraction". Abstraction means to take an object or function which is extremely complicated and to allow it to run in parallel with other code which doesn't need to know how complicated the abstraction is. An example of this is the transistors on a Central processing unit, we don't have to know exactly how the electricity flows through the transistors for a computer to work, but we can abstract this idea and call them Logic Gates instead. Object Orientated programming is good for computational thinking, where problems are solved using objects. It's a very natural way for computer science students to think, so it's naturally the most favorable programming paradigm. As such, Object Orientated Programming is also good for game design and development where each player has a sprite, multiple attributes and possibly objects they can interact with in the world. Object Orientated Programming is not suitable for mathematical based programming or small scripts. Since most Object Orientated Programs force the paradigm on you (Java) creating a small script to check to see if your internet connection is working may require you making multiple objects and classes to check, this is not suitable as you can easily perform the same task in 1 line of code in a scripting language. Task 2 – Programming languages 5 factors that would influence the selection of a programming language used are: The team’s knowledge – The team may already be proficient in a programming language and may choose to use it due to experience. A team would rather use a programming language they are already efficient in and know, then to learn another programming language for a project unless that programming language was essential for the project, such as using SQL to create a database as a database cannot be easily made or operated on in conventional languages. Platform – The platform you want to develop on will alter the language you use as languages are normally platform specific with a few exceptions. Shell will not run on Windows as it's a Unix specific scripting language, and likewise, Windows PowerShell will not work on Unix-based operating systems such as Mac OSX or Linux.
  • 6. 5 Specific uses of programming languages – Some programming languages are created for a specific use and thus are used for that use. Examples of this is SQL which is made only for databasing applications, you cannot use SQL for a web scraper and you cannot use Hadoop for a databasing solution. Need for speed – Some programming languages, due to being classed as level 3 or higher programming languages are slow. Because of this, we may choose to use a faster programming language such as Assembly or C to perform mathematical calculations such as vector graphic calculation for games or calculating prime numbers. Reliability – The language being chosen for the project must be a reliable programming language with a lot of bugs and flaws fixed. NASA uses Pascal to program their rocket ships and Mars rovers because the language has been tried and tested over time by many users and is considered one of the most reliable programming languages today. SQL – SQL is most appropriately used for, according to the ANSI standard, databasing solutions as it can only be used to interact with a database. SQL cannot be used to create fully blown systems with event handling and error correction facilities as it was created to interact with relational databases. HTML- HTML is most appropriately used to create the documents that appear on the web that the user downloads when they want to visit a website. This is HTML’s only use but it is used everywhere to create web-pages. C, C++ - C and C++ are two different languages. C++ is a multi-paradigm programming language which involves Procedural programming and Object orientated programming and is mainly used for Game development and development of platform specific programs such as Google Chrome. C is a procedural based programming language used mainly for control systems or operating systems due to it’s fast operational speeds. Visual Basic – Visual basic is most appropriately used within Microsoft Office applications such as Excel, as it’s the language Excel uses to create queries, variables and other spreadsheet functions. Sequence – A simple definition of a sequence is that it is a set of instructions to follow to complete a task. This is often done in a linear fashion, one after another. Sequencing is important in algorithmic structures as it defines the right steps to take to complete an algorithm. An example of this in C can be seen in the picture above, although the program converts 165 Fahrenheit into Celsius, the actual algorithm “Celsius = (5/9) * (Fahrenheit-32)” uses sequencing to make sure
  • 7. 6 the algorithm is correct. If we were to mess up the order the algorithm would not be the same and thus the program will be void for it does not work. Selection – Selection statements are used in programming to allow users to have an option and the ability to make a choice within the program which is allows for non-linear code. An example of this is the If, If else, and Else statements in C. This allows the user to make a selection about the code they want to run, however due to the abstract nature of selection statements the user may not even know the selection statement is running. An example of selections statements can be seen on the left hand side. The user will input an integer and the program will use comparison statements to check the integer the user has inputted. If the number is bigger than 10, use augmented assignments to add 1 to it. If the number is less than 10, add 10 to it. If the number is neither, tell the user their input isn’t valid for this program. Iteration – Iteration statements are statements which allow code to be repeated several times for it to meet a certain criterion, a certain amount of time or an infinite amount. There are many variations on the Iteration statements, but on the left hand side are two examples of iteration statements. The first statement is a for loop, this will loop repeatedly until the condition “y = 300” is true. We create a variable called y and set it to 0, and then every iteration we add n(10) to it. The second loop is an infinite loop, it will iterate everything while true is true, but since true is always true it’ll iterate infinitely.
  • 8. 7 Task 3 - Data types Type Range of Values Memory Required Purpose/Use Byte 0-255 1 byte Binary Integer -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647 4 bytes Whole Number under 2^32 Longint -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 4 bytes or 8 bytes Whole number under 2^64 Array Infinite, limited by size of hard drive or architecture of CPU. 16 bytes + items in array Storing values in organized list Single 1.401298E-45 to 3.4028235E+38 4 bytes Small numbers Double -1.79769313486231570E+308 to - 4.94065645841246544E-324 and 4.94065645841246544E-324 to 1.79769313486231570E+308 8 bytes Big numbers Decimal 0 to +/-79,228,162,514,264,337 16 bytes Decimal numbers Boolean True / False, 0/1, Yes/No 2 byes True/False, 0/1, Yes/No String 0 to approximately 2 billion Unicode characters 10 bytes + string length Text String(Fixed Length) 1 to approximately 65,400 Length of string Text Unix Time stamp 2^64 16 bytes Time since 1st January, midnight 1970 Date 0:00:00 AM on January 1, 0001 to 11:59:59 PM on December 31, 9999 8 bytes Day, Month, Year, Time
  • 9. 8 We have multiple data types for various reasons. One of these reasons is saving space. When you define a variable with the data type Double, it will always use 8 bytes. When you define a variable with data type Single, it will always use 4 bytes. This may not seem like a lot but on microcontroller systems where memory is limited this is a lot. The main reason we have data types is Abstraction. There are many different objects in the world, so we need many different data types to define these objects. We could define a Unix Timestamp as an integer, however, programmers may be confused by this as a timestamp should be a timestamp object. We use abstraction and multiple datatypes to help programmers understand the objects they are manipulating. In Python, all user input, by default, is a string. If a programmer can’t see this clearly defined they may think it is an integer. Task 4 – Software design Need The system life cycle starts with an individual or organization needing an upgrade or new software, and this creates the need for the new software. Without a need, there isn’t a reason to create new software. In the words of many wise men “Don’t fix what isn’t broken”. Scope The scope is the general outline of the idea that the developer has of what they are planning to build. This includes detailing estimates on how long it might take for the project to be completed, the expected amount of money that will be required to complete the project, the amount of developers needed for this project, the software which may be needed in order to aid creation of this system and perhaps the training that the staff will have to undergo to use the new software. Requirement analysis The requirement analysis is where the programmers look at all the requirements of the program and then determine how they are going to complete the project. This will usually involve asking members of staff who have used the software for a long time their opinions on the current software and how it could be improved upon. Specification This is the specific details of al the requirements that the program has to do and the amount of time that the programmers will have to complete the program in. This is a document that is agreed with both programmers and company.
  • 10. 9 Design stage The design stage is when the programmers prepare a design on how the program will work, all of the programmers will have their own input on how each part of the program should work. Once all the programmers have reached an agreement on how the program will work they will put this into a document for future reference. The design stage may also involve creating pseudocode for the project to help properly visualize how it’s going to work. Code development The code development stage is when the programmers begin to create the code. Once each programmer has created each of their individual parts and performed unit tests, they will put all their code together normally using source control such as GitHub and will compile the code. Testing The testing stage is when the programmers test the code as a whole program instead of individual unit tests. This is one of the most important stages as it makes sure that it can’t be broken by simple user input or other bugs which may annoy users to the extent where they refuse to use the software. Implementation Implementation is the stage where you roll out the working and bug tested program either to a small amount of chosen people, for example, one department or team to test for any bugs or inconsistencies in the program, or to the whole organization if you are confident in the code. The implementation process also involves training all members of staff who need to use the new software. Also, you could directly change over to the system which is dangerous, may cause mass confusion amongst users and cause them to not want to use the software. A better option is to parallel run the software next to the current software and have the users slowly transition into using the new software by offering greater functionality and ease of use. Maintenance Maintenance is the process in which the programmers constantly check for errors in the program, and fix these errors and bugs as users report them. This is known as proactive maintenance since the programmers don't stop looking for bugs until they are sure all bugs are gone, after all bugs have dispersed the programmers may perform reactive maintenance where maintenance is only performed when serious bugs occur. The programmers will often create updates using the software life cycle described in this document. A top-down design chart is a way to plan a program by creating a chart and looking at it from a top-down perspective, this is like pseudocode except you can visually see selection statements in action.
  • 11. 10 Pseudo-code meaning “False code” Is a type of design plan for a program written in Plain English and doesn’t follow a specific language. This often uses words such as “Load file” instead of “with open(file, “w”);”. These words are laid out in a similar way to program code to help understand the flow of a program. Flow charts show the process of what is happening in a program in a visual way. It allows the programmer to design their program as a rough sketch, not pseudocode but a more abstract way of thinking about code. Task 5 – Quality & Readability of Cod Quality of Code is how good looking, understandable, and maintainable code is. If code is easily maintainable and follows a strict guide on how the code is to be written and created, then it is considered good quality code. Code should be easily readable as it allows for easier monkey patching, fixing bugs and finding potential problems and security issues in the code. Many programmers, when they come back to their own code find it confusing and hard to pick up again. If they would have followed a “grammar” guide on code, it would be easier to pick up and maintain again. The advantages of having a good grammar guide on code is that you can understand other peoples code and they can understand yours more easily. An example of a grammar guide is Python’s PEP8 which is universally used at Google and Facebook. In this definition, we have good variable names such as “user_input”. This follows 2 coding standards, snake case where you have a “_” between every word and no capital letters. Capital letters are reserved for constant variables. Here are ways you can make your code more readable. Indentation – Indent your code so code that only runs after selection statements is indented below the selection statement, this makes it easier to read. Indentation is important as it separates code which runs when a selection statement is activated and code that’s run in a procedural style. Look at example 1, an example of well indented code. Each selection statement is preceded with a tab character which puts the next statement on the line below, this is nesting the code.
  • 12. 11 Example 2 is an example of how the code will look if it’s not indented, you can’t read the code properly and you’re not sure what statement is being run after the selection statement runs. Having a lot of white space around your code is important as it makes code more readable. We use whitespace in English as a rule to make our language more readable, so it makes perfect sense to use it in code to make it readable. In English, we can use "Hello!How are you?I'm glad to see you!" as an example. Here, the words "Hello!" and "How" look conjoined because there is no whitespace, but once we add whitespace it should look cleaner and more readable; "Hello! How are you? I'm glad to see you!". In code the same rules apply, the code "3*6/4!==3||>50" looks extremely confusing and unreadable. We can put whitespace before and after every operation which occurs, which make the code read like this "3 * 6 / 4! == 3 || > 50". Notice also how we use a factorial with a comparison operator, however in code with no-whitespace this can become "!==" which means "Not equals to" but we wanted it to be "! ==" which means "factorial comparison operator". White space is just as important for human readability as it is for computer readability. Variables should be aptly named using a naming convention such as snake case or Pascal Case. By not having appropriately named variables you will become discombobulated when you try to figure out what each variable stores and what it's for when other people try to read your code or you read your code in a couple of months’ time. An example of this is using the variables "x, y, p, I, s". These variables are often used as temporary storage in functions such as Bubble Sort. However, these variables should never be used for actual variables because their names aren't clear and they are relatively short variables which can get lost in the code. A good variable name for a variable holding the sum of X + Y is "sum_x_y". In this, we implement snake casing and naming the variable after what it stored inside it. Useless comments are apparent in new coders’ code. Coders often feel like they have to write pseudocode parallel to the code they have written such can be seen in the example to the right. When the code always says “return true” why explain it in a pseudo-code format? It makes code messy and unreadable. You shouldn’t have to comment every single line, just the things that may be confusing such as the algorithm for converting Celsius to Fahrenheit, you could comment this with “Algorithm for converting Celsius to Fahrenheit” to make it more readable.
  • 13. 12 Conclusion In this assignment I haven taken on the persona of a programmer in a software house specializing in varied and diverse projects, I have produce guidance that emphasizes that paradigms and languages should be selected to suit the individual project rather than the programmers favorite or most familiar language. In this assignment I have talk about the different programming paradigms and the key advantages and features. I shall be talking about why readable code is good and the uses for different languages along with a few data types and their uses. I have come to the conclusion that programming languages should be selected based on the suitability for the job and not on the programmers’ preference, however a programmer’s preference should still have a say on what languages are used.
  • 14. 13 References 1. Webopedia.com, (2015). What is Referential Integrity? Webopedia. [online] Available at: http://www.webopedia.com/TERM/R/referential_integrity.html [Accessed 26 Nov. 2015]. 2. Chapple, M. (2015). Here's What 'Referential Integrity' Is in a Database. [online] About.com Tech. Available at: http://databases.about.com/cs/administration/g/refintegrity.htm [Accessed 26 Nov. 2015]. 3. Bbc.co.uk. (2016). BBC Bitesize - KS3 Computer Science - Selection in programming - Revision 1. [online] Available at: http://www.bbc.co.uk/education/guides/z2p9kqt/revision [Accessed 7 Apr. 2016]. 4. C++?, I. (2016). Is there a max array length limit in C++?. [online] Stackoverflow.com. Available at: http://stackoverflow.com/questions/216259/is- there-a-max-array-length-limit-in-c [Accessed 7 Apr. 2016]. 5. Codingforums.com. (2010). number of digits in timestamp. [online] Available at: http://www.codingforums.com/php/200420-number-digits-timestamp.html [Accessed 7 Apr. 2016]. 6. Why are there so many numeric types (bit, l. (2016). Why are there so many numeric types (bit, int, float, double, long)?. [online] Programmers.stackexchange.com. Available at: http://programmers.stackexchange.com/questions/199388/why-are-there-so- many-numeric-types-bit-int-float-double-long [Accessed 7 Apr. 2016]. 7. Guzel, B. (2011). Top 15+ Best Practices for Writing Super Readable Code. [online] Code Envato Tuts+. Available at: http://code.tutsplus.com/tutorials/top- 15-best-practices-for-writing-super-readable-code--net-8118 [Accessed 11 Apr. 2016]. 8. Double Data Type (Visual Basic). (2016). [online] Msdn.microsoft.com. Available at: https://msdn.microsoft.com/en-gb/library/x99xtshc.aspx [Accessed 20 Apr. 2016]. 9. Data Type Summary. (2016). [online] Msdn.microsoft.com. Available at: https://msdn.microsoft.com/en-us/library/aa263420(v=vs.60).aspx [Accessed 20 Apr. 2016].