PHP Classes

Abstract Class vs. Interface

Recommend this page to a friend!

      PHP Classes blog  >  Using PHP Object Inte...  >  All threads  >  Abstract Class vs. Interface  >  (Un) Subscribe thread alerts  
Subject:Abstract Class vs. Interface
Summary:Abstract Class vs. Interface: when to use which?
Messages:2
Author:D
Date:2015-07-22 17:25:47
Update:2015-07-23 02:27:01
 

  1. Abstract Class vs. Interface   Reply   Report abuse  
Picture of D D - 2015-07-23 01:08:58
I have found myself rarely using the Interface in my own coding, though I'm not suggesting that is best practice.

Should interfaces be considered more useful as a tool to help multiple developers work together, or as a help for when you're not sure who will be writing code along side of yours more than something to help one developer?

  2. Re: Abstract Class vs. Interface   Reply   Report abuse  
Picture of Dave Smith Dave Smith - 2015-07-23 02:27:01 - In reply to message 1 from D
I don't hardly use interfaces either, the rule of thumb is to use an interface for distribution with a broad scope and to use an abstract class within a closely related implementation. Everything I do is closely related so abstract classes are the way I go.

Another thread mentioned using them within controller classes where you can then perform a logic check within your code to ensure they are an instance of a particular class. I have not used them in this way, however I have read somewhere that this can be useful, I will have to research a bit more to understand how and when to apply it.

My thoughts on interfaces have always been like yours, that they would be most useful in a development team environment, however I am intrigued with how they can be used within controllers.

Dave