Jonas Schreiber
Jonas Schreiber

Reputation: 457

Spring Business Object Modeling

We're building a service that can handle posts which are proxied from a web app or a dialer application. Users can confirm or cancel appointments via email, SMS, phone calls, or app.

The complicating factor is that with app and email you get a discrete "Confirm" or "Cancel" action, whereas with phone calls you get a digit pressed and with SMS you get a keyword, like "CONFIRM" or "C". (Further complicating is that to different accounts, keywords or digits will resolve to different actions.)

Here's my question. We receive a post and serialize it into a UserInteraction POJO that contains all relevant info and which is persisted to the database. Unfortunately, this POJO doesn't contain the abstraction of the discrete action the user is taking as far as the business logic is concerned.

Should I add to the POJO something like:

@Transient
private ResponseType responseType;

or should this additional attribute pass through all the methods in its lifecycle as a separate argument?

Method signatures would be like this if I was to keep the ResponseType separate:

public GenericResponse handleConfirmation(UserInteraction userInteraction, AppointmentInfo apptInfo, ResponseType responseType) 

Upvotes: 0

Views: 63

Answers (2)

Stephen David
Stephen David

Reputation: 11

IMO base your decision on whether the 'responseType' is part of the 'UserInteraction' abstraction, ie. could it be considered an attribute of a 'User Interaction'

Based on your description, I would think yes -- resolve the actual response (ie. CONFIRM, C, etc) to the corresponding discrete enumeration/type, set on the POJO attribute and then persist in the db.

Upvotes: 1

Zeeshan Adnan
Zeeshan Adnan

Reputation: 829

If refactoring cost is concerned then using a transient property in POJO seems fair enough. But without knowing other surrounding factors and API dependencies its not easy to differentiate the effects of the two solutions.

Upvotes: 1

Related Questions