Wednesday, 23 February 2011

Dealing with Complexity

==========
Code Complete (Steve McConnell)
- Highlight Loc. 5564-67  | Added on Thursday, February 17, 2011, 06:28 AM

Reduce complexity. The single most important reason to create a class is to reduce a program's complexity. Create a class to hide information so that you won't need to think about it. Sure, you'll need to think about it when you write the class. But after it's written, you should be able to forget the details and use the class without any knowledge of its internal workings.
==========

Code Complete (Steve McConnell)
- Highlight Loc. 5871-76  | Added on Thursday, February 17, 2011, 06:43 AM

Reduce complexity. The single most important reason to create a routine is to reduce a program's complexity. Create a routine to hide information so that you won't need to think about it. Sure, you'll need to think about it when you write the routine. But after it's written, you should be able to forget the details and use the routine without any knowledge of its internal workings. Other reasons to create routines—minimizing code size, improving maintainability, and improving correctness—are also good reasons, but without the abstractive power of routines, complex programs would be impossible to manage intellectually.

==========

And not just classes. If you find complexity anywhere in a software system, find a way to modularize it and hide the complexity away.

No comments:

Post a Comment