SOFTWARE DESIGN AND ARCHITECTURE LECTURE#2
DESIGN PRICIPLES ABSTRACTION ENCAPSULATION DECOMPOSITION GENERALIZATION
ABSTRACTION Abstraction breaks a concept down into a simplified description that ignores unimportant details and emphasizes the essentials needed for the concept, within some context. Rule of astonishment Choose abstraction that is more appropriate to the context If situation changes, Reconsider your abstractions.
Encapsulation The ability to “bundle” attribute values (or data) and behaviours (or functions) that manipulate those values, into a self-contained object. The ability to “expose” certain data and functions of that object, which can be accessed from other objects, usually through an interface The ability to “restrict” access to certain data and functions to only within the object.
Data and functions that manipulate that data are “bundled” into a self-contained object. Data and functions of the object can be exposed or made accessible from other objects. Data and functions of the object can be restricted to only within the object
Decomposition It consists of taking a whole thing, and dividing it into different parts. The general rule for decomposition is to look at the different responsibilities of a whole and evaluate how the whole can be separated into parts that each have a specific responsibility “Lifetimes” of whole and part classes should be well defined.
Decomposition Three types of relationship in decomposition Association Aggregation Composition
Generalization Generalization helps reduce redundancy when solving problems. In coding, algorithmic behaviors are often modelled through methods object-oriented modelling achieves generalization by classes through inheritance
Design Principles(cont’d) Evaluating Design Complexity Design complexity applies t both classes and methods Metrics for complexity is Coupling Cohesion