CodingBlocks
Episode 64 – Software Architecture – What is Supple Design?
More Domain Driven Design talk this week: Supple Design, Declarative(ish?) Programming, and Ohio Envy.
Sponsors
- FreshBooks.com/Coding – Use code “CODING BLOCKS” in the “How Did You Hear About Us?” section
- GetAirbrake.com/cb
- Linode – Use code “CODINGBLOCKS17” for $20 towards hosting (up to four months free!)
Start Slack’ing Now.
We’re so happy you’ve found us and now it’s time to become a part of the community. Head to http://www.codingblocks.net/slack to join in on the fun today.
Survey says …
#yop-poll-container-41_yp597aa49961946 { width: 1000; background:#fff; padding:10px; color:#555; overflow:hidden; font-size:12px; } #yop-poll-container-41_yp597aa49961946 input[type='text'] { margin:0px 0px 5px 0px; padding:2%; width:96%; text-indent:2%; font-size:12px; } .yop-poll-name-41_yp597aa49961946 { font-weight:bold; background:#327BD6; color:#fff; padding:5px; text-align:center; font-size:12px; } #yop-poll-questions-container-41_yp597aa49961946 { font-size:14px; margin:5px 0px; } .yop-poll-question-container-41_yp597aa49961946 { padding: 2px; } .yop-poll-question-41_yp597aa49961946 { background:#327BD6; color:#fff; margin-bottom: 21px; margin-top: -10px; font-style: italic; text-align: center; width: 100%; padding:5px; } .yop-poll-answers-41_yp597aa49961946 { } .yop-poll-answers-41_yp597aa49961946 ul { list-style: none outside none; margin: 0; padding: 0; } .yop-poll-li-answer-41_yp597aa49961946 { font-style:normal; margin:0px 0px 10px 0px; padding:0px; font-size:12px; margin-bottom:20px; } .yop-poll-li-answer-41_yp597aa49961946 input { margin:0px; float:none; } .yop-poll-li-answer-41_yp597aa49961946 label { margin:0px; font-style:normal; font-weight:normal; font-size:12px; float:none; } .yop-poll-results-41_yp597aa49961946 { font-size: 12px; font-style: italic; font-weight: normal; margin-left: 15px; } .yop-poll-customs-41_yp597aa49961946 { } .yop-poll-customs-41_yp597aa49961946 ul { list-style: none outside none; margin: 0; padding: 0; } .yop-poll-li-custom-41_yp597aa49961946 { padding:0px; margin:0px; font-size:14px; } /* Start CAPTCHA div style*/ #yop-poll-captcha-input-div-41_yp597aa49961946 { margin-top:5px; } #yop-poll-captcha-helpers-div-41_yp597aa49961946 { width:30px; float:left; margin-left:5px; height:0px; } #yop-poll-captcha-helpers-div-41_yp597aa49961946 img { margin-bottom:2px; } #yop-poll-captcha-image-div-41_yp597aa49961946 { margin-bottom:5px; } #yop_poll_captcha_image_41_yp597aa49961946 { float:left; } /* End CAPTCHA div style*/ .yop-poll-clear-41_yp597aa49961946 { clear:both; } #yop-poll-vote-41_yp597aa49961946 { } /* Start Result bar*/ .yop-poll-results-bar-41_yp597aa49961946 { background:#f5f5f5; height:10px; } .yop-poll-results-bar-41_yp597aa49961946 div { background:#555; height:10px; } /* End Result bar*/ /* Start Vote Button*/ #yop-poll-vote-41_yp597aa49961946 div#yop-poll-vote-41_yp597aa49961946 button { float:left; } #yop-poll-vote-41_yp597aa49961946 div#yop-poll-results-41_yp597aa49961946 { float: right; margin-bottom: 20px; margin-top: -20px; width: auto; } #yop-poll-vote-41_yp597aa49961946 div#yop-poll-results-41_yp597aa49961946 a { color:#fff; text-decoration:underline; font-size:12px; } #yop-poll-vote-41_yp597aa49961946 div#yop-poll-back-41_yp597aa49961946 a { color:#555; text-decoration:underline; font-size:12px; } #yop-poll-vote-41_yp597aa49961946 div#yop-poll-archive-41_yp597aa49961946 a { color:#555; text-decoration:underline; font-size:12px; } #yop-poll-vote-41_yp597aa49961946 div { float:left; width:100%; } /* End Vote Button*/ /* Start Messages*/ #yop-poll-container-error-41_yp597aa49961946 { font-size:12px; font-style:italic; color:red; text-transform:lowercase; margin-bottom:20px; text-align:center; } #yop-poll-container-success-41_yp597aa49961946 { font-size:12px; font-style:italic; color:green; margin-bottom:20px; text-align:center; } /* End Messages*/#yop-poll-container-41_yp597aa49961946 img { max-width: 1000; } .yop-poll-forms-display{}- 6 week bootcamp-er
- Bachelors degree graduate (state university)
- 1 Year Job Experience
- Frequent committer to prestigous open source projects
News
- Thanks to everyone that left a review!
- iTunes: angelagallo44, jbelmont80, polymafk, chiraag926, Tonyb0312, mark2457, juzdepomme, Teddy Why
- Stitcher: royy, APNet, Nickassembly
- Got to meet Andrew Diamond and Casey! (We have Ohio Envy)
- In progress creating a video on the Specification Pattern
- Code is up on GitHub: https://github.com/codingblocks
- PodcastAwards.com – Slate Voting, Aug. 13-Sept. 15 https://www.podcastawards.com/app/signup
- Specificiation Pattern for Selecting data using NHibernate https://davefancher.com/2012/07/03/specifications-expression-trees-and-nhibernate/
- DreamHack was amazing: https://atlanta.dreamhack.com/17/
- Dev Bootcamp shutting down https://news.ycombinator.com/item?id=14758364
- Paul Spoon wrote an interesting article about an approach to “mechanized” architecture that was really interesting. Focus on deliverables, volatility based decomposition https://spoon.codes/2017/07/software-architecture/
Assertions
- Need ability to understand the meaning of a design without digging into the implementation
- Intention revealing interfaces help here
- Assertions describe state – NOT PROCEDURES
- They make side effects explicit
- State post-conditions from operations and invariants of classes and the aggregates
- Write these as Unit Tests if the programming language doesn’t support assertions
- Try to use models with similar concepts which help infer the intended assertion
- Pre-conditions exist in the test setup
- Post-conditions verify that the assertion holds true
- Using these pre/post conditions help a develper understand what’s happening when a procedure is used
- Combining Intention Revealing Interfaces, Side Effect Free Functions and Assertions make encapsulation and abstraction safe
- Paint mixing example in the book – mixin(otherPaint) – should the otherPaint be reduced in volume?
- Changing an argument is a risky side effect and a bad practice
Conceptual Contours
- “Cookbook rules don’t work”
- Don’t try to make everything in a domain fit the same level of granularity
- Will often either create too much duplication of code, or obscure the overall picture by introducing too many details – one size doesn’t fit all
- As new concepts are introduced into the model, you may have to refactor to better suit the new concept
- This creates the CONCEPTUAL CONTOURS – happens when code is adapted to newly understood concepts
- Finding the conceptual unit of functionality will lead to more flexible and understandable designs
- Decompose elements into units (operations, interfaces, classes and aggregates) – using intuition
- The model should be aligned with consistent aspects so it’s understandable and meaningful
- Should line up with the ubiquitous language
- All of this typically comes from constant refactoring and almost never happens on the original design
- If a new concept is introduced and requires significant refactoring, it may mean that our understanding of the domain needs to be revisited
- Accounting example – refactoring the code to the domain enabled future updates that sort of just fit into place
- Having these conceptual contours come out stabilize the model and make unit tests easier to create and understand
Standalone Classes
- Difficulty of understanding a design increases drastically as dependencies are added
- Implicit dependencies / references add to mental complexity more than explicit references
- Implicit concept was the Paint example where red green and blue indicated pigment colors
- This was made explicit as the Paint class was broken down and a Pigment class was added
- EVERY dependency is suspect until proven as essential to the concept behind the object
- Often scrutinizing these dependencies can result in eliminating all of them
- When you can, eliminate all OTHER concepts other than the ones crucial to the class
- This makes the class something that can be self-contained and easier to understand
- Goal is not to eliminate all dependencies, rather just eliminate the non-essential ones
- Intricate computations / algorithms should try to be factored out into value objects if possible
- Low coupling reduces conceptual overload
- Standalone classes are the definition of low-coupling
Closure of Operations
“Where it fits, define an operation whose return type is the same as the type of its arguments.”
- Following this rule allow for interfaces that don’t introduce other concepts
- Very often used with Value Objects
- Not typically used with Entity objects because those aren’t “replaceable” objects – usually they are mutated
- Constantly look for ways to reduce interdependence and increase cohesion
- Additionally, using / returning known standard types can almost be as good as a Closure of Operation because it doesn’t add to mental complexity
Declarative Design
- Definition: “A form of programming in which a precise description of properties actually controls the software. An executable specification.”
- Domain-specific languages can be declarative
- How to be a Programmer by Robert L Read series, specifically episode 40, How to be an Advanced Programmer
- Benefits are realized once you have combinable elements that communicate their meaning and have obvious or no effects
- “The ability to build complex specifications out of simple elements increases the expressiveness of the code.”
- Favorite quote: “Using a pattern doesn’t mean building features you don’t need.”
Angles of Attack
- So…we know we want to clarify the intent of code, make the consequences transparent and decouple the model elements…
- So…where do we start? With the easy stuff!
- Carve off Subdomains that are easy
- Move the complex rules out, make them declarative
- The new subdomains are clean, and the old is cleaner than it used to be
- “It is more useful to make a big impact on one area, […] than to spread you efforts thin”
- Look for established formalisms…meaning…things that are easily understood
-
You don’t often get to create something completely new, most large loftware involves domains that centures old!
-
example: Accounting (well developed: notions like ledgers, payments, orders or even Math)
-
bonus: Math is often highly testable too! (Same w/ anything that is stateless)
-
It’s a contrived example, but still funny to see how clear it is to start and how much better it is at the end
- Separated the query from the modifier (calculate + apply – Commands and Side Effect Free Functions)
- Make implicit concepts explicit (Created an object for a group of objects) (lol – Share Pie – also Order/OrderItems)
- Supple up the code! (Complex logic encapsulated, side effects minimized and suppled up, dependencies are minimized)
-
So…when it needs to change…Add a new loan type, money is probated based on the date
-
In the original “simple” code…it’s tempting to “if”
-
In the new code…make a ProrateStrategy…but why??? Because I can see how things work from the interface!
Resources We Like
- Domain Driven Design – Tackling Complexity in the Heart of Software by Eric Evans (available at Amazon)
- Los Techies (https://lostechies.com/) – Great articles on all types of programming topics, including DDD. “See Habla Code”
- Domain-Driven Design Fundamentals by Julie Lerman and Steve Smith (available at Pluralsight)
- Modern Software Architecture: Domain Models, CQRS, and Event Sourcing by Dino Esposito (available at Pluralsight)
- http://DDDCommunity.org
- http://DomainLanguage.com
Tip of the Week
- Joe: Use your VIP settings to limit distractions: lmgtfy
- Allen
- Visual Studio for Mac
- https://www.visualstudio.com/vs/visual-studio-mac/
- Masters of Scale Podcast – from Andrew Diamond
- https://mastersofscale.com/
- “Imperfect is Perfect” – with Mark Zuckerberg
- Recording video for coding – Drop your resolution
- Outlaw
- Preview the widget. Calculator in the search. Both iOS.
- 7 lesser known hacks for debugging in Visual Studio
- https://blogs.msdn.microsoft.com/visualstudio/2017/06/26/7-lesser-known-hacks-for-debugging-in-visual-studio/
- VS2017 – Debug -> Reattach to Process…