Understanding a Problem Domain
In our book example, we wrote the code based on what we wanted to do with books. The idea of a Book type comes from the problem domain: keeping track of books in a bookstore. We thought about this problem domain and figured out what features of a book we cared about.
We might have decided to keep track of the number of pages, the date it was published, and much more; what you decide to keep track of depends exactly on what your program is supposed to do.
It’s common to define multiple related types. For example, if this code was part of an online store, we might also have an Inventory type, perhaps a ShoppingCart type, and much more.
Object-oriented programming revolves around defining and using new types. ...
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