design_patterns
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
design_patterns [2013/04/30 10:43] – [LifeCycle Workaround] skipidar | design_patterns [2023/11/13 10:22] (current) – [LifeCycle Workaround] skipidar | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Design Patterns ====== | ||
+ | A collection of unusual Design Patterns. | ||
+ | |||
+ | |||
+ | ===== Eclipse RPC4 ===== | ||
+ | |||
+ | === Objects crete themselves === | ||
+ | Make UI Elements create themselves and integrate into the Application, | ||
+ | This is some kind of weird, becuase of the inversion of control: not the toolbar adds the buttons, but buttons add themselves to the toolbar. | ||
+ | |||
+ | ^Pro^Contra^ | ||
+ | |All the logic is encapsulated at one place. | The creation order of buttons can not be explicitely specified. | | ||
+ | |Dynamic changes. Just inject another Toolbar and the Widgets will add themselves to another place.| ? | | ||
+ | |||
+ | |||
+ | **Example**: | ||
+ | Toolbar Buttons are created and injected into the Context. | ||
+ | They retrieve the toolbar on their own and add themselves to the toolbar. | ||
+ | To communicate with the applicaiton EventBroker is used. | ||
+ | |||
+ | <sxh java> | ||
+ | // ... Inject the only Toolbar somewhere into the context. | ||
+ | |||
+ | public class ToolbarItemDelObject { | ||
+ | |||
+ | @Inject | ||
+ | private TableToolbar tableToolbar; | ||
+ | | ||
+ | @Inject | ||
+ | private EventBorker eventBorker; | ||
+ | |||
+ | @PostConstruct | ||
+ | void create() { | ||
+ | // use injected ToolBar. | ||
+ | createItem(tableToolbar.getleftPart()); | ||
+ | } | ||
+ | |||
+ | private void createItem(ToolBar parent) { | ||
+ | // create here | ||
+ | } | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | ===== GUI ===== | ||
+ | |||
+ | |||
+ | ==== LifeCycle Workaround ==== | ||
+ | **Problem: | ||
+ | How to work around the lifecycle dependencies? | ||
+ | What to do if you have GUI COmponents which need to know each to initiate themselves? | ||
+ | |||
+ | < | ||
+ | Example: | ||
+ | Table A's header depends on another table B's header. | ||
+ | Table B controls the functionality of Table A, initiates it's display mode. | ||
+ | </ | ||
+ | |||
+ | **Pattern: | ||
+ | Introduce an own lifecycle. | ||
+ | - Step1: Create all the GUI components | ||
+ | - Step2: Walk over all registered components. Inject other components into the current component. | ||
+ | |||
+ | |||
+ | ===Model View Whatever=== | ||
+ | https:// | ||
+ | |||
+ | {{https:// | ||
+ | ==== Model View Presenter (MVP) ==== | ||
+ | Ansatz um das Modell (engl. model) und die Ansicht (engl. view) komplett voneinander zu trennen und über einen Präsentator (engl. presenter) zu verbinden. | ||
+ | |||
+ | http:// | ||
+ | |||
+ | **Wer ist für die Synchronisation zuständig? | ||
+ | |||
+ | == Die View selbst - " | ||
+ | |||
+ | Supervising Controller (wörtlich etwa „Überwachende Steuerung“) ist ein Entwurfsmuster, | ||
+ | |||
+ | http:// | ||
+ | |||
+ | == Der Presenter - " | ||
+ | |||
+ | Passive View (wörtlich etwa „Untätige Ansicht“) ist ein Entwurfsmuster, | ||
+ | |||
+ | http:// | ||
+ | ==== Model View ViewModel(MVVM) ==== | ||
+ | http:// | ||
+ | |||
+ | |||
+ | ==== GUI und BroadCasts ==== | ||
+ | Die BroadCasts eignen sich sehr gut, um innerhalb der Application zwischen Komponenten zu kommunizieren. | ||
+ | Es eigent sich sehr gut um auf Nutzer Aktionen zu reagieren! | ||
+ | |||
+ | Alle potentiellen EMpfänger müssen aber bereits geladen worden sein! | ||
+ | Deswegen eigent sich ein Brodcast schlecht für automatische Tastk, die eventuell schon beim Laden gestartet werden. \\ | ||
+ | In diesem Fall Besser: ein Modell / State erstellen das von überall erreichbar ist. Die GUI reagiert auf Modell / State Änderungen, | ||
+ | **(siehe MVP)** | ||
+ | |||
+ | == Gut== | ||
+ | * Nutzer drückt Button " | ||
+ | * Button " | ||
+ | * BroadcastReceiver reagiert auf den Broacast. | ||
+ | |||
+ | == Schlecht == | ||
+ | * Beim Laden wird ein Task gestartet, der eine automatische Prüfung asynchron ausführt. | ||
+ | * Die Prüfung ist zuende, das Ergebnis wird per Broadcast verteilt. | ||
+ | * **Ein potentieller Empfänger wurde noch nicht geladen und empfängt den Broadcast nicht!** | ||
+ | |||
+ | |||
+ | ==== Services ==== | ||
+ | Strategie für die richtige Architektur der Services. Wie geht man das an? | ||
+ | - Was will man am Ausgang bekommen? | ||
+ | - Welche Daten braucht man dafür? Wann braucht man diese Daten? | ||
+ | - Was muss man übergeben? | ||
+ | - Wohin soll der Service gelegt werden, damit alle die es brauchen den Service finden können? | ||
+ | |||