Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • But what would be exactly the structure of that interface? Commented Oct 20, 2015 at 11:41
  • Take a look at YAGNI. You shouldn't make methods just because you think one day you are going to need it. If you need a method for something, add and implement it, but in your case, they will be fairly similar to the core methods. Commented Oct 20, 2015 at 12:02
  • But why create an interface? I could just stay with my class and create those functions I need. Sorry if it is a silly question, I am pretty new to OOP. Commented Oct 20, 2015 at 14:51
  • @Sipo You want to create an interface and have a class implement said interface to be able to swap out the implementation, should you ever, without changing anything else. Let's say you decide to use PDO instead of mysqli in 2 years, you will just create a new database driver implementing DatabaseInterface which will use the PDO and simply change in your config you no longer want to use the one using mysqli but the one which uses PDO instead. And everything will still work, because the database contract is guaranteed by the interface and not a specific class. Commented Oct 20, 2015 at 15:04
  • Could you add some basic example to your answer? Thanks. Commented Oct 20, 2015 at 15:08