What makes for good design? Many folks have written about it, and lots more have opinions.
For me, good design comes down to two operations: lumping and splitting. Lumping is the act of combining (or joining) items. Splitting is the act of separating them.
The two obvious domains that benefit from lumping and splitting are database design and object-oriented programming. A good database design brings closely-related fields into the same table, and pushes distinct concepts to separate tables. (There is more to good database design, but this is a good start.)
The same concepts hold for object-oriented design and programming. Keep similar items within a class and push distinct items into separate classes. Keep similar classes together in a namespace, and push different classes into different namespaces.
Lumping and splitting work for procedural programming too. If you've ever looked at a long function that does a lot (or even a small-ish one that works on multiple, disjoint data) and said "ugh" to yourself, then you know the results of improper lumping and splitting.
A high-level function in a system should work with high-level concepts. A function that deals with both high-level concepts and low-level concepts imposes a cognitive load upon the reader. The reader must jump from one level to another, keeping a stack of contexts in his head.
A well-written (or more accurately, a well-lumped and split) function will contain concepts for a single level. With a single level of concepts, the function is easier to comprehend.
Good programmers revise their programs, moving code to the proper place. They may start with tangled concepts, but they identify the different concepts and separate them, organizing the code. Not only do they eliminate duplicate code, but they push code to the proper level, creating methods, classes, namespaces, and libraries to hold the different sets of concepts.
Programming languages, over the years, have adopted syntax to help with such organization. C had limited scoping, C++ advanced coping with classes (and later namespaces), and Java and C# have had classes, packages, and namespaces from their inception. Good programmers take advantage of these structures to organize their code.
So if you are looking for good programmers, good designers, or good architects, look for people with lumping and splitting skills.
No comments:
Post a Comment