14-refpptppt - Improving the Design

Document Sample
14-refpptppt - Improving the Design Powered By Docstoc
					              Improving the Design

                “Can the design be better?”

TCS2411 Software Engineering                  1
              Lecture Objectives

To understand the significance of assessing
 the quality of design
To describe the major factors and criteria
 in assessing the quality of software design
To describe the concepts of coupling and
 cohesion in measuring software design

TCS2411 Software Engineering              2
              A Creative Process
Software design is a creative process, just
 like designing anything else
To see a wrong design, we can check with
 the requirements in the analysis model
To see a bad design, we need to assess
 the design model and analyse the
 components, whether the performance
 can be improved by changing the modules
 or the interfaces

TCS2411 Software Engineering               3
              Example of Wrong &
              Bad Design

If you are designing a PC:
Wrong design
   The resulting PC did not have a component
    specified in requirements, e.g. CD-ROM
Bad design
   The resulting PC have an extremely fast CPU
    but extremely slow hard disk, which reduces
    the performance of the PC

TCS2411 Software Engineering                      4
              Analysing Software

Generally assess the structure of the
 design and the modules, evaluating the
 flexibility, modifiability, understanding and
 overall maintainability of the system
Project team should review the design
 model and improve it
Many factors are used, such as Coupling,
 Cohesion, Factoring, System Shape, etc.
TCS2411 Software Engineering                 5
“The degree of interdependence between
 two modules”
We aim to minimise coupling - to make
 modules as independent as possible
Low coupling can be achieve by:
   eliminating unnecessary relationships
   reducing the number of necessary
   easeing the „tightness‟ of necessary
TCS2411 Software Engineering                6
              Types of Coupling

Data coupling                 good
Stamp coupling
Control coupling
Hybrid coupling
Common coupling
Content coupling              bad

TCS2411 Software Engineering          7
              Data coupling

Modules communicate by               Process
 parameters                           Results

Each parameter is an
 elementary piece of data      mark          grade

Each parameter is
 necessary to the                     Calculate
Nothing extra is needed
TCS2411 Software Engineering                      8
              Data coupling problems

Too many parameters - makes the
 interface difficult to understand and
 possible error to occur
Tramp data - data „traveling‟ across
 modules before being used

TCS2411 Software Engineering             9
              Stamp coupling

A composite data is                    Process
 passed between                         Results
Internal structure            record         updated
 contains data not used
Bundling - grouping of                 Update
 unrelated data into an
 artificial structure
TCS2411 Software Engineering                      10
              Control coupling

A module controls the logic             Check
 of another module through               record
 the parameter
Controlling module needs to     Error
 know how the other module
 works - not flexible!                   Display

TCS2411 Software Engineering                       11
              Hybrid coupling

A subset of data used as               Main
 control                               program

Example: account numbers       Data
 00001 to 99999                 +
If 90000 - 90999, send mail
 to area code of last 3 digit          Process
 (000 - 999)

TCS2411 Software Engineering                     12
              Common coupling

Use of global data as                               Process
 communication                                       Results
 between modules
                               Global data
Dangers of                                    updated
   ripple effect
   inflexibility                     record             Update
   difficult to understand
    the use of data
TCS2411 Software Engineering                                 13
              Content coupling

A module refers to the inside
 of another module
Branch into another module
Refers to data within another
Changes the internal workings
 of another module
Mostly by low-level languages
TCS2411 Software Engineering     14
“The measure of the strength of functional
 relatedness of elements within a module”
   Elements: instructions, groups of instructions,
    data definition, call of another module
We aim for strongly cohesive modules
Everything in module should be related to
 one another - focus on the task
Strong cohesion will reduce relations
 between modules - minimise coupling
TCS2411 Software Engineering                     15
              Types of Cohesion

Functional cohesion           good
Sequential cohesion
Communicational cohesion
Procedural cohesion
Temporal cohesion
Logical cohesion
Coincidental cohesion         bad

TCS2411 Software Engineering          16
              Functional cohesion

All elements contribute to the execution
 of one and only one problem-related task
Focussed - strong, single-minded purpose
No elements doing unrelated activities
Examples of functional cohesive modules:
   Compute cosine of angle
   Read transaction record
   Assign seat to airline passenger
TCS2411 Software Engineering            17
              Sequential cohesion

Elements are involved in activities such
 that output data from one activity
 becomes input data to the next
Usually has good coupling and is easily
Not so readily reusable because activities
 that will not in general be useful together

TCS2411 Software Engineering                   18
              Example of Sequential

module format and cross-validate record
  use raw record
  format raw record
  cross-validate fields in raw record
  return formatted cross-validated record
end module

TCS2411 Software Engineering                19

Elements contribute to activities that use
 the same input or output data
Not flexible, for example, if we need to
 focus on some activities and not the
Possible links that cause activities to
 affect each other
Better to split to functional cohesive ones
TCS2411 Software Engineering                   20
                Example of Communicational

module determine customer details
  use customer account no
  find customer name
  find customer loan balance
  return customer name, loan balance
end module

 TCS2411 Software Engineering            21
              Procedural cohesion

Elements are related only by sequence,
 otherwise the activities are unrelated
Similar to sequential cohesion, except for
 the fact that elements are unrelated
Commonly found at the top of hierarchy,
 such as the main program module

TCS2411 Software Engineering                  22
               Example of Procedural

module write read and edit something
  use out record
  write out record
  read in record
  pad numeric fields with zeros
  return in record
end module
 TCS2411 Software Engineering          23
              Temporal cohesion

Elements are involved in activities that are
 related in time
Commonly found in initialisation and
 termination modules
Elements are basically unrelated, so the
 module will be difficult to reuse
Good practice is to initialise as late as
 possible and terminate as early as possible
TCS2411 Software Engineering                24
               Example of Temporal

module initialise
  set counter to 0
  open student file
  clear error message variable
  initialise array
end module

 TCS2411 Software Engineering        25
              Logical cohesion

Elements contribute to activities of the
 same general category (type)
For example, a report module, display
 module or I/O module
Usually have control coupling, since one
 of the activities will be selected

TCS2411 Software Engineering                26
               Example of Logical

module display record
  use record-type, record
  if record-type is student then
     display student record
  else if record-type is staff then
     display staff record
end module
 TCS2411 Software Engineering         27
              Coincidental cohesion

Elements contribute to activities with no
 meaningful relationship to one another
Similar to logical cohesion, except the
 activities may not even be the same type
Mixture of activities - like „rojak‟!
Difficult to understand and maintain, with
 strong possibilities of causing „side effects‟
 every time the module is modified
TCS2411 Software Engineering                  28
               Example of Coincidental

module miscellaneous functions
  use customer record
  display customer record
  calculate total sales
  read transaction record
  return transaction record
end module
 TCS2411 Software Engineering        29
              Determining Module
                               Yes     Doing one
 Functional                             function
                                         only?                  Coincidental
  Sequential           Yes                   No                    No

                                Data    Module      None      Activities     Yes
                                        related             same category?
                       No                    Control Flow
 Communicational                        Sequence
                                       important?   No
     Procedural                                                    Temporal

TCS2411 Software Engineering                                                       30
              Other Design Factors to

Factoring: reduce module size, clarifying
 system,minimise duplication of code,
 separating work from management,
 creating useful modules, simplifying
System Shape (Structure)
TCS2411 Software Engineering                 31
“Software Engineering: A Practitioner‟s
 Approach” 5th Ed. by Roger S. Pressman,
 Mc-Graw-Hill, 2001
“Software Engineering” by Ian Sommerville,
 Addison-Wesley, 2001

TCS2411 Software Engineering            32

Shared By:
kala22 kala22