factory-pattern

Flexible application configuration in C++

Hi, I am developing a C++ application used to simulate a real world scenario. Based on this simulation our team is going to develop, test and evaluate different algorithms working within such a real world scenrio. We need the possibility to define several scenarios (they might differ in a few parameters, but a future scenario might als...

Activator.CreateInstance: Dynamic Instantiation of Classes

I am designing a loosely-coupled structure. I want to call classes from different assemblies/namespaces via a code which is represented by a String. My design is, each of client's business rules is on different assemblies and not dependent on each other (ONE client is to ONE DLL ratio) so that when I made an update on business rules of 1...

Abstracting the DataLayer (DAL) of a three-tier application.

Hi guys, As continuation to my previous question, (see http://stackoverflow.com/questions/3737848/creating-a-loosely-coupled-scalable-software-architecture Someone suggests to also Abstract the DAL like I abstracted the BLL from the Presentation Layer on my three tier project. Any suggestion on how to do this? Do I also need a factory b...

Generics in static factory methods? (Java)

I have an assignment that is requiring me to use the factory pattern for implementing an immutable data structure, but the problem is that the abstract class is generic, and having static methods make references to generic types is giving me problems. My assignment is requiring me to use static methods so I'm starting to panic. Any hel...

Dynamic base class and factories

I have following code: class EntityBase (object) : __entity__ = None def __init__ (self) : pass def entity (name) : class Entity (EntityBase) : __entity__ = name def __init__ (self) : pass return Entity class Smth (entity ("SMTH")) : def __init__ (self, a, b) : self.a...

Could I use the Factory Pattern in this scenario?

Hi folks, I was wondering if I could - and how - I could use the Factory Pattern in this scenario? I have a the following classes... public interface IStub<T> where T : class { IEnumerable<T> CreateStubs(); } public FooStub : IStub<Foo> { public IEnumerable<Foo> CreateStubs() { ... } } public BarStub : IStub<Bar> { publ...

Python - question about factory functions

I have a series of classes that I'll be registering as services to a higher level abstraction class. The high-level class will have a function that gets the lower level class based on init args, etc. Does this sound berserk? Also, what is this called? I call it factory function/class, but I really have no idea (which makes it harder to G...

Dynamic Inheritance using a factory

I think I know the answer to this but hoping someone has a neat solution. We are currently using two kinds of drop down controls (telerik and .net). I'm hoping to combine these into one control but struggling with a user friendly design. Ideally the control would be created in the design file with a bool property of say "SimpleBox", to...

Socket-based Message Factory

I'm looking for some ideas on implementing a basic message factory that reads a header from an input stream and creates the appropriate message type based on the type defined in the message header. So I have something like (roughly.. and I'm willing to change the design if a better paradigm is presented here) class MessageHeader { ...

Object generator pattern

I have a class that represents a pretty complex object. The objects can be created by many ways: incremental building, by parsing text strings in different formats and by analyzing binary files. So far my strategy was as follows: Have the constructor (__init__, in my case) initialize all the internal variables to None Supply different ...

Is the typical C++ implementation of Factory class flawed?

I have the need to implement factory class in C++, but when I was thinking about that, I found one big problem that I couldn't solve, and I found out, that all factory implementation examples around are flawed in the same way. I'm probably the one who is wrong, but please tell me why. So here is simple "typical" factory implementation, ...

ASP.NET MVC2 - Custom properties on a ViewPage

Hi, What I thought should be a fairly simple search, turned out to be alot more. Atm I'm using a baseclass(MasterModel) for all my Models, that then get passed down from the ViewPage< HomeIndexModel > to the ViewMasterPage< MasterModel > and everything works fine. This was done this way after reading a post by "Scott Gu". Then I thoug...

C# factory question

Consider the factory method below which takes some meta data and creates a column of the relevant type. Its all good until I encounter a column which relies on some additional data (ColumnType.DropDownList). This needs some additional data (a list of values) for display purposes. I dont want to provide this data at a meta data level ...

should a factory utilize another factory if the object to create needs another object?

If I have a factory that creates an object that needs an instance of another object should i use another factory responsible for this second's object creation or should the original factory handle this? ...

Saving Data with the Factory Pattern?

I've been becoming more familiar with the Factory Pattern (along with Strategy Pattern) and what a great benefit the pattern can have. However, I've been struggling with the following situation: Previously, I would have done something like the following, where there's a manager class that would build and save a Car. There's no depende...

a succinct description of the factory design pattern

Hi all, Im having trouble getting my head around the concept of the factory design pattern. As far as i understand its to allow calling code not to have to worry about how an individual object is instantiated, simply to know that it will implement a particular interface. I cant see how this saves any code though. for instance, if i ...

Object factory which Creates objects that require dependencies

Currently in code i have used an object factory to return me a processor based of a string tag, which has severed its purpose up until now. using Core; using Data; public static class TagProcessorFactory { public static ITagProcessor GetProcessor(string tag) { switch (tag) { case "gps0": return new GpsTagProce...

Should the factory pattern be used to disable functionality?

I'm trying to get my head around the usage of the factory pattern, when I wish to disable features within an application. Lets say for example I have a factory called LoggerFactory, which creates a logger instance. If in the configuration logging is disabled in my application: Should the logger factory pass back an instance of the log...