Lecture 5 Design patterns
What is it? reusable solutions clear code easy to develop
Descripion of pattern. what why how the design pattern is you should use it to use it
singleton abstract factory MVC decorator adapter facade composite observer memento chain of responsibility command
Model View Controller what why how the design pattern is you should use it to use it
what Model View Controller controller update notify update user actions model view
why Model View Controller better understanding Cocoa easy add new features use it in other projects
Model View Controller controller update notify update user actions model view
Model View Controller ViewController notify update update user actions Album AlbumView
what Singleton Manager +instance:manager +sharedinstance():manager -init():id
why Singleton global access
Singleton LibraryAPI +instance:libraryapi +sharedinstance():libraryapi -init():id
Singleton
what Facade API remote server database file system memory
why Facade single interface to a complex subsystem reduces dependencies of outside code easier to develop
Facade LibraryAPI HTTPClient Persistency Manager
Facade LibraryAPI HTTPClient Persistency Manager
what Decorator Obj-c category delegation
what Decorator category NewClass : NSString
what Decorator category NSString +NewClass.h NSString +NewClass.m
why Decorator category extend existing classes without subclassing replace existing method add methods to any of Cocoa s own classes
Decorator category
Decorator category
Decorator category
Decorator category
Decorator category titles Artist Album Genre Year values album.artist album.tittle album.genre album.year
Decorator category
what Decorator delegation ViewController UITableView tableview:numberofrowsinsection: return 4 tableview:cellforrowatindexpath: How many rows should I draw? for (int i=0;i<4;i++) What should I present for cell 1? return cell and so on...
why Decorator delegation changes in another object two objects coordinate to solve a problem
Decorator delegation MyCell MainViewController.h.m.m
what Adapter
what Adapter
what Adapter client <target> request adaptee request adapter request [adaptee specificrequest]
why Adapter different types of objects work together easy add new features use it in other projects
Adapter
Adapter HorizontalScroller.h
Adapter HorizontalScroller.m
Adapter HorizontalScroller.m
Adapter HorizontalScroller.m
Adapter HorizontalScroller.m
Adapter HorizontalScroller.m
Adapter
what Observer subject attachobserver:observer detachobserver:observer notify observer update ConcreteSubject getstate setstate:state subjectstate_ ConcreteObserver update observestate_
why Observer one object notifies other objects of any state change
Observer Notification Key-Value Observing (KVO)
Observer Notification AlbumView.m LibraryAPI.m
Observer Notification PresistencyManager.m
Observer Notification LibraryAPI.m
Observer Key-Value Observing (KVO) AlbumView.m
what Memento originator -state + SetMemento + CreateMemento memento - state + GetState + SetState memento caretaker
why Memento save and load app state whenever you want
Memento
what Command client invoker <Command> execute receiver action receiver ConcreteCommand execute [receiver action]
why Command app support undo/redo
Command