Reputation: 528
I am developing a php application using MVC architecture and i really need suggestions about the following design guidelines:
According to php class structure best practises, its noted that someone should minimize module dependencies, my application class inheritance is as followed:
Class organization:
interface StringHelper{
...
}
interface ArrayHelper{
...
}
class GeneralHelper implements StringHelper, ArrayHelper{
......
}
class NewClass extends GeneralHelper{
...
}
// user factory style to create object
class NewClassFactory{
public function create( $options ){
return new NewClass( $options );
}
}
The application has about 15 classes.
Is this approach suitable for this scenario or will i end up having big issues when maintaining my application? Would appreciate for your help.
Upvotes: 2
Views: 1050
Reputation: 3121
In most cases helper classes should always be static and no working class should extend it. Helpers are global and they have no role in the main scope of the working class. Think of helpers as Plumbers, Handymen etc . If you are writing a family class it shouldn't extend plumbers, Plumbers should come in when needed and out with no relation whatsoever to the family.
What you need is this:
class NewClass {
...
$some_string = declaration
$some_string = StringHelper::sanitizeString($some_string);
}
Upvotes: 1