Better software design with domain modeling by Eric Normand

December 7, 2023

In the presentation Better software design with domain modeling by Eric Normand, he emphasizes the importance of making good decisions and having good information for effective software design. Using the domain of a coffee shop as an example, Eric demonstrates the concept of domain modeling through types, relationships, and encoding options. He encourages evaluating different encoding options based on fit and achieving a perfect fit between model and code. Normand also discusses the importance of function signatures, total functions, and alignment of development cycle with software changes. Throughout the presentation, he emphasizes the significance of encoding the domain into a good model, focusing on semantics, and being open to change.

Better software design with domain modeling: A comprehensive overview

Eric Normand delivered an insightful presentation on Better Software Design with Domain Modeling. Drawing from his extensive experience and his ongoing book project on domain modeling, Eric offered valuable perspectives on how to enhance software design through better decision-making and information gathering.

 

Understanding software design through domain modeling

Eric kicked off the session by critiquing conventional software design rules, emphasizing that these guidelines often fail experienced designers or those in greatest need of robust design principles. Instead, he advocates for a focus on informed decision-making, viewing software design as a comprehensive process encompassing all levels of decision-making, from code structures to overarching architectural choices.

 

Domain modeling: A practical approach

Using a coffee shop domain as an example, Eric demonstrated how to model an order by defining types and relationships using TypeScript. He emphasized the importance of maintaining these relationships in the code to reflect the domain accurately. This approach, referred to as the data lens, helps in understanding the structure and interconnections within the domain.

 

Evaluating encoding options

Eric delved into the significance of evaluating different encoding options when modeling ideas. For instance, he discussed various ways to encode a Coffee type with attributes like size, roast, and add-ins, exploring union types, enums, and JavaScript classes with interfaces. He highlighted the importance of ensuring that the code accurately represents the model, matching the number of possible combinations in the code to the model.

 

Achieving perfect fit and handling imperfections

A perfect fit between a model and code, according to Eric, means all representable items are meaningful, and there are no meaningless distinctions. However, he acknowledged the challenges in achieving this, especially with complex combinations like coffee add-ins. He explored different representations, such as arrays and objects, and discussed the trade-offs and potential issues, like the ordering problem in arrays and the need for manual validation with objects.

 

Function signatures and total functions

Function signatures play a crucial role in functional programming, providing a concise representation of a use case. Eric underscored the importance of total functions — functions that always return a valid result for all valid inputs — and offered strategies to handle cases without valid returns, such as augmenting return types, restricting argument types, or changing the function’s meaning.

 

Design decisions and volatility

Eric highlighted the need to make informed design decisions based on various operations and perspectives. Using a coffee shop’s inventory system as an example, he discussed how to handle different frequencies of change — hardcoding never-changing items, adding new code for infrequently changing items, and using databases for runtime updates, while considering type safety.

 

The essence of good software design

Eric stressed that good software design goes beyond organizing and cleaning up code. It involves encoding the domain into a meaningful model that guides development. He also addressed the fear of change in software development, encouraging developers to write straightforward code and be resilient in the face of changing requirements.

 

Conclusion

Eric Normand’s presentation underscores the importance of thoughtful domain modeling in creating better software designs. By focusing on informed decision-making, evaluating encoding options, and understanding the dynamics of functional programming, developers can achieve more robust and adaptable software architectures.

 

Additional resources

Check out more from the MeetUp Func Prog Sweden. Func Prog Sweden is the community for anyone interested in functional programming. At the MeetUps the community explore different functional languages like Erlang, Elixir, Haskell, Scala, Clojure, OCaml, F# and more.