Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
MM .NET Tip 'O The Day - Understanding Factories
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Title:
MM .NET Tip 'O The Day - Understanding Factories
Miscellaneous
Thread ID:
00804176
Message ID:
00804176
Views:
49
At the Advisor DevCon this year an attendee walked up to our booth and said "I don't like Frameworks because they force you to do things their way", and then walked away...OK, then <g>!

In reality, I completely understand this sentiment. That's why when I'm adding a new feature to Mere Mortals, I'm always thinking "someone isn't going to want to do it this way", and I work to make it easy to alter or extend default Framework behavior.

One high-level way we do this is by means of our Factory object. MM .NET has a number of manager objects that provide key services for your applications, such as:

* Application Settings Manager
* Database Manager
* User Manager
* Security Manager
* Form Manager

These manager objects can be accessed from static properties of your Windows Forms or ASP.NET application object.

The MM .NET Factory is a standard "Gang-of-Four" design pattern that allows you to instantiate your own specialized version of these components.

For example, let's say you enhance the MM .NET Database Manager by creating a subclass and extending a few of its methods. Now you need to find the line of code in MM .NET that instantiates the Database Manager, and change it so it instantiates your custom manager instead. If MM .NET buried this line of code within a Framework method, you'd be out of luck. However, this single line of code has been surfaced in the "CreateDatabaseManager()" method of the Factory class. All you have to do is override this single method and return an instance of your custom Database Manager.

For more specifics on how to do this, check out the MM .NET Help topic "The Factory Object", and check out the step-by-step instructions under the heading "Overriding Factory Methods".

Regards,
Kevin McNeish
Eight-Time .NET MVP
VFP and iOS Author, Speaker & Trainer
Oak Leaf Enterprises, Inc.
Chief Architect, MM Framework
http://www.oakleafsd.com
Next
Reply
Map
View

Click here to load this message in the networking platform