Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Constructing a complex object

Reply
Thread Tools

Constructing a complex object

 
 
KiteRunner16@gmail.com
Guest
Posts: n/a
 
      10-19-2007
I tried comp.object first but had no luck so thought I would try here
(this group seems much more active):

I have a question regarding a design issue in my application and was
hoping to get some advice. I'm developing a reporting application
that makes a call to a 3rd party API to retrieve the results to be
displayed in each report. The API method that returns the results
takes one parameter object but it is a fairly complex object that
exposes several other objects as properties (some of which expose
their own object properties). The way this object is constructed and
configured determines the type of results that are returned. Each
report will configure the parameter object slightly differently,
though parts of the configuration will be common to all reports.

My question is, how would you approach the construction/configuration
of this parameter object for each report? I was thinking of creating
a class that exposes various properties and a build method. The code
that uses this class would set the appropriate properties and call the
build method which would construct and return an appropriate parameter
object. The problem I have is that this class seems to have too many
properties and for some reason doesn't quite seem right.

I've looked into the form template method and builder patterns but am
not sure how to apply them here or if they would even be appropriate.
Do you think they apply here or is there some other approach I should
consider?

Thanks in advance for your help.

K

 
Reply With Quote
 
 
 
 
Daniel Pitts
Guest
Posts: n/a
 
      10-21-2007
On Oct 19, 2:41 pm, (E-Mail Removed) wrote:
> I tried comp.object first but had no luck so thought I would try here
> (this group seems much more active):
>
> I have a question regarding a design issue in my application and was
> hoping to get some advice. I'm developing a reporting application
> that makes a call to a 3rd party API to retrieve the results to be
> displayed in each report. The API method that returns the results
> takes one parameter object but it is a fairly complex object that
> exposes several other objects as properties (some of which expose
> their own object properties). The way this object is constructed and
> configured determines the type of results that are returned. Each
> report will configure the parameter object slightly differently,
> though parts of the configuration will be common to all reports.
>
> My question is, how would you approach the construction/configuration
> of this parameter object for each report? I was thinking of creating
> a class that exposes various properties and a build method. The code
> that uses this class would set the appropriate properties and call the
> build method which would construct and return an appropriate parameter
> object. The problem I have is that this class seems to have too many
> properties and for some reason doesn't quite seem right.
>
> I've looked into the form template method and builder patterns but am
> not sure how to apply them here or if they would even be appropriate.
> Do you think they apply here or is there some other approach I should
> consider?
>
> Thanks in advance for your help.
>
> K


It sounds like the objects you pass in might follow the builder
pattern already. If you can set/reset the properties on those, then
perhaps what you really want is some factory method that produces the
object with the "common" configuration, and then have something else
configure the specifics. Of course, this API that you're forced to
work with might have been designed poorly, and you might be well off
to create an abstraction between this API and your application.
Sometimes for prototypes, this isn't worth it, but once you get into a
larger production code base, the abstraction can be invaluable.

Hope this helps,
Daniel.

--
Daniel Pitts' Tech Blog: <http://virtualinfinity.net/wordpress/>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Constructing an object from a superclass object Michael Preminger Java 5 03-18-2010 08:22 PM
(Re) Constructing an object cpp_novice@yahoo.com Java 1 07-24-2006 01:30 PM
constructing complex SOAP requests in javascript using Mozilla API igobonk@gmail.com Javascript 0 06-26-2006 07:28 PM
Member function redeclaration not allowed when constructing temporary object Marco Wedekind C++ 11 04-26-2006 01:25 PM
Re: constructing an object from bytes rather than a constructor Mike Wahler C++ 3 08-01-2003 01:24 PM



Advertisments