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,497
  • 6
  • 37
  • 71
  • 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
  • 191,680
  • 20
  • 149
  • 239
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
  • 45,615
  • 5
  • 55
  • 73