Help with factory design

G

Guest

Hi,
I have been stuck trying to come up with a design for days. I am working on
a small project regarding barcode and I want to implement a factory design. I
am now confused.

I decided factory pattern since I am dealing with EAN13, UPCA12 UPC8 etc.
Can someone provide a small sample on how to start. I have looked at the
factory implementation online but still can't figure it out. Can someone
provide a sample jsut to start with.

I was trying this:

Public Interface IBarcodeFactory

Function CalculateDigit() As Integer

Property ProductType()
Property ManufactureCode()
Property ProductCode()
Property CountryCode()
Property CheckSumDigit()


End Interface



Public Class BarcodeUPCA12

Implements IBarcodeFactory


End Class


Public Class BarcodeFactory

Public Shared Function GetFactory(ByVal factoryType As
BarcodeFactoryType) As IBarcodeFactory


End Class


Please help. I am really confused here.
 
C

Cowboy \(Gregory A. Beamer\)

You have two choices:

1. Interfaces - if the implementations are all extremely different
2. Base class - if there is some common implementation code

You then create a class for each type of bar code. That covers the classes.

For the factory, the normal pattern is abstract factory calling concrete
factories. The Abstract Factory will pass back the Interface or base class.
The concrete factory is responsible for each type of object. You can combine
both types of factories into a single factory class, but think it through
before heading this direction, as you may have to refactor it back out
later.

I would suggest looking at
http://www.dofactory.com/Patterns/PatternFactory.aspx

If you are C# illiterate, create a C# project and copy the code. Compile and
then reverse engineer into VB.NET with Reflector (a must have tool):
http://www.aisto.com/roeder/dotnet/

There are also C# to VB.NET translator web pages on the net.

--
Gregory A. Beamer

*************************************************
Think Outside the Box!
*************************************************
 
G

Guest

I still can't get this figured out. Can I send you my project for you to take
a look?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top