Comments

11/19/05: Feature Envy Rule of Thumb

If you're looking at a method and you see a lot of references to different objects inside it, do the following experiment:

Make the method static (which means turning the "this" pointer into a named parameter). Now count the number of times each object is referred to.

What object is referenced the most? Chances are that it would go better as a method on that object.

And if you can split it into meaningful chunks, each of which primarily references a different object -- then divide and conquer.


Comments made

No comments yet

Add comment

Sorry, but due to blog comment spam, I have to ask you to create an account before you post a comment. Please log in (using the form on the top right of the page) or click here to create an account: Create an account!