Software development
Transcription
Software development
Data Structures and Algorithm Analysis February- June 2008, EUL Instructor: Dr. Pasko Galina Ivanovna Based on lectures by Shaoying Liu Data Structures and Algorithms Course topics • Software development • Linear structures (lists, stacks and queues) • Nonlinear structures (trees and graphs) • Elementary sorting and searching methods • Basics of algorithm analysis Data Structure and Algorithms Software development The University of Queensland's Systems and Software Engineering research division Software Contents development process Problems of software quality Formal Methods Program design www.primeris.com Software development process Abstractly, a software development process can be perceived as a black-box: Software life cycle D e l i v e r y Software life cycle • Requirements analysis and specification is a study aiming to discover and document the exact requirements for the software system to be constructed. • Design is an activity to construct system meeting requirements • Implementation is where the design specification is transformed into a program written in a specific programming language, such as Pascal, C, or Java. • Testing is a way to detect potential faults in the program by running the program with test cases. • Delivery and maintenance is where the ultimate system is delivered to the customer for operation, and is modified either to fix the existing faults when they occur during operation or to meet the new requirements. Software design • Software design is a meaningful engineering representation of some software product that is to be built. • Design can be traced to the customer's requirements assessed for quality against predefined criteria. Design focuses on four major areas of concern: data, architecture, interfaces and components. Problems of software quality 1. The overall problem is that software systems often do not operate as expected. Software systems usually (or correctly speaking, always) contain faults (or bugs), which can be roughly classified into three categories: Implementation does not satisfy the user requirements. Incorrect design (architecture problem) Implementation bugs (in type, array boundary, and file operations). Examples of software quality problems National Aerospace Laboratory of Japan has conducted an airplane flight test of the supersonic experimental airplane (The rocket-powered experimental plane NEXST-1) in Woomera, Australia as part of the Next generation Supersonic Aircraft Technology Research and Development, but failed possibly due to software malfunction, according to the newspaper report after the test flight. Examples of software quality problems • Launched in July of 1962, the Mariner 1 Venus probe veered off course almost immediately and had to be destroyed • The problem was traced to the following line of Fortran code: DO 5 K = 1. 3 The period should have been a comma. An $18.5 million space exploration vehicle was lost because of this typographical error Examples of software quality problems • Therac-25 – Therac-25 was a radiation therapy machine produced by Atomic Energy of Canada Limited. Between June 1985 and January 1987, six known accidents involved massive overdoses by the Therac-25, leading to deaths and serious injuries – There was only a single coding error, but tracking down the error exposed that the whole design was seriously flawed • AT&T Down for Nine Hours – In January of 1990, AT&T’s long-distance telephone network came to a screeching halt for nine hours, because of a software error in the electronic switching systems Examples of software quality problems • UK bank has accidentally transferred 2 billion sterling pounds to UK and US companies because a software design flaw allowed payment instructions to be duplicated.” Computer Weekly (UK), 19 Oct. 1989 • “American Airlines reckons it has lost $50 million in passenger bookings due to a software design error in its own computer reservation system.” Computer Weekly (UK), 22 Sept. 1988. • “The …Bank’s five million credit card customers were yesterday urged to check their statements for mistakes caused by a computer bug.” The Times (UK), 11 August 1992 Problems of software quality 2. Software projects are often over budget and behind schedule. 3. Software requirements are usually not well understood before systems are implemented. The user usually has only a rough idea about the software system they want. The user requirements are not defined precisely, and therefore are often misinterpreted by developers Problems of software quality 4. Software development process is usually not well controlled. – The obligations of system analysts, designers, and programmers are not precisely defined. – Documents are often changed without a rigorous procedure, and such changes are – often not rigorously verified. Problems of software quality 5. Program testing is too late and has limited power in ensuring the correctness of software. – Testing can only show the presence of bugs, but never show the absence of bugs. – Testing is usually costing, around 60% or more of the total cost of software development. – What do you do after you find out that the software cannot be used at all by testing? Problems of software quality 6. Software systems for safety-critical applications may result in the loss of life and/or properties if they are not correct with respect to their requirements specifications: • aircraft control systems. • nuclear power plant control systems. • medical systems. • railway control systems. Important reason for the above problems Specifications are written using informal languages ( English) • Such specifications can be ambiguous offer no foundation for automated formal transformation and verification. Informal Specifications Software system for hotel reservation is required. Hotel has the following resources: single: 100; twin: 50; double: 100 The reservation list must record the following pieces of information of customers: • • • • • • • • Full name address telephone number passport number (if applicable) period of stay type of the room to reserve check in state check out state Following functions must be provided: (1) Make a reservation (2) Cancel a reservation (3) Change a reservation (4) Check in (5) Check out Program Development • Three stages of program development – Develop the algorithm – Implement the algorithm – Maintain the program • When we move from small, well-defined tasks to large software projects, we need to add two extra layers on top of these – Software requirements and specifications Software requirements and specifications • When people talk about a program specification, they refer to a document describing the desired functionality of the program or system using plain English (or whatever language they speak). • The specification of a program or system is simply that what remains if you would abstract from all implementation details. “The Art of Programming” by Frans Faase Software requirements and specifications Software requirements are broad, but precise, statements outlining what is to be provided by the software product Software specifications are a detailed description of the function, inputs, processing, outputs, and special features of a software product Software requirements and specifications • Program specification is definition of what a computer program is expected to do. • It can be: - informal - can be considered as a blueprint or user manual from developer point of view; - formal - it has definite meaning defined in mathematical terms. Contents Software development process Problems of software quality Formal Methods Program design www.primeris.com Possible solution Formal Methods The use of mathematics within software engineering is often called formal methods What are formal methods? Formal methods = Formal Specification + Formal Verification • Formal methods can also be understood as the following three components: • Formal notation (or language) for writing specifications • Logical calculus for formal verification (or proof) • Method for developing software system Formal Verification • Verification of program correctness, independent of data testing, is important area of theoretical computer science research. • Formal verification is act of proving or disproving correctness of a system with respect to a certain formal specification or property, using formal methods. • Formal methods have been used successfully in verifying correctness of computer chips • It is hoped that success with formal verification techniques at the hardware level can lead eventually to success at the software level Specification refinement Specification: squareroot (x: nat0) y: real post: y ** 2 = x Program1: squareroot(x: nat0) begin y: real; y = Math.sqrt(x); return y; end Program2: squareroot(x: nat0) begin y: real; y = Math.sqrt(x); return –y; end Specification refinement Both Program1 and Program2 satisfy the specification, although the results are different This means: Specification: y ** 2 = x Refinement 1: y ** 2 = x and y >= 0 Refinement 2: y ** 2 = x and y <= 0 Software development process using formal methods has changed considerably, as shown next. The change is at the increase of activities and also at the cost and the schedule. For example, formal specification and design may need more time and cost more money. Contents Software development process Problems of software quality Formal methods Program design www.primeris.com Program design What is design What is a program What is program design Principles of program design Overview of design methods What is design When building any complex products, such as cars, bridges, houses, computers, airplanes, trains, … is always necessary to make a well-documented plan to tell how to build them, before they are actually built. The process and activity for making and documenting such a plan is called design. Example 1. Study user requirements: build a house with the following parts: two sides one end one door two roof panels one front 2. Build abstract model of house (abstract description of solution) 2 sides 1 door 1 end 2 roof panels 1 front 3. Evaluate the model against the user requirements. 4. Modify and refine the abstract model to produce a detailed model of the house. 1 back 1 front Bedroom 3 Living room toilet 2 ends 2 roofpanels bathroom Kitchen Bedroom 2 Bedroom 1 front door area Design Design is a process of constructing a preliminary plan or model for producing an expected product or object. Use r re quire ments Desig n Abstract mo del Use r re quire ments Desig n P roduct Product Program design What is design What is a program What is program design Principles of program design Overview of design methods What is program? A program is an algorithm written in a programming language that provides behaviors based on input data. Program = Algorithm + + Data structures Algorithm Algorithm is a sequence of actions or commands. Example: compute the average score of a class with 40 students. (1) Input all scores of the class (2) Compute the total score of the class (3) Divide the total score of the class by the number of students in the class (4) Print out the average score Abstraction of a program Mathematical abstraction of a program: a program is a function, providing mapping P of D to R: P : D →R where P denotes a program; D is its domain; R is its range. Essential task of constructing a program is to decide: (1) domain and range (2) definition of the function P Abstract and detailed program design R e q u ire m e n ts sp e c ific a tio n A b stra c t d e sign P ro gra m d e sign D e ta ile d d e sign C o d in g Abstract design - Identify necessary components, including data items and operations. This may include definitions of the data items and the functionalities of the operations. - Determine the architecture (or structure) of the program that indicates the way to integrate the operations at an abstract level. - Determine relations between data items and operations. For example, what operation processes what data items. Detailed design Define concrete data structures for all the data items identified in the abstract design. Usually, these data items are defined using the data structures available in a specific programming language (e.g., Java, C). Define the functionality of the operations identified in the abstract design in detail. Determine algorithms for implementing the operations. Establish precise logical relations between operations. For example, under what conditions which operations can be integrated to provide what behavior. Characteristics of program design Process of program design lacks a definitive formula to follow. There is no absolute rule for design. This is different from solving a mathematical problem. There is a lack of quality measures that can be used to establish that any program design is the ‘best’ one possible. There is no true or false program design, but good or bad. Program design is a process of creating problems and resolving problems. Program design is an intellectually rigorous discipline. Software development process How the Customer explained it How the Project Leader understood it Software development process How the Analyst design it How the Programmer wrote it Software development process How the Business Consultant described it How the project was documented Software development process What was installed How the Customer was charged Software development process How it was supported What the Customer really needed http://richardwhitehead.com/jokes.htm Welcome to software development! References • David Budgen “Software Design”, AddisonWesley, 1994. • Nell Dale “C++ Plus Data Structures”, 4th ed., John and Bartlett pub., Sudbury, Massachusetts, 2006. • Frans Faase “The Art of Programming” • On-line encyclopedia Wikipedia: www.wikipedia.org Quiz 1 Answer, please, the following questions. • What is software life cycle? • What is a program? • What is an algorithm?