Print Page | Close Window

Create vs Construct

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2009
Forum Discription: For .NET 3.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=1132
Printed Date: 02-May-2025 at 4:48am


Topic: Create vs Construct
Posted By: ken.nelson
Subject: Create vs Construct
Date Posted: 11-Mar-2009 at 4:21am
Hi,
 
Just wondering what your current thoughts are regarding constructor overloading versus using static create methods.  If I recall right, in DevForce classic, using static create methods was the preferred way and was explicitly noted as such.  However, in DevForce EF I'm not seeing any specific information regarding this.
 
The problem I always had with using static Create methods was that it made it impossible to use object initializers, so I'd prefer to overload constructors, but is there a reason why this might be a bad idea with DevForceEF?
 
Thanks,
Ken



Replies:
Posted By: kimj
Date Posted: 12-Mar-2009 at 4:32pm
DevForce EF allows entity creation via a standard constructor, which DevForce Classic does not allow, so the static Create factory methods defined in each entity were one way of highlighting the issue.  In DevForce EF, "new"ing an Entity is allowed, and we're also more enthusiastic about using the Repository and other pertinent patterns.   Our intention really isn't to force you into any pattern.   Overloaded constructors work fine in DevForce EF, just be sure that you call AddToManager to make the new entity part of an EntityManager cache.



Print Page | Close Window