Exforsys

Online Training

Is a ConfigParser/ObjCreator a Builder?

This is a discussion on Is a ConfigParser/ObjCreator a Builder? within the Software Patterns forums, part of the Testing category; I have a Parameters class that takes as input a configuration file name and is able to parse the file ...


Go Back   Exforsys > Testing > Software Patterns

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 11-04-2005, 11:13 PM
miguelf
 
Posts: n/a
Is a ConfigParser/ObjCreator a Builder?

I have a Parameters class that takes as input a configuration file name
and is able to parse the file for initializing it's internal parameter
fields. Then based on it's internal parameters it can create an
instance of a FrameGrabber object. The code would look something like
this:

// read the configuration file
frame_grabber_params params(configfile);

// create the frame grabber object
frame_grabber *fgrabber1 = params.create_frame_grabber();

// add/change other hard-wired settings
params.set_native_display(true);
params.set_multi_buffering(5);

// create another frame grabber object
frame_grabber *fgrabber2 = params.create_frame_grabber();

Also, the create method is able to create/return a subclass of
frame_grabber based on the configuration file.

My question is: Would the Parameters (frame_grabber_params) object be a
Builder Pattern? Or is this a similar pattern, but not really a
Builder. Is there another pattern that is closer to it?

Thanks for any comments on this.

--Miguel

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 11-06-2005, 08:52 PM
Nick Malik [Microsoft]
 
Posts: n/a
Re: Is a ConfigParser/ObjCreator a Builder?

In the sense that your class is used to encapsulate complicated code for the
purpose of creating an object, it is either a factory or a builder.
Normally a builder creates more than one object in response to stimuli,
returning an entire tree of objects in memory. If you are just returning a
single object, I'd say it is a factory method.

Now, the fact that it is configurable is excellent, and exceeds the
requirements for a factory method. I do not know if there is a name for the
specialized form of a factory method pattern that utilizes configuration
data to determine the object to create.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"miguelf" <figueroa.villanueva@gmail.com> wrote in message
news:1131164011.211435.313500@z14g2000cwz.googlegroups.com...
>I have a Parameters class that takes as input a configuration file name
> and is able to parse the file for initializing it's internal parameter
> fields. Then based on it's internal parameters it can create an
> instance of a FrameGrabber object. The code would look something like
> this:
>
> // read the configuration file
> frame_grabber_params params(configfile);
>
> // create the frame grabber object
> frame_grabber *fgrabber1 = params.create_frame_grabber();
>
> // add/change other hard-wired settings
> params.set_native_display(true);
> params.set_multi_buffering(5);
>
> // create another frame grabber object
> frame_grabber *fgrabber2 = params.create_frame_grabber();
>
> Also, the create method is able to create/return a subclass of
> frame_grabber based on the configuration file.
>
> My question is: Would the Parameters (frame_grabber_params) object be a
> Builder Pattern? Or is this a similar pattern, but not really a
> Builder. Is there another pattern that is closer to it?
>
> Thanks for any comments on this.
>
> --Miguel
>



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 11-07-2005, 12:06 AM
miguelf
 
Posts: n/a
Re: Is a ConfigParser/ObjCreator a Builder?

Well, thanks to all who answered. I guess it is clear now that it is
not a Builder. I guess my confusion stems from the fact that I don't
have much experience with patterns and, therefore, try to apply a
formula too narowly to a given problem. I think the fact remains that
it simply is a factory method with other tasks or features, namely it
is configurable.

Thanks again for all the responses.

--Miguel

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools

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

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



All times are GMT -4. The time now is 07:16 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2004 - 2007 Exforsys Inc. All rights reserved.