ec1a6eb59a839b8fc50cc919d6db4b4a.ppt
- Количество слайдов: 54
Programming and Software Engineering 1
Software Development We can define two main classes of software: n User-written software n n solve a particular problem, access information, automate routine tasks this has been a traditional approach for engineers availability of powerful applications software has greatly reduced the need for users to write programs Commercial software n software written for commercial distribution, or for the use of other people within an organization 2
Software Complexity and Software Engineering n n Comparing simple user-written programs to commercial applications is like comparing a birdhouse to the Skydome For example, software for the space shuttle consists of over 40 million lines of code! 3
The State of the Software Industry n n n Software is one of the most important industries in the world Although the applications are high tech, software companies are still run like cottage industries Software is manufactured today the same way the first automobiles were manufactured 100 years ago! 4
Software Manufacturing Methods n n Each program is built from scratch by skilled craftspeople The components must be carefully adjusted for the whole thing to work Parts or components are not interchangeable between programs (or cars in 1900) There are few standards 5
Critical Problems n n n Software takes too long to develop Productivity is low There are many bugs that are difficult to fix Much effort is directed to reinventing the wheel (e. g. , creating user interfaces) Programmers must be highly skilled 6
Software Engineering n n Designing a software system is as complex as designing a rocket, a large building, or a car. Designing software systems requires a sound engineering methodology Currently, most programmers are not trained or certified as engineers Software engineering has become an important discipline 7
Critical Labour Shortage n n n There is a critical shortage of programmers and other information technology professionals Very few engineering schools offer programs in software engineering PPKA will have one of the first software engineering programs in MALAYSIA 8
Software Life Cycle n n The software life cycle consists of several phases, starting with identification of a need, and ending only when the software is no longer in use The software life cycle is similar to the life cycle of any manufactured or engineered product 9
Software Life Cycle (summary) n n n n Identify and describe an application Analyse the application in detail Preliminary design Detailed design Coding Testing and debugging Documentation and maintenance 10
Software Life Cycle n Identify and describe an application n n market and user surveys brainstorming conceptual design Analyse the application in detail n identify the functional modules 11
Software Life Cycle n Preliminary design n Detailed design n n describe the general software structure using flowcharts or pseudocode design alternatives can be explored at this stage completely specify the program logic Coding n n implement the design using a programming language coding from a detailed design is like building a house from a blueprint 12
Software Life Cycle n Test and debug n n n errors can be due to syntax (ie, incorrect grammar), or logic errors are very difficult to detect Documentation and maintenance n n n software may remain in use for years someone must continue to fix bugs, add features, and help users the cost of maintenance can be much higher than the cost of development 13
Programming Languages n n Assembly language High-level languages n n n FORTRAN, C, Pascal Fourth-generation languages (4 GLs) Very high-level languages n n application generators natural language 14
Assembly Language n n Much software is still written in assembly language Advantages n n Disadvantages n n speed, compactness, efficiency not portable difficult to implement and debug every function must be programmed at machine level Thousands of programs written in Intel 80 x 86 assembly language will not run on any other processor 15
High-level Languages n n n Most software is written in high level languages Fortran, Pascal, Basic and C are popular C has become a de facto standard for several reasons n n standards exist, so the code is portable it has much of the power and flexibility of assembly language 16
Problems with these Languages n n n Difficult to learn and use The only built-in I/O support is characterbased read and write Not suitable for occasional “quick and dirty” programming Development of Graphical User Interface is difficult Much of the code is a reinvention of the wheel 17
Fourth Generation Languages (4 GLs) n n n 4 GLs and Rapid Application Development (RAD) tools are used to develop applications with little or no programming Typically use a graphical, drag-and-drop approach Corresponding source code is generated automatically 18
Examples of RAD Tools n n Microsoft Visual Basic Borland Delphi Powersoft Power. Builder Topspeed Clarion 19
Structured Programming n n An important methodology for dealing with complexity is structured programming Complex tasks need to be broken down into simpler subtasks Structured programming reduces complex problems to collections of simple, interconnected modules It is up to the programmer to implement structured programming 20
Programming for DOS n n DOS provides few system services to the programmer It is up to the programmer to implement the following modules for each application from scratch n n n user interface printer drivers video drivers etc. As a result, every application looks and works differently 21
Programming for Windows n n n Windows provides many standard services to the programmer It also specifies a common look and feel for all applications Now the programmer does not need to worry about low level drivers, GUI programming, etc. The programs call Windows Application Program Interface (API) functions Unfortunately, the programmer needs to be knowledgeable about hundreds of API functions 22
Graphical User Interfaces n n n In most applications, the majority of code is associated with the user interface The Windows API provides hundreds of functions to create menus, dialog boxes, etc. Developing the GUI is difficult 23
Procedural Vs. Interactive, Event-driven Programs n n Traditional programs are procedural, with limited user interaction Most Windows applications are event- driven n The program responds to user events, like menu selections, keyboard input and mouse clicks 24
Hello, World! n n A classical C programming example simply prints the message “Hello, world” on the screen. In standard C, the entire program is shown below. #include
Hello, World! n n The equivalent program in Windows requires two pages of cryptic code The program creates a window, and writes “Hello, Windows” in the centre This is the simplest Windows program possible This example demonstrates the shift from text -based applications to event-driven graphical applications 26
Hellowin. c Page 1 /*----------------------------HELLOWIN. C -- Displays "Hello, Windows" in client area (c) Charles Petzold, 1992 ----------------------------*/ #include
Hellowin. c Page 2 if (!h. Prev. Instance) { wndclass. style = CS_HREDRAW | CS_VREDRAW ; wndclass. lpfn. Wnd. Proc = Wnd. Proc ; wndclass. cb. Cls. Extra = 0 ; wndclass. cb. Wnd. Extra = 0 ; wndclass. h. Instance = h. Instance ; wndclass. h. Icon = Load. Icon (NULL, IDI_APPLICATION) ; wndclass. h. Cursor = Load. Cursor (NULL, IDC_ARROW) ; wndclass. hbr. Background = Get. Stock. Object (WHITE_BRUSH) ; wndclass. lpsz. Menu. Name = NULL ; wndclass. lpsz. Class. Name = sz. App. Name ; Register. Class (&wndclass) ; } 28
Hellowin. c Page 3 hwnd = Create. Window (sz. App. Name, // window class name "The Hello Program", // window caption WS_OVERLAPPEDWINDOW, // window style CW_USEDEFAULT, // initial x position CW_USEDEFAULT, // initial y position CW_USEDEFAULT, // initial x size CW_USEDEFAULT, // initial y size NULL, // parent window handle NULL, // window menu handle h. Instance, // program instance handle NULL) ; // creation parameters 29
Hellowin. c Page 4 Show. Window (hwnd, n. Cmd. Show) ; Update. Window (hwnd) ; while (Get. Message (&msg, NULL, 0, 0)) { Translate. Message (&msg) ; Dispatch. Message (&msg) ; } return msg. w. Param ; } long FAR PASCAL _export Wnd. Proc (HWND hwnd, UINT message, UINT w. Param, LONG l. Param) { HDC hdc ; PAINTSTRUCT ps ; RECT rect ; 30
Hellowin. c Page 5 switch (message) { case WM_PAINT: hdc = Begin. Paint (hwnd, &ps) ; Get. Client. Rect (hwnd, &rect) ; Draw. Text (hdc, "Hello, Windows!", -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER) ; End. Paint (hwnd, &ps) ; return 0 ; case WM_DESTROY: Post. Quit. Message (0) ; return 0 ; } return Def. Window. Proc (hwnd, message, w. Param, l. Param) ; } 31
GUI Development Tools n n n Interactive tools have appeared to allow the programmer to design and test the GUI graphically The code is automatically generated to implement the GUI This saves much time, especially for inexperienced programmers 32
Object-Oriented Programming (OOP) n n Traditional languages treat data and procedures as separate entities The programmer designs procedures (instructions) to manipulate data (variables, files, etc. ) 33
Object-Oriented Programming (OOP) n n n Object-Oriented languages treat programs as a collection of objects An object is a combination of data and procedures that are stored together as a reusable unit Objects communicate by sending messages to each other 34
Object-Oriented Programming (OOP) n n n A powerful feature of OOP is inheritance New objects can be based on existing objects, with just minor changes Groups of similar objects can be grouped into classes 35
Object-Oriented Programming (OOP) n n n Each member or instance of a class contains shared code, plus code specific to the instance For example, each open window in Windows is an instance of a class of window objects Methods for opening, closing, moving, resizing, etc. are shared by all instances 36
Advantages of OOP n n Generic objects can be reused in many applications This reuse of software encourages a building block approach to software development, using standardized parts Software development is much faster Software is easier to understand, debug and maintain 37
Disadvantages of OOP n n n Difficult to learn for programmers used to procedural languages A new way of thinking is required Objects reduce portability of code 38
Object-Oriented Languages n n The major OOP language is C++ is standard C with object-oriented extensions Another OOP language is Smalltalk A brand-new alternative is Java 39
Component Software n n n Software reuse can be accomplished using component software Example: Microsoft Component Object Model (COM) and Active. X Existing Active. X components can be incorporated into new applications, saving much development time 40
Java n n Announced by Sun Microsystems in 1995 Greatly hyped! Seen as a way to compete with the Wintel duopoly Issues have been political, as well as technical 41
The Java Promise. . . n n Embedded applications like set-top boxes and cellular phones Internet applications Network computers Platform-independent software development 42
What is Java? n A new language, similar to C++ but without the drawbacks n n n built-in garbage collection no pointers bounds checking Object oriented from ground up The language improvements eliminate many sources of bugs 43
Write Once, Run Anywhere n n Java includes standard libraries for graphical interfaces, etc. Java programs run inside a Virtual Machine (VM) n n VM is an abstract computer that runs compiled Java programs. The JVM is "virtual" because it is generally implemented in software on top of a "real" hardware platform and operating system. They are independent of processor or operating system 44
Applets and Network Software n n n Java can be used to write normal programs, or “applets” that run inside a Web browser Applets are downloaded from a server before running The Network Computers being promoted by Sun, Oracle and others will run Java 45
Java Applets Virtual Machine Browser Applet Server 46
The Hype and the Reality n n Sun is trying to enforce “ 100% Pure” Java that will run on any certified VM Microsoft and others are extending and modifying Java n n Visual J++ makes use of Windows capabilities not portable Microsoft, Netscape and others have developed their own flavours of the VM The Java specification continues to change 47
The Trade-offs Pure Java n n Runs on any platform Lowest common denominator Limited development tools Performance not optimized Proprietary Java n n May be platform-specific Makes use of features of underlying operating system Good development tools Optimized performance 48
User-Oriented Languages n n n Easy to use programming applications have emerged to meet the need of end-user programming A good example is Microsoft Visual Basic Users with limited programming experience can quickly develop powerful, professionallooking applications with full graphical interfaces. 49
Macros and Application Customization n Many useful applications can be created by building on existing software Word and Excel can be extensively programmed using Visual Basic for Applications For example, you could create a program to accept data using an input form, analyze the results, and plot a graph, all in Excel 50
Computer Aided Software Engineering (CASE) n n n CASE is a set of productivity tools for programmers and software developers The tools are analogous to word processors and spreadsheets for business people CASE is still immature, but will become increasingly important in the future 51
Computer Aided Software Engineering (CASE) The CASE toolkit includes: n Design tools n n Prototype tools n n flow diagrams, structure charts, etc. user interface, screen generators, report generators Information repository tools n database for the software development project 52
Computer Aided Software Engineering (CASE) n Program development tools n n organize, generate and test code Methodology tools n support standard development methodology 53
THE END ! 54