Converting object from one format to another Java ( Design pattern ) -
i building service depends on service. typical service oriented architecture. service dependent on exposes api , data types. confused should converting object types exposed service specific objects service understands. expect service change time these 2 different services. have 2 options:
- directly use data types in service , pass in methods.
- transform specific data types service understands. ( objects same if 0 changes ).
i tried answer these questions still not make final call. need in making decision.
why should have encapsulated/transformed types ?
- to prevent building every time build changes in service.
- to prevent widespread changes ( adapter pattern ) : changes wire format lead me change encapsulating classes.
why should not have changes types encapsulated ?
- the classes same wire format classes. ( useless effort maintain classes )
as understand impact same if go either approach. ?
i no architect or soa specialist, excuse me if saying stupid :-)
but think way here keep services simple.
in shoes, i'd directly use existent api. not spent time wrapping or adapting methods api. second service (that uses existent first service) business logic should take care of convertion, imo, except if you're being forced expensive existent api.
remember services mutable. they're software. have bugs, business logic changes time goes , you'll have change api , you'll have keep older methods compatible other service consumers. don't want maintain 2 apis provide same information without practical reason. not twice maintenance work.
creating api adapt data format sounds me little old "dtos evil" flame war. , think few people write advantages of using dto nowadays :-)
Comments
Post a Comment