about
2/21/2022
DesignBites Repo
DesignBites Repository
Short story about Design, with code examples
Quick Status
- First Things blog
Contents:
Design Track Summary - first Bite
Bites:
-
Design Track Summary
Design: What?, Why?, So What?, Why Not? -
Introduction
TextFinder design: Concept development, Architecture, TextFinder Specification, Implementation -
Design
Initial thoughts about design: concept, design, design evolution, design document, building a design, presenting designs -
Structure
Why does TextFinder require a flow architecture? -
Basic
Monolithic structure with code implementing file line counting. -
Factored
Factored: Executive, Input, Compute, Output - code with user-defined types and tests. -
DataFlow
DataFlow: components arranged in data pipeline - code with user-defined types and tests. -
TypeErase
TypeErase: components with interfaces and object factories - code with user-defined types and tests. -
PlugIn
PlugIn: Output component is plugged into Compute at run-time - code with user-defined types and tests.
Summary of Structures:
Structure | Diagram | size | Pros - The good news is: | Cons - the bad news is: | What changed |
---|---|---|---|---|---|
Basic |
|
120 lines | simple, easy to test for small code sizes | as code size increases: hard to understand and test | nothing yet |
Factored |
|
336 lines | If only one package is changed, only that one is compiled. Much easier to understand and test. | Project gets more complex with more pieces to track and deploy. Executive has to participate in each stage of the processing. | Created three new packages, all of which Executive depends on. |
DataFlow |
|
242 lines | Continuous output - good ergonomics for user. Executive doesn't need to handle data. | Harder to implement and test piece by piece. Most applications will need test mocks. | Changed ownership. Now have a chain of dependencies. Each user-defined type depends on its downstream sibling. |
TypeErase |
|
284 lines | Same as DataFlow plus Input, Compute, and Output are now decoupled. Each depends only on interfaces provided by upstream component. | Construction is more complex. Each component needs to use factory function to create its down-stream component. | Introduced traits specified by caller and implemented by called. That reverses the dependency chain, so called depends on caller. |
PlugIn |
|
321 lines | Same as TypeErase plus freedom to define Output processing at run-time through a polymorphic dispatch. The Executive can decide which of several output implementations to use based on command line input. | Same as TypeErase plus Executive needs access to Compute to configure it with Output. | Removed parameterization of Compute since we want to specify Output at run-time. Need to hold Output in an Option since it is not available until after startup. |