473,785 Members | 2,299 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Understanding Abstract Factory Pattern

RSH
Hi,

I am a fairly seasoned developer and have recently started looking at
software design patterns. I am starting with the Abstract Factory Pattern
and was wondering if someone could help me understand where I might use this
Pattern. I get the general concept but I am having a hard time converting
that concept into where I might use that in a real world scenerio for a
business application or web development project.

I appreciate the fact that this is a conceptual question, and I appreciate
your time.

Thank you!
Ron
May 15 '07
16 2647
RSH
So correct me if Im wrong....

The Abstract Factory is really like a runtime switch that instntiates the
appropriate class based on the conditions at run time. It encapsulates not
only the classes but the logic associated with selecting the appropriate
class to create the object.

The use of an interface further promotes loose coupling between the factory
and the underlying classes.

I can see the usefullness in this for sure.

Ron
"RSH" <wa************ *@yahoo.comwrot e in message
news:eB******** ******@TK2MSFTN GP03.phx.gbl...
Hi,

I am a fairly seasoned developer and have recently started looking at
software design patterns. I am starting with the Abstract Factory Pattern
and was wondering if someone could help me understand where I might use
this Pattern. I get the general concept but I am having a hard time
converting that concept into where I might use that in a real world
scenerio for a business application or web development project.

I appreciate the fact that this is a conceptual question, and I appreciate
your time.

Thank you!
Ron

May 15 '07 #11
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
message news:Od******** ******@TK2MSFTN GP04.phx.gbl...
>What happens when you add a provider that's not part of the "standard"
.NET Framework, e.g. MySQL or SqlCe...?

If your DAL factory includes SqlClient, Oracle *and* MySQL and you try to
run it on a machine which doesn't have the MySQL .NET native data
provider, won't your app fall over due to missing references etc...?

Yes, it will fail at runtime. It will fail when you first try to use it
Just to clarify, does that mean the app will fail the first time it tries to
use any part of the DAL...?

E.g. if your DAL supports both SqlClient and SqlCe, can you still use the
SqlClient "bits" even if the SqlCe runtime isn't installed...?
--
http://www.markrae.net

May 15 '07 #12
Hi,

"Mark Rae" <ma**@markNOSPA Mrae.netwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
message news:Od******** ******@TK2MSFTN GP04.phx.gbl...
>>What happens when you add a provider that's not part of the "standard"
.NET Framework, e.g. MySQL or SqlCe...?

If your DAL factory includes SqlClient, Oracle *and* MySQL and you try
to run it on a machine which doesn't have the MySQL .NET native data
provider, won't your app fall over due to missing references etc...?

Yes, it will fail at runtime. It will fail when you first try to use it

Just to clarify, does that mean the app will fail the first time it tries
to use any part of the DAL...?
The application will fail when you first try to use any feature not
currently present in the machine.

In my example if I have no registered the OleDB provider for VFP
(vfpoledb.dll) the application throw an exception when I try to create it
:OleDbConnectio n conn = new OleDbConnection ("......");
May 15 '07 #13
"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
message news:ed******** *****@TK2MSFTNG P03.phx.gbl...
"Mark Rae" <ma**@markNOSPA Mrae.netwrote in message
news:%2******** ********@TK2MSF TNGP05.phx.gbl. ..
>"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote
in message news:Od******** ******@TK2MSFTN GP04.phx.gbl...
>>>What happens when you add a provider that's not part of the "standard"
.NET Framework, e.g. MySQL or SqlCe...?

If your DAL factory includes SqlClient, Oracle *and* MySQL and you try
to run it on a machine which doesn't have the MySQL .NET native data
provider, won't your app fall over due to missing references etc...?

Yes, it will fail at runtime. It will fail when you first try to use it

Just to clarify, does that mean the app will fail the first time it tries
to use any part of the DAL...?

The application will fail when you first try to use any feature not
currently present in the machine.

In my example if I have no registered the OleDB provider for VFP
(vfpoledb.dll) the application throw an exception when I try to create it
:OleDbConnectio n conn = new OleDbConnection ("......");
OK - thanks very much...
--
http://www.markrae.net

May 15 '07 #14
Mark Rae <ma**@markNOSPA Mrae.netwrote:
I'm sure with suitable levels of indirection it should be okay.

All my work tends to be targeted at one specific RDBMS - I've never been
asked to write anything which supported multiple providers...
I've only done one project which really needed it, but then we used
Hibernate so we didn't have our own abstract factory anyway. We only
needed two types of servers for production - Oracle and SQL server -
but we developed and ran unit tests against HSQLDB as well, which was
blindingly fast and therefore great for unit tests.

It's certainly interesting writing multi-backend solutions.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
May 15 '07 #15


There is a difference between the Simple Factory Pattern
and the Abstract Factory Pattern.

I'm very good with the Simple (of course, its simple) pattern.

The Abstract one illudes you for a while, but you can get it.

http://www.dofactory.com/Patterns/PatternAbstract.aspx
but the example is a not so crystal clear.

I have a java book at home ... that gave me an example that I could finally
figure it out.
Let me know if you're interested in the ISBN.

"RSH" <wa************ *@yahoo.comwrot e in message
news:Om******** ******@TK2MSFTN GP06.phx.gbl...
So correct me if Im wrong....

The Abstract Factory is really like a runtime switch that instntiates the
appropriate class based on the conditions at run time. It encapsulates
not
only the classes but the logic associated with selecting the appropriate
class to create the object.

The use of an interface further promotes loose coupling between the
factory
and the underlying classes.

I can see the usefullness in this for sure.

Ron
"RSH" <wa************ *@yahoo.comwrot e in message
news:eB******** ******@TK2MSFTN GP03.phx.gbl...
Hi,

I am a fairly seasoned developer and have recently started looking at
software design patterns. I am starting with the Abstract Factory
Pattern
and was wondering if someone could help me understand where I might use
this Pattern. I get the general concept but I am having a hard time
converting that concept into where I might use that in a real world
scenerio for a business application or web development project.

I appreciate the fact that this is a conceptual question, and I
appreciate
your time.

Thank you!
Ron


May 15 '07 #16
I've recently posted to my blog regarding this pattern, take a look
there are a couple of good examples on this topic:
http://ehsanbraindump.blogspot.com/2...actory_21.html

I'm also going to post another post there in the next few days that will
complete the discussion. Be sure to return in a few days.
*** Sent via Developersdex http://www.developersdex.com ***
May 24 '07 #17

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
6646
by: Medi Montaseri | last post by:
Hi, Given a collection of similar but not exact entities (or products) Toyota, Ford, Buick, etc; I am contemplating using the Abstraction pattern to provide a common interface to these products. So I shall have an Abstract Base called 'Car' implemented by Toyota, Ford, and Buick. Further I'd like to enable to client to say Car *factory;
4
2527
by: max | last post by:
Hello, I analyze this design pattern for a long time but I do not understand how this pattern work and what the purpose is? (I looked a this site http://www.dofactory.com/Patterns/PatternAbstract.aspx). Could anybody try to explain me in his own words how this pattern work and what the purpose is? thanks in advance
33
3355
by: Chris Capel | last post by:
What is the rationale behind the decision not to allow abstract static class members? It doesn't seem like it's a logically contradictory concept, or that the implementation would be difficult or near-impossible. It seems like it would be useful. In fact, there's a place in my code that I could make good use of it. So why not? Chris
2
1759
by: Julia | last post by:
Hi, I have an application composed from layers like the following A --B ---C A is the top layer C uses an Abstract Factory to Create Concrete classes
3
1819
by: Christer | last post by:
Hi all! We're creating an administration for a web application. This includes severeal aspx pages. Our key entity in the web application is "Profile", which can have a certain type. Based on the profile type, the administration pages will have some small changes, such as displaying a few extra tabs, or maybe change the available choices in a dropdown.
2
2567
by: Duy Lam | last post by:
Hi everyone, Sorry, I don't know what group to post this problem, I think may be this group is suitable. I'm styduing DAO (Data Access Object) pattern in this link http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html. While I've read about implementing Data Access Objects by Factory Method Pattern (http://java.sun.com/blueprints/corej2eepatterns/Patterns/images09/figure09_07.gif) and Abstract Factory Pattern...
3
4627
by: suresh_rai | last post by:
Hello I am hoping someone can give me very needed help. I am wanting some C+ + code for 'C++ Abstract Factory'. I need code to be free. I am been learning Design patterns. I found some code on web but dont know which is one is ok. http://programmerjoe.com/2007/03/18/the-abstract-factory-pattern-in-c/ http://www.codeproject.com/KB/architecture/DesignPattern.aspx Loki :in text book http://sourceforge.net/projects/papafactory
4
1981
by: C# | last post by:
http://www.questpond.com/FreeDesign1.htm I was going through the above videos. Can i conclude Abstract factory patterns are extensions of factory patterns. I have made the conclusion after viewing the video and reading GOF books. I am confused by these two patterns.
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9485
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6743
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.