Re: Factory method question
- From: jonathan.broderick@xxxxxxxxx
- Date: Thu, 13 Mar 2008 08:32:59 -0700 (PDT)
On Mar 12, 7:07 pm, "Paul E Collins" <find_my_real_addr...@xxxxxxx>
wrote:
<jonathan.broder...@xxxxxxxxx> wrote:
I was hoping to avoid programming directly to the factory instances
and rather to an interface or abstract class. Is that correct or am I
missing something?
Yes, my suggestion means you'd be programming to concrete classes.
Could you post a short, simplified version of your code, or at least
explain what you're trying to model? Otherwise, it's hard to tell what
approach might be suitable.
Eq.
The application I'm creating is a web application. I would guess 90%
of the processing is loading/saving/deleting/updating from an SQL
database. So there's not much processing going on.
Here's some sample code thats sort of like my problem:
public interface IConditional
{
bool IsMatch(string[] data);
}
public class FieldConditional : IConditional
{
public FieldConditional(IField field)
{
... code
}
bool IsMatch(string[] data)
{
... code
}
}
public class DateConditional : IConditional
{
public FieldConditional(DateTime date)
{
... code
}
bool IsMatch(string[] data)
{
... code
}
}
These objects (FieldCondtional and DateConditional) are saved in the
database with a unique
ID between them. I know I can do this:
IConditional c = ConditionalFactory.Load(id);
Is there a way i could do something like this:
IConditional c = ConditionalFactory.Create(<data>);
That way I let the Factory know which object to create and how. I Dont
want to have to do soemthing like this:
IConditional c = ConditionalFactory.CreateField(<data>);
or...
IConditional c = ConditionalFactory.CreateDate(<data>);
The creating part I'm not so sure how to do.
.
- Follow-Ups:
- Re: Factory method question
- From: Peter Duniho
- Re: Factory method question
- References:
- Factory method question
- From: jonathan . broderick
- Re: Factory method question
- From: Paul E Collins
- Re: Factory method question
- From: jonathan . broderick
- Re: Factory method question
- From: Paul E Collins
- Factory method question
- Prev by Date: Re: Singleton Question
- Next by Date: Re: Identical binaries from same source code
- Previous by thread: Re: Factory method question
- Next by thread: Re: Factory method question
- Index(es):
Relevant Pages
|