Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Helper classes are usually a sign of lack of knowledge about the Model's problem domain and considered an AntiPattern (or at least a Code Smell) by many. Move methods where they belong, e.g. on the objects on which properties they operate on, instead of collecting remotely related functions in static classes. Use Inheritance for classes that share the same behavior. Use Composition when objects are behaviorally different but need to share some functionality. Or use Traits.</p> <p>The static Utils class you will often find in PHP is a code smell. People will throw more or less random functions into a class for organizing them. This is fine when you want to do procedural coding with PHP&lt;5.2. As of 5.3 you would <a href="http://docs.php.net/manual/en/language.namespaces.php" rel="noreferrer">group those into a namespace</a> instead. When you want to do OOP, you want to <a href="http://kore-nordmann.de/blog/0103_static_considered_harmful.html" rel="noreferrer">avoid static methods</a>. You want your objects to have <a href="https://secure.wikimedia.org/wikipedia/en/wiki/GRASP_%28object-oriented_design%29#Low_Coupling" rel="noreferrer">High Cohesion and Low Coupling</a>. Static methods achieve the exact opposite. <a href="http://sebastian-bergmann.de/archives/883-Stubbing-and-Mocking-Static-Methods.html" rel="noreferrer">This will also make your code less testable</a>.</p> <ul> <li><a href="https://blogs.msdn.com/b/nickmalik/archive/2005/09/06/461404.aspx" rel="noreferrer">Are Helper Classes Evil?</a></li> <li><a href="https://blogs.msdn.com/b/nickmalik/archive/2005/09/07/462054.aspx" rel="noreferrer">Killing the Helper class, part two</a></li> <li><a href="http://sourcemaking.com/antipatterns/functional-decomposition" rel="noreferrer">Functional Decomposition AntiPattern</a></li> <li><a href="https://stackoverflow.com/questions/2446376/is-the-word-helper-in-a-class-name-a-code-smell">Is the word &quot;Helper&quot; in a class name a code smell?</a></li> </ul> <p>Moreover, <em>every Class that use Helper class must create a helper object</em> is a code smell. Your collaborators should not create other collaborators. Move creation of complex object graphs into Factories or Builders instead.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload