Jump to content

How often do you use Interfaces?


w1zzerd

Recommended Posts

So I have been writing PHP constantly for a few months now, and have a pretty good grasp on OOP coming from other languages. One thing I never really use is interfaces, I get it when a class implements an interface, that class is required to have implemented methods from a interface, or a constant that is required by an interface. Seems like the kinda thing you would need when you are on a large team mainly for naming consistency? Is this something I should be using? I know I can get away with not using it, but should I use it to be up to modern php standards? 

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/290070-how-often-do-you-use-interfaces/
Share on other sites

Naming consistency? Hardly. That's a job for coding standards and IDEs that can automatically (re)format code for you.

 

Rather than rehash something that is a fairly complicated subject, let me point you to, honestly, the first four results I found in Google that looked decent:

- Why you should always use PHP interfaces

- Understanding and Applying Polymorphism in PHP

- Design Pattern Principles for PHP: Program to an Interface; not an implementation

- When should I use an interface/abstract class?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.