introduction to software construction franco gasperoni [email protected]
TRANSCRIPT
Introduction toSoftware Construction
Franco [email protected]
http://libre.adacore.com/Software_Matters
2http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Course Home page
http://libre.adacore.com/Software_Mattershttp://libre.adacore.com/Software_Matters• All the course slides are there (PDF and PowerPoint)All the course slides are there (PDF and PowerPoint)
http://libre.adacore.com/Software_Mattershttp://libre.adacore.com/Software_Matters• All the course slides are there (PDF and PowerPoint)All the course slides are there (PDF and PowerPoint)
3http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Copyright Notice
© AdaCore under the GNU Free Documentation License
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; provided its original author is mentioned and the link to http://libre.act-europe.fr/ is kept. A copy of the license is included in available at:
http://www.fsf.org/licenses/fdl.html
4http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Course Objectives
Help you build software Help you build software systems that are more:systems that are more:
• DependableDependable• AdaptableAdaptable• Fun to developFun to develop
Help you build software Help you build software systems that are more:systems that are more:
• DependableDependable• AdaptableAdaptable• Fun to developFun to develop
Comparing ways to Comparing ways to structure softwarestructure software
• Functionality-orientedFunctionality-oriented• Object-orientedObject-oriented• Structural problems with Structural problems with
both approachesboth approaches
Comparing ways to Comparing ways to structure softwarestructure software
• Functionality-orientedFunctionality-oriented• Object-orientedObject-oriented• Structural problems with Structural problems with
both approachesboth approaches
Show problems & pitfalls in Show problems & pitfalls in C-derived languagesC-derived languages
• C, C++, JavaC, C++, Java
Show problems & pitfalls in Show problems & pitfalls in C-derived languagesC-derived languages
• C, C++, JavaC, C++, Java
Show how Ada 95 addresses these issuesShow how Ada 95 addresses these issues• Engineering principles we can take from Ada Engineering principles we can take from Ada
and apply in other languagesand apply in other languages
Show how Ada 95 addresses these issuesShow how Ada 95 addresses these issues• Engineering principles we can take from Ada Engineering principles we can take from Ada
and apply in other languagesand apply in other languages
5http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Interesting Books
Programming in Ada 95• by John Barnes (Addison Wesley)
High Integrity Ada: The SPARK Approach• by John Barnes (Addison Wesley)
Object-Oriented Software Construction• by Bertrand Meyer (Prentice Hall)
Objects Unencapsulated: Java, Eiffel, and C++• by Ian Joyner (Prentice Hall)
C Traps and Pitfalls• by Andrew Koenig (Addison Wesley)
Effective C++• by Scott Myers (Addison Wesley)
7http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Course Assumptions
You are interested in the field of software development
You have written computer programs in at least one imperative languages
• E.g. Ada, C, C++, Eiffel, Fortran, Java, Pascal, …
Have a basic knowledge of C• … for the section on problems & pitfalls in C-related languages
Background onSoftware Construction Processes
9http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Software Development PhasesRequirementsRequirements
What needs to be doneWhat needs to be doneRequirementsRequirements
What needs to be doneWhat needs to be done
AnalysisAnalysisHow it should be doneHow it should be done
AnalysisAnalysisHow it should be doneHow it should be done
DesignDesignCreate a software structure Create a software structure (architecture) around which (architecture) around which code will be built code will be built
DesignDesignCreate a software structure Create a software structure (architecture) around which (architecture) around which code will be built code will be built
CodingCodingFill in the software Fill in the software structure with codestructure with code
CodingCodingFill in the software Fill in the software structure with codestructure with code
TestingTestingCheck that the code does what Check that the code does what it is supposed to (functionality, it is supposed to (functionality, performance, reliability, …)performance, reliability, …)
TestingTestingCheck that the code does what Check that the code does what it is supposed to (functionality, it is supposed to (functionality, performance, reliability, …)performance, reliability, …)
Project ManagementProject ManagementDevise a plan,Devise a plan, manage manage resources, costs, time, …resources, costs, time, …
Project ManagementProject ManagementDevise a plan,Devise a plan, manage manage resources, costs, time, …resources, costs, time, …
11http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Example of Software Processes
RequirementsRequirementsRequirementsRequirements
AnalysisAnalysisAnalysisAnalysis
DesignDesignDesignDesign
CodingCodingCodingCoding
TestingTestingTestingTesting
Time
RequirementsRequirementsRequirementsRequirements
AnalysisAnalysisAnalysisAnalysis
DesignDesignDesignDesign
CodingCodingCodingCoding
TestingTestingTestingTesting
RequirementsRequirementsRequirementsRequirements
AnalysisAnalysisAnalysisAnalysis
DesignDesignDesignDesign
CodingCodingCodingCoding
TestingTestingTestingTesting
RequirementsRequirementsRequirementsRequirements
AnalysisAnalysisAnalysisAnalysis
DesignDesignDesignDesign
CodingCodingCodingCoding
TestingTestingTestingTesting
Scope (customer needs)
Requirements
Requirements
Analysis
Analysis
Design
Design
Coding
Coding
Testing
Testing
Requirements
Requirements
Analysis
Analysis
Design
Design
Coding
Coding
Testing
Testing
Requirements
Requirements
Analysis
Analysis
Design
Design
Coding
Coding
Testing
Testing
Requirements
Requirements
Analysis
Analysis
Design
Design
Coding
Coding
Testing
Testing
Requirements
Requirements
Analysis
Analysis
Design
Design
Coding
Coding
Testing
Testing
Requirements
Requirements
Analysis
Analysis
Design
Design
Coding
Coding
Testing
Testing
Waterfall Iterative eXtreme Programming (XP)
12http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Software Phases Related to this Course
DesignDesignCreate a software structure Create a software structure (architecture) around which (architecture) around which code will be built code will be built
DesignDesignCreate a software structure Create a software structure (architecture) around which (architecture) around which code will be built code will be built
CodingCodingFill in the software Fill in the software structure with codestructure with code
CodingCodingFill in the software Fill in the software structure with codestructure with code
13http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Your Software Development Experience
What is the largest software system that you have built?
How did you build it?• What process?• What programming language?• What tools?• Did you use version control tools?
How long will the software be used for?• Who will fix, change, or adapt the software that you wrote?
14http://libre.adacore.com © AdaCore under the GNU Free Documentation License
A Small Software System Is …
Understandable by 1 person
Can be thrown away and rewritten to• Repair or extend it• Port it to a new platform
Anything is OK for small systems
The notion of small is programmer-dependent
Typically something less than 10,000 lines of code is small
15http://libre.adacore.com © AdaCore under the GNU Free Documentation License
A Medium/Large Software System …
Requires a team of people
No single person knows all its aspects
Has a long life-span (> 10 years)
CANNOT throw it away and replace it to• Repair it or extend it• Port it to new platforms
Requires organization, discipline, and the right tools
Software Dependability
17http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Software Dependability
Degree of user confidence
that the system will operate as expected
and it will not fail in normal use
20http://libre.adacore.com © AdaCore under the GNU Free Documentation License
The Blue Screen of Death (BSOD)
22http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Does Software Dependability Matter?
Certainly at the marketing level • No vendor would say its software is undependable• No team would say it produces undependable software
In practice there is plenty of software you cannot depend on
Not all software needs to be dependable
Useful but not very dependable software can be OK • If this machine crashes while doing this presentation I will reboot• If your word processor crashes while you write an important document
there is no harm if you save your document frequently
24http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Warning about Defect Rates
1 document/year lost while word-processing• Great
2 accidents/month at the International Airport in London
22,000 checks/hour drawn from the wrong account in the US
1 document/year lost while word-processing• Great
2 accidents/month at the International Airport in London
22,000 checks/hour drawn from the wrong account in the US
Is a defect rate of 99.9% acceptable? It depends…
Analyze software defect rates in the context of the applicationAnalyze software defect rates in the context of the application
27http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Software Failures: Safety
1986: Therac 25 radiation machine kills several patients• Cause: poor testing of the software
June 4, 1996: 1st flight of Ariane 5 aborted: Ariane 5 destroyed
• Cause: Code from Ariane 4 guidance system was reused in Ariane 5 but not tested.
2000: Deadly accident in French highway• Cause: Software malfunction in car braking system. Car manufacturer
acknowledges responsibility.
Software Evolution
40http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Software Needs to Evolve
Bug Fixes
Port to new architectures• Software lasts for a long time
E.g. Y2K problem• Most useful software outlives the hardware it was designed to run on
E.g. VAX/VMS• When new hardware becomes available it’s cheaper to port existing
applications than rewrite everything from scratch E.g. Intel IA-64
Enhancements & new features• E.g. Dos, Windows 3.1, Windows 95/98/ME, Windows NT/2000/XP
41http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Software Investment Costs in 2001
Typical software productivity is:• Between 2 and 20 lines of working code (LOC) per programmer per day
Average cost of a programmer per day (loaded with all costs):• Between 150 and 500 USD/day
Average cost to write a line of code (LOC)• Between 10 and 50 USD
Cost to develop a 100,000 LOC application• Typically between 1 M USD to 5 M USD
42http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Software Evolution is a Must
You cannot just throw away software and redo it• Cost is one thing• But time-to-market is usually even more important
Your software might not need to be very dependable, but…
… it must be capable to evolve• In a timely fashion• At a reasonable cost
Examples• The GNU Ada/C/C++ compiler is over 2 M LOC• Emacs editor is approx 1.4 M LOC• GNU/Linux is approx 4 M LOC
43http://libre.adacore.com © AdaCore under the GNU Free Documentation License
Software Trend
Software is increasingly developed
by extending and modifying existing systems