Composition Prasun Dewan Department of Computer Science University
- Slides: 62
Composition Prasun Dewan Department of Computer Science University of North Carolina CB 3175 Sitterson Hall Chapel Hill, NC 27599 -3175 dewan@cs. unc. edu http: /www. cs. unc. edu/~dewan 6/13/2021 290 -63: Composition 1
Example 6/13/2021 290 -63: Composition 2
Class Decomposition Model Controller Bar. View 6/13/2021 Semantics State 5 Manipulates State Displays state 290 -63: Composition 3
Reuse Model Controller Text. View 6/13/2021 Semantics State Manipulates State Displays state 290 -63: Composition 4
Inheritance-based Composition IS-A Model Controller Bar. View 6/13/2021 290 -63: Composition 5
Inheritance-based Composition Model Controller Text. View 6/13/2021 290 -63: Composition 6
Inheritance-based Composition Model Text. View Controller 6/13/2021 290 -63: Composition 7
Inheritance-based Composition Model Text. View MController 6/13/2021 290 -63: Composition Menus 8
Delegation & MVC Has-A Model increment Controller Push Button 6/13/2021 Observerable/ Listenable model. Updated get. Val Editing View State Bar. View Editable Text. Field 290 -63: Composition Observer/ Listener Draw Bar 9
Reuse Model & Controller Has-A Model increment add. Listener Observerable/ Listenable model. Updated get. Val Controller Text. View Push Button 6/13/2021 Observer/ Listener Draw Text 290 -63: Composition 10
Multilevel MVC Model Controller Text. View Screen. View 6/13/2021 290 -63: Composition Screen Format 11
Multilevel MVC Model Controller Text. View Print. View 6/13/2021 290 -63: Composition Printer Format 12
Observer but Not View Model Replica Lateral Observer Spread. Cell Dependent Cell “Callback” Mouse 6/13/2021 Controller 290 -63: Composition Higher. Level Observer 13
Delegate but Not Observer Delegator Delegate Stack push add. Element Vector display. Int. Stack push 6/13/2021 display. Stack 290 -63: Composition 14
Delegate but Not Observer • Observer received “notification” about state change in Observable • Notification is Observable-Specific not Observer-specific. • Observer does not “depend” on Observable to do its tasks. 6/13/2021 290 -63: Composition 15
Delegation Vs Inheritance 6/13/2021 290 -63: Composition 16
Inheritance-based Composition IS-A Model Controller Bar. View 6/13/2021 290 -63: Composition 17
Delegation-Based Composition Model Controller 6/13/2021 Bar. View 290 -63: Composition 18
Reuse Model & View Model MController 6/13/2021 Text. View 290 -63: Composition 19
Delegation Vs Inheritance • Arbitrary class can be replaced 6/13/2021 290 -63: Composition 20
Dynamic View Switching 6/13/2021 290 -63: Composition 21
Dynamic View Switching 6/13/2021 290 -63: Composition 22
Dynamic Configuration in Delegation Model add. Listener(Text. View) remove. Listener(Bar. View) set. Model(Model) Controller 6/13/2021 Text. View Bar. View 290 -63: Composition 23
Compile-time binding in Inheritance Model Controller Bar. View 6/13/2021 290 -63: Composition 24
Delegation Vs Inheritance • Arbitrary class can be replaced • Dynamic component replacement • IS-A compile time • HAS-A runtime 6/13/2021 290 -63: Composition 25
Multiple Views 6/13/2021 290 -63: Composition 26
Multiple Instantiation in Delegation Model Bar. View 6/13/2021 Controller 290 -63: Composition Bar. View 27
Multiple Subclasses in Inheritance M_Vars Model M_Vars’ C_Vars Controller C_Vars’ BV_Vars 6/13/2021 Bar. View Text. View 290 -63: Composition TV_Vars 28
Multiple Instantiation in Delegation Model Bar. View TV_Vars 6/13/2021 M_Vars Controller Bar. View C_Vars B_Vars 290 -63: Composition 29
Delegation Vs Inheritance • Arbitrary class can be replaced • Dynamic component replacement • IS-A compile time • HAS-A runtime • Multiple Component Instantiation 6/13/2021 290 -63: Composition 30
Distribution in Delegation Model Controller 6/13/2021 Bar. View 290 -63: Composition 31
Distribution in Delegation Model Controller 6/13/2021 Bar. View Controller 290 -63: Composition Bar. View 32
Distribution in Inheritance Model Controller Bar. View 6/13/2021 290 -63: Composition 33
Proxies in Delegation Model Controller 6/13/2021 Out In Bar. View Controller 290 -63: Composition Model Bar. View 34
Delegation Vs Inheritance • Arbitrary class can be replaced • Dynamic component replacement • IS-A compile time • HAS-A runtime • Multiple Component Instantiation • Distribution • Proxies 6/13/2021 290 -63: Composition 35
Delegation Vs Inheritance n n n Connections made by component users O(N 2) connections explicitly made Connections not visualized 6/13/2021 n n n Connections specified by component definers O(n) connections explicitly made (components define an environment) Links Visualized 290 -63: Composition 36
Delegation Vs Inheritance n n n Connections remade with dynamic links Distribution requires more work and objects Ditto with Proxies 6/13/2021 n No dynamism n No distribution n No proxies 290 -63: Composition 37
Delegation vs Inheritance n n n 6/13/2021 Flexibility of Delegation => Less Automation Provide incremental path Some disadvantages not inherent and can be partially overcome 290 -63: Composition 38
Overcoming Delegation Drawbacks n Connections made by component users n n 6/13/2021 Connections specified by component definers External agent makes connection at instantiation time based on specification 290 -63: Composition 39
External Generic Agent Generic Composer Model Controller 6/13/2021 Text. View Bar. View 290 -63: Composition Specific Composer 40
Facets add. Listener() Model Generic Composer set. Model() Controller 6/13/2021 Text. View Bar. View 290 -63: Composition Specific Composer 41
Registering add. Listener() Model Generic Composer reg(c, m, v) set. Model() Controller 6/13/2021 Text. View Bar. View 290 -63: Composition reg(C, M, V) Specific Composer 42
Auto Connection add. Listener() Model Generic Composer reg(c, m, v) set. Model() Controller Text. View Bar. View AC(c, m, v) Specific Composer 2*n runtime 6/13/2021 290 -63: Composition 43
Auto Connection add. Listener() Auto-connect Facets Model reg(C, M, V) set. Model() Controller 6/13/2021 Generic MVC Composer Text. View 290 -63: Composition AC(new C) Specific Composer n + 1 runtime 44
Dynamic/Explicit Connection 6/13/2021 290 -63: Composition 45
Connection Visualization 6/13/2021 290 -63: Composition 46
Specifying Facets register. Facet (<Facet. Name>, <Facet. Type>, <Method>, arity) register. Facet (listener, Listener, add. Listener, many) add. Listener() Model Server-API Approach set. Model() Controller Text. View Bar. View Facet. Specification API Generic Composer Registration API Specific Composer register. Facet (changeable, Changeable, set. Model, single) 6/13/2021 290 -63: Composition 47
Specifying Facets register. Facet (listener, Listener, add. Listener, many) Facet. Reflection Specification Protocol API add. Listener() Model Introspection Approach set. Model() Controller Text. View Bar. View Generic Composer Registration API Specific Composer register. Facet (changeable, Changeable, set. Model, single) 6/13/2021 290 -63: Composition 48
Basic Connection Patterns public void set<Facet. Name> (<Facet. Type>) [public <Facet. Type> get<Facet. Name> ()] public void add<Facet. Name> (<Facet. Type>) [public Enumeration enumerate<Facet. Name> ()] public void remove<Facet. Name> (<Facet. Type>) public <Facet. Type> <Facet. Name> 6/13/2021 290 -63: Composition 49
Some Advanced Patterns public class Controller implements Auto. Connect. All public String[] get. Auto. Connect. Facets() [public String get. Opposite<Facet. Name>()] [public Object get. Reference. For<Facet. Name>()] Argument to set<Facet. Name> (<Facet. Type>) 6/13/2021 290 -63: Composition 50
Facet Description API public void set. Opposite. Facet (<Object>, <Source. Facet>, <Dest. Facet> 6/13/2021 290 -63: Composition 51
General Connection a: ta u tu tv v b: tb a: ta connect (a, u, b, v) 6/13/2021 290 -63: Composition 52
Direct Connection a: ta u tbu tav vv b: tb connect (a, u, b, v) Direct. Connect(A, U, B, V) -> facet (A, U); facet (B, V); type (A, Ta), type (B, Tb); type(U, Tu), type (V, Tv); subtype (Ta, Tv); subtype (Tb, Tu); colocated(A, B) or (subtype (Ta, Remote); subtype (Tb, Remote)); do. Connect (A, U, B, V) 6/13/2021 290 -63: Composition 53
Proxy-based Connection a: ta u tu tw w ap a: t p: t x tx tv v b: tb a: ta proxy (p, a, u, w, x, v, b) connect (a, u, b, v) Proxy. Connect (P, A, U, W, X, V, B) -> connect (A, U, P, W); connect (P, X, B, V) 6/13/2021 290 -63: Composition 54
Interposition X Client a: ta X Pseudo Server u tbu xb taw vw p: a: u x t b a a t tt, pt p: X Server tva v b: tb a: ta connect (a, u, b, v) 1. connect (A, U, B, V) -> proxy(P, A, U, V, B); interpose (P); Proxy. Connect (P, A, U, V, B) 2. connect(A, U, B, V) -> Direct. Connect (A, U, B, V) 6/13/2021 290 -63: Composition 55
Type Translation: Adapter Lock-Floor Translation Lock Controller a: ta u tu taw w v p: tp ux txb Floor Controller tv v b: tb a: ta connect (a, u, b, v) 3. connect (A, U, B, V) -> proxy(P, A, U, V, B); Proxy. Connect (P, A, U, V, B) 6/13/2021 290 -63: Composition 56
Right Facet Translation a: ta u tu taw w v ap a: t p: t x txb tv v b: tb a: ta connect (a, u, b, v) 4. connect (A, U, B, V) -> proxy(P, A, U, V, X, V, B); Proxy. Connect (P, A, U, W, X, V, B) 6/13/2021 290 -63: Composition 57
Left Facet Translation Observable a: ta Changeable Coupler u tu taw w ap a: t p: t u txb tv v b: tb a: ta connect (a, u, b, v) 5. connect (A, U, B, V) -> proxy(P, A, U, W, U, V, B); Proxy. Connect (P, A, U, W, X, V, B) 6/13/2021 290 -63: Composition 58
General Facet Translation Observable a: ta Changeable Coupler u: tu taw w ap a: t p: t x txb tv v b: tb a: ta connect (a, u, b, v) 6. connect (A, U, B, V) -> proxy(P, A, U, W, X, V, B); Proxy. Connect (P, A, U, W, X, V, B) 6/13/2021 290 -63: Composition 59
Delegation Vs Inheritance n n n Connections made by component users O(N 2) connections explicitly made Connections not visualized 6/13/2021 n n n Connections specified by component definers O(n) connections explicitly made (components define an environment) Links Visualized 290 -63: Composition 60
Manual Vs Assisted Delegation n Connections made by component users O(N 2) connections explicitly made Connections not visualized 6/13/2021 n n n Connections specified by component definers/ registrars 1 - O(N 2) connections explicitly made (components define an environment) Links Visualized 290 -63: Composition 61
Delegation vs Inheritance n n n 6/13/2021 Flexibility of Delegation => Less Automation Provide incremental path Some disadvantages not inherent and can be partially overcome 290 -63: Composition 62
- Prasun dewan
- Prasun dewan
- Webnis
- Ucl computer science bsc
- Electrical engineering northwestern
- Computer science department rutgers
- Stanford vptl tutoring
- Florida state computer science
- Ubc computer science department
- Bhargavi goswami
- What kind of science
- Computer science university of phoenix
- Bridgeport engineering department
- University of bridgeport computer science faculty
- Yonsei university computer science
- York university computer science
- Unc chapel hill cs
- Seoul national university computer science
- Osaka university computer science
- Computer science columbia university
- 7800 york road
- Kansas state university computer science
- Brown university computer science faculty
- Trinity university computer science
- Brandeis computer science
- Institute of computer science university of tartu
- Kotebe metropolitan university fields
- Kalki author of the tiger king
- Dewan bahasa dan pustaka sarawak
- Definisi permainan tradisional menurut kamus dewan
- Tugas dewan sekolah
- Jabatan pengairan dan saliran negeri perlis
- Dewan taklimat serdang
- Pada dewan ambalan ketuanya disebut
- Doa masuk dewan peperiksaan
- Tamadun yunani tingkatan 1
- Maksud plagiat kamus dewan
- Tugas bidang kajian kepramukaan
- Dewan tanvir ahmed
- Dewan satuan pandu berfungsi untuk
- Pp nomor 17 tahun 2010 tentang dewan pendidikan
- Dewan kehormatan pusat ikatan notaris indonesia
- Dewan tanvir ahmed
- Dewan tanvir ahmed
- Iti 1100
- Jenis rumah selangorku
- Pencegahan kecederaan
- Dewan mpsp gurun jaya
- Maksud fitrah dari segi bahasa dan istilah
- Hukum go- food dewan fatwa al- irsyad
- Isi aaoifi dan psak syariah
- Sistem pentadbiran negara ptm
- Contoh ayat kata berimbuhan sisipan
- Ubblu
- Dewan perwakilan rakyat republik indonesia
- Pembaharuan kerajaan abbasiyah dalam bidang ketenteraan
- Perwujudan dalam kamus dewan
- Department of law university of jammu
- Department of geology university of dhaka
- Narrativistic
- University of bridgeport it department
- Isabel darcy
- Department of physics university of tokyo