Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I still code to the interface even if I am ONLY EVER going to have ONE implementation?

I think the title speaks for itself guys - why should I write an interface and then implement a concrete class if there is only ever going to be 1 concrete implementation of that interface?

like image 768
non sequitor Avatar asked Oct 05 '09 13:10

non sequitor


1 Answers

I think you shouldn't ;)

There's no need to shadow all your classes with corresponding interfaces.

Even if you're going to make more implementations later, you can always extract the interface when it becomes necessary.

like image 140
Lennaert Avatar answered Dec 12 '22 22:12

Lennaert