CPSC 3720 - DAY 13 FEBRUARY 15, 2017 ================================================================================ SYSTEM DESIGN ------------- Types of Cohesion: Functional + HIGH COHESION Sequential Communication Procedural Temporal Logical Coincidental - LOW COHESION Coincidental Cohesion Parts of the component are unrelated (unrelated functions, processes, or data) Parts of the component are only related by their location in the source code. Elements needed to achieve some functionality are scattered throughout the system Accidental, worst form Example: Print next line Reverse string of characters in second argument Add 7 to 5th argument Convert 4th argument to float Logical Cohesion Elements of component are related logically and not functionally Several logically related elements are in the same component and one of the elements selectecd by the client component Example: A component reads input from tape, disk and network All the code for these functions are in the same component Operations are related, but functions are significantly different Temporal Cohension Elements are related by timing involved Elements are grouped when they are processed. Example: An exception handler that Closes all open files Creates an error log Notifies user Lots of different activities occur, all at the same time Procedural Cohesion Elements of a component are related only to ensure a particular order of the execution Actions are still weakly connected and unlikely to be reusable Example: Write output record Read new input record Pad input with spaces Return new record Communicational Cohesion Functions performed on the same data or to produce the same data Examples: Update record in data base and send it to printer Fetch unrelated data at the same time Sequential Cohesion The output of one part is the input to another! Data flows between parts (different from procedural cohesion) Occurs naturally in functional programming languages (like C) Good situation Functional Cohesion Every element to a single computation is contained in the component Every element in the component is essential to the computation Ideal situation What is a functionally cohesive component? .One that not only performs the task, but only performs that function and nothing else Not always possible, can affect other systems, make them harder to implement Coupling vs. Cohesion There can be a trade-off between coupling and cohesion High cohesion (good) <==> High coupling (Bad) Every function is its own subsystem Low Cohesion (Bad) <==> Low Coupling (Good) If everything is in one subsystem, there are no dependencies Developers can deal with 7 +/- 2 concepts on any one level of abstraction Hardware/Software Mapping Will this system be distributed among many computers? How do they communicate? Central data repositories? Web Servers? What Hardware will be involved? Limitations of hardware Does this affect any design goals or non-functional requirements What subsystem and objects will be allocated to each node? Any existing subsystems used in this system? Any off the shelf components? Data Management Persistent Data is data that outlives a single execution of the system Saving a file and re-opening later Data in a database Subsystem decomposition has to account for this data management Flat Files Low level of abstraction Sequence of bytes Application must account for concurrent data and loss of data Relational Database Data stored in tables defined by a schema Every column is an attribute Each row is a related tuple Ideal for large datasets Slow for small datasets Bad for unsturctured data (images, natural language)