Factory methods
 
Home My Account Forum Try It! Buy It!
About Contact Us Site Map
StrataFrame Forum
Home      Members   Calendar   Who's On
Welcome Guest ( Login | Register )
      



Factory methodsExpand / Collapse
Author
Message
Posted 03/18/2008 2:45:12 AM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: Today @ 12:54:47 AM
Posts: 115, Visits: 345
In Strataframe documentation, I couldn't find any related information about this topic ?

Could you give us some information ?

Post #14980
Posted 03/18/2008 8:52:59 AM


StrataFrame Developer

StrataFrame Developer

Group: StrataFrame Developers
Last Login: 06/17/2008 9:28:35 AM
Posts: 2,649, Visits: 1,863
There isn't really any information about factory methods in the documentation.  But, creating one would be really simple.  You would want to make the method shared/static, create a new instance of the business object, populate it with the required data, and return it.

public static MyBO SomeFactoryMethod(string param1)
{
    MyBO bo = new MyBO();

    //-- fill the bo

    return bo;
}


www.bungie.net
Post #14983
Posted 03/18/2008 10:33:54 AM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: Today @ 12:54:47 AM
Posts: 115, Visits: 345

From your Web Site ;

"Factory Methods -– Constructors are provided by the BusinessLayer base class that allows the developer to implement custom factories or shared factory methods directly on the business object class."

What is the advantage of Factory Methods ? Could you give me a little bit further information ?

Post #14987
Posted 03/18/2008 4:54:17 PM
StrataFrame VIP

StrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIPStrataFrame VIP

Group: StrataFrame Users
Last Login: 2 days ago @ 3:11:51 PM
Posts: 1,148, Visits: 2,831
I obviously can't speak to what is on the SF web site, but I can let you know how I use factory methods.

Typically I use them in one of two situations:

- There are bunch of ways that an object can be created and constructor overloads are either confusing or don't work (because the arguments wouldn't be unique). In this case it is much easier to create shared (static) factory methods that have clear names and precise arguments. I use it a lot with Forms. I.e. I have a form that can be opened with a single record, or in data entry mode, or with all records that match some criterion and the current record being specified. I could have constructors something like:
public MyForm() {}
public MyForm(int id) {...}
public MyForm(bool dataEntry) {...}
public MyForm(int parentID, int id) {...}


But this is confusing and I have trouble remembering all the permutations. So, instead I would create a set of factory methods:
public static MyForm CreateSingleEdit(int id) {...}
public static MyForm CreateDataEntry() {...}
public static MyForm CreateParentEdit(int parentID, int idToNav) {...}


Now I have no limitation on how complex the constructor is and I have help remembering how I have setup a class.

Hope that provides a bit of clarity. I'm sure others have more/better examples, but I thought I'd get the ball rolling!
Post #15000
Posted 03/19/2008 2:19:00 AM
StrataFrame Novice

StrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame NoviceStrataFrame Novice

Group: StrataFrame Users
Last Login: Today @ 12:54:47 AM
Posts: 115, Visits: 345
Thanks
Post #15009
« Prev Topic | Next Topic »


Reading This TopicExpand / Collapse
Active Users: 0 (0 guests, 0 members, 0 anonymous members)
No members currently viewing this topic.
Forum Moderators: Ben Chase, Trent L. Taylor, Steve L. Taylor

PermissionsExpand / Collapse

All times are GMT -6:00, Time now is 2:35am

Powered By InstantForum.NET v4.1.4 © 2008
Execution: 0.063. 9 queries. Compression Enabled.
Site Map - Home - My Account - Forum - About Us - Contact Us - Try It - Buy It

Microsoft, Visual Studio, and the Visual Studio logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.