Visual analysis of a program helps understand how that program works.
A structure shows movement of data between modules in a program.
It is very useful when the developer is talking to the client as a tool to help explain how the program will work.
Rectangles are drawn and joined by lines.
The top rectangle is often called the 'main' module.
The rectangles under this are other modules or sub-routines.
These other modules or sub-routines get data from the 'main' module and sometimes return data to it.
These data flows look a bit odd, they have a small circle at the end of an arrow.
A white circle is data coupling (data shared by a couple of items/modules)
A black circle is control coupling (returns a boolean value indicating control). eg Has check been printed = True. Therefore it is a control couple.
Image reference: https://en.wikipedia.org/wiki/Structure_chart
Youtube movie that is worth having a look at. Thank you to... Christopher Kalodikis. Published on May 14, 2017
Compilers and interpreters are different forms of programs
Both work to allow us to run programs and perform various functions
Their methods of working however are slightly different
An interpreter is a program that analyzes and executes a program line-by-line
This means that instead of building the whole program before running, it runs each line sequentially
The overall execution time is slower using an interpreter
Interpreters are great for debugging, as they will execute the program line-by-line up until an error occurs
This makes bug finding easy and provides useful error feedback
Languages such as Java, Ruby, Python and Visual Basic use interpreters
A compiler is a program that translates and executes another program in whole
The compiler works to first translate the entire program into machine code
Execution time is generally faster than using interpreters as the code is compiled as one block
Compilers use less system resources (memory) than interpreters
Error messages are only produced after the whole program has been analyzed, hence debugging is comparatively harder
Langauges such as BASIC, C++ and Objective-C use compilers
Read ProgramWiz's article on Interpreter Vs Compiler here
Read TechWelkin's article on Compiler vs. Interpreter here
A control structure is a block of code that analyzes variables and decides where to take the program
There are three types of control structure; sequence, selection and iteration
Each type has its own benefits and disadvantages
The control structure used depends on the type of task being carried out
Although multiple control structures may work for an algorithm, it's best practice to chose the most efficient and cleanest control structure to use
Sequence is the easiest control structure to use and make sense of
This control structure runs through the code sequentially
This means that steps are followed in order from line 1 of the program to the end no matter what conditions are met
The selection control structure allows a program to test conditions based off certain criterion
Selection follows IF [this] THEN [that] logic
It can be seen as a boolean conditon as the result is going to be true or false
Selection structures also rely on an ELSE statement
When the specified or expected criterion isn't met, the program will follow the ELSE instructions
CASE example used in Selection from Visual Basic
Dim grade As String
Private Sub Compute_Click( )
grade=txtgrade.Text
Select Case grade
Case "A"
result.Caption="High Distinction"
Case "A-"
result.Caption="Distinction"
Case "B"
result.Caption="Credit"
Case "C"
result.Caption="Pass"
Case Else
result.Caption="Fail"
End Select
End Sub
Iteration is another term for looping
A function or program utilizing looping will run a specific block of code until certain crtierion is met
Examples in Visual Basic HERE
Three main types of iteration exist; while, do-while and for
WHILE Loops (Test-first)
A while loop can be seen as a repeating IF statement
At the start of the statement, a boolean condition is given
While this statement is true, the code within the WHILE loop will execute
Once this statement is false, the compiler or interpreter will move on to the next block of code
This is known as test-first because the expression is always considered before running the loop, meaning that this block of code has the option to never run if the condition isn't met
Example:
$i = someFunction($value);
while ($i >= 2){
// Do something
}
# Our variable $i will have an arbitrary value from some undefined function.
# While that number is greater than or equal to 2, we'll "do something".
FOR Loops (Fixed)
FOR loops run until a particular condition is satisfied
A boolean expression is given at the start of the control structure
There is an incremental counter in the for loop expression that tells the function when to stop
This is known as a fixed control structure as there's a finite number of times the loop will run (as per determined by the expression)
Example:
for ($i = 1; $i <= 200; $i++){
// Do something
}
# In a FOR loop, we state what value our counter ($i) will begin with (in this case 1)
# We then tell the control to repeat the code while $i is LESS THAN or EQUAL TO 200
# Finally, we increment our counter ($i) by 1 to continue the loop.
# This is a fixed loop because we know that the boundaries are 1 <= $i <= 200 (thus looping 200 times)
DO-WHILE Loops (Test-last)
A DO-WHILE loop will run a condition regardless of the previous outcomes
This is because the boolean expression is evaluated at the end of the control structure
This means that a DO-WHILE loop is garuanteed to run at least once
Example:
do {
// Do something
$i++;
} while ($i < 4);
# In this example, we're telling the code to run some functions and increment $i by 1.
# Since this is a test-last, we will always have this code executed at least once, since $i isn't evaluated until the end of the block.
# $i will increment by 1 until it is equal to 4.
Read more information about Control Structures from Oracle
Find some more looping examples from Processing.org here
Basic and easy to understand here
Flow charts are often used for planning logical tasks in system planning
They present an easy to understand graphical representation of how a system functions
A flow chart shows the method of processing as opposed to the actual data being processed
Look at the flow chart diagram on the right hand side of the page
In the top bubble we can immediately see the problem (the lamp does not work)
The actions (or processing) are represented with a rounded rectangle
The boolean decisions are represented with a diamond
Following the arrows downwards we come to our first decision making process
These are boolean (true or false) decicions which then effect the system's next steps
Think of these as graphical IF-THEN-ELSE statements
If the statement is false (e.g. "Lamp plugged in?") then the movement of the flow chart changes (to the right)
If the statement is true (e.g. "Bulb burned out?") then the movement of the flow chart continues to the next step (downwards)
There's no limit to how long a flow chart can be, nor how many decisions and consequential actions can exist
Flow charts provide a clear, concise and easy understanding of how a system will function
It's easy to make sense of and follow a logical progression of steps when symbolised with shapes
Since computer's only understand logic, flow charts provide a simple approach to often complex logical systems
A decision is represented with a diamond
A process is represented with a rectangle
An input or output is represented with a parallelogram
Data flows (the direction of the processes within a flow chart) is represented by an arrow
Read more about designing algorithms using flow charts by BBC Bitesize here
Read Flowchart Diagrams: Detailed Tutorial by Farshadoo here
Data validation is the process of ensuring data integrity and usefulness
We use validation techniques to make sure our data is both accurate and clean (it won't "break" our program)
Two main forms of data validation are used: range checking and type checking
A range check is used to make sure our data falls within the "boundaries" that we set
We can look at it as the scope of values that our data can fall within
Range checking is most commonly used on data that involves numbers and figures
Example:
Type
Description
Data Validation
Maximum
The maximum grade possible for Computer Science is 100%
<= 100
Minimum
The minimum grade possible for Computer Science is 0%
>= 0
Range
To achieve an 'A' grade in the Computer Science course you must score between 75% and 100%.
>= 75 AND <= 100
A type check is a simple check on the type of data being put in to or pulled out from a function
We do these checks to ensure that the program will not "break" from an incompatible data type
These are often used for date / text fields (including mail addresses) to validate the address or date entered is correct
Example:
Type
Description
Type
Validation
Number
The number entered must be in numerical form. E.g. not "ten"
10 ≠ ten
The email address must follow correct syntax and resolve to a real domain
email@domain.tld
Date
The date must be valid (e.g. there is no 34th day or 13th month)
34/13/2012
(Advanced) Check out this lecture on Type Checking from Chalmers.se here
Check out RevisionWorld.com's article on Checking Data / Data Quality here
Pseudocode can be seen as non-technical programming
It exists as documentation for planning out and assessing an algorithm
We often write pseudocode on pen and paper, although it is generally up to the author's personal preference
Pseudocode is never compiled or interpreted - it is purely used as a high-level description of the process(es) for human interpretation
Pseudocode (along with trace tables) can be used as a proof of concept or solution for application
1.1 Return the student's academic status based off their mark [English orientated]
IF Student's grade is greater than or equal to 65
PRINT "Passed"
ELSE
PRINT "Failed"
1.2 Return the student's academic status based off their mark [Programming orientated]
var = Input("Student's grade")
IF var >= 65
PRINT("Passed")
ELSE
PRINT("Passed")
2.1 Determine the percentage of student's that have passed [English orientated]
Set passCounter to 0
Set totalStudents to 0
FOREACH Student
ADD 1 to totalStudents
IF Student's grade is greater than or equal to 65
PRINT "Passed"
ADD 1 to passCounter
END FOREACH
SUBMODULE: percentageOfPasses(totalStudents, passCounter)
Set percentageTotal to 0
percentageTotal = (passCounter divided by totalStudents) times 100
Return percentageTotal
2.2 Return the student's academic status based off their mark [Programming orientated]
passCounter = 0
totalStudents = 0
FOREACH Student
totalStudents += 1
IF(studentGrade >= 65)
PRINT "Passed"
passCounter += 1
END FOREACH
SUBMODULE: percentageOfPasses(totalStudents, passCounter)
percentageTotal = 0
percentageTotal = (passCounter / totalStudents) * 100
Return percentageTotal
Parameter passing is the technique of passing values between functions or subroutines
Two common methods of passing exist; value passing and reference passing
A parameter's scope is the boundary of which a value can exist in
The lifetime of an identifier is dependent on the type of passing being performed
A parameter called by value simply outputs the value of the actual parameter
Passing by value is essentially passing a copy of the original value to function or submodule
If the value of the original parameter were to change, our copy would not reflect this change (because the value we were given initially is the only copy we have)
A parameter passed by reference refers to the original location of the parameter's value
This means that any changes to this value will be reflected to our own value (because our value is really just a "link" to the original value)
Reference passing can be thought of as "symbolic linking" between a parameter's value and the calling submodule or function
If we were to print out a copy of this web page and handed one to each student, this would be an example of value passing
This is because the original copy of the website remains unchanged - if we were to destroy the printout of our website or make annotations and notes, these changes wouldn't be reflected on the original copy. This is an example of passing by value.
If we were to send a copy of the URL to each student, this would be an example of reference passing
Any changes that were made to the web page would be reflected on both the original and the given link to the website. In the same notion, if we were to delete the URL pointing to the website, the actual contents (or value) of the website would remain unchanged, because we're only deleting a reference (link) to that page.
Read this thread on the differences between passing by reference and value from Stackoverflow.com here
Read an article with some examples in Pascal and C by SwinBrain on Pass by Value vs. Pass by Reference here
Each program is uniquely written to perform a specific set of functions
For data to be converted in to meaninful and useful information, it must first be processed
Much like a computer system, programs deal with data in three main steps
These program components allow us to alter and create all types of data
Program's often utilize an input method to gather information
This is usually in the form of human input, such as through a prompt or text field
Some programs use the output of another program as their own input
This is especially common in number crunching and statistical programs
Some programs even make use of sensors and other hardware for data input
Other programs may even allow for advanced input, such as voice recognition and facial detection
Data input is a crucial component of any program as it defines what information is going to be processed, and in turn the end result
Program processing is handled by the host computer's processor
The computer's processor is responsible for manipulating a program's given information and returning a result
The data type processed is often dependant on the program's capabilities and purpose
Read The Computing Teacher's article on CPUs here
Read The Computing Teacher's article on the Fetch Execute cycle here
A program's output is the end result of the processed data
We may not see the output of a program if the information released is intended for further processing (e.g. a value returned as part of a submodule)
Outputs often occur as information we can understand and work with
Common outputs may be things such as photo, video and audio files, text, charts, graphs and even physical feedback (e.g. synaptic feedback)
The data output from a program is dependent on the program's purpose
Read more on C Programming Input Output (I/O) by Programiz.com here
Read more on Input/Output (I/O) on Wikipedia here
A number system is a writing system for expressing numbers
These mathematical notations can be presented using digits or other symbols
Number systems are an integral part of a computer system as they provide the backbone of processing and computing
Computer's utilize three main number systems; binary, decimal and hexadecimal
The binary number system is a base-2 number system that consists of only two digits: 0 and 1
These digits represent the state of which a computer switch can fall under, with 0 commonly referring to off and 1 referring to on
The short name for a binary digit is a bit (the smallest amount of information available in a computer system)
Binary works by using 0's and 1's to represent the value of larger numbers
Each value of a digit in binary is double that of the number to the right of it
If a "1" is placed in a values column, we add that value to the total count to get our number
Example:
Value
8
4
2
1
Binary
1
1
0
1
Number
13
5
1
1
(Hint: Read from right to left. The binary number 1101 is equal to 13.)
The decimal number system is a base-10 number system and is one we use on a day-to-day basis
A decimal number system uses the digits 0, 1, 2, 3, 4, 5, 6, 7, 8 and 9 to represent numbers
These numbers use a decimal seperator (full-stop or period) to indicate a fraction
We use a + symbol to represent a positive number, and a - symbol to represent a negative number
The properties of the decimal number system make it hard for a computer to be fully accurate when rounding with numbers
This is because computers work with a base-2 number system (binary)
These numbers get less accurate the bigger or smaller they get (often both extremities)
These inaccuracies are often minute and still offer far more reliability than a person!
The hexadecimal (hex) number system is a base-16 number system
It utilizes the decimal system's 10 digits (0, 1, ..., 9) as well as an additional 6 characters (A, B, C, D, E, F)
Hexadecimal values are widely used by programmers and developers as they allow for writing large values easily
This notation is often used to reference colour options
E.g. the HEX value #FF0000 is the equivalent colour of red
Hex values can be written in capitals or lowercase
Read more about Binary Numbers at CSUnplugged.org here
3 Ways to Understand Hexadecimal at WikiHow here
Read more about the numeral systems on RapidTables here
Convert between binary, decimal and hexadecimal with an online converter
Started in the 1940s
First generation programming languages are machine-level languages, ie to make the CPU work and connect hardware. Not many apps in those days.
This means that there were no compilers or assemblers to translate human-readable code in to binary
Programming instructions (in the form of binary) were entered through the front panel switches of a computer system
Instructions were entered directly in to the CPU for processing
As these instructions were binary based, programming was much harder to interpret and understand for the human programmer
Pros; achieved the objective to get CPU working
Cons; many errors, slow compared to these days, limited memory in those days, difficult of programmers
Examples; Motorola 68000 used in early macs, Intel 8088 used in early window machines
Want to write code in 1GL? Learn binary here
Started in the 1950s
The second generation of programming languages introduced an assembler
This assembler's job was to convert code that could be written and understood by a human in to binary that could be intepreted by a computer
The assembler's ability to read these instructions is entirely dependent on the processor's architecture and make
2GL programming languages allow for better understanding and interpretation for the human programmer
Pros; programmer could read it and make it
Cons; Had poor program flow control
Examples; RISC, CISC, x86
Examples of code include identifying the memory location for placement of numbers, the calculation and next is the result and the storage location for that result.
Started in the 50s
Third generation programming languages are known as high-level languages
These languages are much more machine independent and programmer friendly
Has program flow control such as if-else statements, arrays and more structured programming
High-level languages are often English-based and provide the programmer with a broad understanding of the code
Pros; programmer friendly
Cons; need to know lots of programming
Examples; C, C++, Java and BASIC are third generation programming languages
Examples of difference between 2GL and 3GL see here
Started in the 1970s
They are built to work more with databases
Pros; programmer friendly, support databases, support web-development
Cons; increased developer learning
4GL programming languages can be seen as more programmer-friendly 3GL languages
They focus on bringing power and versatility to programming (e.g. the ability to adapt to more types of processors / computers)
These languages are written to operate with larger collections of data rather than just bits and bytes
Examples are SQL, Coldfusion, CSS
Example syntax; Extract all Sales WHERE price < $200
Procedural Languages
These languages are seen as the traditional programming languages
They're based on algorithms and logical step-by-step processes
Procedural languages make use of control structures such as iteration and selection to perform a task
In these languages, the programmer tells the program what and how to do it
Example languages: C++, COBOL, FORTRAN, ALGOL
Non-procedural Languages
These languages only care for the what of the program as opposed to how to get the results
Non-procedural languages are used to specify the conditions that the answer should produce, but now how to go about it
These languages are generally constructed in the form of commands entered by the programmer
Example languages: SQL, Visual Basic
Object-oriented programming (OOP) is a modern concept of programming
It focuses on data structures that contain data in the form of fields (known as attributes)
Code is written in the form of procedures known as methods
An object is a structure that contains both data and procedures
A class defines the data format and available procedures (methods) for a given type or class of object
These languages work by allowing objects to interact with one another
Example languages: Python, C++, Objective-C, Delphi, Java, Swift, Ruby, PHP
Unlike programming languages, scripting languages are interpreted rather than compiled
These languages are interpreted one command at a time
They're commonly used to add functionality and enhanced features to websites
Unlike other programming languages, web-based scripts are run on the end-user's web browser as opposed to the server
Example languages: JavaScript, ASP, JSP, PHP, Perl, Python
Read a List of Programming Languages on WikiPedia here
Read the article Procedural and Non-Procedural Languages from EnggPedia here
Read an Introduction to Object Oriented Programming Concepts and More on Code Project here
Read the differences on Scripting and Programming here
Documentation is a set of documents that provide information on a program
A program will often consist of internal and external documentation
Both provide developers and end-users alike with instructions and information on the program
Internal documentation is documentation written within a program
This refers to any comments and instructions written by and for the developer(s)
Internal documentation is used to keep a form of communication open between developer(s)
It's used to explain parts of code as well as provide useful information on the program internally
This form of documentation can be written as comments or manuals
External documentation refers to manuals and guides written for end users
These documents explain how to operate a program and use it for its intended use
External documents are common with all types of software and hardware
These documents are written by developers and other end-users
Unlike internal documentation, these notes don't explain how functions work, but rather how to use them
Read Lamar University's Guidelines for Programming Documentation here
Read Technology Evaluation Center's article on Difference between Internal and External Documentation here
Programming is all about writing the most efficient code to achieve a specific task
By using variables and constants, we're able to store values temporarily
These values can then be referenced or re-used to perform other tasks and functions
Variables and constants are used in both programming and pseudocode
A variable is a memory location that has its own associated name (known as an identifier)
Variables are simply temporary stores that a program can access to reference or re-use a value during execution
Unlike constants, variables can vary and have changing values
Variables are used religiously throughout programming as they streamline efficienecy and allow for easier referencing
A constant is another memory location that, like a variable, consists of an identifier and a value
Unlike a variable, however, a constant does not change in value
These are handy for fixed values such as the mathematical symbol Pi
Pi is a constant is the value does not change
Pi is given a symbol to represent the fixed value number, which is known as its identifier
A naming convention is simply a set of rules put in place to ensure organization and consistency of variables and constants
Many programming languages allow for a vast array of naming options for variables and constants
How variables and constants are named in a program are often up to the discression of the developer(s)
They're used to reduce the effort needed to read code as well as maintain consistency
Some variables and constants have system or programming language restraints, such as words reserved for predefined functions
It's generally sought after to name variables and constants with clear English words that relate to their use
A local variable is a variable that is only accessible in the current code or module
To write code you need to set up numbers and words that can be read by the program
These numbers and words are given data types and values so they can be read.
For calculating the area of a rectangle we need to be able to use the following variables
length
width
total area
To make length, width and total area, variables we need a data type and a value (VB example)
Dim length As Double
Dim width As Double
Dim totalArea As Double
The purpose of a global variable is to provide a variable that is accessible from anywhere within the program. eg so other functions or modules can use them.
They are placed prior to other modules or functions.
So, a global variable can be used in a module, only if it is in the code prior to that code.
Ideally you want a variable to change, but as a global variable is used by different modules, it will cause confusion when it is changed.
Global variables are not used much as they are limited in what they can do.
A parameter is a referenced variable or constant that is passed to a function or module
We define a parameter of a function or module and tell the program what values are needed for it to operate
These parameters can be passed into and out of a function or module
They usually have brackets (parentheses) around them so are easy to find.
Check out ProgramWiz's article on C Variables and Constants here
Check out Tuts+'s article on 9 Confusing Naming Conventions for Beginner's here
Check out CodingUnit's article on Global and Local variables here
Check out MSDN's article on Parameter Passing in C# here
Structured programming is a methodology used in programming
It aims for clear, concise and high quality efficient programs
Structured programming makes use of blocks of code (aka subroutines) that allow for the re-use of functions
Loops (for, while and do-while) are commonly used in structured programming
Structured programming is the fundamental concept behind Object-Oriented Programming
A computer function is a procedure or routine a computer follows when executing a program
Programs contain vast amounts of functions that, when processed and executed, return results
Some languages define a function as something that returns a value as opposed to a routine which doesn't
Functions allow us to re-use code without having to re-write it in different locations
Functions do not execute immediately after the program has loaded, but rather when called upon
By breaking down a program into functions, we're able to keep code efficient and clean
Example function (PHP):
<?php // This function returns the value of $x. function myFunction(){ $x = 3; return $x; }?>
Modularisation is a term used for organizing and reducing the complexity of a program
This is achieved by breaking up sections of code in to modules
Visual Basic is a programming language that utilises modules
Each module is used to define a set of tasks for the program to execute once called upon
Modules are very similar to functions, although a module does not have to return a value
A statement is a line or chunk of text written within a program.
It causes some action to be carried out.
A stub in programming can be seen kind of like a placeholder
It holds the place for code that is either handled remotely or code that has yet to be developed
A stub can mimic the functionality of the intended code, but almost certainly is always smaller in size and contains less functionality
Stubs are used to remind developers what a section of code is used for or to call in the remote processing function if necessary
Read about Structured Programming by c2.com here
Read a WikiBooks entry about Computer Programming/Structured Programming here
Code is a system of words, letters, symbols or characters that are processed by a computer in order to perform specific functions
Computer code is the instructions carried out to run programs
Code exists in two forms, source code and executable code
Source code can be seen as the "before" code of a program
It exists as plain text that has yet to be compiled or interpreted
Source code contains the exact content of the program to be compiled; yet does not perform any function
Programmers often write code in text editors such as NotePad++, once a file is saved as a file it becomes source code until executed
Try it yourself! Right-click on this webpage and select the option to "View Page Source"
Executable code (or object code) is the low-level language that is executed when compiled or interpreted
Once a compiler or interpreter has done its job with the source code, the resulting low-level code (or machine code) is executed
Machine code is the hardware-specific code that is translated in to instructions to be carried out
Executable code, unlike source code, is responsible for performing specified functions
Bytecode is code that is processed by a virtual machine (VM). The VM translates it to machine code.Examples of translators are Java Virtual Machine, Python.
Errors and mistakes often occur in programming
When staring at a computer screen for hours on end, errors and mishaps are more than likely to appear throughout a development process
Programming faults exist as syntax, run-time and logical errors
Syntax errors (or semantic errors) can be seen as the spelling errors of programming
They occur when the compiler or interpreter is unable to make sense of a word or character
Syntax errors can occur commonly as small mistakes; such as missing semi-colons to end a line, are often hard to pick up without running the program
Generally they are easy to fix. Just find the typo and fix it.
Example:
System.otu.println("Hello, world!");
In the above example, the word "out" is misspelled
This would result in an error as the compiler or interpreter would not be able to make sense of the line
Run-time errors are errors that happen at run-time. ie when the program is running.
The program was made correctly, it compiled correctly, but it can't follow the instructions
Example 1; a user enters the number 0 which is unexpected. eg while x >1 AND <100 ...will cause a run-time error
Example 2; print(Name). This will crash at run-time if the variable Name is not defined...will cause a run-time error
Good programmers will write programs that have expected error handling. But sometimes they just happen when we are developing programs.
Examples HERE
Logical errors (or logic errors) occur when a program produces incorrect or unexpected results due to poor logical processing
Unlike a syntax error or runtime error, the program does not end abruptly or abort
These are caused by programmers' mistakes within the source code
Common examples include using incorrect operators
Examples HERE at the University of Waterloo
Example HERE at wikipedia