0

I am creating a java app and wanted to know that is it a good practice to use getter and setter method in a interface. The interface would just be used for 1 class and not multiple. My app is not even a MVC app but should really follow java design patterns. Also, when implementing a basic java app, how can I see that the developer cares about java design.

fscore
  • 2,567
  • 7
  • 40
  • 74
  • 1
    This is one google search away: http://stackoverflow.com/questions/1130294/java-interface-usage-guidelines-are-getters-and-setters-in-an-interface-bad – Kon Apr 13 '14 at 02:05

2 Answers2

0

Maybe, if you're using it in multiple places. It depends on context. MVC is irrelevant to using accessors and mutators (e.g. getters and setters). Finally, if you are the developer; check if you care!

Elliott Frisch
  • 198,278
  • 20
  • 158
  • 249
0

interface defines a contract.

It can be anything. You just define the methods that needs to be implemented by any class that is inherited.

Its a good practice to use interface but sometime fever composition over inheritance.

Braj
  • 46,415
  • 5
  • 60
  • 76