Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Design Lecture : 9.

Similar presentations


Presentation on theme: "Software Design Lecture : 9."— Presentation transcript:

1 Software Design Lecture : 9

2 Software Design Components
Principle Criteria (this lecture) Techniques

3

4

5 Range of Coupling High Coupling Content Common Control Stamp Data
Uncoupled Loose Low

6 Common Coupling – High Coupling
Definition: Two components share data Global data structures Common blocks Usually a poor design choice because Lack of clear responsibility for the data Reduces readability Difficult to determine all the components that affect a data element (reduces maintainability) Difficult to reuse components Reduces ability to control data accesses Pp220+ pfleeger

7 Example-1 Process control component maintains current data about state of operation. Gets data from multiple sources. Supplies data to multiple sink. Each source process writes directly to global data store. Each sink process reads directly from global data store.

8 Diagrammatic Representation
Shared Data Store Source -1 Sink Variable a Source -2 Read directly from Variable a Write directly to Variable a Source -3

9 Example-2 Process control component maintains current data about state of operation. Gets data from multiple sources. Supplies data to multiple sinks. Each source process writes directly to global data store. Each sink process reads directly from global data store. Improvement Data manager component is responsible for data in data store. Processes send data to and request data from data manager.

10 Diagrammatic Representation
Data Manager Source -1 Sink Variable a Source -2 Places request to read Places request to write Source -3

11 Control Coupling – Moderate Coupling
Definition: One module controls the internal logic of the the other one through parameters May be either good or bad, depending on situation. Bad when component must be aware of internal structure and logic of another module Good if parameters allow factoring and reuse of functionality

12 Example of Control Coupling
Two modules exhibit control coupling if one (``module A'') passes to the other (``module B'') a piece of information that is intended to control the internal logic of the other Unsorted List Sort the list

13 Stamp Coupling Definition:
Stamp coupling is when modules share a composite data structure and use only a part of it, possibly a different part (e.g., passing a whole record to a function that only needs one field of it). Be sure you know the difference between the insightful designer and the lazy programmer. Know what tradeoffs you are making in your design.

14 Example-1 Customer billing system
The print routine of the customer billing accepts a customer data structure (cid, cname, address, phone no, address, NIC, cell no, passport no) as an argument, parses it, and prints the name, address, and billing amount.

15 Example-2 Customer Billing System
The print routine of the customer billing accepts a customer data structure as an argument, parses it, and prints the name, address, and billing information. Improvement The print routine takes the customer name, address, and billing information as an argument rather than taking the whole structure as input.

16 DATA COUPLING – Lowest level of coupling
Data coupling occurs between two modules when data are passed by parameters using a simple argument list and every item in the list is used. 

17 Example

18 Cohesion A measure of the closeness of the relationships between elements of a component or "module" of a system. High cohesion is desirable because: simplifies correction, change and extension reduces testing promotes reuse

19 Range of Cohesion High Cohesion Coincidental Low Functional
Informational Sequential Communicational Procedural Temporal Logical Coincidental Low

20 Coincidental Cohesion – Lowest Cohesion
Definition: Parts of the component are only related by their location in source code A coincidentally cohesive module is one whose activities have no meaningful relationship to one another.

21 Example – Module with multiple argument
Print next line Reverse string of characters in second argument Add 7 to 5th argument Convert 4th argument to float  All the above functions have no relationship but they are there in the same module by chance!! I don’t even want to think about it.

22 Logical Cohesion Definition: Elements of component are related logically and not functionally. Several logically related elements are in the same component and one of the elements is selected by the client component. A logically cohesive module performs several activities of the same general category in which the activity or activities to be executed are selected by the invoking module

23 Example- I/O Operation
A component reads inputs from tape, disk, and network. All the code for these functions are in the same component. Operations are related, but the functions are significantly different. I don’t even want to think about it.

24 TEMPORAL COHESION A temporally cohesive module is one which performs several activities that are related in time. Temporally cohesive modules typically consist of partial activities whose only relationship to one another is that they are all carried out at a specific time..

25 Example One of the most common examples of a temporally cohesive module is an initialization routine that initializes data used by many modules throughout a system. I don’t even want to think about it.

26 Procedural Cohesion Definition: Elements of a component are related only to ensure a particular order of execution.  Module with (only) procedural cohesion is one supporting different and possibly unrelated activities, in which control passes from one activity to the next.

27 Example ... Read part number from data base update repair record on maintenance file. May be useful to abstract the intent of this sequence. Make the data base and repair record components handle reading and updating. Make component that handles more abstract operation.

28 Communicational Cohesion
Definition: Module performs a series of actions related by a sequence of steps to be followed by the product and all actions are performed on the same data A communication ally cohesive module is one which performs several functions on the same input or output data. 

29 Example Update record in data base and send it to the printer.
Obtain author, title, or price of book from bibliographic record, based on a passed flag. I don’t even want to think about it.

30 Sequential Cohesion The output of one component is the input to another. Occurs naturally in functional programming languages Good situation

31 Example Retrieve customer Data Retrieve customer order
Generate invoice Get and edit input data.

32 Functional Cohesion – Highly cohesive
Definition: Every essential element to a single computation is contained in the component. A functionally cohesive module performs one and only one problem related task. Ideal situation.

33 Examples Read Customer Record, Calculate Net Pay
A complex module with numerous sub modules may still be functionally cohesive if all of its subordinate modules are only performed to carry out the task of the parent module. For example, Calculate Net Pay is functionally cohesive although it contains many different functions (e.g., calculate taxable deductions, calculate tax, calculate CPP deduction).

34 Sufficient Each component has all the features needed for a sensible and efficient usage within the abstraction The interface is as small as possible. Minimum possible interface is to be selected

35 Complete Each component has all relevant features within the abstraction; a general interface can be reused.

36 Simple All features of a components are easy to understand (and implement); Complex features are built up of simpler features.

37 Simple All features of a components are easy to understand (and implement); Complex features are built up of simpler features.


Download ppt "Software Design Lecture : 9."

Similar presentations


Ads by Google