FIT3077 Lecture 5: Principles of OO Design 2
Principles of OO Design 2
Three levels of paerns in soware design:
●Architectural patterns : describe overall shape of an applicaon
●Design patterns : concerned with modules and their interacons
●Code patterns (idioms) : language specific, express common ways of doing certain operaons
in a parcular language
Rotting Design
When soware fixes and changes are requested during soware maintenance and change that are
made violate the original idea. This make sit very hard to make even small change to the code.
Symptoms:
●Rigidity
○Present when it is hard to make changes to the soware
○Every change causes chain reacon with dependencies
●Fragility
○Exist if the soware tends to break in mulple places whenever a change is made
due to rigidity
○Maintenance becomes impossible as every fix causes another issue
●Immobility
○Exists when it is very hard to reuse modules between applicaons, or even within an
applicaon
●Viscosity
○In regards to the environment is to do with the soware development environment
○Example:
■Compile mes are long - engineers will want the fewest modules to be
recompiled
○Good design can address issues without necessarily needing to change the
environment
Changing requirements and dependency management:
● Reduce dependencies between modules
●Create ‘firewalls’ across which dependencies do not propagate
●Manage the direcons of dependencies
The Dependency Inversion Principle (DIP)
●Provides the mechanism for geng the open-close principle to work
●Depends on interfaces - abstract funcons and classes - rather than concrete funcons or
classes
Dependency structure of an OO system designed according to the DI
Document Summary
Architectural patterns : des(cid:272)(cid:396)i(cid:271)e o(cid:448)e(cid:396)all shape of a(cid:374) appli(cid:272)a(cid:415)o(cid:374) Design patterns : (cid:272)o(cid:374)(cid:272)e(cid:396)(cid:374)ed (cid:449)ith (cid:373)odules a(cid:374)d thei(cid:396) i(cid:374)te(cid:396)a(cid:272)(cid:415)o(cid:374)s. Code patterns (cid:894)idio(cid:373)s(cid:895) : la(cid:374)guage spe(cid:272)i (cid:272), e(cid:454)p(cid:396)ess (cid:272)o(cid:373)(cid:373)o(cid:374) (cid:449)a(cid:455)s of doi(cid:374)g (cid:272)e(cid:396)tai(cid:374) ope(cid:396)a(cid:415)o(cid:374)s i(cid:374) a pa(cid:396)(cid:415)(cid:272)ula(cid:396) la(cid:374)guage. Whe(cid:374) so(cid:332)(cid:449)a(cid:396)e (cid:454)es a(cid:374)d (cid:272)ha(cid:374)ges a(cid:396)e (cid:396)e(cid:395)uested du(cid:396)i(cid:374)g so(cid:332)(cid:449)a(cid:396)e (cid:373)ai(cid:374)te(cid:374)a(cid:374)(cid:272)e a(cid:374)d (cid:272)ha(cid:374)ge that a(cid:396)e (cid:373)ade (cid:448)iolate the o(cid:396)igi(cid:374)al idea. This (cid:373)ake sit (cid:448)e(cid:396)(cid:455) ha(cid:396)d to (cid:373)ake e(cid:448)e(cid:374) s(cid:373)all (cid:272)ha(cid:374)ge to the (cid:272)ode. P(cid:396)ese(cid:374)t (cid:449)he(cid:374) it is ha(cid:396)d to (cid:373)ake (cid:272)ha(cid:374)ges to the so(cid:332)(cid:449)a(cid:396)e. E(cid:448)e(cid:396)(cid:455) (cid:272)ha(cid:374)ge (cid:272)auses (cid:272)hai(cid:374) (cid:396)ea(cid:272)(cid:415)o(cid:374) (cid:449)ith depe(cid:374)de(cid:374)(cid:272)ies. E(cid:454)ist if the so(cid:332)(cid:449)a(cid:396)e te(cid:374)ds to (cid:271)(cid:396)eak i(cid:374) (cid:373)ul(cid:415)ple pla(cid:272)es (cid:449)he(cid:374)e(cid:448)e(cid:396) a (cid:272)ha(cid:374)ge is (cid:373)ade due to (cid:396)igidit(cid:455) Mai(cid:374)te(cid:374)a(cid:374)(cid:272)e (cid:271)e(cid:272)o(cid:373)es i(cid:373)possi(cid:271)le as e(cid:448)e(cid:396)(cid:455) (cid:454) (cid:272)auses a(cid:374)othe(cid:396) issue. E(cid:454)ists (cid:449)he(cid:374) it is (cid:448)e(cid:396)(cid:455) ha(cid:396)d to (cid:396)euse (cid:373)odules (cid:271)et(cid:449)ee(cid:374) appli(cid:272)a(cid:415)o(cid:374)s, o(cid:396) e(cid:448)e(cid:374) (cid:449)ithi(cid:374) a(cid:374) appli(cid:272)a(cid:415)o(cid:374) I(cid:374) (cid:396)ega(cid:396)ds to the e(cid:374)(cid:448)i(cid:396)o(cid:374)(cid:373)e(cid:374)t is to do (cid:449)ith the so(cid:332)(cid:449)a(cid:396)e de(cid:448)elop(cid:373)e(cid:374)t e(cid:374)(cid:448)i(cid:396)o(cid:374)(cid:373)e(cid:374)t. Co(cid:373)pile (cid:415)(cid:373)es a(cid:396)e lo(cid:374)g - e(cid:374)gi(cid:374)ee(cid:396)s (cid:449)ill (cid:449)a(cid:374)t the fe(cid:449)est (cid:373)odules to (cid:271)e (cid:396)e(cid:272)o(cid:373)piled.