4 ms·
One thing I think is missing from this exposition is a discussion of tradeoffs. You can't blindly apply these rules, because they're to some degree contradicto
by ajross 18y ago
One thing I think is missing from this exposition is a discussion of tradeoffs. You can't blindly apply these rules, because they're to some degree contradictory. Example: you can make all your variables private to better "minimize accessibility of variables", but that requires elaborate accessor methods which increase "vertical complexity".
Which is the right path? It depends, and the solution is a sense of aesthetic. That, not the rules themselves, seems to me what this techniques is all about. It's really just a different, more specific way of rephrasing PG's essay about taste in software engineering.
- jimbokun 18y ago"Example: you can make all your variables private to better "minimize accessibility of variables", but that requires elaborate accessor methods which increase "vertical complexity"." No. don't create accessors and don't access the data in private variables outside of the scope in which they are defined. Accessors, in most cases I have seen, simply outright defeat the entire purpose of having a private keyword to begin with. EDIT: replaced CAPS with italic emphasis, in order to reduce decibel level.
- ajross 18y agoChill. That was exactly my point. Clearly you have a strong aesthetic sense. :) You might want to lose a few of those CAPITALS though. Someone might think you were screaming about software.
- snorkel 18y agoI've programmed in many styles until I read Martin Fowler's "Refactoring Code" and it taught me the best style is simple READABILITY! The only thing that matters is "Is it reabable"? For example, don't be afraid of replacing 5 lines of code with a descriptively named function whose only content is those 5 lines of code. It may seem pointless to have a function that is only called once but if it makes the code more readable then do it.
- cousin_it 18y agoExtracting a single-use function can get in the way of future refactorings that cross the function's boundary. I inline single-use functions whenever I see them, and almost always after that, other, more useful possible refactorings become visible. This can happen with multiple-use functions too, but much less often.