| | | StrataFrame User
       
Group: StrataFrame Users Last Login: Yesterday @ 2:01:52 AM Posts: 129, Visits: 394 |
| | In Strataframe documentation, I couldn't find any related information about this topic ? Could you give us some information ? |
| | | | 
StrataFrame Developer

Group: StrataFrame Developers Last Login: Today @ 9:09:33 AM Posts: 2,661, Visits: 1,876 |
| | 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 |
| | | | StrataFrame User
       
Group: StrataFrame Users Last Login: Yesterday @ 2:01:52 AM Posts: 129, Visits: 394 |
|
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 ? |
| | | | StrataFrame VIP
       
Group: StrataFrame Users Last Login: Today @ 7:29:55 PM Posts: 1,168, Visits: 2,931 |
| 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! |
| | | | StrataFrame User
       
Group: StrataFrame Users Last Login: Yesterday @ 2:01:52 AM Posts: 129, Visits: 394 |
| | |
|
|