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
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?

  • Like 1
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.