SlideShare a Scribd company logo
1 of 44
Download to read offline
A Pinch of Indirection
And don’t cut yourself chopping onions…
... practical tips for using component architecture(s).
Sean	Upton
University	of	Utah	Department	of	Pediatrics	/	UPIQ.org
#ploneconf2016	|	@sdupton
Photo	credit:	https://www.flickr.com/photos/ampersandyslexia (CC:by-sa)
Hello Boston!
This talk is about (pick one):
(a) Plone
(b) Food
(c) Components
(d) APIs
(e) Some, none, or all of the above.
#ploneconf2016	|	@sdupton
All uncredited photos in this slide deck:
© 2013-2016 Sean Upton, free for your re-use via CC-by-3.0
The topic…
• Let’s talk about components
• Idioms and helpful ideas
• Cooking analogies
• Round and round we go: how many #ploneconf ZCA
talks have there been over the years? Why this, why
now?
• I have opinions.
– There might even be JavaScript involved.
– Run while you still can!
#ploneconf2016	|	@sdupton
Photo	credit:	https://en.wikipedia.org/wiki/Penrose_stairs
This Old Hat
The	old	hat	surely	beats… …the	new	hat?
#ploneconf2016	|	@sdupton
Photo	credit:	©	HBO	(used	here	under	fair	use)
Photo	credit:	Gary	Steward	(CC-by-3.0)
https://commons.wikimedia.org/wiki/File:Bullwhip_and_IJ_hat.jpg
Components are our craft!
• Our “old hat” dates 1.5 decades. It is
weathered, sturdy -- not rotting in the fridge.
• Anyway, we are in Boston, home to public
television show “This Old House”…
– And some of the best American food media have
roots here too.
– Plan for kitchen metaphors "peppered" throughout
the discussion...
• Components are relevant part of our craft.
#ploneconf2016	|	@sdupton
Goals
• Talk about components;
– ...in the kitchen of Python;
– ...in the fine dining experience of Plone;
– ...in "foreign cuisine" (e.g. JavaScript).
• Explore idioms and ideas
• Motives: why does this approach matter?
• Hacks, workarounds, surviving a bit of
pdb.set_trace()
#ploneconf2016	|	@sdupton
No fear!
• Complexity is okay, if essential.
• Components solve problems.
• I am probably more contrarian than necessary about
simplified "public" APIs (though I use them).
#ploneconf2016	|	@sdupton
"If you're convinced that
cooking is drudgery, you're
never going to be good at it,
and you might as well warm
up something frozen."
-- James Beard
Photo:	James	Beard	Foundation (used	here	under	fair	use)
Disclaimers
• I am not sure if this talk is about software
architecture, development practice, or
cooking.
• All truths are contingent on your own practical
realities.
• I hope to impart three things:
– Why and how I think ZCA matters to all kinds of
developers on this platform.
– A few scattered ideas on making use easier.
– Applications outside the box (e.g. JavaScript).
#ploneconf2016	|	@sdupton
A brief history…
• "Zope 3"
– Motivations spurred from
anxiety over mixin mazes
• Trying to solve the Z-shaped
learning curve?
• We still have these mazes today
(e.g. read Zope 2 OFS.* source).
– Community absorbed the complexity
that works, ignored what didn’t?
#ploneconf2016	|	@sdupton
• IIRC, my earliest recollection is 2002 BOF at
OSCON with Jim Fulton
Photo	credit:	https://commons.wikimedia.org/wiki/File:Inside_a_corn_maze_near_Christchurch,_New_Zealand.JPG
(public	domain)
Now ZCA + ZTK
• From	bigger	stack	to	
smaller	parts	
– Mirepoix,	not	the	
whole	soup	pot.	
– Buffet,	not	table	
d'hôte	/	prix	fixe	
– Eat	what	you	want.	
• e.g.	Twisted	uses	only	
zope.interface
#ploneconf2016	|	@sdupton
Photo credits: via WikiMedia Commons
https://commons.wikimedia.org/wiki/File:Onion_on_White.JPG (CC-by-sa)
https://commons.wikimedia.org/wiki/File:C%C3%A9leri.jpg (CC-by-sa)
https://commons.wikimedia.org/wiki/File:Baby_Carrots_2.jpg (CC-by-2.0)
https://upload.wikimedia.org/wikipedia/commons/4/44/Mirepoix_on_cutting_board.jpg
(CC:by-sa)
The “holy trinity” of components
Adapters
ü Single context
ü Views and multiple context
ü Subscribers (event notification)
Resources
ü Content
ü Utilities
ü Request/response
Schema
…because resources are nouns, why think in verbs?
#ploneconf2016	|	@sdupton
🌶
Categorizing objects
• There are two broad categories of objects
– Those you look up
• By path (content traversal)
• By component registry
• By both (views)
– Those you don't
• But many of these are in the service of some kind of lookup:
– Request objects (object publishing)
• Site-global state
– But plone.app.registry makes even this less likely.
• We have indirection everywhere; that’s okay.
#ploneconf2016	|	@sdupton
Indirection
• Scary departure from imperative
programming?
• You still will eventually end up in the debugger.
• We get a lot of flexibility, and very consistent
idioms doing this.
• Components are the mirepoix of good
software, registries are our larder.
• Using adapters does not require a registry, but
it does help keep the kitchen tidy.
#ploneconf2016	|	@sdupton
Principles and patterns
#ploneconf2016	|	@sdupton
Recipe-driven development
1. Write interfaces first;
2. then tests, often doctests;
3. write your implementation(s);
4. refine and adjust.
5. Break the build (hey, it happens sometimes!)
#ploneconf2016	|	@sdupton
“Design by contract”
• Who on Earth thinks this is a trademark-
worthy phrase?
• Interfaces are contracts.
• We can use multiple implementations to fulfill
contracts.
• This is a good thing
– Form widgets
– Separation of concerns
– Test to the interface, not to the implementation.
#ploneconf2016	|	@sdupton
Component Corollary #1: Language Idioms
• Make components that look like native Python
data structures!
– Mappings
– Sequences
– Sets
• If you do this, chances are you will represent
things as nouns, not verbs.
• Resource-centric development
#ploneconf2016	|	@sdupton
Resource-centric Development
• Driven by state, not by action
• Placeful, often.
• M in MVC matters more than V, C.
• Our community and our platform has unique
talents:
– Traversal, Traversal, Traversal!
– Persistent objects: objects are first class, they are the
things we want, not mere proxies.
• Components should be more noun than verb,
suiting both platform and language idioms.
#ploneconf2016	|	@sdupton
Now, I’m just being contrary…
#ploneconf2016	|	@sdupton
Simplified API Love/hate
THIS: NOT	THIS:
#ploneconf2016	|	@sdupton
APIs
Procedural
• Benefit:	simplify	to	single	
resource:	the	site.
– But	now,	the	site	is	mega-
controller.
• Costs:	
– Does	not	always	represent	what	
we	are	working	with.
– Leaky	abstractions	(e.g.	
IPropertiedUser).
– Lost	opportunity	at	simplified	
resource/noun/state	idioms.
State-driven
• Benefits:
– Components	obey	idioms
– Components	look	like	state	they	
directly	represent.
• Cost:	you	must	traverse	to	the	
resource	you	want	to	work	with.
– Is	that	such	a	bad	thing?
– Sometimes	this	is	traversal	to	a	
folder,	instead	of	using	the	site	as	
a	controller.		More	OO.
– Sometimes	component	lookup.
#ploneconf2016	|	@sdupton
…at it’s most hyperbolic:
• Are procedural APIs the "frozen microwave
meal" of software design?
– They have utility;
– Some can be quite good;
– Not always as satisfying or complete as the heart
of component-driven software.
• Placeful interfaces (e.g. traversal) made clean
URLs before the cool kids in the other
frameworks thought about routes, mappings,
and slugs.
#ploneconf2016	|	@sdupton
These approaches are not mutually exclusive.
• I can and do use parts of plone.api I like or
that save me time.
• I can use components that have state, place --
and don’t act procedurally.
• I can mix these.
• I’m okay with that.
• Use procedural APIs when they save time or
help learning curve – however, imperative,
action-driven code is not always appropriate.
#ploneconf2016	|	@sdupton
My point
• Components, ZCA are not just for ninjas.
• Keep your kitchen appliances, but know how to
handle a knife without cutting yourself!
• You should not be afraid to get a knick or two. Even
pro chefs have scars. Scars teach.
• Sometimes it’s okay to buy pre-cut Mirepoix from
Whole Foods. I won’t tell, or judge.
• I even bought a frozen Chicken Tikka meal from Trader
Joes last week.
• I do make my own stock, but don’t grind my own
sausage. Make choices you are comfortable with.
#ploneconf2016	|	@sdupton
“Just enough”
Zope Component Architecture
…and	what	to	do	when	it	won’t	
cooperate.
#ploneconf2016	|	@sdupton
zope.interface
Components are “objects connected by interfaces”
• Fundamental to all of this.
• Should infuse how you think and write code.
• Interface is a contract for behavior and state.
#ploneconf2016	|	@sdupton
“What's important about components is that
you can put them together. Interfaces are the
mechanism for connecting things. “
-- Jim Fulton in 2004 [1]
[1]:http://ftp.ntua.gr/mirror/python/pycon/dc2004/papers/3/PyCon2004ZopeRoadmap.pdf
Separation of concerns
• Content type implementations should not do
much. Separate concerns, and…
• ...write adapters that do heavy lifting (actions)
and transformation.
• Resources work much better with pluggable
components, whether widgets, behaviors, etc.
• Make global functionality site-independent.
• OO by composition, not inheritance.
#ploneconf2016	|	@sdupton
Schema
• Let’s suppose we have
a recipe system.
• Where each ingredient
is stored with
structured data, in a
grid.
• The recipe is just
about state, as is its
ingredients.
– Describe state (schema)
– Store state (content)
#ploneconf2016	|	@sdupton
Methods in interfaces
#ploneconf2016	|	@sdupton
Debatable merit?
Adapters
• Fetch density (utility, or adapter of site)
• Give me metric
• Give me fractions! Or decimals!
• Give me volume to weight! Or vice-versa.
• Each with specific concern, purposeful, pluggable.
#ploneconf2016	|	@sdupton
Adapters usually registered
• Adapter declares it implements an interface.
• Python or ZCML declares what adapter
adapts.
• ZCML registers adapter in (usually global)
component registry.
• Lookup is by calling interface:
adapter = IIngredientFormatter(my_ingredient)
title = adapter()
#ploneconf2016	|	@sdupton
When registrations attack
• Pdb needs a bit of help from you before you dive into
debugging adapter, widget, and event subscriber
registration problems.
– Move _zope_interface_coptimizations.so out of your
zope.interface distribution;
– Restart, coffee, debug;
– Fix it, coffee, really fix it;
– Move the optimizations back into place.
• Specificity helps, sometimes you need to resort to
interface subclassing to make your registrations more
specific.
#ploneconf2016	|	@sdupton
Browser Views
• Other frameworks see views as endpoints to
URLs.
• We see views as all about context.
• Multi-adapter: a view is a component that
takes a resource (e.g. content) and a request,
and makes a response.
– Placeful
– Graceful
– All about the content!
#ploneconf2016	|	@sdupton
Global utilities
• Useful for site-agnostic things like:
– Vocabulary lookups
– Integration with other services (e.g. message or job
queues)
– Quick static transformation of content that needs no
configuration.
– Object serialization or cryptographic signing
– Custom field types for plone.schemaeditor
#ploneconf2016	|	@sdupton
Vocabularies
• When we write schema for ”Choice” type
fields, we need choices.
• Sometimes this is static (in your Python or
your supermodel XML for a TTW type).
• Sometimes, you want a dynamic source.
– Stock global: e.g. timezone
– Site or context-local: e.g. show only items in navroot.
• Used for enumeration and/or validation.
– Sometimes, just one or the other.
#ploneconf2016	|	@sdupton
Site-global functionality
• Four approaches
– Persistent component (utility)
– Adapter-of-site
– plone.api functions, where applicable.
– CMF tools (deprecated)
• If you need to store state in the site, you likely
need to choose between the first two.
#ploneconf2016	|	@sdupton
Persistent utilities
• Can store state in ZODB: good.
• Uninstalling can be a hard problem: bad.
• Cache data in _v_ attrs across requests: good.
• No need for proxies – data, methods in one
place: good.
• Requires use of
zope.component.hooks.setSite.
• Might be responsible for the 2008 global
recession? ;-)
#ploneconf2016	|	@sdupton
Adapter of site
• Needs to be cheap to construct, because you
will do this more than once, though you can
avoid doing more than once per request if
clever.
• No need for setSite() in scripts.
• No uninstallation nightmares.
• Forces you to think about how to use OOTB
data structures in Annotations: good or bad,
depending on need.
#ploneconf2016	|	@sdupton
Related technologies
#ploneconf2016	|	@sdupton
Related, worth mention
• Martijn Faassen’s Reg (and Morepath)
• Python ABCs
– Pauper’s interface
– IMHO, problem:
• “Is a” is possible relationship
• “As a” is not
• No per-instance markers, no per-instance behavior based on
such.
– E.g. https://github.com/seanupton/experimental.flavors
» Disclaimer: may suffer some bit rot.
– Better critique:
• https://glyph.twistedmatrix.com/2009/02/explaining-why-interfaces-are-great.html
#ploneconf2016	|	@sdupton
Outside the (server) box
Transplanting	component	ideology	
into	a	JavaScript	environment.
#ploneconf2016	|	@sdupton
Some examples
• For UPIQ, I recently wrote:
– A mockup widget that extends PickADate, using an
adapter pattern (but not any kind of component
presumptions otherwise).
– Several incarnations of JavaScript zope.schema
look-alikes. I will briefly show you what one of these
looks like; I see much promise in the idea.
– https://github.com/upiq/plotqi/blob/master/spec/modelref/dataviz.js#L357
• We plan to write a 100% JavaScript forms
library based on client-side schema, that
groks plone.supermodel XML.
#ploneconf2016	|	@sdupton
“Components” vs “Web Components”
• My use of “component architecture” in
JavaScript is distinct from “web components”:
– We can have schema in JavaScript.
• And resource-centric development, validation, etc.
• And design by contract for applications where JSON is an
interchange format. JSON Schema is very limited.
– We could have component registries in JavaScript, if
we wanted.
– We can use adapters, we could try using
synchronous event notification as adjunct to
asynchronous callback ideology.
– Form applications are an opportunity.
#ploneconf2016	|	@sdupton
#ploneconf2016	|	@sdupton
In food and in software, there is always room for
good cooking.

More Related Content

What's hot

Principles, Backbone and Bottlenose
Principles, Backbone and BottlenosePrinciples, Backbone and Bottlenose
Principles, Backbone and BottlenoseJustin Halsall
 
Engineers need to learn UXR
Engineers need to learn UXREngineers need to learn UXR
Engineers need to learn UXRNeha Batra
 
Making Software Management tools work for you - 2011 PHPBenelux Conference
Making Software Management tools work for you - 2011 PHPBenelux ConferenceMaking Software Management tools work for you - 2011 PHPBenelux Conference
Making Software Management tools work for you - 2011 PHPBenelux ConferenceJohn Mertic
 
PhoneGap at JSConf
PhoneGap at JSConfPhoneGap at JSConf
PhoneGap at JSConfBrian LeRoux
 
STAQ Development Manual (Redacted)
STAQ Development Manual (Redacted)STAQ Development Manual (Redacted)
STAQ Development Manual (Redacted)Mike Subelsky
 
Full stack-web-design
Full stack-web-designFull stack-web-design
Full stack-web-designKevin Conboy
 
More Productivitiy with Spring Roo
More Productivitiy with Spring RooMore Productivitiy with Spring Roo
More Productivitiy with Spring RooEberhard Wolff
 
Continuous Deployment at Etsy: A Tale of Two Approaches
Continuous Deployment at Etsy: A Tale of Two ApproachesContinuous Deployment at Etsy: A Tale of Two Approaches
Continuous Deployment at Etsy: A Tale of Two ApproachesRoss Snyder
 

What's hot (9)

Principles, Backbone and Bottlenose
Principles, Backbone and BottlenosePrinciples, Backbone and Bottlenose
Principles, Backbone and Bottlenose
 
Deployments in one click!
Deployments in one click!Deployments in one click!
Deployments in one click!
 
Engineers need to learn UXR
Engineers need to learn UXREngineers need to learn UXR
Engineers need to learn UXR
 
Making Software Management tools work for you - 2011 PHPBenelux Conference
Making Software Management tools work for you - 2011 PHPBenelux ConferenceMaking Software Management tools work for you - 2011 PHPBenelux Conference
Making Software Management tools work for you - 2011 PHPBenelux Conference
 
PhoneGap at JSConf
PhoneGap at JSConfPhoneGap at JSConf
PhoneGap at JSConf
 
STAQ Development Manual (Redacted)
STAQ Development Manual (Redacted)STAQ Development Manual (Redacted)
STAQ Development Manual (Redacted)
 
Full stack-web-design
Full stack-web-designFull stack-web-design
Full stack-web-design
 
More Productivitiy with Spring Roo
More Productivitiy with Spring RooMore Productivitiy with Spring Roo
More Productivitiy with Spring Roo
 
Continuous Deployment at Etsy: A Tale of Two Approaches
Continuous Deployment at Etsy: A Tale of Two ApproachesContinuous Deployment at Etsy: A Tale of Two Approaches
Continuous Deployment at Etsy: A Tale of Two Approaches
 

Viewers also liked

éTica y estética en la interacción en red
éTica y estética en la interacción en redéTica y estética en la interacción en red
éTica y estética en la interacción en redCristian Suárez Siles
 
Astronomy & science questions dlideshow
Astronomy & science questions dlideshowAstronomy & science questions dlideshow
Astronomy & science questions dlideshowTony Jackson
 
Green business group
Green business groupGreen business group
Green business groupputlocker66
 
Abengoa Biomasa
Abengoa BiomasaAbengoa Biomasa
Abengoa BiomasaAbengoa
 
Buscar un rpm_instalado
Buscar un rpm_instaladoBuscar un rpm_instalado
Buscar un rpm_instaladoJames Jara
 
Keynote at the AACCI meeting 2016
Keynote at the AACCI meeting 2016Keynote at the AACCI meeting 2016
Keynote at the AACCI meeting 2016Johannes Keizer
 
Curso de informática basica apresentação 3
Curso de informática basica  apresentação 3Curso de informática basica  apresentação 3
Curso de informática basica apresentação 3Luiz Pereira de Souza
 
Jakie warunki musi spełniać nowoczesna strona internetowa?
Jakie warunki musi spełniać nowoczesna strona internetowa?Jakie warunki musi spełniać nowoczesna strona internetowa?
Jakie warunki musi spełniać nowoczesna strona internetowa?eTechnologie sp. z o.o.
 
عرض تقديمي1
عرض تقديمي1عرض تقديمي1
عرض تقديمي1NHJ251
 
VueJS - Uma alternativa elegante
VueJS - Uma alternativa eleganteVueJS - Uma alternativa elegante
VueJS - Uma alternativa eleganteJonathan Bijos
 
2016 RAPS Convergence - Ruthsatz 1609012
2016 RAPS Convergence - Ruthsatz 16090122016 RAPS Convergence - Ruthsatz 1609012
2016 RAPS Convergence - Ruthsatz 1609012Manfred Ruthsatz
 

Viewers also liked (18)

éTica y estética en la interacción en red
éTica y estética en la interacción en redéTica y estética en la interacción en red
éTica y estética en la interacción en red
 
Astronomy & science questions dlideshow
Astronomy & science questions dlideshowAstronomy & science questions dlideshow
Astronomy & science questions dlideshow
 
Tutoría y moderación de grupos en entornos virtuales
Tutoría y moderación de grupos en entornos virtualesTutoría y moderación de grupos en entornos virtuales
Tutoría y moderación de grupos en entornos virtuales
 
Proyecto
ProyectoProyecto
Proyecto
 
SERIAL DE PC 7
SERIAL DE PC 7SERIAL DE PC 7
SERIAL DE PC 7
 
vwvsrf
vwvsrfvwvsrf
vwvsrf
 
Green business group
Green business groupGreen business group
Green business group
 
Abengoa Biomasa
Abengoa BiomasaAbengoa Biomasa
Abengoa Biomasa
 
Buscar un rpm_instalado
Buscar un rpm_instaladoBuscar un rpm_instalado
Buscar un rpm_instalado
 
Keynote at the AACCI meeting 2016
Keynote at the AACCI meeting 2016Keynote at the AACCI meeting 2016
Keynote at the AACCI meeting 2016
 
Curso de informática basica apresentação 3
Curso de informática basica  apresentação 3Curso de informática basica  apresentação 3
Curso de informática basica apresentação 3
 
asdygh ff sm may'12
asdygh ff sm may'12asdygh ff sm may'12
asdygh ff sm may'12
 
Jakie warunki musi spełniać nowoczesna strona internetowa?
Jakie warunki musi spełniać nowoczesna strona internetowa?Jakie warunki musi spełniać nowoczesna strona internetowa?
Jakie warunki musi spełniać nowoczesna strona internetowa?
 
عرض تقديمي1
عرض تقديمي1عرض تقديمي1
عرض تقديمي1
 
VueJS - Uma alternativa elegante
VueJS - Uma alternativa eleganteVueJS - Uma alternativa elegante
VueJS - Uma alternativa elegante
 
Unidad ii iot 2015
Unidad  ii   iot 2015Unidad  ii   iot 2015
Unidad ii iot 2015
 
Tecnicas de tiro
Tecnicas de tiroTecnicas de tiro
Tecnicas de tiro
 
2016 RAPS Convergence - Ruthsatz 1609012
2016 RAPS Convergence - Ruthsatz 16090122016 RAPS Convergence - Ruthsatz 1609012
2016 RAPS Convergence - Ruthsatz 1609012
 

Similar to A pinch of indirection, and don't cut yourself chopping onions...

Using React for the Mobile Web
Using React for the Mobile WebUsing React for the Mobile Web
Using React for the Mobile WebC4Media
 
Introducing Pair Programming
Introducing Pair ProgrammingIntroducing Pair Programming
Introducing Pair ProgrammingSteven Smith
 
Free iOS apps for education
Free iOS apps for educationFree iOS apps for education
Free iOS apps for educationAmy Terrell
 
Everyone wants (someone else) to do it: writing documentation for open source...
Everyone wants (someone else) to do it: writing documentation for open source...Everyone wants (someone else) to do it: writing documentation for open source...
Everyone wants (someone else) to do it: writing documentation for open source...Jody Garnett
 
Case study for agile software development:
Case study for agile software development: Case study for agile software development:
Case study for agile software development: Joe Crespo
 
רועי פלד
רועי פלדרועי פלד
רועי פלדNetcraft
 
'10 Great but now Overlooked Tools' by Graham Thomas
'10 Great but now Overlooked Tools' by Graham Thomas'10 Great but now Overlooked Tools' by Graham Thomas
'10 Great but now Overlooked Tools' by Graham ThomasTEST Huddle
 
Course Tech 2013, Gina M. Bowers-Miller, Using Mobile Technology in the Class...
Course Tech 2013, Gina M. Bowers-Miller, Using Mobile Technology in the Class...Course Tech 2013, Gina M. Bowers-Miller, Using Mobile Technology in the Class...
Course Tech 2013, Gina M. Bowers-Miller, Using Mobile Technology in the Class...Cengage Learning
 
Surviving a Hackathon and Beyond
Surviving a Hackathon and BeyondSurviving a Hackathon and Beyond
Surviving a Hackathon and Beyondimoneytech
 
Why do mobile projects (still) fail - September 2014 edition
Why do mobile projects (still) fail - September 2014 editionWhy do mobile projects (still) fail - September 2014 edition
Why do mobile projects (still) fail - September 2014 editionIndiginox
 
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom GambleDev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom GambleThomas Gamble
 
Course tech conf_2013_ppt_mobile_technology_bowers-miller
Course tech conf_2013_ppt_mobile_technology_bowers-millerCourse tech conf_2013_ppt_mobile_technology_bowers-miller
Course tech conf_2013_ppt_mobile_technology_bowers-millerGina Bowers-Miller
 
Informal talk at pict
Informal talk at pictInformal talk at pict
Informal talk at pictMayank Jain
 
State of the inline debate
State of the inline debateState of the inline debate
State of the inline debateRasmus Skjoldan
 
Building a wow product by @RuthlessUx
Building a wow product by @RuthlessUxBuilding a wow product by @RuthlessUx
Building a wow product by @RuthlessUxSHAHEENA ATTARWALA
 
Agile Prototyping Best Practices
Agile Prototyping Best PracticesAgile Prototyping Best Practices
Agile Prototyping Best Practicesuxpin
 
Kill Your Darlings: Solving Design by Throwing Away Your Prototypes
Kill Your Darlings: Solving Design by Throwing Away Your PrototypesKill Your Darlings: Solving Design by Throwing Away Your Prototypes
Kill Your Darlings: Solving Design by Throwing Away Your Prototypesjsokohl
 
Making Effective Prototypes
Making Effective PrototypesMaking Effective Prototypes
Making Effective PrototypesMatthew Ho
 
By the power of Plone - Case Carousel at University of Jyväskylä
By the power of Plone - Case Carousel at University of JyväskyläBy the power of Plone - Case Carousel at University of Jyväskylä
By the power of Plone - Case Carousel at University of JyväskyläRikupekka Oksanen
 
Multi-Device Prototypes
Multi-Device PrototypesMulti-Device Prototypes
Multi-Device PrototypesDoug Gapinski
 

Similar to A pinch of indirection, and don't cut yourself chopping onions... (20)

Using React for the Mobile Web
Using React for the Mobile WebUsing React for the Mobile Web
Using React for the Mobile Web
 
Introducing Pair Programming
Introducing Pair ProgrammingIntroducing Pair Programming
Introducing Pair Programming
 
Free iOS apps for education
Free iOS apps for educationFree iOS apps for education
Free iOS apps for education
 
Everyone wants (someone else) to do it: writing documentation for open source...
Everyone wants (someone else) to do it: writing documentation for open source...Everyone wants (someone else) to do it: writing documentation for open source...
Everyone wants (someone else) to do it: writing documentation for open source...
 
Case study for agile software development:
Case study for agile software development: Case study for agile software development:
Case study for agile software development:
 
רועי פלד
רועי פלדרועי פלד
רועי פלד
 
'10 Great but now Overlooked Tools' by Graham Thomas
'10 Great but now Overlooked Tools' by Graham Thomas'10 Great but now Overlooked Tools' by Graham Thomas
'10 Great but now Overlooked Tools' by Graham Thomas
 
Course Tech 2013, Gina M. Bowers-Miller, Using Mobile Technology in the Class...
Course Tech 2013, Gina M. Bowers-Miller, Using Mobile Technology in the Class...Course Tech 2013, Gina M. Bowers-Miller, Using Mobile Technology in the Class...
Course Tech 2013, Gina M. Bowers-Miller, Using Mobile Technology in the Class...
 
Surviving a Hackathon and Beyond
Surviving a Hackathon and BeyondSurviving a Hackathon and Beyond
Surviving a Hackathon and Beyond
 
Why do mobile projects (still) fail - September 2014 edition
Why do mobile projects (still) fail - September 2014 editionWhy do mobile projects (still) fail - September 2014 edition
Why do mobile projects (still) fail - September 2014 edition
 
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom GambleDev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
Dev Nexus 2017 - TDD with React - Josh Quintana & Tom Gamble
 
Course tech conf_2013_ppt_mobile_technology_bowers-miller
Course tech conf_2013_ppt_mobile_technology_bowers-millerCourse tech conf_2013_ppt_mobile_technology_bowers-miller
Course tech conf_2013_ppt_mobile_technology_bowers-miller
 
Informal talk at pict
Informal talk at pictInformal talk at pict
Informal talk at pict
 
State of the inline debate
State of the inline debateState of the inline debate
State of the inline debate
 
Building a wow product by @RuthlessUx
Building a wow product by @RuthlessUxBuilding a wow product by @RuthlessUx
Building a wow product by @RuthlessUx
 
Agile Prototyping Best Practices
Agile Prototyping Best PracticesAgile Prototyping Best Practices
Agile Prototyping Best Practices
 
Kill Your Darlings: Solving Design by Throwing Away Your Prototypes
Kill Your Darlings: Solving Design by Throwing Away Your PrototypesKill Your Darlings: Solving Design by Throwing Away Your Prototypes
Kill Your Darlings: Solving Design by Throwing Away Your Prototypes
 
Making Effective Prototypes
Making Effective PrototypesMaking Effective Prototypes
Making Effective Prototypes
 
By the power of Plone - Case Carousel at University of Jyväskylä
By the power of Plone - Case Carousel at University of JyväskyläBy the power of Plone - Case Carousel at University of Jyväskylä
By the power of Plone - Case Carousel at University of Jyväskylä
 
Multi-Device Prototypes
Multi-Device PrototypesMulti-Device Prototypes
Multi-Device Prototypes
 

Recently uploaded

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作qr0udbr0
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfLivetecs LLC
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....kzayra69
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationBradBedford3
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commercemanigoyal112
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Natan Silnitsky
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noidabntitsolutionsrishis
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 

Recently uploaded (20)

英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作英国UN学位证,北安普顿大学毕业证书1:1制作
英国UN学位证,北安普顿大学毕业证书1:1制作
 
How to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdfHow to Track Employee Performance A Comprehensive Guide.pdf
How to Track Employee Performance A Comprehensive Guide.pdf
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....What are the key points to focus on before starting to learn ETL Development....
What are the key points to focus on before starting to learn ETL Development....
 
Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
How to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion ApplicationHow to submit a standout Adobe Champion Application
How to submit a standout Adobe Champion Application
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Cyber security and its impact on E commerce
Cyber security and its impact on E commerceCyber security and its impact on E commerce
Cyber security and its impact on E commerce
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
Taming Distributed Systems: Key Insights from Wix's Large-Scale Experience - ...
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in NoidaBuds n Tech IT Solutions: Top-Notch Web Services in Noida
Buds n Tech IT Solutions: Top-Notch Web Services in Noida
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 

A pinch of indirection, and don't cut yourself chopping onions...

  • 1. A Pinch of Indirection And don’t cut yourself chopping onions… ... practical tips for using component architecture(s). Sean Upton University of Utah Department of Pediatrics / UPIQ.org #ploneconf2016 | @sdupton Photo credit: https://www.flickr.com/photos/ampersandyslexia (CC:by-sa)
  • 2. Hello Boston! This talk is about (pick one): (a) Plone (b) Food (c) Components (d) APIs (e) Some, none, or all of the above. #ploneconf2016 | @sdupton All uncredited photos in this slide deck: © 2013-2016 Sean Upton, free for your re-use via CC-by-3.0
  • 3. The topic… • Let’s talk about components • Idioms and helpful ideas • Cooking analogies • Round and round we go: how many #ploneconf ZCA talks have there been over the years? Why this, why now? • I have opinions. – There might even be JavaScript involved. – Run while you still can! #ploneconf2016 | @sdupton Photo credit: https://en.wikipedia.org/wiki/Penrose_stairs
  • 4. This Old Hat The old hat surely beats… …the new hat? #ploneconf2016 | @sdupton Photo credit: © HBO (used here under fair use) Photo credit: Gary Steward (CC-by-3.0) https://commons.wikimedia.org/wiki/File:Bullwhip_and_IJ_hat.jpg
  • 5. Components are our craft! • Our “old hat” dates 1.5 decades. It is weathered, sturdy -- not rotting in the fridge. • Anyway, we are in Boston, home to public television show “This Old House”… – And some of the best American food media have roots here too. – Plan for kitchen metaphors "peppered" throughout the discussion... • Components are relevant part of our craft. #ploneconf2016 | @sdupton
  • 6. Goals • Talk about components; – ...in the kitchen of Python; – ...in the fine dining experience of Plone; – ...in "foreign cuisine" (e.g. JavaScript). • Explore idioms and ideas • Motives: why does this approach matter? • Hacks, workarounds, surviving a bit of pdb.set_trace() #ploneconf2016 | @sdupton
  • 7. No fear! • Complexity is okay, if essential. • Components solve problems. • I am probably more contrarian than necessary about simplified "public" APIs (though I use them). #ploneconf2016 | @sdupton "If you're convinced that cooking is drudgery, you're never going to be good at it, and you might as well warm up something frozen." -- James Beard Photo: James Beard Foundation (used here under fair use)
  • 8. Disclaimers • I am not sure if this talk is about software architecture, development practice, or cooking. • All truths are contingent on your own practical realities. • I hope to impart three things: – Why and how I think ZCA matters to all kinds of developers on this platform. – A few scattered ideas on making use easier. – Applications outside the box (e.g. JavaScript). #ploneconf2016 | @sdupton
  • 9. A brief history… • "Zope 3" – Motivations spurred from anxiety over mixin mazes • Trying to solve the Z-shaped learning curve? • We still have these mazes today (e.g. read Zope 2 OFS.* source). – Community absorbed the complexity that works, ignored what didn’t? #ploneconf2016 | @sdupton • IIRC, my earliest recollection is 2002 BOF at OSCON with Jim Fulton Photo credit: https://commons.wikimedia.org/wiki/File:Inside_a_corn_maze_near_Christchurch,_New_Zealand.JPG (public domain)
  • 10. Now ZCA + ZTK • From bigger stack to smaller parts – Mirepoix, not the whole soup pot. – Buffet, not table d'hôte / prix fixe – Eat what you want. • e.g. Twisted uses only zope.interface #ploneconf2016 | @sdupton Photo credits: via WikiMedia Commons https://commons.wikimedia.org/wiki/File:Onion_on_White.JPG (CC-by-sa) https://commons.wikimedia.org/wiki/File:C%C3%A9leri.jpg (CC-by-sa) https://commons.wikimedia.org/wiki/File:Baby_Carrots_2.jpg (CC-by-2.0) https://upload.wikimedia.org/wikipedia/commons/4/44/Mirepoix_on_cutting_board.jpg (CC:by-sa)
  • 11. The “holy trinity” of components Adapters ü Single context ü Views and multiple context ü Subscribers (event notification) Resources ü Content ü Utilities ü Request/response Schema …because resources are nouns, why think in verbs? #ploneconf2016 | @sdupton 🌶
  • 12. Categorizing objects • There are two broad categories of objects – Those you look up • By path (content traversal) • By component registry • By both (views) – Those you don't • But many of these are in the service of some kind of lookup: – Request objects (object publishing) • Site-global state – But plone.app.registry makes even this less likely. • We have indirection everywhere; that’s okay. #ploneconf2016 | @sdupton
  • 13. Indirection • Scary departure from imperative programming? • You still will eventually end up in the debugger. • We get a lot of flexibility, and very consistent idioms doing this. • Components are the mirepoix of good software, registries are our larder. • Using adapters does not require a registry, but it does help keep the kitchen tidy. #ploneconf2016 | @sdupton
  • 15. Recipe-driven development 1. Write interfaces first; 2. then tests, often doctests; 3. write your implementation(s); 4. refine and adjust. 5. Break the build (hey, it happens sometimes!) #ploneconf2016 | @sdupton
  • 16. “Design by contract” • Who on Earth thinks this is a trademark- worthy phrase? • Interfaces are contracts. • We can use multiple implementations to fulfill contracts. • This is a good thing – Form widgets – Separation of concerns – Test to the interface, not to the implementation. #ploneconf2016 | @sdupton
  • 17. Component Corollary #1: Language Idioms • Make components that look like native Python data structures! – Mappings – Sequences – Sets • If you do this, chances are you will represent things as nouns, not verbs. • Resource-centric development #ploneconf2016 | @sdupton
  • 18. Resource-centric Development • Driven by state, not by action • Placeful, often. • M in MVC matters more than V, C. • Our community and our platform has unique talents: – Traversal, Traversal, Traversal! – Persistent objects: objects are first class, they are the things we want, not mere proxies. • Components should be more noun than verb, suiting both platform and language idioms. #ploneconf2016 | @sdupton
  • 19. Now, I’m just being contrary… #ploneconf2016 | @sdupton
  • 20. Simplified API Love/hate THIS: NOT THIS: #ploneconf2016 | @sdupton
  • 21. APIs Procedural • Benefit: simplify to single resource: the site. – But now, the site is mega- controller. • Costs: – Does not always represent what we are working with. – Leaky abstractions (e.g. IPropertiedUser). – Lost opportunity at simplified resource/noun/state idioms. State-driven • Benefits: – Components obey idioms – Components look like state they directly represent. • Cost: you must traverse to the resource you want to work with. – Is that such a bad thing? – Sometimes this is traversal to a folder, instead of using the site as a controller. More OO. – Sometimes component lookup. #ploneconf2016 | @sdupton
  • 22. …at it’s most hyperbolic: • Are procedural APIs the "frozen microwave meal" of software design? – They have utility; – Some can be quite good; – Not always as satisfying or complete as the heart of component-driven software. • Placeful interfaces (e.g. traversal) made clean URLs before the cool kids in the other frameworks thought about routes, mappings, and slugs. #ploneconf2016 | @sdupton
  • 23. These approaches are not mutually exclusive. • I can and do use parts of plone.api I like or that save me time. • I can use components that have state, place -- and don’t act procedurally. • I can mix these. • I’m okay with that. • Use procedural APIs when they save time or help learning curve – however, imperative, action-driven code is not always appropriate. #ploneconf2016 | @sdupton
  • 24. My point • Components, ZCA are not just for ninjas. • Keep your kitchen appliances, but know how to handle a knife without cutting yourself! • You should not be afraid to get a knick or two. Even pro chefs have scars. Scars teach. • Sometimes it’s okay to buy pre-cut Mirepoix from Whole Foods. I won’t tell, or judge. • I even bought a frozen Chicken Tikka meal from Trader Joes last week. • I do make my own stock, but don’t grind my own sausage. Make choices you are comfortable with. #ploneconf2016 | @sdupton
  • 25. “Just enough” Zope Component Architecture …and what to do when it won’t cooperate. #ploneconf2016 | @sdupton
  • 26. zope.interface Components are “objects connected by interfaces” • Fundamental to all of this. • Should infuse how you think and write code. • Interface is a contract for behavior and state. #ploneconf2016 | @sdupton “What's important about components is that you can put them together. Interfaces are the mechanism for connecting things. “ -- Jim Fulton in 2004 [1] [1]:http://ftp.ntua.gr/mirror/python/pycon/dc2004/papers/3/PyCon2004ZopeRoadmap.pdf
  • 27. Separation of concerns • Content type implementations should not do much. Separate concerns, and… • ...write adapters that do heavy lifting (actions) and transformation. • Resources work much better with pluggable components, whether widgets, behaviors, etc. • Make global functionality site-independent. • OO by composition, not inheritance. #ploneconf2016 | @sdupton
  • 28. Schema • Let’s suppose we have a recipe system. • Where each ingredient is stored with structured data, in a grid. • The recipe is just about state, as is its ingredients. – Describe state (schema) – Store state (content) #ploneconf2016 | @sdupton
  • 30. Adapters • Fetch density (utility, or adapter of site) • Give me metric • Give me fractions! Or decimals! • Give me volume to weight! Or vice-versa. • Each with specific concern, purposeful, pluggable. #ploneconf2016 | @sdupton
  • 31. Adapters usually registered • Adapter declares it implements an interface. • Python or ZCML declares what adapter adapts. • ZCML registers adapter in (usually global) component registry. • Lookup is by calling interface: adapter = IIngredientFormatter(my_ingredient) title = adapter() #ploneconf2016 | @sdupton
  • 32. When registrations attack • Pdb needs a bit of help from you before you dive into debugging adapter, widget, and event subscriber registration problems. – Move _zope_interface_coptimizations.so out of your zope.interface distribution; – Restart, coffee, debug; – Fix it, coffee, really fix it; – Move the optimizations back into place. • Specificity helps, sometimes you need to resort to interface subclassing to make your registrations more specific. #ploneconf2016 | @sdupton
  • 33. Browser Views • Other frameworks see views as endpoints to URLs. • We see views as all about context. • Multi-adapter: a view is a component that takes a resource (e.g. content) and a request, and makes a response. – Placeful – Graceful – All about the content! #ploneconf2016 | @sdupton
  • 34. Global utilities • Useful for site-agnostic things like: – Vocabulary lookups – Integration with other services (e.g. message or job queues) – Quick static transformation of content that needs no configuration. – Object serialization or cryptographic signing – Custom field types for plone.schemaeditor #ploneconf2016 | @sdupton
  • 35. Vocabularies • When we write schema for ”Choice” type fields, we need choices. • Sometimes this is static (in your Python or your supermodel XML for a TTW type). • Sometimes, you want a dynamic source. – Stock global: e.g. timezone – Site or context-local: e.g. show only items in navroot. • Used for enumeration and/or validation. – Sometimes, just one or the other. #ploneconf2016 | @sdupton
  • 36. Site-global functionality • Four approaches – Persistent component (utility) – Adapter-of-site – plone.api functions, where applicable. – CMF tools (deprecated) • If you need to store state in the site, you likely need to choose between the first two. #ploneconf2016 | @sdupton
  • 37. Persistent utilities • Can store state in ZODB: good. • Uninstalling can be a hard problem: bad. • Cache data in _v_ attrs across requests: good. • No need for proxies – data, methods in one place: good. • Requires use of zope.component.hooks.setSite. • Might be responsible for the 2008 global recession? ;-) #ploneconf2016 | @sdupton
  • 38. Adapter of site • Needs to be cheap to construct, because you will do this more than once, though you can avoid doing more than once per request if clever. • No need for setSite() in scripts. • No uninstallation nightmares. • Forces you to think about how to use OOTB data structures in Annotations: good or bad, depending on need. #ploneconf2016 | @sdupton
  • 40. Related, worth mention • Martijn Faassen’s Reg (and Morepath) • Python ABCs – Pauper’s interface – IMHO, problem: • “Is a” is possible relationship • “As a” is not • No per-instance markers, no per-instance behavior based on such. – E.g. https://github.com/seanupton/experimental.flavors » Disclaimer: may suffer some bit rot. – Better critique: • https://glyph.twistedmatrix.com/2009/02/explaining-why-interfaces-are-great.html #ploneconf2016 | @sdupton
  • 41. Outside the (server) box Transplanting component ideology into a JavaScript environment. #ploneconf2016 | @sdupton
  • 42. Some examples • For UPIQ, I recently wrote: – A mockup widget that extends PickADate, using an adapter pattern (but not any kind of component presumptions otherwise). – Several incarnations of JavaScript zope.schema look-alikes. I will briefly show you what one of these looks like; I see much promise in the idea. – https://github.com/upiq/plotqi/blob/master/spec/modelref/dataviz.js#L357 • We plan to write a 100% JavaScript forms library based on client-side schema, that groks plone.supermodel XML. #ploneconf2016 | @sdupton
  • 43. “Components” vs “Web Components” • My use of “component architecture” in JavaScript is distinct from “web components”: – We can have schema in JavaScript. • And resource-centric development, validation, etc. • And design by contract for applications where JSON is an interchange format. JSON Schema is very limited. – We could have component registries in JavaScript, if we wanted. – We can use adapters, we could try using synchronous event notification as adjunct to asynchronous callback ideology. – Form applications are an opportunity. #ploneconf2016 | @sdupton
  • 44. #ploneconf2016 | @sdupton In food and in software, there is always room for good cooking.