473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Help with factory design

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.
Jun 19 '06 #1
2 1380
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!
*************************************************
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
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.

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

Thanks

"Cowboy (Gregory A. Beamer)" wrote:
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!
*************************************************
"Chris" <Ch***@discussions.microsoft.com> wrote in message
news:9F**********************************@microsof t.com...
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.


Jun 20 '06 #3

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

Similar topics

1
by: orel | last post by:
Please, As i tried hundreds different implementation to make it work and actually didn't succeed, can someone here help me to understand and use the implementation of the Object Factory design...
10
by: sunny | last post by:
Does this following program implement the factory design.if not what are things that i have to change in order to make this following program to be designed to factory design pattern. ...
2
by: NITHYA LATHA | last post by:
XYZ Company is a Car production company. It has four factories and many distribution outlets spread across the country. The company keeps online records of the sales of its cars. It also creates...
4
by: Pallav singh | last post by:
Hi , when should i select Factory Method / Prototype Design Pattern during my design phase ?? as both look similar to me Thanks in Advance Thanks Pallav
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...
0
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,...
0
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...

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.