Answers
This section contains the solutions to the thought experiments and answers to the lesson review questions in this chapter.
Objective 2.1: Thought experiment
Some of the types that you can use in building your web shop are: Order, OrderLine, Product, Customer, Review, SearchCriteria, BusinessRule.
When designing the system, you should focus on the behavior and then make sure that you have the data to support it. For example, instead of publicly exposing the OrderLines that an order contains, you should expose a method AddProduct(product, amount) that creates an OrderLine internally and makes sure that the Order follows all business rules.
By making sure that you have the correct constructors, users of your types can easily see which data is ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access