Getters/setters in interfaces

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Re: Getters/setters in interfaces

Post by Jenk »

Chris Corbyn wrote:
Jenk wrote:Let's also not forget that if an Interface is overly descriptive, you may as well not bother having an interface at all, and just use the classes interface as the er.. interface.
Except then you've tightly coupled your dependant class to a concrete class which will need to follow that code around everywhere == bulky.
As opposed to creating a concrete interface, superglued to the class it was designed for? I see little difference. Just because you are creating an interface, does not mean you are loosely coupling. If you have to create an interface for each class you create, due to the grainularity, you are actually creating more bulk.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Re: Getters/setters in interfaces

Post by Chris Corbyn »

I see what you're saying, but I just think any dependencies which are to be injected should have interfaces, not concrete types. I'm sticking to this very rigidly for this particular project since it's 100% DI-driven so far and it's probably the best code I've ever produced... I'd like to keep going with this seemingly simple, yet well-structured design.

Part of the reason I'm going down this route is to make it easier to swap out implementations (and for users to do so). It may become more apparent why after I release it :)
Post Reply