473,770 Members | 1,799 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 #1
16 2646
On May 15, 1:21 pm, "RSH" <way_beyond_o.. .@yahoo.comwrot e:
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.
Suppose you had encapsulated your data access into an interface, and
had implemented that interface for Oracle, SQL Server etc.

The abstract factory pattern would give you a central factory to call
which would in turn call the appropriate concrete factory depending on
configuration.

At least, that's the way I understand it.

Jon

May 15 '07 #2
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** *************@q 75g2000hsh.goog legroups.com...
Suppose you had encapsulated your data access into an interface, and
had implemented that interface for Oracle, SQL Server etc.

The abstract factory pattern would give you a central factory to call
which would in turn call the appropriate concrete factory depending on
configuration.

At least, that's the way I understand it.
Yes indeed.

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...?
--
http://www.markrae.net

May 15 '07 #3
On May 15, 1:49 pm, "Mark Rae" <m...@markNOSPA Mrae.netwrote:
At least, that's the way I understand it.

Yes indeed.

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...?
I believe the references will only be fetched when they're first
actively used. That's what I'd hope, anyway - I haven't actually tried
it :)

I'm sure with suitable levels of indirection it should be okay.

Jon

May 15 '07 #4
RSH
I almost understand that.

Are there any tutorials you know of that illustrate this concept?

Thanks,
Ron
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** *************@q 75g2000hsh.goog legroups.com...
On May 15, 1:21 pm, "RSH" <way_beyond_o.. .@yahoo.comwrot e:
>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.

Suppose you had encapsulated your data access into an interface, and
had implemented that interface for Oracle, SQL Server etc.

The abstract factory pattern would give you a central factory to call
which would in turn call the appropriate concrete factory depending on
configuration.

At least, that's the way I understand it.

Jon

May 15 '07 #5
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** *************@h 2g2000hsg.googl egroups.com...
I believe the references will only be fetched when they're first
actively used. That's what I'd hope, anyway - I haven't actually tried
it :)
Hmm - I'm sure that's correct, although I've never tried it either!
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...

Therefore, I have four quite separate DALs - SqlClient, OleDb, MySql and
most recently SqlCe...

I guess an abstract factory pattern might be more efficient as far as
development goes, but I'm not sure there's much point in a client receiving
a bespoke app with redundant code...
--
http://www.markrae.net

May 15 '07 #6
Hi,

Buy the Design Pattern book :
http://www.amazon.com/Design-Pattern...9238351&sr=8-1

There you will find a good example of how to use each pattern based on a
Text Editor.

IIRC the example there is to how to handle different UI libraries without
modifying the code, let's say you want a program to run on MacOS, Win,
Linux, etc. You know that each of these system implement the same set of
controls (TextBox, CheckBox, ListBox,etc)
in such a way that you can declare an anbstract class (or inteface).

Your code does not need to know which one especifically is being used. It
just request an instance of ITextbox and the factory returns an instance of
it. Depending of what library is in used you get a instance of a Textbox of
the running system(MacOS, Win, Linux).

Take also a look at wikipedia, they have good articles explaining the
differents patterns.
"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 #7
Hi,

"RSH" <wa************ *@yahoo.comwrot e in message
news:eS******** ******@TK2MSFTN GP03.phx.gbl...
>I almost understand that.

Are there any tutorials you know of that illustrate this concept?
The original book (see my other email) about Design pattern has a very
extense example using a Text Editor.

Also google for the desired pattern and you will get several examples
May 15 '07 #8
Hi,

"Mark Rae" <ma**@markNOSPA Mrae.netwrote in message
news:%2******** ********@TK2MSF TNGP03.phx.gbl. ..
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** *************@q 75g2000hsh.goog legroups.com...
>Suppose you had encapsulated your data access into an interface, and
had implemented that interface for Oracle, SQL Server etc.

The abstract factory pattern would give you a central factory to call
which would in turn call the appropriate concrete factory depending on
configuratio n.

At least, that's the way I understand it.

Yes indeed.

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
May 15 '07 #9
Hi,

"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** *************@h 2g2000hsg.googl egroups.com...
On May 15, 1:49 pm, "Mark Rae" <m...@markNOSPA Mrae.netwrote:
At least, that's the way I understand it.

Yes indeed.

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...?

I believe the references will only be fetched when they're first
actively used. That's what I'd hope, anyway - I haven't actually tried
it :)
You are correct, I have one app that use VFP and when I install it on a
machine without the OLEDB provider I get the error when I first try to use
the provider.
May 15 '07 #10

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
3354
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
4626
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
9617
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
10257
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
10037
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,...
0
9904
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8931
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6710
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
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
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
3609
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.