News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Mathias Verraes:
Resolving Feature Envy in the Domain
August 12, 2014 @ 11:55:24

Mathias Verraes has a new post today about something he calls "feature envy" in the domain, related to this code smell (based on a definition from Martin Fowler).

Benjamin Eberlei did a really nice job of explaining refactoring the Feature Envy code smell on his blog. I wrote a comment because I felt the example could be taken one step further. You should read the original post. Below are Benjamin's code examples (for reference), followed by a repost of my comment.

The "smell" is defined as "a method that seems more interested in a class other than the one it's in". Mathias includes the code examples from the other post showing a datetime calculation and how it could be abstracted out to another class and method. He talks about the migration and how it relates to the "Whole Value" pattern and integrating some of the logic into a factory, generating a "reporting period" instance. He finishes the post with a brief look at an application of domain-driven design concepts to the problem, suggesting that the reporting be even more abstracted from the datetime data and using the "reporting period" object instead.

0 comments voice your opinion now!
feature envy whole value designpattern class object abstraction domaindriven

Link: http://verraes.net/2014/08/resolving-feature-envy-in-the-domain/

blog comments powered by Disqus

Similar Posts

Zend Developer Zone: PHPSecInfo: New release (0.1.2), new plans

DevShed: PHP 5 Helpers: Calling Methods Out of Object Scope

Michael Kimsal: Purpose of Benchmarking Framework Speed

Cocoliso's Blog: Adding A Syntax Highlighter To Your Site: The Power Of Geshi

Mathias Verraes: Resolving Feature Envy in the Domain


Community Events

Don't see your event here?
Let us know!


series language example podcast community introduction xdebug opinion laravel library api interview extension unittest voicesoftheelephpant framework release laravel5 php7 install

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework