FIT3077 Lecture 6: Principles of OO Design 3+4
Principles of OO Design 3
Software Reuse
●Oen stated goals
●Not code copying
○Copy pasng from one program to another
○Maintenance must be done by us
●Don’t maintain it
●Don’t distribute it
●Only need to link it
●Depend only on the interface of the reused product
Principles of Package Architecture
●Packages allow to group classes together into single, higher level, module
●How to decide which classes belong together?
○The Package Cohesion Principle
■The Release Reuse Equivalency Principle
●A reusable modules cannot be reused unless there is a release
system to manage new versions
●Clients need to be able to choose which version of the module they
want to use
●Clients will refuse to reuse modules that do not have the release
management as described above
●Packages are a good candidate for releasable enty
■The Common Closure Principle
●Soware maintenance is even more important than soware reuse
●Whenever a change must be made, all the affected modules affected
must be:
○Rebuilt, Retested, Released
●Ideally, all changes to be limited to a single package
●Should group together classes that are likely to change together for
the same reasons
●Should group together classes that cannot be completely closed with
respect to each other
●Closely related to the open-closed principle
■The Common Reuse Principle
●Classes that aren’t reused together should not be grouped together
●Rare for classes to be reused in isolaon as they typically collaborate
with other classes that go together to form a reusable abstracon
Document Summary
Cop(cid:455) pas(cid:415)(cid:374)g f(cid:396)o(cid:373) o(cid:374)e p(cid:396)og(cid:396)a(cid:373) to a(cid:374)othe(cid:396) Depe(cid:374)d o(cid:374)l(cid:455) o(cid:374) the i(cid:374)te(cid:396)fa(cid:272)e of the (cid:396)eused p(cid:396)odu(cid:272)t. Pa(cid:272)kages allo(cid:449) to g(cid:396)oup (cid:272)lasses togethe(cid:396) i(cid:374)to si(cid:374)gle, highe(cid:396) le(cid:448)el, (cid:373)odule. A (cid:396)eusa(cid:271)le (cid:373)odules (cid:272)a(cid:374)(cid:374)ot (cid:271)e (cid:396)eused u(cid:374)less the(cid:396)e is a (cid:396)elease s(cid:455)ste(cid:373) to (cid:373)a(cid:374)age (cid:374)e(cid:449) (cid:448)e(cid:396)sio(cid:374)s. Clie(cid:374)ts (cid:374)eed to (cid:271)e a(cid:271)le to (cid:272)hoose (cid:449)hi(cid:272)h (cid:448)e(cid:396)sio(cid:374) of the (cid:373)odule the(cid:455) (cid:449)a(cid:374)t to use. Clie(cid:374)ts (cid:449)ill (cid:396)efuse to (cid:396)euse (cid:373)odules that do (cid:374)ot ha(cid:448)e the (cid:396)elease (cid:373)a(cid:374)age(cid:373)e(cid:374)t as des(cid:272)(cid:396)i(cid:271)ed a(cid:271)o(cid:448)e. Pa(cid:272)kages a(cid:396)e a good (cid:272)a(cid:374)didate fo(cid:396) (cid:396)eleasa(cid:271)le e(cid:374)(cid:415)t(cid:455) So(cid:332)(cid:449)a(cid:396)e (cid:373)ai(cid:374)te(cid:374)a(cid:374)(cid:272)e is e(cid:448)e(cid:374) (cid:373)o(cid:396)e i(cid:373)po(cid:396)ta(cid:374)t tha(cid:374) so(cid:332)(cid:449)a(cid:396)e (cid:396)euse. Whe(cid:374)e(cid:448)e(cid:396) a (cid:272)ha(cid:374)ge (cid:373)ust (cid:271)e (cid:373)ade, all the a e(cid:272)ted (cid:373)odules a e(cid:272)ted (cid:373)ust (cid:271)e: Ideall(cid:455), all (cid:272)ha(cid:374)ges to (cid:271)e li(cid:373)ited to a si(cid:374)gle pa(cid:272)kage. Should g(cid:396)oup togethe(cid:396) (cid:272)lasses that a(cid:396)e likel(cid:455) to (cid:272)ha(cid:374)ge togethe(cid:396) fo(cid:396) the sa(cid:373)e (cid:396)easo(cid:374)s. Should g(cid:396)oup togethe(cid:396) (cid:272)lasses that (cid:272)a(cid:374)(cid:374)ot (cid:271)e (cid:272)o(cid:373)pletel(cid:455) (cid:272)losed (cid:449)ith (cid:396)espe(cid:272)t to ea(cid:272)h othe(cid:396) Classes that a(cid:396)e(cid:374)(cid:859)t (cid:396)eused togethe(cid:396) should (cid:374)ot (cid:271)e g(cid:396)ouped togethe(cid:396)