factory

Complicated .NET factory design

Hello SO; I'm planning to ask a fairly elaborate question that is also something of a musing here, so bear with me... I'm trying to design a factory implementation for a simulation application. The simulation will consist of different sorts of entities i.e. it is not a homogenous simulation in any respect. As a result, there will be nu...

Seam @Factory in abstract base class?

I've got a series of web actions I'm implementing in Seam to perform create, read, update, etc. operations. For my read/update/delete actions, I'd like to have individual action classes that all extend an abstract base class. I'd like to put the @Factory method in the abstract base class to retrieve the item that is to be acted upon. ...

How to delay static initialization within a property

I've made a class that is a cross between a singleton (fifth version) and a (dependency injectable) factory. Call this a "Mono-Factory?" It works, and looks like this: public static class Context { public static BaseLogger LogObject = null; public static BaseLogger Log { get { return LogFactory...

[Spring] Programatically creating an object?

Hi, Is there a way in Spring to get an object programatically as if it was injected by the xml file. Here is what i mean I have this class called securityDelegate. It's instances are always created by spring <bean id="securityDelegate" class="securityBusinessDelegate" lazy-init="true"> <property name="securityServiceEJB" ref="sec...

Turning my inherited classes in an Abstract 'factory' C#

Hi all, I'm not really pro and find my question quite hard to describe, so please ask if anything is unclear: I have an abstract class called BaseDevice. Other devices, as Beacon and Transponder, inherit from BaseDevice. For example the Beacon, it has the BaseClass methods PLUS its own properties and methods. Let's say, the difference ...

How to define factory methods in Groovy/Grails ?

I buid a factory in groovy, this code works, but I think, this code can be improved (or reduced) : abstract class Processing { abstract getDirName(); abstract getFileType(); abstract moveFile(); abstract processFile(); abstract openFile(); abstract closeFile(); } class ProcessingBuilder { def process...

Smalltalk equivalent of a factory method?

Are factory methods used in Smalltalk, and if so, how should one go about writing one, as opposed to how they would in Java, for example? Thanks. ...

How do you set specific properties to a class created by an abstract factory?

Is it possible to have concrete factories create concrete classes with type specific parameters for them using the abstract factory pattern? Or do the different concrete classes created by their respective concrete factories need to to have the same fields? Best regards, Christian ...

C++ factory function with boost::noncopyable

hello. Suppose I need to implement factory function which returns object O which inherits/has members inheriting from boost::noncopyable. struct O : boost::noncopyable {}; O factory() { return O(); } Obviously returning value fails to compile. What method do you know or use to implement such factory methods? I really like to avoid ...

Factory pattern implementation using ANSI C

Can anyone point me to a reference on how to implement the factory pattern using ANSI C? If more patterns are covered to that would just be a bonus. Doing this in C++ i trivial for me, but since C does not have classes and polymorphism I'm not quite sure how to do it. I was thinking about having a "base" struct with all the common data t...

Where to delete an object created by factory?

If I have a factory, that creates an object and returns a pointer to it, what will be a better way to delete it: By delete call in the "user" code, or by a new DestructObject function which I should have together with the factory? ...

Is factory method appropriate here?

I am generating a sequence of Step objects that differ by "Type" and data contained within. e.g: The Step objects should basically be structs that look like this { GRAB, CASCADE_ONE, FACEUP, SOMEOTHERDATA }, { DROP, DECK, FACEDOWN, MOREDATA, ANDSOMEMORE }, { MOVE, 34, 89 }, where GRAB, MOVE and DROP indicate StepType: typedef enum ...

Factory using categories for registering classes.

I want to create a factory that: - would create instance of object for some id (string), - would allow for class to register itself for an id. Currently this is implemented with centralized register of mapping. I would like to decentralize the register, so every class would register itself in its implementation file. My idea for this ...

Abstract static factory method [getInstance()] in Java?

Of course, the following doesn't work in Java (no abstract static methods)... public abstract class Animal { public abstract static Animal getInstance(byte[] b); } public class Dog extends Animal { @Override public static Dog getInstance(byte[] b) { // Woof. return new Dog(...); } } public class Cat ext...

Proper MXML Class Factory

I would really like to be able to write something like the following: <magical:ClassFactory id="factory"> <some:UIComponentOrWhatever with_event="handlers(event)" event_snippets="like.so()" code_values="{ foo + ' ' + bar }" bound_values="{bindabl...

What is the purpose of this code?

I am struggling to understand why the initialization of pprocessor, below, is written like this: class X { ... private: boost::scoped_ptr<f_process> pprocessor_; }; X:X() : pprocessor_( f_process_factory<t_process>().make() ) //why the factory with template {...} instead of just writing X:X() : pprocessor_( new t_process() ) {...

I'm playing around with different design patterns in Javascript. This factory has got me confused.

Hey Team, I'm playing around with different JS design patterns, and im trying to modify some samples I've seen out there. I saw an example of a xhr factory, that had several nested try/catch statements that were nested within eachother. try{ ... }catch(e){ try{ ... }catch(e){} } I figured I'd be able to do a self-invoking...

Creational Pattern: "Bastard Factory", a Abstract Factory spinoff

I am currently trying to figure out what the best way is to create my objects on my current PHP 5.2 project. I basicly have a Registry which returns objects by keys. If the Registry does not have an object with the specified key it will try to create one by calling a factory method that is supplied to the registry by construction. Look a...

How to name factory like methods?

I guess that most factory like methods start with create. But why are they called "create"? Why not "make", "produce", "build", "generate" or something else? Is it only a matter of taste? A convention? Or is there a special meaning in "create"? createURI(...) makeURI(...) produceURI(...) buildURI(...) generateURI(...) Which one would...

Usign traits with a factory

I'm currently discovering scala and I was wondering if I could use traits with a factory. I tried this : abstract class Foo { ... } object Foo { def apply() = new Bar private class Bar extends Foo { ... } } Foo() with MyTrait // Not working I guess it's because with must be preceded by new. So is there any way to do t...