In a java developed REST based app java architecture, should I split an implementation for requests/validations and one for domain? -


in past lets have domain model of bike, i'd make interface called bike, , in past i'd create implementation of that. , in implementation, i'd cram validation, json rules, database mapping annotations, etc. seems make system ugly , brittle. many gyrations map , display , transform.

i'm wondering (as experiment) if should create 1 implementation takes inputs , validates data, , creates instance of model use deeper inside code after transformations. so:

(type)bike -> bikeweb, bikemodel 

however when seems lose whole point of json transformations, , add complexity interface hell. because see happening is

(type)bike -> (types) bikeweb, bikemodel -> bikewebimpl, bikemodelimpl 

...times 1000

i'm asking design pattern i'm describing 1 typical debate on way go, actual pattern should using, or i'm out of gourd.

it seems every rest solution in java world has dilemma me, maybe should using solution, i'm open well.

to honest i've no idea why need interface along implementation model. why don't use bike class represent model?

it seems you're looking dto pattern. dto object represents instance of payload sent via request or response. such object can validated in terms of json syntax, , some values - mean fields may set hold value between 0 , 10. such validation can done @ level. second kind of object model itself. way there 2 classes bikedto , bike. please have @ article. might shed light on doubts.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -