02 - SW Design Principles - OOP Concepts
02 - SW Design Principles - OOP Concepts
▪ SW Design Concepts
▪ Summary
▪ Whose quality cannot be assessed until late in the software process, when
time is short, and many dollars have already been spent.
+Open() +Grant()
+Close() +Decrease()
+GetBalance():double +GetInstallment():double
+Activate() +Activate()
+Reactivate() +GetLoanBalance():double
+GetLoanBalance():double
High Cohesion?! High Cohesion?!
High Cohesion?!
23-Feb-23 MOBILE PROGRAMMING 9
SW Design Concepts
▪ Coupling describes how much tight the code structure (i.e class) is to
another code structure.
▪ Class Uses:
▪ The users of a class do not know how the class stores its
data.
▪ A class can change the data type of a field, and users of the
class do not need to change any of their code.
23-Feb-23 MOBILE PROGRAMMING 19
Implement Encapsulation
▪ Keep instance variables private.
▪ Advantage:
▪ To take advantage code reuse.
▪ To use polymorphism.
Inheritance
▪ Given the parent class Person and the child class Student,
we add another subclass of Person which is Employee.
p.printName();
▪ a.buck();
Compiler
error
▪ Example:
▪ Draw method in class shape.
▪ IS-A (Inheritance)
▪ HAS-A(association)
▪ Aggregation
▪ Composition
▪ As one class, for all intents and purpose belongs to another class, and
exists because of it.
▪ A Student class is defined with name and the college he is studying at.
▪ SW Design Concepts