Re: Factory method question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.
.



Relevant Pages

  • Re: Beginning C# Q
    ... starting out with a network app0lication, you have an awful lot to swallow. ... Designing your database is therefore, not quite the first step, particularly ... Groups table, which defines which Groups users belong to, and a Permissions ... That is why an Interface is called an Interface. ...
    (microsoft.public.dotnet.framework)
  • Re: Transaction Oriented Architecture (TOA)
    ... If one builds the application around the database view, ... The problem solution should not have to know about mechanisms like SQL query construction, optimizations like anticipatory caches, or encoding/decoding of dataset formats. ... Note that the CRUD/USER environments already provide exactly that encapsulation by providing a Data Layer that is isolated from the rest of the application through an interface. ... TOA/TOP proposes the database and its application domain stored procedures are the only persistence mechanism necessary, and that the benefits of a focused, single, data-permeable gateway between application and database far exceed the benefits of O/R mappings--regardless of abstraction--and that its lightweight appearance shouldn't be dismissed as missing heavyweight kick. ...
    (comp.object)
  • Re: Transaction Oriented Architecture (TOA)
    ... I don't think the issue is ignoring the database; it is recognizing that the database is a different subject matter applying different business rules than the problem solution. ... There is nothing to prevent abstracting the database subject matter in a classic OO manner with objects like Schema, Table, Tuple, and Query. ... I'm of the opinion that the more obvious the database (or at least its interface) is the more easily maintainable an application becomes. ... I've nothing against creating frameworks and patterns to facilitate those programming activities, but prefer the concept of a problem domain transaction to language-specific expressions mapping 1:1 with anything physically present in the database. ...
    (comp.object)
  • Re: OOP style
    ... Component classes have all their main logic in a Custom base class ... database access unit if they didn't already start with a full DB layer; ... My latest application started with an extensively designed object model ... Typing in the implementation of the database interface is ...
    (comp.lang.pascal.delphi.misc)
  • Re: OOP/OOD Philosophy
    ... You appear to assume that, in order to isolate the database from the gui, ... the GUI layer uses a specific interface of the business ... This is where you need to place logic against the data structure that ...
    (comp.object)