PDA

Click to See Complete Forum and Search --> : Singleton Design Pattern & Facade Pattern


shutty
May 7th, 2003, 08:43 AM
An interesting FAQ about the singleton design pattern. The examples are in C# altho the VB.NET implementation is very similar. (one difference is I tend to use the Mutex class rather than the VB Synclock or lock in C#)

Singleton Design Pattern (http://www.devcity.net/forums/faq.asp?fid=30&cat=General&#TID25632)

Edneeis
May 7th, 2003, 11:16 AM
It seems easier to make good use of shared methods although I could see how that may not fit every situation.

shutty
May 7th, 2003, 11:27 AM
The product I'm involved with uses a singleton to control access to a database. Once the user starts up the application a connection is made. Only one connection is allowed and the use of a singleton ensures that the connection object cannot be created multiple times. Therefore the connection handle retrieved is guarenteed to be the correct one.

Of course shared methods are still used for other tasks when the uniqueness of the object is not as important.

VBCrazyCoder
May 7th, 2003, 12:55 PM
And it's so easy to do! Sweet.

A pattern that I always use is Facade. The intent of the Façade design pattern is to provide a unified interface to a set of interfaces in a sub system. Using the facade pattern basically defines a high level interface that makes the subsystem easier to use.

This ultimately serves to reduce complexity, and to minimize the communication and dependencies between subsystems.

I can ALWAYS find a case to use this in every application - such as using a facade handle all database interaction.

Edneeis
May 7th, 2003, 01:09 PM
Can you give us an example of a Facade Pattern or links to info on it?

VBCrazyCoder
May 7th, 2003, 03:47 PM
Couldn't actually find any good links in English - but I reference the GOF's book - "Design Patterns" ISBN 0201633612.

shutty
May 8th, 2003, 04:30 AM
This site has a few links about it. (http://www.instantiations.com/codepro/ws/docs/features/patterns/facade_pattern.html#Applicability) Haven't actually looked at them all so don't know how good they'll be.

I tend to use the books below...

Amazon link to VB Design Patterns Book (http://www.amazon.com/exec/obidos/tg/detail/-/1861006985/qid=1052382160/sr=1-2/ref=sr_1_2/002-4606469-8916801?v=glance&s=books)

Amazon link to the 'bible' of all Design Pattern books. (http://www.amazon.com/exec/obidos/tg/detail/-/0201633612/qid=1052382485/sr=1-2/ref=sr_1_2/002-4606469-8916801?v=glance&s=books)

jaycee
May 30th, 2003, 10:25 AM
You could also look at :

http://www.dofactory.com/patterns/Patterns.aspx