Page 1 of 1

where to put interfaces in mvc

Posted: Wed Apr 20, 2011 2:32 pm
by pfeatherstone
Hi all,

Sorry if this is in the wrong section but here goes!

I have developed my own mini framework to use for testing and I have started to use interfaces. At the moment I have an interface for my abstraction object in my controllers where I then implement as part of my class. I'm not sure where interfaces are actually supposed to live - in a separate file / section?

Not sure how the 'commercial' frameworks such as zend et al integrate interfaces into the MVC architecture (as I am new to these too!)?

Any pointers / insight would be much appreciated.

Thanks in advance.

Regards,
Paul

Re: where to put interfaces in mvc

Posted: Thu Apr 21, 2011 6:06 pm
by Christopher
Interfaces are usually put in their own files and located with the files that implement that interface.

Re: where to put interfaces in mvc

Posted: Tue Apr 26, 2011 7:38 pm
by josh
Interfaces are used within all layers. (model, view, and controllers). You can put them anywhere as long as they are included by the compiler (explicitly or with autoloading), there are different convensions. Some people prefix it with an I for interface, like "IOutlet", others add "_interface", like "Outlet_Interface". Others name the same as classes, like "Outlet" (the fact it is an interface isn't apparent from it's file/member name, this is my preference). You can literally just cram them all in the same file as the classes that implement them, it just wouldn't be considered clean.