+1 --- Anthony Carlucci | SW App Dev Eng, Sr. | R501 / KW App Development & Maint e: [email protected] | v: 781.271.2432 | f: 781.271.3299 The MITRE Corporation | 202 Burlington Rd | Bedford, MA 01730-1420
-----Original Message----- From: Franklin, Matthew B. [mailto:[email protected]] Sent: Wednesday, April 13, 2011 11:54 AM To: [email protected] Subject: Interface vs POJO for Model Objects I envision model objects as simple containers for data, and IMO, making them interfaces over-complicates their use within the system. Scott has expressed that he prefers interfaces over POJOs, so this thread is intended to discuss the issue and build the community's consensus. To clarify my thinking I present the following example pseudo code to demonstrate my preferred pattern: class Widget { String Title; String Author; ... //getters & setters } A Widget object is both retrieved from the persistence layer and created from data posted by the client. Coming from the client, the creation of a Widget instance is obvious and simple with the above approach. If we were to have a Widget interface defining the same getters & setters, object creation becomes more difficult, as you need a factory (or some other method of instantiation) to control what implementation gets created. On the other hand, I am a big advocate of interfaces for services, repositories and any other components that perform actions. -Matt
