Purple Blog
Navigation
Today
Archives
Adjust font size:
Small
Medium
Large
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!
Login
Username
:
Password
:
Shared Computer
Create an account
Search
Recent posts
Rails / lighttpd gotcha: AJAX stalling? Check your Content-Length header
Trapped in the Closet
JSLint
Language Elegance
Save Considered Harmful
JavaScript and Ruby support in IDEA
JavaScript and CSS Versioning in Rails
Real Lessons for Rails Deployment
Getting Started With ActiveRecord Migrations
Ruby on Rails Cheat Sheet
Eclipse Am Bizarro IDEA
Life Without Getters
Creational Patterns: The Factory Family
Computer Science vs. Software Engineering
Refactoring Combo: Extract Method Object
Feature Envy Rule of Thumb
State of Grace
Primitive Obsession
Flexible JUnit assertions with assertThat()
Zen Refactoring
Categories
All
Code
General
Links
Links
Nucleus CMS official site
Nucleus CMS forum
Get more Nucleus skins!
Designer of this skin
Roel - Nucleus guru
Bert Garcia - Nucleus guru
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.