DOC PREVIEW
UNC-Chapel Hill COMP 401 - comp401sp13lecture13Composition_Aggregation_Delegation

This preview shows page 1-2-3 out of 9 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 9 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Compos&on,)Aggrega&on,))and)Delega&on)COMP)401)Spring)2013)Lecture)13)2/21/2013)Layers)of)Abstrac&on)• Simple)objects)– Object)state)(i.e.,)fields))are)basic)data)types)• As)objects)become)more)complex…)– Encapsulated)object)state)is)complex)enough)to)require)addi&onal)“layers)of)abstrac&on”.)– Object)state)is)modeled)by)a)combina&on)of)other)objects.)– Recall)earliest)examples)with)Triangle)and)Point)• Lecture3,)ta.v09)and)ta.v10)Composi&on)and)Aggrega&on)• Two)design)techniques)for)crea&ng)an)object)that)encapsulates)other)objects.)– Any)specific)situa&on)is)not)necessarily)strictly)one)or)the)other.)• In)a)nutshull…)– Composi&on)• The)individual)parts)that)make)up)the)whole)are)“owned”)solely)by)the)whole.)– They)don’t)otherwise)have)a)reason)for)being.)– Aggrega&on)• The)individual)parts)that)make)up)the)whole)may)also)exist)on)their)own)outside)of)the)whole.)– Or)even)as)a)component)or)part)of)other)objects.)Example)of)Aggrega&on)• lec13.v1)– Course)• Models)a)course)at)the)university)• Encapsulates)Room,)Professor,)and)a)list)of)Student)objects)Characteris&cs)of)Aggrega&on)• Encapsulated)objects)provided)externally)– As)parameters)to)constructor)– GeYers)and)seYers)for)these)components)oZen)provided.)• Encapsulated)objects)may)be)independently)referenced)outside)of)the)aggrega&ng)object)– Including)possibly)as)part)of)another)aggrega&on.)Example)of)Composi&on)• lec13.v2)– Car)• Two)implementa&ons:)HondaOdyssey)and)Porche911)• Both)encapsulate)an)implementa&on)of)Horn)and)an)implementa&on)of)Engine)– Implementa&ons)of)Engine)wriYen)with)inheritance.)• EngineImpl)provides)most)of)the)implementa&on)– Abstract)class)• ManualEngine)and)Automa&cEngine)are)subclasses)– Override)setGear())Characteris&cs)of)Composi&on)• Encapsulated)objects)created)internally)– Usually)within)the)constructor)– No)seYers)and)oZen)no)geYers)• Encapsulated)objects)do)not)make)sense)outside)of)the)abstrac&on.)– Not)shared)with)other)abstrac&ons ))• Func&onality)/)state)of)encapsulated)objects)only)accessible)through)the)abstrac&on)Delega&on)• Claiming)an)“isaa”)rela&onship)with)an)interface)but)relying)on)another)object)to)actually)do)the)work.)• Can)occur)with)either)aggrega&on)or)composi&on.)– Although)more)common)with)composi&on)• Composi&on)example)revisited)– lec13.v3)– Both)Car)implementa&ons)also)now)claim)Horn)and/or)AdjustableHorn)interfaces)as)well.)• Actual)work)of)these)interfaces)delegated)to)internal)horn.)Discussion)•


View Full Document

UNC-Chapel Hill COMP 401 - comp401sp13lecture13Composition_Aggregation_Delegation

Documents in this Course
Objects

Objects

36 pages

Recursion

Recursion

45 pages

Load more
Download comp401sp13lecture13Composition_Aggregation_Delegation
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view comp401sp13lecture13Composition_Aggregation_Delegation and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view comp401sp13lecture13Composition_Aggregation_Delegation 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?