java - Utility vs. Composition vs. Inheritance for JAX-RS Response -


i thinking writing utility class creates , returns jax-rs response. goal simplify , standardize generation of response's. here's idea:

public object success (class targetclass, string methodname, object responseentity) {      uri location = uribuilder.fromresource(targetclass).path(targetclass, methodname).build(localvar1, localvar2);      loginfo(location, methodname); //log4j stuff      return response.created(location).entity(responseentity).build(); } 

and there additional methods other response types (e.g. canceled, error, etc).

i curious how else may solve design problem, perhaps using inheritance or composition.

how have solved in past? did create single utility class well, or did use inheritance or composition design solution? why did go design?

this looks low-level utility me. don't on think - creating kind of bespoke response inheritance hierarchy , or new family of composed types (for sake of added 'patterniness') feels unnecessary.

i'd create simple response utility, extract private method commons parts, , rethink simple design if (and if) requirements become more complex.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -