SlideShare una empresa de Scribd logo
1 de 41
Descargar para leer sin conexión
epic refactorings and
patterns to make
your jesse collis (@sirjec)
      code awesome
     luke cunningham (@icaruswings)
firstly, read this book!
insert a pic of us
reading our books
having a
‘lightbulb’ moment



    we did and it
    made us better
    engineers
we do agile...
write the minimum
amount of code to
implement the story
12 months later...
1 small card
But that isn’t
what this talk is
about
the problem
just too much for one
view controller
First Diagram
alright stop!
refactor time.
first problem
view controllers need
only worry about
standard UIViews and
manage the display.
coordination and
containment!
ViewCoordinator
view lifecycle
@protocol ViewCoordinator <NSObject>

- (UIView *)view;

- (void)viewWillAppear;

- (void)viewDidAppear;

- (void)viewWillDisappear;

- (void)viewDidDisappear;

- (void)viewDidUnload;

- (void)didReceiveMemoryWarning;

@end
@interface YourViewController : UIViewController {

 id<ViewCoordinator> viewCoordinator_;

}

...

@end
@implementation YourViewController

- (id)initWithNibName... {
 viewCoordinator_ = [[MyViewCoordinator alloc] init];
}

- (void)loadView {
 [super loadView];
 [self.view addSubview:[viewCoordinator_ view]];
}

- (void)viewWillAppear {
 [[viewCoordinator_ view] viewWillAppear];
}

...

@end
single responsibility

a class should only
have one reason to
change.
second problem
they’re not
simple views
ListCoordinator
basic selection
callbacks
@protocol ListCoordinator

- (void)onSelectListItem:^(id)block;

...

@end
@interface YourViewController : UIViewController {

 id<ViewCoordinator> viewCoordinator_;

 id<ViewCoordinator, ListViewCoordinator> listCoordinator_;

}

...

@end
@implementation YourViewController

- (id)initWithNibName... {
 listCoordinator_ = [[MyListCoordinator alloc] init];


 [listCoordinator_ onSelectListItem:^(id listing) {
      [self showListing:listing];
 }];
}

- (void)showListing:(Listing *)listing;{

...

}

...

@end
interface segregation
clients should not
be forced to depend
on methods they
don’t use.
QueryCoordinator
after configure/
cancel configure
callbacks
SearchBarCoord...



and so on...
now our
structure is more
like this...
Go to Xcode
under the hood
EventDispatcher
@interface MapCooordinator <ViewCoordinator, ListCoordinator>
{
    ...
}

@end
@implementation MapCoordinator

...

- (void)onSelectListItem:^(Listing *)block;
{
      [eventDispatcher_ on:@"select-listing”
        performWithObject:block];
}

- (void)mapView:(... *)mapView didSelectAnnotationView:(... *)view;
{
      Listing *listing = ... find listing ...
      [eventDispatcher_ fire:@"select-listing" withObject:listing];
}

...

@end
there are no
special cases
If you implement
patterns -
follow your patterns
Coming in iOS5
thanks,
  jesse collis (@sirjec)
  luke cunningham (@icaruswings)

Más contenido relacionado

Destacado

CATiled Layer - Melbourne Cocoheads February 2012
CATiled Layer - Melbourne Cocoheads February 2012CATiled Layer - Melbourne Cocoheads February 2012
CATiled Layer - Melbourne Cocoheads February 2012Jesse Collis
 
Terra malalta
Terra malaltaTerra malalta
Terra malaltae3005339
 
Bedre Samarbeid, Kommunikasjon og Stressmestring i en travel arbeidsdag
Bedre Samarbeid, Kommunikasjon og Stressmestring i en travel arbeidsdagBedre Samarbeid, Kommunikasjon og Stressmestring i en travel arbeidsdag
Bedre Samarbeid, Kommunikasjon og Stressmestring i en travel arbeidsdagmarga_dijkman
 
Diffusion meeting Spain
Diffusion meeting SpainDiffusion meeting Spain
Diffusion meeting Spaine3005339
 
LOGO CONTEST
LOGO CONTESTLOGO CONTEST
LOGO CONTESTe3005339
 
La Primavera
La PrimaveraLa Primavera
La Primaverae3005339
 
A Brief History of Melbourne Cocoaheads - May 2013
A Brief History of Melbourne Cocoaheads - May 2013A Brief History of Melbourne Cocoaheads - May 2013
A Brief History of Melbourne Cocoaheads - May 2013Jesse Collis
 
Integrating iAds (Melbourne Cocoaheads November 2010)
Integrating iAds (Melbourne Cocoaheads November 2010)Integrating iAds (Melbourne Cocoaheads November 2010)
Integrating iAds (Melbourne Cocoaheads November 2010)Jesse Collis
 
Writing Online News Leads
Writing Online News LeadsWriting Online News Leads
Writing Online News LeadsBill Edwards
 
Implementing CATiledLayer
Implementing CATiledLayerImplementing CATiledLayer
Implementing CATiledLayerJesse Collis
 
Xcode 4 shortcuts (Melbourne Cocoheads April 2011)
Xcode 4 shortcuts (Melbourne Cocoheads April 2011)Xcode 4 shortcuts (Melbourne Cocoheads April 2011)
Xcode 4 shortcuts (Melbourne Cocoheads April 2011)Jesse Collis
 

Destacado (13)

CATiled Layer - Melbourne Cocoheads February 2012
CATiled Layer - Melbourne Cocoheads February 2012CATiled Layer - Melbourne Cocoheads February 2012
CATiled Layer - Melbourne Cocoheads February 2012
 
Terra malalta
Terra malaltaTerra malalta
Terra malalta
 
Bedre Samarbeid, Kommunikasjon og Stressmestring i en travel arbeidsdag
Bedre Samarbeid, Kommunikasjon og Stressmestring i en travel arbeidsdagBedre Samarbeid, Kommunikasjon og Stressmestring i en travel arbeidsdag
Bedre Samarbeid, Kommunikasjon og Stressmestring i en travel arbeidsdag
 
Habitats
HabitatsHabitats
Habitats
 
Diffusion meeting Spain
Diffusion meeting SpainDiffusion meeting Spain
Diffusion meeting Spain
 
LOGO CONTEST
LOGO CONTESTLOGO CONTEST
LOGO CONTEST
 
La Primavera
La PrimaveraLa Primavera
La Primavera
 
A Brief History of Melbourne Cocoaheads - May 2013
A Brief History of Melbourne Cocoaheads - May 2013A Brief History of Melbourne Cocoaheads - May 2013
A Brief History of Melbourne Cocoaheads - May 2013
 
editorial
editorialeditorial
editorial
 
Integrating iAds (Melbourne Cocoaheads November 2010)
Integrating iAds (Melbourne Cocoaheads November 2010)Integrating iAds (Melbourne Cocoaheads November 2010)
Integrating iAds (Melbourne Cocoaheads November 2010)
 
Writing Online News Leads
Writing Online News LeadsWriting Online News Leads
Writing Online News Leads
 
Implementing CATiledLayer
Implementing CATiledLayerImplementing CATiledLayer
Implementing CATiledLayer
 
Xcode 4 shortcuts (Melbourne Cocoheads April 2011)
Xcode 4 shortcuts (Melbourne Cocoheads April 2011)Xcode 4 shortcuts (Melbourne Cocoheads April 2011)
Xcode 4 shortcuts (Melbourne Cocoheads April 2011)
 

Similar a Epic Refactorings - Melbourne Cocoaheads June 2011

React.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UIReact.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UIMarcin Grzywaczewski
 
ngSummit 2017: Angular meets Redux
ngSummit 2017: Angular meets ReduxngSummit 2017: Angular meets Redux
ngSummit 2017: Angular meets ReduxMichał Michalczuk
 
Welcome to React & Flux !
Welcome to React & Flux !Welcome to React & Flux !
Welcome to React & Flux !Ritesh Kumar
 
All the reasons for choosing react js that you didn't know about - Avi Marcus...
All the reasons for choosing react js that you didn't know about - Avi Marcus...All the reasons for choosing react js that you didn't know about - Avi Marcus...
All the reasons for choosing react js that you didn't know about - Avi Marcus...Codemotion Tel Aviv
 
Why you should consider a microframework for your next web project
Why you should consider a microframework for your next web projectWhy you should consider a microframework for your next web project
Why you should consider a microframework for your next web projectJoaquín Muñoz M.
 
Design Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-BinderDesign Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-BinderSimon Massey
 
Bringing Swift into your Objective-C Projects
Bringing Swift into your Objective-C ProjectsBringing Swift into your Objective-C Projects
Bringing Swift into your Objective-C ProjectsRené Cacheaux
 
Reusing your frontend JS on the server with V8/Rhino
Reusing your frontend JS on the server with V8/RhinoReusing your frontend JS on the server with V8/Rhino
Reusing your frontend JS on the server with V8/RhinoKenneth Kalmer
 
Gitter marionette deck
Gitter marionette deckGitter marionette deck
Gitter marionette deckMike Bartlett
 
Android howto hellowidget
Android howto hellowidgetAndroid howto hellowidget
Android howto hellowidgetHiron Das
 
iOS UIStoryboard presentation
iOS UIStoryboard presentationiOS UIStoryboard presentation
iOS UIStoryboard presentationGerald Kim
 
jquery summit presentation for large scale javascript applications
jquery summit  presentation for large scale javascript applicationsjquery summit  presentation for large scale javascript applications
jquery summit presentation for large scale javascript applicationsDivyanshGupta922023
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsclimboid
 
CQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureCQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureThomas Jaskula
 

Similar a Epic Refactorings - Melbourne Cocoaheads June 2011 (20)

React.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UIReact.js - and how it changed our thinking about UI
React.js - and how it changed our thinking about UI
 
ngSummit 2017: Angular meets Redux
ngSummit 2017: Angular meets ReduxngSummit 2017: Angular meets Redux
ngSummit 2017: Angular meets Redux
 
Welcome to React & Flux !
Welcome to React & Flux !Welcome to React & Flux !
Welcome to React & Flux !
 
All the reasons for choosing react js that you didn't know about - Avi Marcus...
All the reasons for choosing react js that you didn't know about - Avi Marcus...All the reasons for choosing react js that you didn't know about - Avi Marcus...
All the reasons for choosing react js that you didn't know about - Avi Marcus...
 
IOS Storyboards
IOS StoryboardsIOS Storyboards
IOS Storyboards
 
Intro to AngularJs
Intro to AngularJsIntro to AngularJs
Intro to AngularJs
 
Why you should consider a microframework for your next web project
Why you should consider a microframework for your next web projectWhy you should consider a microframework for your next web project
Why you should consider a microframework for your next web project
 
Design Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-BinderDesign Patterns in ZK: Java MVVM as Model-View-Binder
Design Patterns in ZK: Java MVVM as Model-View-Binder
 
Bringing Swift into your Objective-C Projects
Bringing Swift into your Objective-C ProjectsBringing Swift into your Objective-C Projects
Bringing Swift into your Objective-C Projects
 
Reusing your frontend JS on the server with V8/Rhino
Reusing your frontend JS on the server with V8/RhinoReusing your frontend JS on the server with V8/Rhino
Reusing your frontend JS on the server with V8/Rhino
 
Gitter marionette deck
Gitter marionette deckGitter marionette deck
Gitter marionette deck
 
iOS storyboard
iOS storyboardiOS storyboard
iOS storyboard
 
React js
React jsReact js
React js
 
Android how to hellowidget
Android how to hellowidgetAndroid how to hellowidget
Android how to hellowidget
 
Android howto hellowidget
Android howto hellowidgetAndroid howto hellowidget
Android howto hellowidget
 
iOS UIStoryboard presentation
iOS UIStoryboard presentationiOS UIStoryboard presentation
iOS UIStoryboard presentation
 
jquery summit presentation for large scale javascript applications
jquery summit  presentation for large scale javascript applicationsjquery summit  presentation for large scale javascript applications
jquery summit presentation for large scale javascript applications
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
Yeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web appsYeoman AngularJS and D3 - A solid stack for web apps
Yeoman AngularJS and D3 - A solid stack for web apps
 
CQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architectureCQRS recipes or how to cook your architecture
CQRS recipes or how to cook your architecture
 

Último

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 

Epic Refactorings - Melbourne Cocoaheads June 2011