Upload
franbimari
View
217
Download
0
Embed Size (px)
Citation preview
8/13/2019 Unit 18 Software Design
1/38
While not every IT practitioner is a programmer, an understanding of
the process by which programs are written is important. Developing
software is a complex process and so the design phase is very
important. This unit looks at what is involved in the development
process and the tools and techniques which can be used to createa design.
For anyone considering a career in software development, understanding softwaredesign is clearly important. A job as a software designer is a senior position requiringmany years of experience, but even a trainee programmer is expected to understandthe principles of software design.
The software designer must first of all understand what the program needs to doand then develop a design which will guide the programmers who will writethe software. The creation of the design is therefore very important thedesign must be correct, otherwise it is unlikely that the software that will beproduced from it will do what is required.
Learning outcomesAfter completing this unit you should:
1. know the features of programming languages
2. know the software development process
3. be able to design software development solutions
18Software
design
Credit value: 10
8/13/2019 Unit 18 Software Design
2/38
Assessment and grading criteriaThis table shows you what you must do in order to achieve a pass, merit or distinction grade, awhere you can find activities in this book to help you.
To achieve a passgrade theevidence must show that youare able to:
To achieve a meritgrade theevidence must show that, inaddition to the pass criteria,you are able to:
To achieve a distinctiongradethe evidence must show that, inaddition to the pass and meritcriteria, you are able to:
P1 describe the characteristics ofprogramming paradigms
See Assessment activity18.1 on page 18
M1describe the features ofprogramming languages;
including how sequence,
selection and iteration
are usedSee Assessment activity18.1 on page 18
P2 identify the factors influencingchoice of programming
language
See Assessment activity18.1 on page 18
P3 describe the stages of thesoftware developmentlife cycle
See Assessment activity
18.2 on page 24
P4 outline a specification for abusiness requirement
See Assessment activity18.2 on page 24
M2select and justify theprogramming language
to be usedSee Assessment activity18.2 on page 24
P5 design a software solution toa business requirement using
appropriate design tools
See Assessment activity18.3 on page 36
M3describe the data types andsoftware structures used in a
design solution
See Assessment activity18.3 on page 36
D1 develop algorithms torepresent a design solution
See Assessment activity
18.3 on page 36
P6 review the design against theoriginal requirementSee Assessment activity18.3 on page 36
D2 evaluate the designtools usedSee Assessment activity18.3 on page 36
2
BTECs own resources
8/13/2019 Unit 18 Software Design
3/38
How you will be assessedThis unit is internally assessed. You will provide a portfolio of evidence to showthat you have achieved the learning outcomes.Your portfolio of evidence canbe supplied in many formats including electronically as well as paper-based. Thegrading grid in the specification for this unit lists what you must do to obtain pass,merit and distinction grades. The Assessment activities in this unit will guide youthrough tasks that will help you to be successful in this unit.
Your tutor will tell you exactly what form your assessments will take, but you couldbe asked to produce:
presentations written documentation: o supporting documents o specification o design documentation an evaluation of your work.
Unit 18Software
Amir Khalid, a 17-year-oldLevel 3 learner
I studied this unit last year, and now Im on the Level 3 course. I was
really interested in this unit, as software development is what I want
to do. To be honest, design isnt the most interesting part of software
development but now I realise how important it is.
I think one thing that we found quite hard was relating the fairly simpleexamples of programs and designs that we looked at with real commercial software.
The part I found most difficult was creating the structure and dataflow diagrams. To start with,
I found this very hard and needed to practise it. I discovered that the best way to produce
these diagrams was to have a very good understanding of what the software is supposed to
do and then to follow the whole process through, using action lists and storyboards initially.
As far as the assessments were concerned, the toughest parts were justifying my choice
of programming language and evaluating the design tools I used. Of course, I also found
producing the design hard too!
Overall I think this was the most challenging unit we did, but I found it really interesting.
Over to you
Do you have an interest in software development? Have you ever wonderedabout how computer games are designed and created, for example? Whatsort of attitude or personality do you think makes a good programmer?
Do you know anyone who has done programming, perhaps on a higher levelcourse or at university, or as a job? Speak to them and find out howthey find writing programs (easy or difficult, fun or challenging?).
8/13/2019 Unit 18 Software Design
4/384
BTECs own resources
1. Know the features ofprogramming languages
4
BTECs own resources
Warm upStart up Programming a robotImagine you have to write a program that controls a robot. It might be an industrial
robot that paints a car in a factory or a robot the army would use to search for
roadside bombs.
Working in a group, think about how you would design the program to control
the robot.
The first thing you would need to decide is what sort of robot it is and exactly
what it will do.
How would you split up the design and creation of the control program
between the members of your group?
What techniques could you use to design the way the robot works?
You dont need to define this in a lot of technical detail, just think in general terms
about how you could create a design.
Case study: Working as a specialist software developer
I run a small software
company that writesspecialist software forthe building trade. Wehave created a programwhich is used to helpbuilders estimate howmuch a particular jobwill cost. Over the yearswe have developedand added to the
program so it now includes many different modules.It is used by over 250 different building companiesaround the country.
We wrote the original version in Visual Basicbecausethats the language my partner and I knew best.Also, we wanted to use MicrosoftAccessas thedatabase and these two link together well. We havebuilt up expertise in these products in the company,so it would be difficult to change the programminglanguage we use now, although we have consideredit because it does restrict our customer base to thosewho run MicrosoftWindows.
The software is always being developed and, because
we have lots of customers, we have to survey themall on the features they would like to see in the nextversion. In that way we create a wish list ofnew features.
Its very important to understand the building tradeand what they need from the program. Once weare clear on what new features we will add in thenext version, we begin the design. Over the yearsweve found that, although the design stage can bedifficult and not as interesting or as exciting as writingthe programs and getting them working, it is veryimportant to get the design right. If its not right, wehit problems when we come to write the programs.
1. What influenced the companys choice ofprogramming language?
2. What must the company do before they startwork on a new version of their software?
3. Why is the design stage so important?
8/13/2019 Unit 18 Software Design
5/38
Unit 18Software
What is a computer program?A computer program is a series of instructions that tells the computers
processor what to do. Programs are what make computers powerful. Unlike
typewriters or fax machines, which have only one function, computers must
carry out many different tasks. Programs make this possible.
Computers, however, can understand only machine codeinstructions
in the form of binary codes. Programs for the very first computers were
written using these binary codes, but they are very difficult for people
to understand. Because of this, programminglanguages(sometimes
called high-level languages) were developed.
Programs consist of two important parts:
instructions, which tell the computer what to do
data, which the instructions act on.
Data is often input by the user of the program. In the Windows
Calculator program, the user enters the numbers that they want to do
the calculation with this is input data. The program then carries outthe instructions to do the calculation and displays the result this is the
output data. The data varies depending on what the user inputs, but the
instructions for a given calculation stay the same.
1.1 Programming paradigmsComputer programs can be very complex indeed. Over the years a
number of different paradigmshave been developed to deal with
this complexity and encourage the development of efficient and
error-free programs.
Procedural programmingIn this approach the programmer writes the instructions as a series of
logical steps to produce the desired result. Different functions within
the program are provided by different procedures (or subroutines). In
the WindowsCalculator, different procedures might be provided to do
addition, subtraction, multiplication, etc.
Procedures can be run from the main program to carry out their specified
function or from within other procedures. One of the benefits of this
approach is that where tasks need to be carried out several times within
the program, the instructions do not need to be duplicated. Instead, the
procedure runs as many times as required. This provides a better way
to organise or structure a large, complex program. With the procedural
approach the data in the program is shared between the procedures.
Object-orientedObject-oriented (or OO) methods were developed as a response to the
increasing complexity of software, which was difficult to handle with the
procedural approach.
Unit 18Software
Machine code the instructions that
are executed directly by the computer
CPU, sometimes called the instruction
set. These instructions are in the form o
binary numbers.
Programming language a defined
set of English-like instructions which
are used to create a program. These
instructions are easier for people to
understand than binary codes. The
instructions are converted into the bina
codes that the computer understands,
using a piece of software called
a compiler.
Paradigm an approach, framework o
way of doing something.
Key terms
8/13/2019 Unit 18 Software Design
6/386
BTECs own resources
Object
With the OO approach to programming, the things a procedure does
(its functions) are put together with the data it needs in something
called an object. The idea of an object is based on the real things the
program is dealing with, for example:
in a library system, the objects might include books, members
and loans in a mail order system, the objects might include customers, orders
and products.
Objects in a software system can represent physical things like
customers or books, or conceptual things like an order or a loan.
Class
A class is a template for an object and defines the data (or attributes in
OO terminology) that each object of that class will have. For example, think
of a library system which has a class for books. The data that the book class
would define includes things such as the book title, author, ISBN number,
etc. An object of the book class is created using the class template and hasactual values for the data that the class defines, such as Harry Potter and
the Goblet of Fireas the title and J. K. Rowling as the author.
Methods
Classes also have functions (things the class can do), which in OO
terminology are called methods.
A customer class might have a change of address method.
A book class in a library system might have a go on loan method.
Remember that a class is like a template for objects and defines the data
and methods (functions) of the class. All the objects of that class have
the same attributes and methods. Classes can be defined by a classdiagram. This lists the name of the class, its attributes and methods.
Figure 18.1 shows the class diagram for a learner class in a system for
recording learners assignment marks. This simple class has just two
attributes (name and marks) and three methods (set name, show marks
and update marks).
An OO system is made up of objects (created using the class as a
template). These objects work together by one object requesting a
service from another (using the methods of that class). For example,
if there is also a Tutor class, then an object of the Tutor class might
request an object of the Learner class to run its showMarks method, soit could find out the marks that the learner currently has.
It is important to understand that the only way in which other objects
can gain access to the attributes of a class is by the methods of that
class. This is one of the key differences between the procedural
approach to programming (where data is shared between procedures)
and the OO approach (where the data is contained within the object
and is only accessible via the objects methods). This concept is known
as encapsulation.
Attributes the name given to the data
used within a class.
Methods the functions of a class, i.e.
the things a class can do.
Encapsulation the technical term for
the way in which the attributes (data) and
the methods (functions) of a class are
packaged together within a class, and
the data of a class can only be accessed
by the methods.
Key terms
Figure 18.1:Class diagram for the
Learner Class.
LearnerName
LearnerMarks
Learner
setName
showMarks
updateMarks
8/13/2019 Unit 18 Software Design
7/38
Unit 18Software
Event drivenThe event driven approach to programming refers to how the program
responds to user input, not to how the program is structured. Therefore,
event driven programs can be written using a procedural or an object-
orientated approach.
Event driven programming is used with the Windowsuser interface.
Windowsprograms respond to user input for example, when you
click a button or choose a menu option a particular function is carried
out. Clicking buttons or choosing menu options are all considered
events. Event driven programming therefore involves writing event
procedures which respond to the actions the user takes.
Events inputs to the program that
control what the program does. Events
are often user inputs, such as mouse
clicks or menu selections.
Key term
What different events can a Windowsprogram respond to? As wellas left-clicking on a button or menu on the screen, there are severalother events that popular Windowsapplications respond to. List asmany as you can.
Activity: Events in a Windowsprogram
1.2 Program featuresTo help you understand the features that programs have, well look
at some simple examples of programs written using the Visual Basic
programming language. This is not intended to be a tutorial on writingprograms in Visual Basic the programs are shown to help you
understand the features and structures of programs.
As mentioned on page 5, a program consists of instructions and data.
The data in a program is usually input by the user. It is then stored in
the program in a memory area that the programmer creates called a
variable.Variables have three properties:
A name, which is given by the programmer. Variable names should
give some clue as to what the variable is used for, but they cannot
contain spaces.
A data type, also defined by the programmer. This defines the sortof data the variable can hold. Typically a programming language will
have data types for text and various numerical formats.
A value, which is held in the variable. This may often be set as a
result of user input.
Lets look at a simple program, as shown in Figure 18.2 on page 8.
Here we are using a console application, which does away with the
visual side of the language and uses simple text input and output via a
console window. Using a console application helps us to concentrate on
Variable a storage area in a program
for data. This data might come from us
input or from a calculation done within
the program.
Console application a text-based
application that runs in a command
prompt window.
Key terms
Did you know?
You can download MicrosoftVisu
Basic2010 Express for free by
going to Hotlinks and clicking on
this unit.
8/13/2019 Unit 18 Software Design
8/388
BTECs own resources
the key features of programming, rather than having to worry about the
complexity that using a Windowsapplication adds.
This program takes two numbers input by the user, adds them together
and outputs the result. Figure 18.3 shows the program running.
In this simple example, the instructions in the program are followed
in the order they appear in the program. However, programs can also
select to carry out one set of instructions instead of another. The choice
(selection) of which set of instructions to follow is usually made by
the user.
There are other sections of code which may be repeated a certain
number of times or until some condition is met. These different
situations give us three ways that the flow of program instructions can
be arranged:
Sequence: Instructions are followed one after the other, as in the
example above.
Selection: A choice is made as to which set of instructions to follow.
Figure 18.2:A simple Visual Basicconsole application.
These instructions define 3 variables,called input1, input2 and result all with adata type of integer (whole numbers).
These output instructions display theresult variable and wait for the user topress any key before the console
window closes.
This instruction adds together the valuesin Input1 and Input2 and assigns theresult to the variable called result.
These instructions output messages tothe user and then assign the input theuser makes to the variables input1 andinput2.
8/13/2019 Unit 18 Software Design
9/38
Unit 18Software
Iteration: A set of instructions is repeated in what is sometimes
called a loop.
We will demonstrate selection and iteration by making some
modifications to the simple program we looked at earlier.
SequenceWhen the program needs to do things like calculations, acceptinguser input or outputting data, the program instructions are followed in
sequence from top to bottom. But in many situations, a program needs
to do different things, perhaps because of the input the user has made.
In these situations selection is used.
SelectionIn most programming languages selection is done using an if
instruction. The instruction compares one value or variable with another
and if the outcome is true, the instructions following the if statement
are executed. If the outcome of the comparison is false, the followinginstructions are skipped and the program continues at the end of
the if instructions.
Several different comparisons can be done to take into account various
different possibilities. Figure 18.4 (on page 10) shows a modified version
of the program we looked at in Figure 18.2 (on page 8). The new
instructions are in red.
Figure 18.3:The adding program running.
8/13/2019 Unit 18 Software Design
10/380
BTECs own resources
This type of instruction is sometimes called if... then... else. Notice
how the instructions are indented following the if instruction. This
shows which instruction is executed depending on the result of the if
comparison. For example, the instruction in figure 18.5 is only executed
if the choice variable contains an A.
Where there are a number of different values to consider in a selection
instruction block, the if instruction can be rather long and complex. A
slightly simpler alternative is the Case instruction. Look at the modified
version of the previous program shown in Figure 18.6. This allows the
Sub Main()
Dim input1 As Integer
Dim input2 As Integer
Dim result As Integer
Dim choice As String
Console.WriteLine("Enter a number")
input1 = Console.ReadLine()
Console.WriteLine("Enter another number")
input2 = Console.ReadLine()
Console.WriteLine("Enter A to add or M to multiply")
choice = Console.ReadLine()
If choice = "A" Then
result = input1 + input2
ElseIf choice = "M" Then
result = input1 * input2
Else
Console.WriteLine("Invalid choice")
End If
Console.WriteLine("The result is " & result)
Console.WriteLine("Press any key to continue")
Console.ReadLine()
End Sub
This new variable is namedchoice and has a data typeof String (text).
The user is requested to
enter an A or an M andtheir input is placed inthe choice variable.
An if instruction checks thechoice variable and carriesout add or multiply basedon what the user enters.
If the user enters somethingother than an A or an M this
part of the if instructionis executed.
Figure 18.4:Program demonstrating selection.
Console.WriteLine("Enter A to add, M to multiply, ")
Console.WriteLine("S to subtract or D to divide
choice = Console.ReadLine()
Select choice
Case "A"
result = input1 + input2
Case "M"
result = input1 * input2
Case "S"
result = input1 - input2
Case "D"
result = input1 / input2
End Select
Console.WriteLine("The result is " & result)
result = input1 + input2
Figure 18.5:This instruction is only executed
if the choice variable contains an A.
Figure 18.6:Program demonstrating the use of the Case instruction.
8/13/2019 Unit 18 Software Design
11/38
Unit 18Software
user to carry out all four arithmetic operations (add, subtract, multiply
and divide). Note that not all the program code has been included.
The case instruction starts with the instruction Select, followed by the
name of the variable which contains the value to be inspected. Then for
each possible value you have a Case instruction followed by the value
you are expecting. This is followed by the instructions which will be run
if the variable contains that value.
IterationIteration is when instructions are repeated. Lets look at a version of
our program that includes a loop. As it stands the program will just
run once, then finish. By putting the main part of the instructions in an
iteration loop, it can run until the user ends it.
Sub Main()
Dim input1 As Integer
Dim input2 As Integer Dim result As Integer
Dim choice As String
Dim EndIt As String = "Y"
Do While EndIt = "Y"
Console.WriteLine("Enter a number")
input1 = Console.ReadLine()
Console.WriteLine("Enter another number")
input2 = Console.ReadLine()
Console.WriteLine("Enter A to add or M to multiply")
choice = Console.ReadLine()
If choice = "A" Then
result = input1 + input2
ElseIf choice = "M" Then
result = input1 * input2
Else
Console.WriteLine("Invalid choice")
End If
Console.WriteLine("The result is " & result)
Console.WriteLine("Press Y to continue or any key to exit")
EndIt = Console.ReadLine()
Loop
End sub
Another new string variable,set to Y so the loop runsat least once.
This is the start of the loop.It will keep looping while theEndIt variable is set to Y.
End of the lo
At the end of the calculationthe user inputs a Y, whichis placed in the EndIt variableto keep the program looping.Any other input will endthe loop.
Figure 18.7:Program demonstrating a loop.
In this example, a Do while loop continues while the EndIt variable
contains a Y. If the user enters any other value, the loop (and therefore
the whole program) ends.
8/13/2019 Unit 18 Software Design
12/382
BTECs own resources
Do while loops are not the only types of loop there are also forloops and other types. Find out how these loops are coded and whatthey can be used for.
Activity: Loops
Logical operatorsThe logical operators AND and OR are used to create more complex
comparisons in if, Do while and other selection and loop instructions.
With these operators you can create comparisons which look at more
than one value. For example, imagine you are writing a fantasy game
program. You have decided that if a dragon character in the game has
collected two swords and a golden key, they are awarded 200 extra
bonus points. The instructions you write might look something like
those shown in Figure 18.8.
Figure 18.8:Instruction using the logical operator AND.
If Swords = 2 AND Gkey = 1 Then
BonusP = BonusP + 200
End if
Swords, Gkey and BonusP are all variables with a data type of integer
(whole number). One problem with this code is if the dragon has
already collected three swords when it gets the golden key. With this if
instruction the bonus points would not be awarded.
As well as using equals signs in comparisons, you can also use the
symbols for greater than and less than. In this case we need to modify
the code so if swords is equal to or greater than 2 then the bonus points
are awarded, as shown in Figure 18.9.
Figure 18.9:Instruction using the symbol for greater than or equal to.
If Swords> = 2 AND Gkey = 1 Then
BonusP = BonusP + 200
End if
The list of comparison operators are shown below in Table 18.1.
Table 18.1: Comparison operators.
Operator Meaning Operator Meaning
> greater than = greater than or equal to
8/13/2019 Unit 18 Software Design
13/38
Unit 18Software
Using the AND logical operator means both values that you compare
must be true, but there may be situations where you want to make
comparisons where either one OR the other can be true. In these
situations we use the OR logical operator. For example, using the same
imaginary game, if a dragon has 400 bonus points or more OR they
have two golden keys then they get an extra life. The if instruction
would look something like that shown in Figure 18.10.
Figure 18.10: Instruction using the logical operator OR.
If BonusP >= 400 OR Gkey = 2 Then
Lives = Lives + 1
End if
Local and global variablesThe simple programs we have looked at so far only contain a single
procedure, so all the variables we have created are localto that
procedure in other words, the variables are only used in thatprocedure. In more complex programs with lots of different procedures,
some variables may be created which are globaland can be used in all
the procedures of the system.
Global variables are generally created at the start of the instructions for
the whole system, whereas local variables are created at the start of the
individual procedure where they can be used, like the variables we have
seen so far.
It is good programming practice to avoid global variables where
possible and stick to local variables, although sometimes the use of
global variables may be unavoidable. The reason for this is that globalvariables can cause program errors if they are used improperly. For
example, two different procedures may use the same global variable in
a slightly different way or one procedure may modify a global variable
that another procedure is using, and this may cause an unexpected
result or even cause a program to crash.
Assignment statementsWe have already seen a number of assignment statements.
For example, lets start with the following instruction:
Assignment statements these carry
out assignment operations, which cons
of taking the value on the right side of
the assignment operator (=) and storin
it in the variable on the left.
Key term
BonusP = 100
This can also be done as part of an arithmetic operation, such as:
result = input1 + input2
You can also assign an initial value to a variable when you create it,
such as:
Dim EndIt As String = "Y"
8/13/2019 Unit 18 Software Design
14/384
BTECs own resources
Input and output statementsIn the example programs weve looked at so far, input and output with a
console (text-based) application can be done with instructions, such as
ReadLine and WriteLine. Input and output with Windowsprograms are
a little different. These programs normally use a form in Visual Basic
Express this is created by using a forms editor which allows you to add
controls, such as labels, text boxes and buttons to your form. Figure18.11 shows the Visual Basicforms editor.
Figure 18.11:The Visual Basicforms editor.
Visual languages languages designed
to create Windowsprograms.
Key term
Windows
applications like this are event driven, so input can be madevia the mouse by clicking on controls such as buttons and check boxes.
Text input can be made using text boxes, and text output can be made
using a text box or label.
1.3 Types of languagesThere are a number of different general types of programming
languages best known are visual, script and markup.
Visual languagesBecause the Windowsuser interface is so widely adopted, many of theprogramming languages utilised today are known as visual languages.
Visual languages come with many of the standard Windowsfeatures
(such as dialog boxes, menus, buttons and scroll bars) already built into
them, so the programmer does not have to create these from scratch.
It obviously saves a lot of program development time if all these
visual elements are already made for you. Visual languages normally
support event driven procedures. As we have seen, the forms editor in
8/13/2019 Unit 18 Software Design
15/38
Unit 18Software
MicrosoftVisual Basicallows you to create buttons and other controls
that the user can interact with. Event procedures are written to deal with
these user interactions.
Script languagesTwo common examples of script languagesare macros and web
page scripts. A macrois a small program that is written or recorded to carry
out some task in another application. The best known examples
of macros are the ones you can create in MicrosoftOffice
applications, such as Wordor Excel, to carry out a complex or
repetitive task within a document or spreadsheet. You can learn
more about macros in Unit 9: Customising software(page 165).
Web page scriptsare small programs, embedded within web
pages, which are run by an Internet browser, such as Microsoft
Internet Explorerand carry out a task related to the web page.
Typical tasks a web page script might perform are validating a users
input into a web page form or opening a new browser window orpop-up window. One of the most common scripting languages is
JavaScript, which is related to the Javaprogramming language.
Markup languagesHTML is the best known example of a markup language it is used to
format web pages. In many ways HTML is not really a true programming
language, as it does not support many of the features associated with
programs, such as selection structures and loops. HTML is really just a
way of formatting text by using tags. These tags indicate how the text
following the tag should be formatted when it is displayed by the web
browser. HTML allows you to include graphic images, links and many
other elements. You can learn more about HTML in Unit 17: Website
development (pages 292293).
Other types of languagesIt may seem that all the programs you use are Windowsprograms
and that there isnt really any other type of program, but this is not the
case. Windowsprograms are the ones that users interact with directly,
but in the background there are many other programs running. A
device driveris a good example of this. Every new piece of hardware,
such as a printer or digital camera, needs to have a device driverprogram written for it which interfaces between the hardware and the
Windowsoperating system. Device drivers are programs that run in
the background. Because they dont interface directly with the user
they would not be written using a visual or event driven programming
language. Device drivers are often written using languages such as C.
Script language a type of
programming language which, rather
than being standalone programs that
run on their own, runs within some othe
application to carry out a specific task.
Device driver a program that provid
an interface between a piece of hardwa
(such as a graphics card or network
interface) and the operating system.
Key terms
8/13/2019 Unit 18 Software Design
16/386
BTECs own resources
1.4 Choice of languageThere are a very large number of different programming languages
available. Most programs are written using a piece of software called
an IDE (integrated development environment). This includes all the
things a programmer needs to write the program, such as:
aneditor this often provides additional tools to help write theinstructions, such as pop-up help
acompiler this converts the instructions into machine code that
the computer can understand
aWindowsforms editor to create Windowsforms and add all
the required controls (buttons, text boxes, check boxes, etc.)
adebugger to help identify bugsin the program.
Visual BasicExpress edition is an example of a sophisticated IDE which
includes all these tools.
Integrated development environment
(IDE) a piece of software which lets
you write code, test it and build it into an
application or game.
Bugs errors or mistakes in the program
which prevent it from working properly.
Key terms
There are many different programming languages. Find examples onthe Internet of code written in the most popular ones, such as C++,Javaor Pascal. Can you spot any similarities between them?
Activity: Programming languages
With such a wide range of languages, the choice of which one to use
to write a program may seem impossibly complex. In reality the
choice is often quite simple and will depend on one or more of the
following factors.
Organisational policyAn organisation that develops a lot of computer software will often have
a policy to use a particular language. This may be for reasons such as
consistency or to maintain compatibility with other software they have
developed. It will also enable a company to develop expertise in that
particular language.
Suitability in terms of available features
and toolsCertain languages are better suited, in terms of the features andtools they have available, to particular tasks or hardware and software
environments. For example, as discussed earlier, visual programming
languages, such as MicrosoftVisual Basic, may be best suited to a
project to develop a Windowsapplication. Visual Basicalso has very
good links to other Microsoftproducts, such as the Accessdatabase.
So if you are developing a program which needs to interface to an
Accessdatabase, then this may be a good choice.
8/13/2019 Unit 18 Software Design
17/38
Unit 18Software
On the other hand, if you are developing a program that needs to be able
to run on a wide range of different hardware and operating systems, then
Visual Basicwould be a poor choice as it only runs on PC hardware with
the MicrosoftWindowsoperating system. Javamight be a much better
choice as it is available for a wide range of hardware and operating systems.
Availability of trained staffIt takes a considerable amount of time to develop a good level of
expertise in a particular programming language. This means that if a
company already has staff who are experts in a particular programming
language, then that language will be the obvious choice for any new
project. Also, if a company is setting out on a new software development
project it may need to employ new programmers. It will be easier for
the company to find programmers with knowledge of the most popular
languages rather than the lesser known ones, even if the less well-known
languages are better suited to the project for other reasons.
ReliabilitySome programming languages are specifically designed for applicationswhere reliability is very important. These are sometimes called mission
critical applications. They include things like aircraft or nuclear power
plant control systems where failure would be catastrophic. Ada is an
example of a language developed for these types of application. It was
originally developed for the United States Department of Defense for
use on military projects.
Development and maintenance costsSome languages and software development approaches have a
reputation for being able to create software systems in a shorter
timescale than other approaches. This means they can provide systems
at a lower cost. For example, rapid application development (RAD) is
one approach which uses prototyping to speed up the development
process. Prototypes are simple versions of the program under
development with limited functionality. The prototypes are used to gain
user feedback and develop improved versions.
Equally, some languages have a reputation for being easier to
maintain. Maintenance can include updates, bug fixes and additions to
the original program. A company may, therefore, choose a particular
language or development approach, because they hope to achievelower development and maintenance costs.
ExpandabilitySome software systems may only be used by a small number of people,
while others many need to be used in a large organisation by thousands
of employees simultaneously. For example, a banking application that
controls ATMs (hole in the wall cash machines) will need to handle
many thousands of simultaneous transactions from machines all around
8/13/2019 Unit 18 Software Design
18/388
BTECs own resources
the country (and world!). The choice of programming language and
database systems to support such a huge system will need to consider
how well they can cope with a large and growing number of users.
Some programming and database systems are designed with such
expandability in mind (sometimes called scalability), while others are
better suited to single user or small multi-user applications.
What are the most popular programming languages at the moment?Take a look at programming job adverts on the Internet and see whichlanguages are in the most demand. Please go to Hotlinks and click onthis unit to access a good website to start you off on this activity.
Activity: Popular programminglanguages
PLTS
Investigating different programming
approaches will provide evidence that
you are an independent enquirer.
Functional skills
Preparing a presentation will provide
evidence for your functional ICTskills
find and select information and
develop, present and communicate
information.
It will also provide evidence for your
functional Englishskills in writing.
You are working for a mobile phone company which is consideringstarting their first software development project. One of themanagers has asked you to investigate the different approachesto programming (paradigms) and factors that might influence theirchoice of programming language.
1. Create a presentation for the manager describing theapproaches to programming (paradigms) and identifying thefactors influencing the choice of language. P1 P2
2. Add to the presentation you prepared for task 1 by describingthe features of a programming language of your choice,including how sequence, selection and iteration are used. M1
Grading tip
When completing question 2, you will need to describe thefeatures of programming languages, including how sequence,selection and iteration are used. Check the unit content forlearning outcome 1 and make sure you cover the featureslisted there.
P1 P2 M1Assessment activity 18.1
Just checking
1. What features does HTML not have that can be found in most programming languages?
2. What instruction is used in most programming languages to implement (write instructions to
perform) selection?
3. Explain the difference between local and global variables.
4. What three attributes or properties does a variable have?
8/13/2019 Unit 18 Software Design
19/38
Unit 18Software
2. Know the software developmentprocess
2.1 Software development
life cycleLike any large commercial project, there is a series of steps that must
be completed when developing a software system. This is sometimes
called the software development life cycle. It is represented by the
diagram in Figure 18.12.
Figure 18.12:The software development life cycle.
Gather user
requirements
Write
programs
Create
specification
Create
design
Maintain
system
Test
programs
We refer to this process as a life cycle because, even when the
software is completed and has entered the maintenance phase, new
requirements and developments are likely to be suggested, resulting
in work starting on a new version of the software. In this way the
development cycle begins and repeats again and again.
Lets now look at each stage in detail.
Gather user requirementsMost commercial programs are written to solve some kind of problem
or to take advantage of an opportunity. Clearly, you need to understand
the nature of the problem or opportunity before you can write a
program that will achieve what is required. This involves working with
8/13/2019 Unit 18 Software Design
20/3820
BTECs own resources
the people who understand the problem and who will be using the new
system. Since these people will probably not be computer experts, the
discussions at this stage focus on the business aspects of the problem
or opportunity.
The work to gather user requirements is normally carried out by a
systems analyst. As well as being an expert in systems development,
a systems analyst is usually also an expert in the business area that thesystem is being developed for. For example, if the software is being
developed for use in a bank, the systems analyst will need to be an
expert in banking and finance systems.
The gather user requirements stage is when information is collected
about what the exact requirements of the system are. The information
may be collected by a number of different methods including
interviews, observation of current working practices and
reviewing documentation.
Systems analyst someone who
operates at the design stage of systems
development. They work closely with the
people who will use the system beingdeveloped to identify exactly what it
needs to do.
Key term
Case study: Requirements gathering for a learner gradetracking system
A college needs some software to keep track oflearners grades. The grade tracking records arecurrently kept using a paper-based system.
At the requirements gathering stage, the systemanalyst speaks to the tutor who looks after the gradetracking records. He takes copies of the documentscurrently used and discusses with the tutor how thecurrent system works so he is sure he fully understandsit. He also discusses with the tutor the limitations of
the current system and what improvements he hopesthe new computerised system will provide.
1. What improvements do you think anelectronic system is likely to provide over apaper-based one?
2. Is there anyone else you think the systemsanalyst should speak to, other than thetutor, about the new system?
Create specificationAt the end of the requirements investigation stage, the systems analyst
will produce a specificationdocument. This is an important document
as it is often the basis of a contract between the company developing
the software and the company who is paying for the software to be
developed. There are a number of things which need to be described in
the specification, and these are listed below.
What is the scope of the system?
To decide on the scopeyou need to ask the question What will the
system do, and what wont it do? This may be an obvious question,
but it is an important one. Computers are very powerful machines and,
if you had endless time and money, there are many facilities you could
include in the software you are developing. You may need to decide
what the most important features are (referring back to the aims of the
system) and develop the first version of the software with just those
features, putting the rest on a wish list for future versions.
Specification a document describing
what the system that will be developed
will do in non-technical terms.
Scope all the functions and facilities
that are to be included in the system.
Key terms
8/13/2019 Unit 18 Software Design
21/38
Unit 18Software
Inputs and outputs
The data that will be input to the system and the outputs that it will
provide are clearly important. There are a number of possible sources
of input data; they may come from a human user or from another
computer system, for example. Outputs may also be in a number of
different formats, such as on the computer screen, in a printed report or
to another computer system.
Case study: Identifying the scope of the learner gradetracking system
The scope of the learner grade tracking system isquite straightforward. It will record the grades forlearners on the CTEC Diploma course, which consistsof three units only. Each unit can be graded as:
Incomplete
Pass
Merit
Distinction.
The system should also calculate an overall grade foreach learner. It should allow a tutor to input learnernames and view, add and update their grades. Allinput and output should be via a Windowson-screen form.
Possible future versions of the program might includthe following additional features:
dealing with multiple class groups
dealing with other qualifications with differentnumbers of units
printing class lists of grades.
1. Is writing a program the only solution to thisproblem? Are there other ways that this gradrecording system could be implemented? Whaadvantages and disadvantages would otherapproaches have?
2. Sketch out the main menu form for this system
Processing
This aspect of the specification describes how the input data will be
transformed, for example calculations may be carried out on the inputdata. In a system that calculates employees monthly salaries, the input
data will probably be the number of hours worked by each employee
plus any additional information, such as overtime hours or days off sick.
This data will be used to calculate each employees pay by multiplying
it by their hourly rate and then subtracting things like tax and National
Insurance contributions.
User interface
The specification will give details of how the user will interface with the
system. Most commonly this will be by a standard Windowsinterface
using a monitor, mouse and keyboard, but there may be other methods.
Many applications these days use the Internet and so their user
interface may be via a web browser, such as MicrosoftInternet
Exploreror Mozilla Firefox.
Specialist applications may use a text-based interaction (like the
console applications we looked at on pages 78).
Touch screens are particularly well suited to applications where a
keyboard is not convenient, such as mobile applications or in retail
(for example, point of sale terminals in shops).
8/13/2019 Unit 18 Software Design
22/3822
BTECs own resources
Constraints
Most software is developed to a budget which will constrain (limit) the
amount of time that can be spent developing the software. Estimating
how long it will take to develop a software system and, therefore,
how much it will cost is one of the most difficult aspects of software
development. There are many examples of systems which have taken
far too long and cost much more than originally estimated.
The budget available may restrict the features that can be included in
the system, and may mean some features have to be pushed onto the
wish list for the next version. Other possible constraints include the
hardware platform and software system that must be adopted. The new
system may well have to be used on existing hardware and software,
including a particular operating system.
Case study: Learner grade tracking system processing,user interface and constraints
Processing:The processing requirements of the learner gradetracking system are fairly simple. The systems mainpurpose is the storing and retrieval of learner grades,so there is not much processing involved. However,the calculation of the final grade does requiresome processing and this should be defined in thespecification. The rules for deciding on thefinal grade are:
for a pass a learner gets one point
for a merit a learner gets two points
for a distinction a learner gets three points.There are three units, so if a learner has less than threepoints they have failed. If they get three to five points
they get a pass. If they get six to eight points they geta merit. Nine points achieves a distinction.
User interface:The user interface of the system will be a standardWindowsinterface.
Constraints:The system needs to work with standard PC hardwareand the Windows7 operating system.
1. Is any other information required to fullyunderstand how the grade tracking system
will work?
2. Create several imaginary sets of learner unitgrades and work out what overall gradethey achieve.
Create designThe design stage builds on the requirement and the specification.
The requirement and the specification documents describe whatthe
software will do, whereas the design considers howthe software is
going to work.
The first step may be to break the problem down into components,
particularly for large, complex software.
Once the general structure of the solution has been decided (what
the components are and how they interact), each component can be
designed in detail.
There are many different tools available to software designers: action
lists, storyboards, structure diagrams, data flow diagrams, algorithms,
and so on. These are discussed on pages 2629 of this unit.
8/13/2019 Unit 18 Software Design
23/38
Unit 18Software
Write programs (coding)The coding (or implementation) stage is when the program is written.
Programmers follow the design and refer back to the requirements
to help them. If implementation highlights any problems with the
requirements or design, then these documents should be
updated appropriately.
Test programsAll but the simplest of programs contains bugs. In some ways, writing
software is like writing a book try as you might to avoid spelling mistakes,
poor grammar and factual errors, some inevitably slip through the net.
Software developers use testing (just as publishers use editors and
proofreaders) to minimise the severity and number of errors as much as
possible. If the requirements have been written carefully, then many of
the tests will be taken directly from these.
For a large software project, each component is tested individually
these tests are called unit tests. They may be run manually or writtenas extra software that can be run automatically. Further tests, called
integrationtests, check that the components work properly together.
Documentation
Each stage of the software development process results in the creation
of one or more documents. The requirements investigation stage results
in a formal requirements specification. During the design stage, various
charts and documents are produced to record the design decisions that
have been made. Even the implementation and testing stages need
documentation in the form of program comments and test plans and logs.
Often, additional time must be put aside to finalise the internaldocumentation (for example, to make sure that the design documents
are up to date) and to prepare customer documentation, such as a user
manual or help pages built into the software.
Maintain systemSoftware maintenance is rather like car maintenance. After a car
has been manufactured, it still requires regular tune-ups to keep it
performing efficiently. It may even be taken to a mechanic for an
upgrade, such as fitting satellite navigation. In the same way, software
bugs that are discovered after release will need to be fixed, and users
may request that developers add new features to the software.
One measure of the success of a software product is the length
of time for which it remains in use. Some software in use today
has gone through many versions over the course of years, or even
decades. Because of this, over the lifetime of a software product, the
maintenance stage is likely to last the longest and take the most effort.
If the earlier stages have been rushed or performed carelessly (for
example, if the design documentation is poor) then the maintenance
Did you know?
Software developers often find
writing the code to be the most
enjoyable stage of a project. When
planning for, and working on, your
own software development projec
make sure you allocate a generous
proportion of your time to the
requirements and design stages
(which will save you time overall) a
to the testing and documentation
stages (which will improve the qua
of your software product).
Integration the process of bringing
together software components, perhapwritten by different development teams
into a single piece of software.
Key term
8/13/2019 Unit 18 Software Design
24/3824
BTECs own resources
stage will be heavy going, difficult, inefficient and boring. If care has
been taken, though, the maintenance stage can be as interesting and
productive as the implementation stage.
PLTS
By creating the outline specificationand selecting and justifying the
programming language, you will
demonstrate that you are a
creative thinker.
Functional skills
Creating the outline specification will
provide evidence for your functional
Englishskills in writing.
1. Following the work you have done for Assessment activity18.1, your manager has asked you to add further slides toyour presentation describing the stages of the softwaredevelopment life cycle. P3
2. Your manager has also asked you to produce an outlinespecification for the software they are thinking of developing.The program will be used in their shops so customers can seehow much different mobile phone tariffs would cost them eachmonth. You only need to produce a specification for the basicversion of the system, which will allow customers to enter thenumber of minutes they think they will use each month at
off-peak and peak times. They can choose three different tariffs: low usage 10 monthly fee, peak calls 5p a minute, off
peak calls 1p a minute
high usage 15 monthly fee, peak calls 3p a minute, offpeak calls 1p a minute
business usage 25 monthly fee, peak calls 2p a minute,off peak calls 1p a minute.
Produce an outline specification for this mobile phonecost-estimator program. P4
3. Select a programming language to be used for the mobilephone cost-estimator program and provide written justificationfor your choice.
M2
Grading tips
Check the unit content for learning outcome 2 to makesure you have covered each stage of the softwaredevelopment life cycle.
When justifying the choice of programming language youneed to give reasons why you chose that language. Youcould also include the reasons why you didnt chooseother languages.
P3 P4 M2Assessment activity 18.2
Just checking
1. List the main steps of the software development life cycle.
2. Explain the term scope of the system.
3. List the typical constraints that a development project might have.
4. What sorts of user interface may a program make use of?
8/13/2019 Unit 18 Software Design
25/38
Unit 18Software
3. Be able to design softwaredevelopment solutionsOnce the specification for the system has been completed and it has
been agreed by the users, and whoever is paying for the system to be
developed, the next stage is the detailed design.
3.1 DesignThe system design provides more detailed information about the
internal working of the software. The work at this stage involves taking
what has already been decided at the investigation stage and adding
more detail to it. There are a number of things that need to be designed
and planned for example, how the program will look to the user, what
data the program will need to store and how that data will be processed.
As you already know, programs take some kind of data as input,
perform some kind of processing on that data (perhaps a calculation)and produce some kind of output. At the design stage, software
developers must add more detail based on their research about what is
to be input, how it will be processed and what will be output.
Where the problem is large and complex, the developers also need
to consider how it can be split into manageable sections. The key to
this is to choose sections that can be as self-contained as possible.
When dividing a system into different sections (called modulesor
procedures), these modules will need to communicate with each other
to some extent (probably by passing values, often called parameters).
However, this should be kept to a minimum, with each module having a
clearly defined purpose and as little interaction with other modules
as possible.
When several programmers are working on the same software
development project, dividing the system up into modules is necessary
so that each programmer can work on an individual module. Dividing
a program into modules also makes the testing easier, because
developers can test each module as it is completed rather than having
to wait until the whole program is complete.
3.2 Design toolsNumerous different methods have been developed to help model the
complexity that is often involved in a software system. Many of these
involve creating diagrams to show the flow of data or the structure of
the system (such as how it is split into different modules). Many of the
methods also rely on a technique which is sometimes called functional
decomposition. This involves creating a general overview model or
diagram of the system which is then refined by creating more and more
detailed diagrams.
Module or procedure a program tha
is part of a larger system. It normally
carries out some specific function or tas
Parameter data that is passed to a
module or procedure. For example, if
you create a procedure which calculate
the area of a circle, it will need to be sethe radius of the circle as a parameter.
Key terms
8/13/2019 Unit 18 Software Design
26/3826
BTECs own resources
Structure diagramsStructure diagrams are graphical tools which are used to split a system
down into more detailed procedures or modules. As with many design
tools, you can start with an overall structure diagram which shows how
the whole system is split into different procedures and then draw a more
detailed structure diagram for each procedure. With a really complex
system, you may even draw further levels of structure diagrams, eachone describing a smaller part of the system in more detail.
A structure diagram is drawn with a box showing the main program
or procedure name at the top and then each procedure or section
presented in boxes below. Arrows show inputs or outputs for each box.
A structure diagram for the learner grade tracking system is shown in
Figure 18.13. By looking at the specification, we can see what the main
functions of the software should be. These main functions form the
main procedures.
Did you know?
At this stage you dont need to worry
too much about detail, although
the procedures you define should
be as self-contained as possible.
Remember that you can always
refine your design as it develops and
its quite acceptable to make many
revisions to it as you work through.
Later in the design process you may
realise that what you had in mind
at this early stage wont work well.
Thats fine all you need to do is
return to this stage and update
your design.
Figure 18.13:Structure diagram for the learner grade tracking system.
Learner GradeTracking System
Update grades
Learner nameLearner name Learnername
Grades
Grades
View gradesInput new
learner details
Narratives and action listsAnother technique often used at the early stage in developing a design
for a software system is to define the way that the system will interact
with the user. The user requirements should have already defined what
inputs and outputs the system will have in the form of a narrative. This
is really just a written description of what the inputs and outputs are. But
narratives are a rather long-winded way of describing the interaction the
program will have with the user and the sequence of events. A simple
action listis a more convenient way of designing the way the user willinteract with the system.
An example of an action list for the Update Grades procedure of the
learner grade system is:
1. open Update Grades screen
2. enter learner name
3. if not found display an error message
4. if found display learner details and current mark
Narrative a written description of how
the system will interact with the user.
Action list a list of user actions and
inputs and the programs responses.
Key terms
8/13/2019 Unit 18 Software Design
27/38
Unit 18Software
5. choose to update marks or exit
6. if updating marks, enter new mark
7. confirm update
8. exit.
StoryboardsFrom this simple list we can go on to create a more detailed design for
the interaction using a storyboard.
A storyboard is simply a series of drawings (which you can draw by
hand or electronically) which demonstrate the stages of the interaction
between the program and the user. They are like a cartoon story of
the Windowsforms the user will work through to complete a task. An
example of a set of storyboards for the Update Grades procedure is
shown in Figure 18.14.
Did you know?
Storyboards were first used in the
animated film industry and were
developed by the Walt Disney stud
Figure 18.14:Storyboards for the Update Grades procedure.
Storyboards are particularly important when developing software that
has a strong visual element, such as a game.
Data flow diagramsAnother graphical technique you can use is data flow diagrams (DFDs).
This is a series of diagrams drawn at different levels each level adds
further detail to the system. Data flow diagrams, as the name suggests,
are designed to help you figure out how data will flow between the
various procedures within the system as such, they are better suited
to a system which works in conjunction with a database. DFDs would
not be of much use for designing a system such as a game, but wouldbe more useful with a system like the learner grade tracking system we
have been considering.
The first step in creating a data flow diagram is to create the Level 0
diagram, which simply shows the system as a box. Oval shapes are
drawn outside the box representing external people or systems (known
as external entities) that have inputs or outputs to or from the system.
Arrows are drawn and labelled indicating what those inputs or
outputs are.
Entities real world things, such as
customers, products or books, that nee
to be represented in the system that yo
are designing.
Key term
8/13/2019 Unit 18 Software Design
28/3828
BTECs own resources
Figure 18.15 shows an example Level 0 DFD for the Update Grades
procedure. The tutor entity is shown twice only to make the diagram
easier to read the same tutor would complete all the interactions
involved in updating a learners grade.
Figure 18.16:Level 1 DFD for the Update Grades procedure.
Figure 18.15:Level 0 DFD for the Update Grades procedure.
Learner class
Tutor TutorLearner name
Current mark Confirm update
Input new mark
Having completed the Level 0 DFD, the next step is to create the Level
1 DFD. This keeps the same external entities as the Level 0 DFD and
the same inputs and output, but includes details of the processes and
data stores that exist within the system. As a general rule you will need
a process to deal with each input and output you identified in the
Level 0 DFD.
Processes are drawn as a numbered box with the description of the
process inside it. Where the system or procedure needs to store data
(to be read or written to by the processes) it is shown as an open-ended
rectangle, which is also given a number, starting with a letter D. Figure
18.16 shows the Level 1 DFD for the Update Grades procedure.
Tutor Tutor
1.1
D1 Learner name, grade
Find learner
1.2
Find learner
Learner name
Learner name New grade
Grade
Input new grade
Confirm updateConfirm update
8/13/2019 Unit 18 Software Design
29/38
Unit 18Software
There are some rules for drawing the Level 1 DFD:
1. you must have the same external entities and data flows in the Level
1 diagram as in the Level 0 diagram
2. in a Level 1 diagram only processes can read or write to data stores
3. each input or output must be handled by a process in the
Level 1 diagram.
Like many of the design techniques we have looked at, creating DFDs
is not easy and needs practice. It is also difficult to figure out the
processing steps involved unless you have a good understanding of
how programs are written.
Entity relationship modelsEntity relationship models (ERMs) show the relationships between
data items.
When an analyst has used the DFDs to identify the processes and data
stores in the system, the ERMs can be produced. There is no strict order
in producing these diagrams; often the design evolves over some time,with DFDs, ERMs and other diagrams being refined through several
versions. ERMs are used to model the relationships that exist between
different entities in the system.
Entities have attributes these are the elements that define a particular
entity. Some simple examples are shown in Table 18.2.
An occurrenceof the entity Customermight be:
Name: John Smith Office Supplies
Address: 10 Main Street, Watford
Credit limit: 1,500
Primary and foreign keys
One (or more) of the attributes of a particular entity is normally defined
as the primary keyattribute.
To guarantee uniqueness, numbers are normally used for primary
key attributes. So, for example, on a database recording details of
the entity Learner, the attribute Learnernumberwould be the primary
key. The system would need to ensure that each learner received a
unique number.
Most systems have a number of entities within them, and entities often
have relationships between them. For example, the entity Customers
and the entity Ordersare related, because every order a company
receives comes from a customer. The relationship between two entities
can normally be described by a verb. In this example, the verb is place,
because customers place orders see Figure 18.17.
Table 18.2: Examples of entitiesand attributes.
Entity Possible attributes
Customer Name
Address
Credit limit
Product Description
Type
Price
Book Title
Publisher
Price
Occurrence one complete set of valu
for each attribute for a particular entity
is sometimes called a record.
Primary key the attribute used to
uniquely identify a particular occurrenc
of an entity.
Key terms
Figure 18.17: The ERM showing the relationship Customers place orders.
Customers OrdersPlace
8/13/2019 Unit 18 Software Design
30/3830
BTECs own resources
How could you know which orders were placed by a particular
customer? One of the attributes of the entity Customerwill be the
customer number. This unique number identifies each customer and so
is the primary key of that entity. When that customer places an order, an
occurrence of the orders entity is created. We need to be able to tell
which customer placed the order, so the customer number is inserted
into that occurrence of the orders entity. This is known as a foreignkey
(foreign because the key value belongs to another entity); an example is
shown in Figure 18.18.
Foreign key an attribute that is a
primary key in a different entity.
Foreign keys are used to create links
between entities.
One-to-many relationship where one
occurrence in an entity can be related to
many occurrences in another entity.
Key terms
Figure 18.18: Primary and foreign keys.
Entity: CUSTOMER
Customer number
Primary key
Attributes:
Name
AddressCredit limit
Etc.
Entity: ORDERS
Order number
Primary key
Customer number
Foreign key
Attributes:
DateTotal value
Etc.
Note that the fields used to create the relationship between the two
entities must have the same data type in both entities. This is one of the
reasons why you must choose data types with care.
One-to-many relationships
Each customer will have at least one order that they placed, and
probably many more. So, for one customer there will be many
occurrences of the orders entity. This type of relationship is called a
one-to-many relationship. In an ERM, this is shown by a fork at the
many end of the line that joins the two entities, as shown in Figure 18.19.
Figure 18.19:A one-to-many relationship.
Customers Orders
One-to-one relationshipsOne-to-many relationships are the most common type of relationship
between entities, but they are not the only type. Imagine a company
that has a system to store data about its employees. The entity
Employeewill have attributes, such as name, address and salary, and
the primary key will probably be Employee number.
Some employees who work for the company are provided with a company
car. That gives us another entity, Company car, which has attributes such
as registration number, make, model, etc. There is a relationship between
8/13/2019 Unit 18 Software Design
31/38
Unit 18Software
the two entities Employeeand Companycar, which can be described
by the verb uses because an employee uses a company car. As each
employee is assigned only one company car at a time, this is not a one-to-
many relationship, but a one-to-one relationship.The ERM for this type
of relationship is shown in Figure 18.20.
One-to-one relationship where one
occurrence in an entity is related to onl
one occurrence in a different entity.
Structured English or pseudo code
method of representing programming
code using English language rather
than the strict syntax of a programming
language.
Key terms
Figure 18.20: A one-to-one relationship.
Salesperson Company carUses
DFDs and ERMs are techniques used most often when designing
software that works with a database. When designing programs which
dont use a database, such as a game, then DFDs and ERMs would not
be used.
Create an ERM design for a doctors surgery appointments system.The surgery has several doctors and, of course, lots of patients.
Activity: ERMs
AlgorithmsAn algorithm is a mathematical expression which defines how a
complex calculation is done. As part of the design for a program,
algorithms may be defined using techniques like structured Englishor
pseudo code.
Both these methods are a type of half-way house between writing a
description of the calculation or processing and the actual program
instructions. Rather than having to worry about the exact syntax (rules)
of the programming language instructions, these methods allow you
to concentrate on the workings of the algorithm. Structured English
and pseudo code dont really have any rules as such; you just write the
calculation in a way that resembles program code. But if you dont have
much experience of writing program code, this is quite hard.
Lets look at an example. The specification for the learner grade tracking
system includes an explanation of how the overall grade is calculated.Written in pseudo code it might look like Figure 18.21.
This looks a bit like the code that will eventually be written, but it does
not follow all the rules of if instructions in Visual Basic.
3.3 Data typesWeve already seen a number of data types used for the variables in the
example programs weve looked at. Choosing the correct data type for
Figure 18.21: Pseudo code for the learngrade tracking system.
If points < 3 then Fail
If points >3 and 6 and
8/13/2019 Unit 18 Software Design
32/3832
BTECs own resources
a variable is important because if you choose an unsuitable data type
your program may not be able to manipulate the data in the variable
in the way it needs to. For example, you cannot do calculations with
variables that have a text data type. Its also very important that you
do not allow your program to assign a text value to a variable with a
numerical data type, as this will cause the program to crash.
Various numerical data types are provided to store integers (wholenumbers) and numbers with a decimal part of various sizes. Again, it
is important that your program should not place a numerical value in
a variable which cannot store a number of that size, otherwise your
program will crash.
The actual data types you have available will depend on the program
language you use. The data types available in Visual Basic Express are
listed in Table 18.3.
Table 18.3: Data types in Visual BasicExpress.
Type Used for Range of values
Boolean Values that can be true or false True or false
Byte Whole numbers 0 to 255
Integer Whole numbers 32,768 to +32,767
Long Very large whole numbers Approximately plus or
minus 2 billion
Currency Decimal numbers with 2 digits
after the decimal
Single Floating point numbers Up to 7 significant digits
Double Large floating point numbers Up to 14 significant digitsDate Date and time
Variant Any type of data
String Any type of text
3.4 Software structures
Functions, procedures, classes
and objectsAs mentioned on page 25, one of the benefits of breaking a large and
complex system into different procedures is that different programmers
can then work on the different procedures. However, a team of
programmers working on the same system needs to follow the same
rules and procedures to avoid problems. They must be aware of the
structure of the system that is, the way it is divided into procedures
and how the procedures interact. They must also follow certain rules
and guidelines about how the code is written.
8/13/2019 Unit 18 Software Design
33/38
Unit 18Software
Clearly the functions and procedures or classes and objects (if the
object-orientated approach is used) must be well defined to ensure
they can work together, even though they are being written by different
people. The way the data in the system is used must also be clear to
everyone. This point applies in particular to global variables which are
used by more than one procedure.
Abstraction of dataIn a complex software system, the abstraction of datacan help deal
with the complexity.
Abstraction of data works well in large projects with many different
programmers working on the system, each writing their own
procedures. For example, programmer A creates a procedure which
programmer B needs to use. All programmer B needs to know about
is the functions of that procedure; she does not need to know anything
about the internal workings of that procedure. If at some stage of
the development project, programmer A needs to modify or rewrite
his procedure, he can do that and, as long as he keeps the samefunctions, this wont have any impact on programmer Bs use of
that procedure.
This is a concept related to object-orientated programming, where
data and functions are encapsulated together in an object and global
variables are not used.
There are a number of other considerations when working on a large
and complex project with many programmers.
Pre-defined codeMany different software systems share similar requirements and itmay be possible for some functions to use procedures or code from
previous projects. Using pre-defined code can save a lot of time as the
procedures have already been written and tested.
ReadabilityThe people running complex software projects will often set standards
which the programmers must follow. These standards will include things
like adding comments to the programming code they write.
Comments
Comments are ignored by the computer but make it much easierfor other people to read the code. This is important on a large
project, as other people may need to work on the program. In
particular, during the maintenance phase, the person who carries
out bug fixes or modifications will usually not be the programmer
who originally wrote the code. Even on small software development
projects, adding comments to the program instructions is regarded
as good practice. Figure 18.22 (on page 34) shows an example of a
program with comments added.
Abstraction of data when the way
a procedure deals with data is hidden
inside the procedure, but the interface
with other procedures remains the
same. This is useful in situations where
number of different procedures are usi
the same data.
Pre-defined code programming cod
which has already been written and can
be re-used in another software project.
Key terms
8/13/2019 Unit 18 Software Design
34/3834
BTECs own resources
Using appropriate names for variables
Using appropriate names for variables is another example of good
practice. Variables can be given names, such as A or Bor Data1, but this
kind of name gives no clue as to the purpose of the variable. Its a much
better idea to use names which describe what the variable is used for,
such as LearnerNameor Unit1Grade(note that variable names cannot
contain spaces).
Some programmers recommend prefixing the variable name with a
code which indicates its data type. So a text variable called LrnName
(shortened version of LearnerName) might be named TxtLrnName,
while an integer variable called Pointsmight be named IntPoints. Thiscan help prevent the mistake of assigning an incorrect type of data to a
variable, such as a text value to a numeric data type variable.
Indentation
A final example of good practice, which improves readability of code, is
indenting loop or selection blocks of code, which makes it easier to see
where they start and finish. In fact Visual Basicdoes this for you.
Quality of codeIt takes a long time and a lot of practice to become a proficient
programmer there are many pitfalls in writing programs that youreally only discover with experience. Some attributes of a well-written
program are listed below.
Reliable and robust
You might imagine users will exploit the program in the way it was
intended, but sometimes they may misuse it. For example, users may
make a text input where a numeric one is expected. A well-written,
robust program will be able to cope with such a user error and display
Figure 18.22:Program with comments added.
8/13/2019 Unit 18 Software Design
35/38
Unit 18Software
an error message rather than crashing. The best way to ensure a
program is as robust as possible is by thoroughly testing it to ensure it
works properly and can cope with being used incorrectly.
Usable
The best programs are easy to use and are intuitive. Ease of use is a
subject of its own (sometimes called HCI human computer interface),
but there are some simple things you can do when designing the userinterface to make a program accessible to users. The following features
all make it easier for the user to figure out how your program is to
be used:
clearly labelled controls (buttons, text boxes, etc.)
logically arranged controls (i.e. arranged in the order they are likely
to be used)
controls grouped by function.
Portable
This is the ability of a program to run on different hardware or software
platforms. This may be important for some systems. As mentionedearlier, some languages such as Javasupport many different types
of hardware.
Maintainable
Every commercial software product needs to be maintained with
updates, bug fixes and new features. There are a number of things that
can be done to make software easier to maintain. These include:
good, detailed technical documentation describing the design and
implementation of the software
well-written programs see pages 34 and 35 for discussion of
several good practices, such as adding comments, using meaningfulvariable names and indenting loop and selection instructions.
3.5 ReviewBefore the work on actually writing the program starts, its wise to review
the design produced and compare it to the specification to make sure
it really matches what is required. Also, once the software is complete,
you should review it against the requirements to see if it matches the
original design.
In a commercial software development project, the organisation that is
paying for the development will often want to check that the completedsoftware meets the requirements defined in the specification, using
what is often called acceptance testing. The final payment for the
development work will often not be made until the system passes its
acceptance tests.
Intuitive when describing a person,
intuitive refers to someone who can wo
out how to do something instinctively,
without being told. An intuitive user
interface is easy to use because the
user can easily see how to achieve thedesired effect.
Key term
Acceptance testing a defined set of
tests which a completed software syste
must pass before it will be accepted by
the customer. The tests are often definearly in the project development proce
and may be contractual (i.e. payment
may depend on the software passing th
acceptance tests).
Key term
8/13/2019 Unit 18 Software Design
36/3836
BTECs own resources
PLTS
By designing a software solution for a
business requirement, you will show
that you are an effective participator.
By evaluating your design you will
show that you are a reflective learner.
Functional skills
Developing an algorithm for
calculating the different tariffs could
provide evidence of your functional
Mathsskills (identify the situation
or problem and the mathematical
methods needed to tackle it).
1. Following on from the work you did in Assessment activity 18.2,create a design for the mobile phone cost-estimator program