• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Joe's Pattern Writing
 

Joe's Pattern Writing

on

  • 1,499 views

 

Statistics

Views

Total Views
1,499
Views on SlideShare
1,498
Embed Views
1

Actions

Likes
0
Downloads
1
Comments
0

1 Embed 1

http://www.heej.net 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Joe's Pattern Writing Joe's Pattern Writing Document Transcript

    • Writing Patterns “The Straight Scoop” Joseph Yoder joe@refactory.com www.refactory.com www.joeyoder.com gnisiR adniL & redoY hpesoJ 7002 thgirypoC Writing Patterns Can Be Hard Good Judgment comes from Experience comes from bad Judgment….Patterns come from Experience. Capturing and communicating (sharing) our experiences is not easy. While writing a pattern might not be difficult, writing good patterns can be very difficult. For most of us, any writing can be a difficult task. Clear communication takes practice and iterations. 2
    • Alexander’s Pattern Definition Each pattern describes a problem that occurs over and over again in our environment and then describes the core of the solution to that problem in such a way that you can use this solution a million times over without ever doing it the same way twice. Alexander - building architect and author The Timeless Way of Building A Pattern Language 3 What is a Pattern Quite often you hear: ” . t x e t n o c a ni m el b o r p a o t n oi t ul o s n e v o r p a si n r e t t a p A “ Alexander writes: n oi t al e r a s e s s e r p x e h ci h w , el u r t r a p - e e r h t a si n r e t t a p h c a E “ ” . n oi t ul o s a d n a , m el b o r p a , t x e t n o c ni a t r e c a n e e w t e b Are these definitions the same? 4
    • 6 Help to construct new systems Help to comprehend existing systems experience of the experts Tell a good story which captures the Be prescriptive about the solution solving problem Provide Facts (ref manual) about A Patterns Should 5 snrettap rehto ni secrof eht fo tnednepedni era taht secrof gnitcaretni fo tes esned a evah dluohs tI )nrettap a gnitirw fo daetsni taht od ,nac ti fi( detamotua ro dezilamrof eb tonnac tI eciwt emas eht gnieb reve tuohtiw semit noillim a detnemelpmi eb nac dna ,revlos melborp eht fo thgisni eht no dliub dluohs noitulos ehT )eluR s’nnamhcsuB( flesruoy tnevni t’ndid uoy gnihtemos eb tsum tI efil fo ytilauq ro trofmoc namuh ot etubirtnoc tsum tI )3 fo seluR( noitulos nevorp ,erutam a eb tsum tI melborp eht evlos ot woh ,od ot tahw revlos melborp eht llet ot elba eb tsum uoY txetnoc a ni melborp a ot noitulos a eb tsum tI What is a Pattern
    • What is not a Pattern Just a simple solution to a problem in a context • A simple rule • A prescriptive recipe • An algorithm • A data structure 7 How do Experts help decide what makes good patterns? Focus on Practicability Disregard of originality Non-Anonymous Review Writer’s Workshop Careful Editing Buschmann et. al. in Pattern-Oriented Software Architecture 8
    • Parts of a Pattern (Alexander) Problem - when to use the pattern Solution - what to do to solve problem Context - when to consider the pattern Forces - pattern is a balance of forces Consequences, positive and negative Examples: Teach both problem and solution Are the best teacher Are proof of pattern-hood Small Meeting Rooms
    • Small Meeting Rooms 11 e c a p S r o o d n I f o e p a h S e h T , t h gi L f o sl o o P , s ri a h C t n e r e f fi D , el c ri C g ni t ti S , m o o R y r e v E f o s e di S o w T n o t h gi L : e e S . s e c al p k r o w e h t g n o m a d e r e t t a c s yl n e v e , g ni dli u b e h t f o s t r a p cil b u p t s o m e h t ni m e h t e t a c o L . s s el r o el p o e p 2 1 r o f - - ll a m s yll a e r s m o o r g ni t e e m ll a f o % 0 7 t s a el t a e k a M . kl a t r e v e n o h w el p o e p 6 e r a e r e h t , 4 2 f o p u o r g a n I . s kl a t r e v e n n o s r e p e n o , 2 1 f o p u o r g a n I . ] e zi s p u o r g h ti w [ yl di p a r y r e v s b mil c kl a t r e v e n o h w r e b m u n e h t t a h t r a el c si ti t u b ; e zi s p u o r g r o f dl o h s e r h t l a r u t a n yl r al u ci t r a p o n si e r e h T . s s e r p x e o t el b a n e e b t o n e v a h y e h t h ci h w s a e di e v a h y e h t l e e f o h w r e b m u n e h t d n a , kl a t r e v e n o h w r e b m u n e h t h t o b s e c n e ul f ni p u o r g a ni el p o e p f o r e b m u n e h t t a h t n w o h s n e e b s a h t I . sll a h e r u t c el d n a s m o o r g ni t e e m e g r al o t ni n oi t n e t t a d n a y e n o m ri e h t t u p n e t f o s n oi t u ti t s ni t u B . m e h t f o t u o t e g el p o e p s s el e h t , e r a s g ni t e e m r e g r al e h T Small Meeting Rooms
    • Parts of a Pattern (Gamma et. al.) Intent - brief description of problem and solution Also Known As Motivation - prototypical example Applicability - problem, forces, context Structure/Participants/Collaborations - solution Consequences - forces Implementation/Sample Code - solution Known Uses Related Patterns Example Pattern Form s e s ail A , e m a N t x et n o C s ecr o F m el b o r P n oi t ul o S ) s e c n e u q e s n o C ( t x e t n o C g ni tl u s e R el a n oi t a R s n r e t t a P d e t al e R ses U n won K h ct e k S r o ht u A s e c n er ef e R s el p m a x E 41
    • Pattern Example How long should pattern sections be? As short as possible but no shorter! Albert Einstein and David Parnas 51 Name Word or short phrase—the essence of the pattern, some say noun phrase. Naming is not trivial and very important. Good names enhance communication— especially when you can guess the intent from the name. Patterns “build” something. The name should say what the pattern builds. 61
    • Aliases The same pattern may exist elsewhere, at another company, in a publication. Experts use non-intuitive names that recall folklore or deeper meanings. Aliases can help novices. An abbreviation or nickname can be helpful for discussions. 71 Context The setting—target user, patterns applied, size, scope, timing, memory constraints, anything that might invalidate the solution if changed. You’re an Evangelist or Dedicated Champion who has called a meeting to introduce a new idea. Members of the user community are free to attend or not. You have resources, your own personal contribution or those of a Local Sponsor or Corporate Angel. 81
    • Forces Why the problem is hard. The forces are often contradictory—create tension: You want to make your customers happy. You have limited resources. There’s always more important work to do. Most people are curious about new ideas. 91 Problem Short, complete statement of the problem the pattern will solve. Usually a meeting is just another ordinary, impersonal event. How do we get people to want to attend our meeting? 02
    • Solution Your proposed method of solving the problem. Resolve important forces determined by context; other forces may be ignored. Keep the target audience in mind. Best Patterns are Generative Have food at the meeting—donuts or bagels in the morning, with coffee, tea, and juice, and cookies and drinks in the afternoon, lunch at noon-time. 12 Resulting Context What happens if the solution is applied, what forces resolved, what problems may arise, what costs and benefits. Just “problem solved” is not enough. Food will turn a mundane meeting, presentation or other gathering into a more special event. If offered in the beginning, it starts the meeting on a positive note. 22
    • Rationale Why the solution solves the problem. Sell the pattern, teach the reader. In Alexander’s pattern Communal Eating (147), “eating plays a vital role in almost all human societies as a way of binding people together and increasing the extent to which they feel like members of a group. The act of eating together is by its very nature a sign of friendship.” 32 Other Sections Known Uses: A one-time occurrence is an event. A double occurrence is a coincidence. If it occurs more than twice, it’s a pattern. Jim Coplien/Gerald Weinberg/Bunny Duhl Related Patterns: Use, be used with, be similar to other patterns While the prospect of free food is nice, Brown Bag can be used when funding is not available. People can still eat together, even if they bring their own food. 42
    • Ward’s Tips for Writing Patterns Pick a whole area, not just one idea Make a list of things you learned Cast each item on your list as a solution Now write each item as a Pattern Try a four paragraph form where the second paragraph ends with the pivotal "therefore” Organize your patterns into sections Write an Introduction 52 Joe’s Tips for Writing Patterns Take some small 3x5 or equivalent cards Brainstorm the catalogue of ideas For each pattern, take a card and write the problem solution as simple sentences Add any other ideas such as forces, related patterns, aliases, etc. Organize the patterns Use this to start writing the patterns 62
    • 82 level security. Secure Access Layer Integrating application security with low access to. Limited View Allowing users to only see what they have exceptions when needed. Full View With Errors Provide a full view to users, showing user environment. Session Localizing global information in a multi- privileges. Roles Organizing users with similar security repercussions. Check Point Organizing security checks and their log into the system. Providing a security module and a way to Single Access Point Intent Pattern Name Security Pattern Example 72 ) s el u r d n a s ei t r e p o r p – s ti n u ci m o t a g ni ni b m o c y b s e r u t c u r t s x el p m o c e s o p m o c ( n oi ti s o p m o C ci m a n y D ) r e t e r p r e t ni + r e dli u b + y r o t c a f e vi t c el f e r : n r e t t a p e ti s o p m o c ( r e dli u B M O A ) y g e t a r t s + y r o t c a f e vi t c el f e r : n r e t t a p e ti s o p m o c ( y g e t a r t S ci m a n y D ) e h c a c y ti t n e h ti w d e t al e r e b y a M . n oi t c el f e r g ni s u , s s al c e h t f o r e ni a t n o c d n a e m a n s s al c e h t g ni v a h t s uj , el y t s ” g ni d ni b e t al “ a ni s e c n a t s ni g ni t a e r c r o f l u f e s u y r e v si si h t ( y r o t c a F e vi t c el f e R ) M V o t r ali mi s s M O A f o s e c n a t s ni s e h c a c ( g ni h c a C y ti t n E ) s w ei v f o s g ni r e d n e r e t el p m o c r o s t n e m g a r f s e h c a c ( g ni h c a C g ni r e d n e R ) M O A n a r o f w ei v e t el p m o c n a e t a e r c o t s r e r e d n e r y t r e p o r p l a r e v e s s e t a r t s e h c r o ( r o t a r t s e h c r O g ni r e d n e R ) ytr e p or p a r of st n e m g arf I U s et ar e n e g( r er e d n e R ytr e p or P AOM Pattern Catalogue
    • 03 .hcnual ot snoitacilppa-bus hcihw gnidiced rof msinahcem a etaerc ,yrassecen fi dna ,metsys eht otni teg ot yaw eno ylno pu teS Solution: .noitamrofni yrassecennu retne ot evah ton seod resu a ,yaw sihT .tniop yrtne taht ta dedeen noitamrofni eht ylno tcelloc ot dezimotsuc eb nac noitacilppa na ot stniop yrtne elpitluM .noitacilppa eritne eht rof dedeen si taht noitamrofni resu eht fo lla tcelloc ot deen yam tniop yrtne elgnis A .edoc etacilpud evah dluoc serudecorp ro swodniw nigol tnereffiD .eruces eb ot deen lla taht snoitacilppa-bus lareves fo etisopmoc a eb yam noitacilppa nA .stnemnorivne tnereffid ni desu eb ot ti rof reisae ti sekam noitacilppa na nepo ot syaw elpitlum gnivaH Forces: .noitacilppa eht gniretne rof ”srood edis“ dna ”,srood kcab“ ”,srood tnorf“ elpitlum sah ti nehw etadilav ot tluciffid si ledom ytiruces A Problem: Single Access Point 92 . n oi t a cil p p a n a g ni s u t r a t s o t d e e n o h w sresu tuoba dedeen noitamrofni labolg tcelloc dna sresu etadilav ot ecalp eruces a gnidivorp yb siht sevlos tnioP sseccA elgniS .gnissecorp retal rof tpek eb ot deen yam noitamrofni deilppus -resu eht fo emos ,yllanoitiddA .smetsys lareves no detacitnehtua eb ot deen yam resu a semitemoS .htiw gnitcaretni eb lliw ti taht smetsys morf seludom ytiruces rehto htiw etargetni ot dna ,od t o n n a c d n a n a c r e s u e h t t a h w p u t e s o t , m e t s y s e h t o t ni r e s u a g ol ot yaw a deen lliw noitacilppa ehT .smetsys erutcurtsarfni rehto dna ,sesabatad ,smetsys gnitarepo ,gnikrowten htiw setacinummoc taht noitacilppa na rof ytiruces edivorp ot drah si tI .yrtne fo tniop elgnis a hguorht ssap tsum enoyreve nehw eetnaraug ot reisae si ytiruceS Motivation/Context: Single Access Point
    • Big Ball of Mud Alias: SHANTYTOWN, SPAGHETTI CODE 13 Big Ball of Mud - Context Shantytowns are squalid, sprawling slums. Everyone seems to agree they are a bad idea, but forces conspire to promote their emergence anyway. What is it that they are doing right? Shantytowns are usually built from common, inexpensive materials and simple tools. Shantytowns can be built using relatively unskilled labor. Even though the labor force is "unskilled" in the customary sense, the construction and maintenance of this sort of housing can be quite labor intensive. There is little concern for infrastructure, since infrastructure requires coordination and capital, and specialized resources, equipment, and skills. 23
    • Big Ball of Mud - Context Shantytowns emerge where there is a need for housing, a surplus of unskilled labor, and a dearth of capital investment. Shantytowns fulfill an immediate, local need for housing by bringing available resources to bear on the problem. Loftier architectural goals are a luxury that has to wait. Maintaining a shantytown is labor-intensive and requires a broad range of skills. One must be able to improvise repairs with the materials on-hand, and master tasks from roof repair to ad hoc sanitation. However, there is little of the sort of skilled specialization that one sees in a mature economy. 33 Big Ball of Mud - Context All too many of our software systems are, architecturally, little more than shantytowns. Investment in tools and infrastructure is too often inadequate. Tools are usually primitive, and infrastructure such as libraries and frameworks, is undercapitalized. Individual portions of the system grow unchecked, and the lack of infrastructure and architecture allows problems in one part of the system to erode and pollute adjacent portions. Deadlines loom like monsoons, and architectural elegance seems unattainable. 43
    • 63 s el p m a x E s e c n er ef e R r o ht u A h ct e k S ses U n won K s n r e t t a P d e t al e R el a n oi t a R t x e t n o C g ni tl u s e R n oi t ul o S m el b o r P s ecr o F t x et n o C s e s ail A , e m a N Let’s Write a Pattern! 53 performance functionality, then focus on architecture and Therefore, focus first on features and . n r e c n o c g ni s s e r p a s a e r u t c e ti h c r a d r a g e r t o n od ylpmis ssecorp tnempoleved eht eganam dna lortnoc ohw elpoep eht ,netfO .worromot yb gnikrow gnihtemos s d e e n r e m o t s u c e h t , n e t f o e r o M . e s a c e h t m o dl e s si h c u S .elbaliava eb ot sneppah emit dna yenom sulprus sselnu ro ,ffo-etirw xat a hcus ,tifeneb etaidemmi elbignat emos si ereht sselnu ,ti ssimsid ot sllib eht gniyap era ohw elpoep eht rof ysae si tI .tnemtsevni mret-gnol a si erutcetihcrA and under budget. You need to deliver quality software on time, Big Ball of Mud – Prob/Sol
    • 83 ”.rohtua eht“ esu ;denoitnem reven si eman s’rohtua ehT .edam si tcatnoc eye oN .elcric eht edistuo ”,llaw eht no ylf“ a semoceb neht ,nrettap eht morf noitceles a sdaer ,sdnats rohtua ehT .snigeb pohskrow eht erofeb nrettap eht daer stnapicitraP stnapicitraP citehtapmyS rezirammuS rotaredoM rohtuA :seloR .puorg eht yb dootsrednu si nrettap eht woh no rohtua eht ot kcabdeef sedivorp taht ,rotaredom lartuen ,gnorts a yb del ,seugaelloc detseretni fo elcric A leirbaG…sgnihT gnikaM fo kroW eht & spohskroW 'sretirW Writers Workshop 73 Patterns (Meszaros & Doble) A Pattern Language for Writing
    • 04 . yr ots d e t al e r n u n a sll e t e n o e m o s d n a t a e s t n e r effi d a s e k a t e n o y r e v e , d e p p o h s k r o w e b o t si n r e t t a p r e h t o n a f I . n oi t u bi r t n o c s’ r o h t u a e h t s d u al p p a d n a s d n a t s p u o r g e h T . st n e m m o c ll a s n w o r o h t u a e h T . s n oi t s e g g u s o t yl e t ai r p o r p p a t c a o t d e m u s s a si d n a t r e p x e n a d e r e di s n o c si r o h t u a e h T . n oi s s u c si d si h t g ni r u d e z i g o l o p a r e v e n dl u o h s r o h t u a e h T . s t n e m m o c y n a r e w s n a r o ni al p x e t o n dl u o h s r o h t u a e h T . p u o r g e h t m o rf s t n e m m o c yfi r al c o t s n oi t s e u q s k s a yl n o d n a k c a b d e ef e h t r of p u o r g e h t s k n a h t r o h t u a e h T . el c ri c e h t o t ni k c a b r o h t u a e h t e ti v n I . o w t r o t n e m m o c g ni s ol c e vi ti s o p a h ti w d n E Writers Workshop 93 . p o h s kr o w e ht r etf a r o ht u a e ht r of y p o c p u - d e k r a m a n o e d a m e b n a c s o p y t d n a s t n e m m o c l ai vi r T . r e t al r o f s e u s si a t e m e v a S ” . d e t o n t ni o p “ , h ti w yll a u s u , d n a h t a n r e t t a p e h t o t n oi s s u c si d s ni a r t s n o c r o t a r e d o m e h T . n w o s ti n o d n a t s t s u m n r e t t a p e h T . r o h t u a e h t r o f k a e p s r o y fi r al c t o n dl u o h s n r e t t a p e h t w o n k o h w e s o h T . t n e m e v o r p mi d e t s e g g u s e h t n e h t d n a y ti n u t r o p p o e h t e t a t S . t n e m e v o r p mi r of s n oi t s e g g u s , t x e N . e n ol a e v a el dl u o h s r o h t u a e h t t a h w y a S . s t n e m m o c e vi ti s o p h ti w ni g e B .r ot ar e d o m r o r o ht u a e ht n a ht r e h t o e n o e m o s y b n e vi g si n r e t t a p e h t f o y r a m m u s A Writers Workshop
    • Conclusions Good writing is not an accident—it comes from dedication, focus, and practice…. http://www.dreamsongspress.com/ Writing patterns is not necessarily hard but can take patience and iterations Just do it, thinking about it or theorizing about it will not write the pattern Get regular feedback specifically from the Patterns Community 14