Five Ways to Reduce the Size of Classes
Andrew Binstock writes that the best developers keep their classes to 50-60 lines of code. How can you do that? Here are five techniques:
- Diminish the workload -- Each class should just one thing.
- Avoid primitive obsession -- Don't use collections in their raw form.
- Reduce the number of class and instance variables -- If you have a lot of variables, you can probably move a group of them to a separate class.
- Subclass special-case logic -- If you have logic that isn't used very often, move it to a sub-class or a separate class.
- Don't repeat yourself (DRY) -- Discipline yourself to avoid duplicate code in both the writing and the maintenance phases.
Tags:
programming
0 Comments (click to add your comment)
Networking Solutions



Solid state disks (SSDs) made a splash in consumer technology, and now the technology has its eyes on the enterprise storage market. Download this eBook to see what SSDs can do for your infrastructure and review the pros and cons of this potentially game-changing storage technology.