The constraints of an index card are also a good measure of approximate complexity. A component that is expected to perform more tasks than can fit easily in this space is probably too complex...
This reminds me of many other quotes.
A Forth word should not have more than one or two arguments. This stack which people have so much trouble manipulating should never be more than three or four deep. ... And that is in my mind one of the keystones of Forth, you factor and you factor and you factor until most of your definitions are one or two lines long.
http://www.ultratechnology.com/1xforth.htm
Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you're screwed anyway, and should fix your program.
http://www.kernel.org/doc/Documentation/CodingStyle
If a function exceeds about 40 lines, think about whether it can be broken up without harming the structure of the program.
http://google-styleguide.googlecode.com/svn/trunk/cppguide.xml#Write_Short_Functions
So far almost all of the OO code I have read has been in frameworks for web or windows applications. The components would NOT fit on note cards. I have not decided what that means yet, but it rings true to me that real world usage will add hair to a program.
1 comments:
By "hair" I refer to the following statement from Joel's article: "Yes, I know, it's just a simple function to display a window, but it has grown little hairs and stuff on it and nobody knows why. Well, I'll tell you why: those are bug fixes."
Post a Comment