cultivating your design heuristics
TRANSCRIPT
![Page 1: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/1.jpg)
![Page 2: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/2.jpg)
Heuristic
“anything that provides a plausible aid or direction in the solution of a problem but is in the final analysis unjustified, incapable of justification, and potentially fallible.”
—Billy Vaughn Koen
![Page 3: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/3.jpg)
The Nature of Heuristics
Heuristics aid in design
Guide use of other heuristics
Even determine our attitude and behavior
![Page 4: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/4.jpg)
Examples
![Page 5: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/5.jpg)
![Page 6: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/6.jpg)
Pithy Phrases?A Few Useful Engineering Heuristics by Billy Koen
Heuristic: Solve problems by successive approximations
Heuristic: Always give an answer
Heuristic: Always give yourself a chance to retreat
Heuristic: Use feedback to stabilize the design
Heuristic: Break complex problems into smaller, more manageable pieces
Heuristic: Always make the minimum decision
Heuristic: Design for a specific time frame (product lifetime)
Heuristic: Make small changes to your state-of-the-art (sota)
![Page 7: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/7.jpg)
ContextIn which situations
can I use this pattern?
ProblemWhat does it try to solve?
What questions does it answer?
SolutionWhat can I
do that usually works?
patterns are nicely
“packaged” heuristics
![Page 8: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/8.jpg)
![Page 9: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/9.jpg)
Pattern Languages
“In short, no pattern is an isolated entity. Each pattern can exist in the world only to the extent that is supported by other patterns: the larger patterns in which it is embedded, the patterns of the same size that surround it, and the smaller patterns which are embedded in it.” —Christopher Alexander
© Can Stock Photo / sauletas
![Page 10: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/10.jpg)
Pattern Languages are never complete…
© Can Stock Photo / TopVectors
![Page 11: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/11.jpg)
Some Age Well!
© Can Stock Photo / Noofoo
![Page 12: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/12.jpg)
Heuristics May Conflict…
and still be useful© Can Stock Photo / DaneeShe
![Page 13: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/13.jpg)
Heuristic: Use a Transaction Script when you have simple logic for a small database application
Heuristic: Use a Domain Model when you have complex logic that you want to model in objects and can accommodate database mapping
Heuristic: Use a Table Module when you have complex (existing) data and you need to write logic that applies to multiple rows in underlying database tables
Heuristics:3 Ways to Structure a Domain Layer
Patterns of Enterprise Application Architecture
![Page 14: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/14.jpg)
Table ModuleHeuristic
p
Solvable problems
my problem
Domain Model Heuristic
Transaction Script
![Page 15: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/15.jpg)
Table ModuleHeuristic
p
Solvable problems
my problem
RichDomain Model
Heuristic
Transaction Script
![Page 16: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/16.jpg)
Heuristics Need to be Challenged
© Can Stock Photo / 4774344sean
![Page 17: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/17.jpg)
![Page 18: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/18.jpg)
Unscientific Chart: Maintenance Effort*
Database Script
Complexity of Domain Logic
Effort toEnhance
Transaction Script
Domain Model
Table Module
*Inspired by the unquantified chart in Fowler’s Patterns of Enterprise Architecture
![Page 19: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/19.jpg)
Unscientific Chart: Code Reuse Potential*
Database Script
Transaction Script
Complexity of Domain Logic
PotentialCodeReuse
Domain Model
Table Module
*Inspired by the unquantified chart in Fowler’s Patterns of Enterprise Architecture
![Page 20: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/20.jpg)
“Best Fit” ProfilesStyle Design Skills Driving Forces Project
DurationSystemComplexity
System Longevity
Transaction Script
Programming Dev speed Short Low Short
Domain Model- Rich
OO Design Business concepts in code
Medium Medium toHigh
Medium to Long
Domain Model-Simple
Moderate OO +DB
Simple representation of business concepts
Medium Medium Medium
Database script
Specialized Performance,security
Medium Low to Medium
Long
Table Module
DB + Moderate prog/OO design
Technology fit Medium Low to Medium
Medium toLong
Rules Engine
Specialized Complexity/ changeability
Long High Long
…
![Page 21: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/21.jpg)
![Page 22: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/22.jpg)
“As a rule, the more demanding the application, the more leverage you get from
using a powerful language. But plenty of projects are not demanding at all. Most
programming probably consists of writing little glue programs, and for little glue programs you
can use any language that you’re already familiar with and that has good libraries
for whatever you need to do”
— Paul Graham, Revenge of the Nerds
![Page 23: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/23.jpg)
The “best” is debatable Paul Graham’s Heuristic: It doesn’t matter what
programming language you use if you have a simple program. Use programming languages, tools, and frameworks and libraries you are familiar with.
Rebecca: But Paul… Heuristic: Use a rich domain model when you have
rich behavior in your application.
Heuristic: Use transaction scripts for really simple stuff that isn’t going to change much.
Heuristic: Learn something new. Don’t always do things the same way. That’s soul sucking!
![Page 24: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/24.jpg)
![Page 25: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/25.jpg)
“choose the heuristic to use from what you take to be the best option at the time you are required to choose.” —paraphrase of Billy Koen
![Page 26: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/26.jpg)
We each have our own cherished heuristics
As new ones become useful we add to our collection
No longer useful ones fall out of fashion
Sometimes, even useful ones fade away
Our SOTA(State of the Art)
https://xkcd.com/1823/
![Page 27: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/27.jpg)
![Page 28: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/28.jpg)
Nothing ever goes
exactly by the book
![Page 29: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/29.jpg)
Nothing ever goes
exactly by the book
![Page 30: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/30.jpg)
Choices for user input validation: How much to validate in the browser?
Hand code validation logic or use declarative style?
How much validation is performed by framework-specific classes: simple, syntactic edits, or more?
Choices for constraint checking: Which objects are assigned constraint checking
responsibilities?
When are constraints enforced?
Where to enforce cross-attribute and cross-object constraints?
An Examination of some Pesky Details:Validation and Constraint Checking
![Page 31: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/31.jpg)
Perform simple edits (syntactic) in browser code
Don’t universally trust browser-validated edits. Reapply them if receiving requests from an untrusted source
Consistently assign validation responsibilities to framework-specific validation classes
Consistently use domain layer validation and constraint enforcement patterns
HeuristicsMy Design Recommendations✗
![Page 32: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/32.jpg)
Rationale: Factoring out constraint checking behavior into a separate class enables constraints be enforced by a domain service, that can determine when to check constraints.
Merit: Possible to dynamically configure constraints.
Drawback: Harder to understand all the rules at once.
Option 1: Make Constraints Explicit
Create Separate Classes
“xxxPolicy” or “xxxRule” is a common name for constraint objects
Constraint: “An out of stock item can’t be added to an expedited order”
![Page 33: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/33.jpg)
Rationale: Putting a constraint in the code that changes the state is most direct.
Merit: Factoring constraint into an intentionally named helper method aids discussing with domain experts.
Drawback: Clutters the domain object with a lot of checking, creates dependencies on other domain objects. No ability to
modulate when constraints are enforced.
Option 2: Give objects responsibilities for maintaining their state
Check Constraints in Domain Object
Constraint: “An out of stock item can’t be added to an expedited order”
![Page 34: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/34.jpg)
![Page 35: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/35.jpg)
Responsibility-Driven Design (RDD)
1990
2002
![Page 36: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/36.jpg)
RDD Concept: Role StereotypesTypical behaviors in an object-oriented design
knowing, doing, deciding
Information holder—knows and provides information.
Structurer—maintains relationships between objects.
Service provider—performs work on demand.
Coordinator—reacts to events by delegating to others.
Controller—makes decisions & directs actions.
Interfacer—transforms information and requests
between distinct parts of a software system.
![Page 37: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/37.jpg)
RDD Heuristic:Blend stereotypes to make objects more responsible.
Add behaviors to make objects “smarter”
information holders that compute or derive information based on other information they maintain
service providers that maintain information to be more efficient
structurers that answer deeper questions or derive facts about what they are structuring
interfacers that also transform
Be constantly aware of Overlapping Heuristics
Heuristic: Design objects to do one thing well. (Single Responsibility Principle
from Bob Martin)
Heuristic: Make the overall system simpler by having objects do something with
what they know. (Responsibility-Driven Design Heuristic)
![Page 38: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/38.jpg)
2001
People, Places, Things, Aggregate Things, Events
Heuristic: Separate out stuff that varies depending on the current relationship
Heuristic: Locations can be hierarchical or even more complex
Heuristic: Events can be point-in-time, interval, depend on other events…and event information is often messy and complex
![Page 39: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/39.jpg)
Heuristic: By characterizing a domain entity’s attributes you can understand/find/identify needed system behaviors
Descriptive Attributes reflect a domain object properties (not identity).
Time-dependent attributes Most attributes can change values, but for some, maintaining a history of past values is important.
Lifecycle state attributes Some entities go through a one-way lifecycle, from initial to final state.
Operational state Some entities switch between different states. The state it is currently in determines how it behaves.
Create
Active
Store
Reconstitute Database Representation
Database or File Representation
Archive Delete
Delete
Modify
![Page 40: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/40.jpg)
![Page 41: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/41.jpg)
![Page 42: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/42.jpg)
Heuristic*: Distinguish between “superficial” and “domain” validations and handle them differently
“superficial”: what must be true, regardless of the state of the domain
Heuristic: Validate these before issuing a command, ideally on the client side as well as the server side
“superficial” but requires lookup of other information
Heuristic: Validate in the service before invoking the command
“domain”: validity of a command is dependent on the state of the model
Heuristic: Validate in domain objects
*http://danielwhittaker.me/2016/04/20/how-to-validate-commands-in-a-cqrs-application/
![Page 43: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/43.jpg)
![Page 44: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/44.jpg)
Sorting out heuristics…
![Page 45: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/45.jpg)
© Can Stock Photo / andrewgenn
![Page 46: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/46.jpg)
Let’s Just Get On With It
© Can Stock Photo / Zinkevych
![Page 47: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/47.jpg)
Sorting things out…
![Page 48: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/48.jpg)
Beware of Dogma
DogmaticSynonyms: bullheaded, dictative, doctrinaire, fanatical, intolerant
Antonyms: amenable, flexible, manageable
PragmaticSynonyms: common, commonsense, practical, realistic, sensible
Antonyms: idealistic, unrealistic
![Page 49: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/49.jpg)
Heuristics Need Champions
![Page 50: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/50.jpg)
Books, blogs, case studies, critiques
Reference apps
Journaling, design logs..
![Page 51: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/51.jpg)
“The Tactical Modeling patterns were never intended to be the one-and-only way to do DDD, but many consider them as such. They produce extraneous noise and detract attention away from the most important, and unique-to-DDD material.” —Vladik Khononov
*http://vladikk.com/2016/04/05/tackling-complexity-ddd/
What if we removed the tactical patterns?*
Advocacy: Blogging/Critique
![Page 52: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/52.jpg)
![Page 53: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/53.jpg)
Advocacy: JournalingDescribe Your Design Principles
Guidelines:
You prefer a rich domain model
Aggregate roots should not directly communicate with each other
Communication protocols and why
Conventions:
Common service interfaces/capabilities
Extension points configured by…
When you can break the rules...
53
ConstructiveReasonedClearTestableSignificant
![Page 54: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/54.jpg)
Advocacy: JournalingDocument Decisions
Rationale—why you made it
Other options considered
An appreciation of your thought process
Goal: Convey why your architecture, or a piece of it, is a good solution
54
Decisions worth justifying
Spent lots of time on
Critical to achieving a requirement
Confusing at first
Widespread impact
Difficult to undo
![Page 55: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/55.jpg)
One option*
1-2 pages of text describing a set of forces forces & a single decision in response
Title
Context - Forces at play
Decision - Stated with active voice: "We will ..."
Status - “proposed” or “accepted” later may be “deprecated” or “superseded”
Consequences positive, negative, and neutral that affect the team and project in the future
*Useful for recorded decisions that have a “lifecycle”. Thanks to Michael Nygard: http://thinkrelevance.com/blog/2011/11/15/documenting-architecture-decisionsUseful link to github project on decision records: https://github.com/joelparkerhenderson
![Page 56: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/56.jpg)
Used with permissions under the under the Creative Commons Attribution-Share Alike 3.0 Unportedicense.By MichaelMaggs Edit by Richard Bartz (Own work) [CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0)], via Wikimedia Commons
Reshape your sotabased on what you
learn.
Heuristic: Make small changes to your state-of-the-art (sota)
![Page 57: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/57.jpg)
![Page 58: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/58.jpg)
Cultivating Your
Heuristics Requires Care and Attention
![Page 59: Cultivating Your Design Heuristics](https://reader031.vdocument.in/reader031/viewer/2022030318/5aab578e7f8b9a43728b4d25/html5/thumbnails/59.jpg)
Credits & Acknowledgements
Erik Simmons who encouraged me to read Discussion of TheMethod.
Richard Gabriel, a thinker and doer, critic of my work, and inspiration too.
Eric Evans always makes me think deeply about design matters.
The Ouroboros image is from the Ouroboric Philosophy page, an inspiration https:ouroboricphilosophy.wordpress.com/tag/ouroboros/
Rebecca Wirfs-Brock photograph of the Blue Apron meal.
Allen Wirfs-Brock photograph of Rebecca Wirfs-Brock at Haystack Rock.