220 likes | 602 Views
CSE1301 Computer Programming: Lecture 21 Software Engineering. Topics. Software Engineering tools and techniques Prototyping Structure Charts Coupling Control coupling Data coupling Reading: Brookshear 6-2, 6-3. Software Engineering. Structured development of software systems
E N D
CSE1301 Computer Programming: Lecture 21Software Engineering
Topics • Software Engineering tools and techniques • Prototyping • Structure Charts • Coupling • Control coupling • Data coupling Reading: Brookshear 6-2, 6-3
Software Engineering • Structured development of software systems • Examples:software for banking, stock exchange, space probe control, toll charge, operating system, games • Tools and Techniques • Structured process rather than trial-and-error. • Important goal: eliminate errors. • “Engineering” • Zero tolerance to error. • Pre-fabricated components. • Re-usable components.
Software Engineering • Tasks • project planning (cost, schedule, personnel) • project management • documentation • prototyping and simulation • interface design • programming • testing • Computer-Aided Software Engineering (CASE) Tools
Recall: Components of the Software Development Process: • Define the problem clearly • Analyse the problem • Design an algorithm • top-down / bottom-up design • Code (Implement) the algorithm • Test the code • Document the system
Development Approach:Water-Fall Model • Requires that each stage be completed before beginning next stage. Analysis Design Implement Test
Development Approach:Incremental Model • Increments from simplified version with limited functionality to complete system. • At each stage: prototype. Analysis Design Implement Test
Prototyping • Construction of simplified version of parts of the proposed system that can be analyzed before further development. • Types of items that can be prototyped: • screen and report format, database and file structures, system protocols. • Types of prototyping • throwaway, evolutionary
Modularity • Top-down analysis and design. • Break problem down into manageable sub-problems.
Modularity • Top-down analysis and design. • Break problem down into manageable sub-problems.
Structure Chart • Pictorial representation of a modular structure • each module represented by a rectangle • arrows represent dependencies between modules
Coupling • Links and dependencies between modules • Control coupling: • when one module passes control to another • Examples: function call, return • Data coupling: • sharing of data between modules. • Examples: function parameters, return values
name name name venue venue date inviteToParty name ringUp askToParty sayGoodbye Example 1 Structure chart with labels showing data coupling inviteToParty ( name,date , venue ) { ringUp ( name) askToParty (date , venue ) sayGoodbye ( name ) } control coupling data coupling
name etc... ringUp name number searchAddrBook Example 2 Structure chart with labels showing data coupling ringUp ( name) { set number to result of searchAddrBook ( name ) pick up the phone dial number say “Hello name, it’s Jim” } return value
Notes on Coupling • Aim: maximize module independence = minimize coupling. • Use of global variables is a form of implicit data coupling: dangerous! • It is NOT recommended to have global variables in your program.
Notes on Coupling • How is control coupling represented in code? • Function call: When a function is called, control is passed to that function. • Function return: When the code in a function has been executed, control is returned to the code that called the function. • How is data coupling represented in code? • Parameters: Data sent to a function via parameters. • Return Values: Data returned from function using "return".
Cohesion • Internal binding within function. • Logical cohesion (weaker) • Internal elements perform activities that are logically similar. • Example: I/O function • Functional cohesion (stronger) • all parts are geared towards single activity • Aim: high intra-module cohesion
Example 1 contact ( company , message, mode ) { if mode is by fax { sendFax ( company , message) } else if mode is by email { sendEmail ( company , message) } } Cohesive.
Example 2 contact ( company , message, mode ) { if mode is by fax { sendFax ( company , message) } else if mode is by email { sendEmail ( company , message) } printAddressBook ( ) } Not cohesive.
Structure Chart Examples: • MaxAndMin • IsPalindrome • ContinuingFraction • Factorial
Function interactions • Some systems are not hierarchical in nature. • Two functions interacting as equals. • Superior function relies on subordinates to perform its task. • Recursive functions are not well represented --- need to have loops.
Summary • Modularity is crucial for developing large software projects • Structure charts represent functions and the dependencies between them To be continued ... • Software Engineering topics continued in Lectures 27-29 and Group project.