Entity Factory

Posts   
 
    
Krish
User
Posts: 91
Joined: 02-Jan-2008
# Posted on: 05-Feb-2008 12:25:57   

What is the purpose of the GetEntityFactory method in a entity class. How do you use it. If possible give simple code examples.

How and when are we supposed to use the generated Factory classes.

Version of LLBLGen Pro 2.5. Self servicing 2 class template. C# and .Net 2.0.

Thanks.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39887
Joined: 17-Aug-2003
# Posted on: 05-Feb-2008 13:25:54   

What's the problem you're trying to solve? GetEntityFactory is precisely doing what it says: it returns the factory which can create instances of the type of the entity.

Frans Bouma | Lead developer LLBLGen Pro
Krish
User
Posts: 91
Joined: 02-Jan-2008
# Posted on: 05-Feb-2008 20:51:12   

I am not trying to solve any problem but trying to understand how you have implemented the factory design pattern. For example, one definition of factory design pattern is :

Defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory method lets a class defer instantiation to subclasses.

I am trying to study and understand above definition with your implementaion of GetEntityFactory.

Walaa avatar
Walaa
Support Team
Posts: 14994
Joined: 21-Aug-2005
# Posted on: 06-Feb-2008 10:01:27   

Please search for it in the Source COde of the runtime libraries. Some usage examples would be in Serialization, creating EntityCollections, and in Fetching a new entity of some type (in the DataAccessAdapter)

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39887
Joined: 17-Aug-2003
# Posted on: 06-Feb-2008 13:52:40   

Krish wrote:

I am not trying to solve any problem but trying to understand how you have implemented the factory design pattern. For example, one definition of factory design pattern is :

Defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory method lets a class defer instantiation to subclasses.

I am trying to study and understand above definition with your implementaion of GetEntityFactory.

The factories are just used to produce entity instances. For example if you fetch a collection of entities, the factories are used to produce new instances to store the data in.

There are a couple of different factory implementations, we use the simple one, as life's already complicated enough wink . I.o.w.: not abstract factory pattern, just factory pattern.

Frans Bouma | Lead developer LLBLGen Pro
Krish
User
Posts: 91
Joined: 02-Jan-2008
# Posted on: 06-Feb-2008 21:20:36   

Thank you for the interesting replies. I guess you are following the KIS principle which is great.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39887
Joined: 17-Aug-2003
# Posted on: 06-Feb-2008 22:46:25   

Krish wrote:

Thank you for the interesting replies. I guess you are following the KIS principle which is great.

That's right simple_smile

Frans Bouma | Lead developer LLBLGen Pro