Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
1.33/5 (3 votes)
See more:
Why is "feature envy" considered as a code smell? What problems does it create when we have feature envy in our code base?
Posted
Updated 20-Jan-15 10:34am
v2
Comments
ZurdoDev 20-Jan-15 16:52pm    
What?
Sergey Alexandrovich Kryukov 20-Jan-15 19:26pm    
The question is quite bad, but the notions mentioned do make a lot of sense.
We already have one answer.
—SA

Here is an explanation of "feature envy":
http://sourcemaking.com/refactoring/feature-envy[^]

and here:
http://eclipse-metrics.sourceforge.net/descriptions/pages/FeatureEnvy.html[^]

And here "code smell"
http://en.wikipedia.org/wiki/Code_smell[^]

As Andreas has pointed out it breaks encapsulation and is an indicator of poor design and discipline in the code.

[Edit] The problems it creates are canvassed here:
http://www.whitewashing.de/2014/08/11/spotting_featureenvy_and_refactoring.html[^]

and here under "Feature envy Why do we care.":
https://www.simple-talk.com/dotnet/.net-framework/exploring-smelly-code/[^]
 
Share this answer
 
v4
Comments
Andreas Gieriet 20-Jan-15 19:32pm    
My 5!
Cheers
Andi
Sergey Alexandrovich Kryukov 20-Jan-15 20:20pm    
Agree, my 5, too.
—SA
[no name] 21-Jan-15 0:10am    
Thanks SA. Your vote is not visible?
Sergey Alexandrovich Kryukov 21-Jan-15 0:23am    
I voted, don't worry. These days, some votes are not shown due to some problems. I see this problem when I vote and then reload page. The votes does count on the scores, but not shown.
—SA
[no name] 21-Jan-15 0:10am    
Thanks
See What is a "feature envy" code and why is it considered a code smell?[^]:
[...] because it breaks encapsulation. [...]
Cheers
Andi
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 20-Jan-15 20:19pm    
Hi Andi.
I think "breaks encapsulation" is one of the possible aspects of the problem, but the link is useful; I voted 4 this time.
—SA
Andreas Gieriet 20-Jan-15 20:25pm    
Thanks for your 4. I think this is the main code smell.
Cheers
Andi

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900