1 CSE1301 Computer Programming: Lecture 25 Software Engineering 2.

Slides:



Advertisements
Similar presentations
10 Software Engineering Foundations of Computer Science ã Cengage Learning.
Advertisements

Chapter 3: Modularization
Chapter 2: Modularization
Programming Logic and Design Fourth Edition, Introductory
1 CSE1301 Computer Programming: Lecture 23 Algorithm Design (Part 1)
OOAD Using the UML - Use-Case Analysis, v 4.2 Copyright  Rational Software, all rights reserved 1/18 Use Case Analysis – continued Control Classes.
Representing a Game Board In a game, we represent the action taking place using an array – In a very simple game, we use individual variables to represent.
1 CSE1301 Computer Programming Lecture 25: Software Engineering.
Software Engineering and Design Principles Chapter 1.
1 CSE1301 Computer Programming Lecture 26: Case Study.
Computer Programming and Basic Software Engineering 4. Basic Software Engineering 1 Writing a Good Program 4. Basic Software Engineering 3 October 2007.
Jump to first page 1 System Design (Finalizing Design Specifications) Chapter 3d.
CSE1301 Computer Programming: Lecture 27 Game Programming: Bingo.
Chapter 1 Principles of Programming and Software Engineering.
CSE1301 Computer Programming: Lecture 21 Software Engineering.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts, Testing and Debugging.
Chapter 1 Program Design
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
CSE1301 Computer Programming: Revision. Topics Type of questions What do you need to know? About the exam Exam technique Sample questions.
CSE1301 Computer Programming: Lecture 29 Group Project: “Quabble”
PRE-PROGRAMMING PHASE
Fundamentals of Python: From First Programs Through Data Structures
1 CSE1301 Computer Programming: Lecture 25 Group Project: "Hunt the Wumpus”
System Implementation System Implementation - Mr. Ahmad Al-Ghoul System Analysis and Design.
Chapter 7 Software Engineering Objectives Understand the software life cycle. Describe the development process models.. Understand the concept of modularity.
Fundamentals of Python: First Programs
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Copyright © 2012 Pearson Education, Inc. Publishing as Pearson Addison-Wesley C H A P T E R 6 Value- Returning Functions and Modules.
Chapter 12: How Long Can This Go On?
CSE 219 Computer Science III Program Design Principles.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
VB Games: Preparing for Memory Brainstorm controls & events Parallel structures (again), Visibility, LoadPicture, User-defined procedures, Do While/Loop,busy.
1 CSE1301 Computer Programming: Lecture 24 - Supplement Teddy’s Modules.
C++ Programming Language Lecture 2 Problem Analysis and Solution Representation By Ghada Al-Mashaqbeh The Hashemite University Computer Engineering Department.
I Power Higher Computing Software Development The Software Development Process.
Chapter 7 Software Engineering Introduction to CS 1 st Semester, 2015 Sanghyun Park.
An Object-Oriented Approach to Programming Logic and Design Fourth Edition Chapter 6 Using Methods.
Control Structures II Repetition (Loops). Why Is Repetition Needed? How can you solve the following problem: What is the sum of all the numbers from 1.
CS Data Structures I Chapter 2 Principles of Programming & Software Engineering.
Chapter 10 Software Engineering. Understand the software life cycle. Describe the development process models. Understand the concept of modularity in.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
CCSB223/SAD/CHAPTER131 Chapter 13 Designing the System Internals.
Loops (cont.). Loop Statements  while statement  do statement  for statement while ( condition ) statement; do { statement list; } while ( condition.
1 FUNCTIONS - I Chapter 5 Functions help us write more complex programs.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
First Steps in Modularization. Simple Program Design, Fourth Edition Chapter 8 2 Objectives In this chapter you will be able to: Introduce modularization.
1 CSE1301 Computer Programming Lecture 24: Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
The Hashemite University Computer Engineering Department
Systems Design.  Application Design  User Interface Design  Database Design.
1 COS 260 DAY 12 Tony Gauvin. 2 Agenda Questions? 5 th Mini quiz –Chapter 5 40 min Assignment 3 Due Assignment 4 will be posted later (next week) –If.
Guide to Programming with Python Chapter Six Functions: The Tic-Tac-Toe Game.
1 CSE1301 Computer Programming: Lecture 16 Flow Diagrams and Debugging.
CONDITIONALS CITS1001. Scope of this lecture if statements switch statements Source ppts: Objects First with Java - A Practical Introduction using BlueJ,
Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable 6.0.
Coupling and Cohesion Schach, S, R. Object-Oriented and Classical Software Engineering. McGraw-Hill, 2002.
Chapter 9: Value-Returning Functions
Modern Systems Analysis and Design Third Edition
Coupling and Cohesion 1.
Introduction To Repetition The for loop
Software Design Mr. Manoj Kumar Kar.
Lesson 5 Functions I A function is a small program which accomplishes a specific task. For example, we invoke (call) the function, sqrt(x), in the library.
Modern Systems Analysis and Design Third Edition
Modern Systems Analysis and Design Third Edition
Structure Charts Agenda: What are Structure Charts
Software Design Lecture : 9.
Topics Introduction to Value-returning Functions: Generating Random Numbers Writing Your Own Value-Returning Functions The math Module Storing Functions.
Oriented Design and Abstract Data Type
Presentation transcript:

1 CSE1301 Computer Programming: Lecture 25 Software Engineering 2

2 Topics Software quality Design principles Production principles Sample Problem: Bingo –Analysis –Assumptions and Limitations –Modules and data flow –Data representation

3 Software Quality What is Software Quality? –Programs run correctly every time and unexpected errors do not occur –Changes/Updates are easy to add to the software –The user understands how to use the software without too much work on their part Why? –To ensure things work the way they should –To save time and money in the long run –To make it easy to update the software

4 Software Quality Features Correctness and Reliability –satisfying the requirements, level of trust Efficiency –obtaining the desired goal with a limited use of resources (such as time or hardware) Modifiability –possibility of adapting software to changes in requirements, and to correct errors Reusability –having modules which may be useful in other applications, thus avoiding repetition

5 Design Principles Recall: Modular –Divide the system into manageable units. Highly cohesive –Elements inside a module should be highly- related in purpose. Loosely coupled –Maximize independence between modules. –Avoid implicit coupling (such as the use of global variables).

6 Production Principles Recall Design top-down –Break problem down into manageable sub- problems. Build bottom-up –Code and test the simplest components first. –Test each component before using them to build more complex components. (continued...)

7 Development incrementally –Make simplified versions first. –Add and test one functionality at a time, so that it evolves into a complete system. Document as you go along, from the start –System documentation: describes the software's internal composition (e.g. Pre- and Post- conditions of functions, struct definitions, etc.) –User documentation: describes how to use the software. Production Principles

8 Recall: Software Development Cycle AnalysisDesignImplementTest Maintain documentation of the system throughout the entire cycle.

9 Write a program to play the game Bingo Problem specification: –What are the requirements of the system? –How do you play the game Bingo? –What are the program's tasks in the game? –What’s involved? –Who’s involved? Analysis

10 What's involved? –Bingo Game Boards –A Jar of numbered balls Who's involved? –The Game Master –An N number of Players (Note: There can be a number of variations of the Bingo game. We will look at one version.) The Game of Bingo

11 A 5 x 5 grid. Each square is a cell. Bingo: The Game Board "cell" The central cell is marked initially.

The boards have random numbers assigned to cells in the ranges shown (each number can appear at most once only.) The central cell is marked initially Range for each column

13 Contains 75 numbered balls. Bingo: The Jar etc...

14 At the start of game: –Puts all balls into the jar. –Shakes the jar to mix. During the game: –Takes a randomly-selected ball from the jar. –Calls out the number on the ball. –Note: The balls taken out are not returned back to the jar until the next game. Bingo: The Game Master

15 At the start of game: –Fills the game board randomly (according to rules). During the game: –Marks a cell on the game board if it contains the number called out by the Game Master. –Checks if the board has winning positions-- i.e. if there is a row, column or main diagonal where all the cells have been marked. –Calls out "Bingo!" if it is a winning board. Bingo: The Player

16 Bingo: Sample Winning Boards

17 Winner is the first player who has a winning game board. –Q: What if several players have winning boards? –A: It depends. Usually, the first player to call out "Bingo!" is the winner. Another option is to divide the prize equally among those with winning boards. The game ends when either: –there is a winner, or... –the jar is empty. Bingo: End of Game

18 is winning board? Player Jar true or false rows and columns Game Board pick ball Game Master number call out number mark board number marked cell Data-flow diagram during game:

19 ask for N (i.e. the number of players) ask for names of N players initialize player scores to 0 What are the program's tasks? Initialization: At the start of the program... Algorithm:

20 loop { ask what the user wants to do if ( user wants to start all over again ) { re-initialize program } else if ( user wants to play ) { play game here } else if ( user wants to see scores so far ) { print all scores } else if ( user wants to quit ) end program /* say goodbye and all that */ } What are the program's tasks? (cont)

21 main Structure Chart (Draft): Main (shows control coupling only) initialize program print all scores end program options menu play game

22 Structure Chart (Draft): Main (shows control coupling only) main initialize program print all scores end program options menu play game

23 place and mix all numbers in jar fill N game boards randomly print out all N game boards while ( ( no player has won yet ) and ( the jar is not yet empty ) ) { call out a random number from jar update game boards for all players print out all N game boards } if ( there is a winner ) { announce winner add one to winner’s score } Algorithm to Play Game

24 Write a Program to Play Bingo... (cont) Start with a simple version of the problem Define the assumptions and limitations of this version Break into manageable modules Write algorithms and structure charts for each module

25 Number of boards per player. –Assume: Only one board per player. Filling game boards randomly. –Should each player have unique boards? –Assume: No need to verify that the players fill their boards out differently. Multiple winning boards. –Assume: All players with winning boards get a score each. Assumptions and Limitations

26 Limited functionality. –Version 1: Only one player can play. –Version 2: Allow N players. Possible future enhancements. –Allow several boards per player. –Players can play over network (so that first player with winning board to press “Bingo!” wins). –Graphic user interface so players can mark board themselves. Assumptions and Limitations

27 place and mix all numbers in jar fill game board randomly print out game board while ( ( player has not won yet ) and ( the jar is not yet empty ) ) { call out a random number from jar update player’s game board print out game board } if ( player has won ) { announce winner add one to player’s score } Version 1: Algorithm

28 Structure Chart (Draft): Version 1 (shows control coupling only) main start play print board call out number update player initialize jar fill board

29 update player Structure Chart (Draft): Version 1 (shows control coupling only) mark board check diagonals check rows check columns

30 So far… Drafted a design –wrote the algorithm for main task –divided the main task into modules –prepared structure charts Note: The data-flow diagrams, structure charts and algorithm become part of the documentation.

31 Still to do... System details –data representation –identify data coupling of the modules Implement and test incrementally –Review the analysis and the design Continue software development cycle until software satisfies the requirements.

32 Data Representation Identify shared "objects" in the system, and how to represent information about them in the program. Produce a common data dictionary of type definitions for the different modules. –In C, the type definitions are usually stored in a shared header file ( bingo.h ). The header file is #include -d by the members in their test programs during development. –Keep possible future enhancements in mind.

33 game player board Data Representation What are the "objects" in Bingo? cell jar ball called number

34 game player board Data Representation cell jar ball called number Variables of type int

35 player board Data Representation: Cell cell int cell; #define MAX_VAL 75 Each cell normally contains an integer between 1 and MAX_VAL.

36 player board Data Representation: Cell cell int cell; How would you indicate a marked cell? #define MARKED_VAL 0 A cell with value MARKED_VAL indicates that it has been marked.

37 player board Data Representation: Board cell struct BingoRec { int cell[BOARD_DIM][BOARD_DIM]; }; typedef struct BingoRec BingoBoard; #define BOARD_DIM 5 Makes future modifications (large-sized boards) easy.

38 /* ================================================ * * DATA: * BingoBoard * * DESCRIPTION: * A board is a grid of BOARD_DIM x BOARD_DIM * cells. * * USAGE: * Each cell normally contains an integer * between 1 and MAX_VAL. * A cell with value MARKED_VAL indicates that * it has been marked. * * ================================================ */ Data Documentation: Board

39 typedef struct { BingoBoard board; } PlayerInfo; player board Data Representation: Player cell

40 typedef struct { BingoBoard board; char name[NAME_LEN]; int isWinner; } PlayerInfo; Data Representation: Player #define NAME_LEN 80 Acts as a "flag": True or false

41 /* ====================================== * * DATA: * PlayerInfo * * DESCRIPTION: * Contains a player's details and bingo board. * * USAGE: * `isWinner' is 1 if this player currently * has a winning board; 0 otherwise. * * ======================================= */ Data Documentation: Player

42 typedef struct { /* stuff to follow */ } JarInfo; Data Representation: Jar Can begin development on some modules when other modules are not yet complete. Complete the data representation of the Jar in the same way as the Cell, Board and Player. jar ball

43 Data Representation: Game typedef struct { PlayerInfo player; JarInfo jar; int calledNumber; } GameInfo; Encapsulates all the information needed for Bingo (Version 1: one player only).

44 Summary Software Quality –Why? –What? Design Principles Production Principles Example: The game Bingo Analysis Data flow, modules and structure charts Data representation and documentation

45 Readings Brookshear (5/e or 6/e): Chapter 6 Additional: –S. Ceri, D. Mandrioli and L. Sbattella. The Art and Craft of Computing. Addison-Wesley, Chapters 20 to 24.