I’m a newbie implementing OOP in PHP. For PHP project, I often use codeigniter framework. Currently, I face a problem in designing classes for my own library.
Here is the description:
class ABC{
function A(){
}
function B(){
}
function C(){
}
}
class XYZ{
function A(){
}
function similarToB(){
}
function X(){
}
}
Class ABC and XYZ have similar features. Function A is shared between both classes. Function B from class ABC is similar to function similarToB from class XYZ (they have the same name and parameter, but different implementation). Function C is totally different from function X. There may be also another similar classes.
What is the best way to design those classes (e.g. using inheritance, interface, etc)?
My Recommendation:
I know everyone is going to give you the “it depends” shtick (and it really does depend on what you want to do), but I think this is what you are looking for.