



















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




















What makes a Good System? ๏ We may remark that a good system has the following properties: ๏ Useful and usable; ๏ Reliable; ๏ Flexible; ๏ Affordable; ๏ Available. ๏ During this lecture we will be considering design properties of modules. ๏ Question : How do modules allow us to meet some or all of the above goals of a good system?
Interfaces โ an Example
Interfaces โ an Example
Linguistic Modular Units ๏ A programming language (or design language) should support the principle of linguistic modular units: ๏ Modules must correspond to linguistic units in the language used ๏ EXAMPLE: Java methods and classes ๏ COUNTER EXAMPLE: Subroutines in BASIC are called by giving a line number where execution is to proceed from; there is no way of telling, just by looking at a section of code, that it is a subroutine.
Few Interfaces ๏ This principle states that the overall number of communication channels between modules should be as small as possible: ๏ Every module should communicate with as few others as possible. ๏ So, in the system with n modules, there may be a minimum of n- 1 and a maximum of links; your system should stay closer to the minimum. 2 n ( n ๏ญ 1 )
Small Interfaces (Loose Coupling) ๏ Loose coupling implies that : ๏ If any two modules communicate, they should exchange as little information as possible.
๏ COUNTER EXAMPLE. Declaring all instance variables as public!
Coupling ๏ Coupling is a measure of the strength of the inter- connections between system components. ๏ Loose coupling means component changes are unlikely to affect other components. ๏ Shared variables or control information exchange lead to tight coupling (usually bad). ๏ Loose coupling can be achieved by state decentralization (as in objects) and component communication via parameters or message passing.
Loose Coupling Module A Aโs data Module B Bโs data Module D Dโs data Module C Cโs data
Stepwise Refinement ๏ The simplest realistic design method, widely used in practice. ๏ Not appropriate for large-scale, distributed systems: mainly applicable to the design of methods. ๏ Basic idea is: ๏ Start with a high-level spec of what a method is to achieve; ๏ Break this down into a small number of problems (usually no more than 10) ๏ For each of these problems do the same; ๏ Repeat until the sub-problems may be solved immediately.
Explicit Interfaces ๏ If two modules must communicate, they should do it so that we can see it: ๏ If modules A and B communicate, this must be obvious from the documentation of A or B or both. ๏ Why? If we change a module, we need to see what other modules may be affected by these changes. A traceability matrix can be used for this purpose.
Cohesion Cohesion - A measure of how well a component โfits togetherโ ๏ A component should implement a single logical entity or function. ๏ Cohesion is a desirable design component attribute as when a change has to be made, it is localized in a single cohesive component. ๏ Various levels of cohesion have been identified.
Cohesion Levels ๏ Coincidental cohesion (weak) ๏ Parts of a component are simply bundled together. ๏ Logical association (weak) ๏ Components which perform similar functions are grouped. ๏ Temporal cohesion (weak) ๏ Components which are activated at the same time are grouped.