Deciding on larger classes or more classes
One of the decisions you will need to make when designing classes is how many classes you should have. The advantage of having fewer classes is that, in general, the code becomes conceptually simpler. The advantage of having more classes is that the code becomes more modular, and it easier to change parts of it. There is a balancing act here. Too few classes can result in large God objects that are difficult to change and refactor. Too many classes can result in conceptual overload, and make it difficult for the programmer using the classes to figure out which classes they need to use.
Let's say you are building a library to handle the construction of HTML tables. This library will take an enumerable (rows) of enumerable objects (cells), and construct an HTML table with table
/tbody
/tr
/td
elements, with all the content in the td
elements being HTML escaped. One approach is a single class. You can require a standard library to handle...