Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software Design and Architecture

Similar presentations


Presentation on theme: "Software Design and Architecture"— Presentation transcript:

1 Software Design and Architecture
Lecture #3

2 CRC For conceptual design
Components Responsibilities Collaborators

3 Class diagrams for technical design

4 Class from code

5 Encapsulation and access modifiers

6 Decomposition Three types of relationship in decomposition Association
Aggregation Composition

7 Association

8 Aggregation(Weak “has-a”)

9 Composition(strong “has-a”)

10 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

11 Generalization with inheritance

12 Inheritance

13 Generalization with interfaces

14 Coupling Coupling focuses on complexity between a module and other modules If a module is too reliant on other module(s) it is “tightly coupled” other wise “loosley coupled”. Metrics to consider for coupling are Degree(Number of connections to other modules) Ease (How obvious are the connections?) Flexibility(replaceable modules without effecting each other)

15 Cohesion Cohesion focuses on complexity within a module, and represents the clarity of the responsibilities of a module A module that performs one task and nothing else, or that has a clear purpose, has high cohesion. if a module encapsulates more than one purpose, if an encapsulation has to be broken to understand a method, or if the module has an unclear purpose, it has low cohesion

16

17

18 High or Low cohesion?

19 Separation of concerns
Abstraction occurs as each concept in the problem space is separated with its own relevant attributes and behaviors. Encapsulation occurs as the attributes and behaviors are gathered together into their own section of code called a class. Access to the class from the rest of the system and its implementation are separated, so details of implementation can change while the view through an interface can stay the same. Decomposition occurs as a whole class can be separated into multiple classes. Generalization occurs as commonalities are recognized, and subsequently separated and generalized into a superclass.

20 Example public class SmartPhone { } private byte camera;
private byte phone; public SmartPhone() { … } public void takePhoto() { … } public void savePhoto() { … } public void cameraFlash() { … } public void makePhoneCall() { … } public void encryptOutgoingSound() { … } public void decipherIncomingSound() { … } }

21

22 public class SmartPhone { private ICamera myCamera; private IPhone myPhone; public SmartPhone( ICamera aCamera, IPhone aPhone ) { this.myCamera = aCamera; this.myPhone = aPhone; } public void useCamera() { return this.myCamera.takePhoto(); public void usePhone() { return this.myPhone.makePhoneCall();

23 Information hiding Access Modifiers Public Private Default Protected

24


Download ppt "Software Design and Architecture"

Similar presentations


Ads by Google