marinmitev / smarthome

Eclipse SmartHome project
Eclipse Public License 1.0
2 stars 1 forks source link

DTO model is not "clean" #60

Closed kaikreuzer closed 9 years ago

kaikreuzer commented 9 years ago

We have DTOs for almost everything, but not for ModuleTypes (e.g. no ActionTypeDTO). From what I see, the reason is that ActionType etc. are already pojos, which are nicely serializable. Still, this somehow brings some strange mix as the Parsers will return an object model that consists partly of DTOs and partly of classes from the API.

I see two ways to fix this:

  1. Create ActionTypeDTO etc. classes that simply extend the ActionType and nothing more.
  2. Remove the specific DTO classes altogether and instead use in general pojos from the API bundle. Since Action etc. are currently interfaces and not pojos, this would mean to change them to be classes (this could be easily done by moving the getters and setters from the ActionImpl etc. classes).

Looking at this, I think option 2 would very much simplify the architecture and move it towards what we had initially in mind (to have the API to be a representation of the JSON and not requiring additional DTOs). This would also go very well with option 2 of https://github.com/marinmitev/smarthome/issues/58, since the rule registry could deal with the simply pojos and the RuleEngine could wrap them into Impl classes when instantiating them, connecting them and injecting handlers into them.

danchom commented 9 years ago

We are agree with this idea (2), we will check if it works.

dnobel commented 9 years ago

OK, as Kai said we would also prefer option 2)