SlideShare a Scribd company logo
Design Patterns
Robert Brown
@robby_brown
What is a Design Pattern?


After working on related problems, patterns often
appear in the solutions.
Formalized description of best practice.
Singleton
What is a Singleton?

 A singleton is an object that only has one instance for
 the lifetime of the application.
 Some things are not safe to have more than one
 instance running. For example, an updater.
 Objective-C classes are singletons by design. You can
 take advantage of this when creating singletons.
Creating a Singleton



 https://gist.github.com/1116294
Related Patterns


Abstract Factory
Plug-in Registry
Notification Center
Delegate
What is a Delegate?

A delegate defines the behavior of a generic class.
This keeps implementation specific behavior out of the
generic class.
Data sources are similar to delegates, except they
define content rather than behavior.
UITableViews use both a delegate and a data source.
Delegate Interaction

            UIApplication




                            UIApplication
                              Delegate
Delegate Interaction

                     UITableView




       UITableView                 UITableView
       DataSource                   Delegate
Gotchas


Use “assign” instead of “retain” to avoid retain cycles.
  When using assign, be sure to nullify the delegate
  reference when deallocating the object.
Use “weak” instead of “assign” when using ARC.
Related Patterns
Data Source
Block Delegation
Callback
Chain of Responsibility
State
Flyweight
Block Delegation
What is Block Delegation?
Similar to a delegate object.
Rather than give an object that has one or more
methods defined, give a block that has the
implementation of one method.
Rule of thumb: If you have three or more delegate
methods, use a delegate. Otherwise, use block
delegation.
  Sometimes it’s appropriate to break this rule.
Block Delegation Interaction

                 Object




       Block 1            Block 2
Gotchas

Watch out for retain cycles, particularly with “self”
  __block __unsafe_unretained id selfRef = self;
  __block __weak id selfRef = self;
Don’t forget to copy your blocks. They are created on
the stack.
Related Patterns


Delegate
Callback
Model View Controller
What is MVC?
A strict organization of classes into their different roles.
  Model: Any underlying data.
  View: The graphical presentation of the data.
  Controller: Coordinates the interactions between the
  views and model.
Keeps programs modular and makes it easy to swap
out views when needed.
Model View Controller

Interface   View             Controller   Xcode
 Builder



                     Model



                   Core Data
Gotchas


Some implementations of MVC have the View and
Model directly connected. This can cause infinite
update cycles.
Related Patterns
Observer
Layers
What is the Layer Pattern?

 Modules of a program can be organized like a stack of
 layers.
 Strict Layering: A layer can only use the layer directly
 below it.
 Non-strict Layering: A layer can use any layer below it.
Core Data Layers
                       Application

                           NSManagedObject Subclass
  NSManagedObject
     Context
                                NSManagedObject

 NSPersistentStoreCoordinator   NSManagedObjectModel

                    NSPersistentStore

 XML       SQLite      Binary   In Memory   Custom
Gotchas

Occasionally you may find a need to call up a layer. To
do this, you will need to use dependency inversion.
Dependency inversion: A lower layer defines an
interface to interact with other layers. This is often used
with notifications. An upper layer can register itself to
receive these notifications through the defined
interface.
Façade
What is a Façade?

A façade is a single entry point to a complex collection
of classes.
Makes interaction with complex collections easier and
less dependent on internal implementation.
This is the basis of the layer pattern.
External   External   External
 Object     Object     Object




           Façade




Object                Object




Object     Object     Object
Related Patterns


Class cluster
Layer
Proxy
Observer
What is an Observer?

Sometimes you want to know when an object
changes.
Often used with MVC.
  When a model object changes, you want to update
  the view(s) accordingly.
The observer pattern is built into every NSObject via
Key-Value Observing (KVO).
Gotchas



Don’t forget to remove an object as an observer when
that object is deallocated.
Related Patterns


Model View Controller
Notification Center
Proxy
What is a Proxy?
A proxy receives actions in behalf of another object.
Many types of proxies:
  Lazy loading proxy
  Distributed (network) proxy (NSDistantObject)
  Immutable proxy
NSProxy can be used to make any kind of proxy
object.
Lazy Loading Proxy


   Object   Proxy    Photo
Distributed Proxy


                           Remote
Object   Proxy   Network   Object
Immutable Proxy


                    Mutable
   Object   Proxy   Object
Gotchas



If you use NSProxy, you need to be very familiar with
message forwarding.
Want to Learn More?


Design Patterns: Elements of Reusable Object-
Oriented Software
  Every developer should own this book!
Cocoa Design Patterns in the Apple Docs
Questions?

More Related Content

What's hot

Modern JavaScript Development @ DotNetToscana
Modern JavaScript Development @ DotNetToscanaModern JavaScript Development @ DotNetToscana
Modern JavaScript Development @ DotNetToscanaMatteo Baglini
 
Headless fragments in Android
Headless fragments in AndroidHeadless fragments in Android
Headless fragments in Android
Ali Muzaffar
 
Paris Tech Meetup talk : Troubles start at version 1.0
Paris Tech Meetup talk : Troubles start at version 1.0Paris Tech Meetup talk : Troubles start at version 1.0
Paris Tech Meetup talk : Troubles start at version 1.0
Laurent Cerveau
 
Introduction to Akka
Introduction to AkkaIntroduction to Akka
Introduction to Akka
Knoldus Inc.
 
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency ProgrammingConcurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
Sachintha Gunasena
 
Introduction to nodejs
Introduction to nodejsIntroduction to nodejs
Introduction to nodejsJames Carr
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton Pattern
Mudasir Qazi
 
CoffeeScript By Example
CoffeeScript By ExampleCoffeeScript By Example
CoffeeScript By Example
Christopher Bartling
 
Modern Java Concurrency
Modern Java ConcurrencyModern Java Concurrency
Modern Java Concurrency
Ben Evans
 
Module Ninja .JS
Module Ninja .JSModule Ninja .JS
Javascript classes and scoping
Javascript classes and scopingJavascript classes and scoping
Javascript classes and scoping
Patrick Sheridan
 
Singleton Design Pattern - Creation Pattern
Singleton Design Pattern - Creation PatternSingleton Design Pattern - Creation Pattern
Singleton Design Pattern - Creation Pattern
Seerat Malik
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and AkkaYung-Lin Ho
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and Akka
Yung-Lin Ho
 
Node.js Enterprise Middleware
Node.js Enterprise MiddlewareNode.js Enterprise Middleware
Node.js Enterprise MiddlewareBehrad Zari
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
Bhanuka Uyanage
 
Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805LearningTech
 
Redux
ReduxRedux
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
murugeswariSenthilku
 
Lecture 5 javascript
Lecture 5 javascriptLecture 5 javascript
Lecture 5 javascript
Mujtaba Haider
 

What's hot (20)

Modern JavaScript Development @ DotNetToscana
Modern JavaScript Development @ DotNetToscanaModern JavaScript Development @ DotNetToscana
Modern JavaScript Development @ DotNetToscana
 
Headless fragments in Android
Headless fragments in AndroidHeadless fragments in Android
Headless fragments in Android
 
Paris Tech Meetup talk : Troubles start at version 1.0
Paris Tech Meetup talk : Troubles start at version 1.0Paris Tech Meetup talk : Troubles start at version 1.0
Paris Tech Meetup talk : Troubles start at version 1.0
 
Introduction to Akka
Introduction to AkkaIntroduction to Akka
Introduction to Akka
 
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency ProgrammingConcurrency Programming in Java - 01 - Introduction to Concurrency Programming
Concurrency Programming in Java - 01 - Introduction to Concurrency Programming
 
Introduction to nodejs
Introduction to nodejsIntroduction to nodejs
Introduction to nodejs
 
Design Pattern - Singleton Pattern
Design Pattern - Singleton PatternDesign Pattern - Singleton Pattern
Design Pattern - Singleton Pattern
 
CoffeeScript By Example
CoffeeScript By ExampleCoffeeScript By Example
CoffeeScript By Example
 
Modern Java Concurrency
Modern Java ConcurrencyModern Java Concurrency
Modern Java Concurrency
 
Module Ninja .JS
Module Ninja .JSModule Ninja .JS
Module Ninja .JS
 
Javascript classes and scoping
Javascript classes and scopingJavascript classes and scoping
Javascript classes and scoping
 
Singleton Design Pattern - Creation Pattern
Singleton Design Pattern - Creation PatternSingleton Design Pattern - Creation Pattern
Singleton Design Pattern - Creation Pattern
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and Akka
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and Akka
 
Node.js Enterprise Middleware
Node.js Enterprise MiddlewareNode.js Enterprise Middleware
Node.js Enterprise Middleware
 
JavaScript Basics
JavaScript BasicsJavaScript Basics
JavaScript Basics
 
Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805Design pattern proxy介紹 20130805
Design pattern proxy介紹 20130805
 
Redux
ReduxRedux
Redux
 
Constructors and Destructors
Constructors and DestructorsConstructors and Destructors
Constructors and Destructors
 
Lecture 5 javascript
Lecture 5 javascriptLecture 5 javascript
Lecture 5 javascript
 

Viewers also liked

Design Patterns in iOS
Design Patterns in iOSDesign Patterns in iOS
Design Patterns in iOS
Yi-Shou Chen
 
iOS design patterns: blocks
iOS design patterns: blocksiOS design patterns: blocks
iOS design patterns: blocksAlessio Roberto
 
iOS Design Patterns
iOS Design PatternsiOS Design Patterns
iOS Design Patterns
Bruno Guidolim
 
Peña - Analisis de datos multivariantes
Peña - Analisis de datos multivariantesPeña - Analisis de datos multivariantes
Peña - Analisis de datos multivariantes
Robert_Hooke
 
Robert Hooke
Robert Hooke Robert Hooke
Robert Hooke
varainca
 
Claudio Galeno
Claudio GalenoClaudio Galeno
Robert hooke
Robert hookeRobert hooke
Robert hooke
Robert Hooke
 
Cientificos y sus aportaciones a la bilogia
Cientificos y sus aportaciones a la bilogiaCientificos y sus aportaciones a la bilogia
Cientificos y sus aportaciones a la bilogiaBichitaa Stradlin
 

Viewers also liked (9)

Design Patterns in iOS
Design Patterns in iOSDesign Patterns in iOS
Design Patterns in iOS
 
iOS design patterns: blocks
iOS design patterns: blocksiOS design patterns: blocks
iOS design patterns: blocks
 
iOS Design Patterns
iOS Design PatternsiOS Design Patterns
iOS Design Patterns
 
Carlos lineo
Carlos lineoCarlos lineo
Carlos lineo
 
Peña - Analisis de datos multivariantes
Peña - Analisis de datos multivariantesPeña - Analisis de datos multivariantes
Peña - Analisis de datos multivariantes
 
Robert Hooke
Robert Hooke Robert Hooke
Robert Hooke
 
Claudio Galeno
Claudio GalenoClaudio Galeno
Claudio Galeno
 
Robert hooke
Robert hookeRobert hooke
Robert hooke
 
Cientificos y sus aportaciones a la bilogia
Cientificos y sus aportaciones a la bilogiaCientificos y sus aportaciones a la bilogia
Cientificos y sus aportaciones a la bilogia
 

Similar to Mac/iOS Design Patterns

JAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsJAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp concepts
Rahul Malhotra
 
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design Pattern
Nishith Shukla
 
Jump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsJump Start To Ooad And Design Patterns
Jump Start To Ooad And Design Patterns
Lalit Kale
 
Dependency Inversion in large-scale TypeScript applications with InversifyJS
Dependency Inversion in large-scale TypeScript applications with InversifyJSDependency Inversion in large-scale TypeScript applications with InversifyJS
Dependency Inversion in large-scale TypeScript applications with InversifyJS
Remo Jansen
 
Design Patterns in Cocoa Touch
Design Patterns in Cocoa TouchDesign Patterns in Cocoa Touch
Design Patterns in Cocoa Touch
Eliah Nikans
 
Bartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsBartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsJason Townsend, MBA
 
Design patterns difference between interview questions
Design patterns   difference between interview questionsDesign patterns   difference between interview questions
Design patterns difference between interview questions
Umar Ali
 
Design patterns
Design patternsDesign patterns
Design patterns
Akhilesh Joshi
 
P Training Presentation
P Training PresentationP Training Presentation
P Training PresentationGaurav Tyagi
 
ActionScript Design Patterns
ActionScript Design Patterns ActionScript Design Patterns
ActionScript Design Patterns
Yoss Cohen
 
Design patterns
Design patternsDesign patterns
Design patterns
mudabbirwarsi
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
Satheesh Sukumaran
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
Satheesh Sukumaran
 
Gnizr Architecture (for developers)
Gnizr Architecture (for developers)Gnizr Architecture (for developers)
Gnizr Architecture (for developers)
hchen1
 
Design patterns
Design patternsDesign patterns
Design patterns
F(x) Data Labs Pvt Ltd
 
Design Pattern with Actionscript
Design Pattern with ActionscriptDesign Pattern with Actionscript
Design Pattern with Actionscript
Daniel Swid
 
Core Data
Core DataCore Data
Core Data
Robert Brown
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
naveen kumar
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
danhaley45372
 

Similar to Mac/iOS Design Patterns (20)

JAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp conceptsJAVA design patterns and Basic OOp concepts
JAVA design patterns and Basic OOp concepts
 
Jump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design PatternJump start to OOP, OOAD, and Design Pattern
Jump start to OOP, OOAD, and Design Pattern
 
Jump Start To Ooad And Design Patterns
Jump Start To Ooad And Design PatternsJump Start To Ooad And Design Patterns
Jump Start To Ooad And Design Patterns
 
Dependency Inversion in large-scale TypeScript applications with InversifyJS
Dependency Inversion in large-scale TypeScript applications with InversifyJSDependency Inversion in large-scale TypeScript applications with InversifyJS
Dependency Inversion in large-scale TypeScript applications with InversifyJS
 
Design Patterns in Cocoa Touch
Design Patterns in Cocoa TouchDesign Patterns in Cocoa Touch
Design Patterns in Cocoa Touch
 
Gof design patterns
Gof design patternsGof design patterns
Gof design patterns
 
Bartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsBartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design Patterns
 
Design patterns difference between interview questions
Design patterns   difference between interview questionsDesign patterns   difference between interview questions
Design patterns difference between interview questions
 
Design patterns
Design patternsDesign patterns
Design patterns
 
P Training Presentation
P Training PresentationP Training Presentation
P Training Presentation
 
ActionScript Design Patterns
ActionScript Design Patterns ActionScript Design Patterns
ActionScript Design Patterns
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Gnizr Architecture (for developers)
Gnizr Architecture (for developers)Gnizr Architecture (for developers)
Gnizr Architecture (for developers)
 
Design patterns
Design patternsDesign patterns
Design patterns
 
Design Pattern with Actionscript
Design Pattern with ActionscriptDesign Pattern with Actionscript
Design Pattern with Actionscript
 
Core Data
Core DataCore Data
Core Data
 
Gof design pattern
Gof design patternGof design pattern
Gof design pattern
 
Patterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docxPatterns (contd)Software Development ProcessDesign patte.docx
Patterns (contd)Software Development ProcessDesign patte.docx
 

More from Robert Brown

High level concurrency
High level concurrencyHigh level concurrency
High level concurrency
Robert Brown
 
Data Source Combinators
Data Source CombinatorsData Source Combinators
Data Source Combinators
Robert Brown
 
Elixir
ElixirElixir
Elixir
Robert Brown
 
Reactive Cocoa
Reactive CocoaReactive Cocoa
Reactive Cocoa
Robert Brown
 
UIKit Dynamics
UIKit DynamicsUIKit Dynamics
UIKit Dynamics
Robert Brown
 
iOS State Preservation and Restoration
iOS State Preservation and RestorationiOS State Preservation and Restoration
iOS State Preservation and Restoration
Robert Brown
 
Pragmatic blocks
Pragmatic blocksPragmatic blocks
Pragmatic blocks
Robert Brown
 
Grand Central Dispatch Design Patterns
Grand Central Dispatch Design PatternsGrand Central Dispatch Design Patterns
Grand Central Dispatch Design Patterns
Robert Brown
 
Grand Central Dispatch
Grand Central DispatchGrand Central Dispatch
Grand Central Dispatch
Robert Brown
 
Quick Look for iOS
Quick Look for iOSQuick Look for iOS
Quick Look for iOS
Robert Brown
 

More from Robert Brown (11)

High level concurrency
High level concurrencyHigh level concurrency
High level concurrency
 
Data Source Combinators
Data Source CombinatorsData Source Combinators
Data Source Combinators
 
Elixir
ElixirElixir
Elixir
 
Reactive Cocoa
Reactive CocoaReactive Cocoa
Reactive Cocoa
 
UIKit Dynamics
UIKit DynamicsUIKit Dynamics
UIKit Dynamics
 
iOS State Preservation and Restoration
iOS State Preservation and RestorationiOS State Preservation and Restoration
iOS State Preservation and Restoration
 
Anti-Patterns
Anti-PatternsAnti-Patterns
Anti-Patterns
 
Pragmatic blocks
Pragmatic blocksPragmatic blocks
Pragmatic blocks
 
Grand Central Dispatch Design Patterns
Grand Central Dispatch Design PatternsGrand Central Dispatch Design Patterns
Grand Central Dispatch Design Patterns
 
Grand Central Dispatch
Grand Central DispatchGrand Central Dispatch
Grand Central Dispatch
 
Quick Look for iOS
Quick Look for iOSQuick Look for iOS
Quick Look for iOS
 

Recently uploaded

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 

Recently uploaded (20)

Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdfFIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
FIDO Alliance Osaka Seminar: FIDO Security Aspects.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 

Mac/iOS Design Patterns

  • 2. What is a Design Pattern? After working on related problems, patterns often appear in the solutions. Formalized description of best practice.
  • 4. What is a Singleton? A singleton is an object that only has one instance for the lifetime of the application. Some things are not safe to have more than one instance running. For example, an updater. Objective-C classes are singletons by design. You can take advantage of this when creating singletons.
  • 5. Creating a Singleton https://gist.github.com/1116294
  • 6. Related Patterns Abstract Factory Plug-in Registry Notification Center
  • 8. What is a Delegate? A delegate defines the behavior of a generic class. This keeps implementation specific behavior out of the generic class. Data sources are similar to delegates, except they define content rather than behavior. UITableViews use both a delegate and a data source.
  • 9. Delegate Interaction UIApplication UIApplication Delegate
  • 10. Delegate Interaction UITableView UITableView UITableView DataSource Delegate
  • 11. Gotchas Use “assign” instead of “retain” to avoid retain cycles. When using assign, be sure to nullify the delegate reference when deallocating the object. Use “weak” instead of “assign” when using ARC.
  • 12. Related Patterns Data Source Block Delegation Callback Chain of Responsibility State Flyweight
  • 14. What is Block Delegation? Similar to a delegate object. Rather than give an object that has one or more methods defined, give a block that has the implementation of one method. Rule of thumb: If you have three or more delegate methods, use a delegate. Otherwise, use block delegation. Sometimes it’s appropriate to break this rule.
  • 15. Block Delegation Interaction Object Block 1 Block 2
  • 16. Gotchas Watch out for retain cycles, particularly with “self” __block __unsafe_unretained id selfRef = self; __block __weak id selfRef = self; Don’t forget to copy your blocks. They are created on the stack.
  • 19. What is MVC? A strict organization of classes into their different roles. Model: Any underlying data. View: The graphical presentation of the data. Controller: Coordinates the interactions between the views and model. Keeps programs modular and makes it easy to swap out views when needed.
  • 20. Model View Controller Interface View Controller Xcode Builder Model Core Data
  • 21. Gotchas Some implementations of MVC have the View and Model directly connected. This can cause infinite update cycles.
  • 24. What is the Layer Pattern? Modules of a program can be organized like a stack of layers. Strict Layering: A layer can only use the layer directly below it. Non-strict Layering: A layer can use any layer below it.
  • 25. Core Data Layers Application NSManagedObject Subclass NSManagedObject Context NSManagedObject NSPersistentStoreCoordinator NSManagedObjectModel NSPersistentStore XML SQLite Binary In Memory Custom
  • 26. Gotchas Occasionally you may find a need to call up a layer. To do this, you will need to use dependency inversion. Dependency inversion: A lower layer defines an interface to interact with other layers. This is often used with notifications. An upper layer can register itself to receive these notifications through the defined interface.
  • 28. What is a Façade? A façade is a single entry point to a complex collection of classes. Makes interaction with complex collections easier and less dependent on internal implementation. This is the basis of the layer pattern.
  • 29. External External External Object Object Object Façade Object Object Object Object Object
  • 32. What is an Observer? Sometimes you want to know when an object changes. Often used with MVC. When a model object changes, you want to update the view(s) accordingly. The observer pattern is built into every NSObject via Key-Value Observing (KVO).
  • 33. Gotchas Don’t forget to remove an object as an observer when that object is deallocated.
  • 34. Related Patterns Model View Controller Notification Center
  • 35. Proxy
  • 36. What is a Proxy? A proxy receives actions in behalf of another object. Many types of proxies: Lazy loading proxy Distributed (network) proxy (NSDistantObject) Immutable proxy NSProxy can be used to make any kind of proxy object.
  • 37. Lazy Loading Proxy Object Proxy Photo
  • 38. Distributed Proxy Remote Object Proxy Network Object
  • 39. Immutable Proxy Mutable Object Proxy Object
  • 40. Gotchas If you use NSProxy, you need to be very familiar with message forwarding.
  • 41. Want to Learn More? Design Patterns: Elements of Reusable Object- Oriented Software Every developer should own this book! Cocoa Design Patterns in the Apple Docs

Editor's Notes

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n