Re: Switch statement alternative?
- From: "Phuff" <pc.huff@xxxxxxxxx>
- Date: 17 Oct 2006 09:49:06 -0700
I just solved my problem. I will replace the blanks in the database
with tokens...%exteriorFin% or %interiorFin% or %wallThick% or
%panelHeight% etc etc. Then I just need to write a simple parser to
replace those tokens instead of generic blanks. thanks!!
Phuff wrote:
Thanks for the responses. I'm reading the deswign practices right
now...this is the type of answer I was looking for, thank you.
As to pvdg42: No, I am not storing data in my runtime. The data is
stored in SQL Server. I am trying to automate the generation of a
materials list for a manufacturing company that has one standard: there
are few standards and everything is customizable. I get the parts for
each job based on xml files etc etc....anyway now that I have all the
parts I need to calculate quantites. Some of the parts need their
descriptions altered based on what's going on with the job...for
instance a dimension based on the thickness of the wall, a color based
on surrounding panel finishes. We want this list to be 100% automatic
so I need to replace the blank received from the db with the proper
descrtiption. Almost every part is very different and based on a
combination of different factors. My problem was, How do I code for
this without the need to change the code for each part that might
change in the future. The book chapter and information from the first
response's links is, seeming, what I need. I'll post if I have any
other questions
Thanks!
pvdg42 wrote:
"Phuff" <pc.huff@xxxxxxxxx> wrote in message
news:1161098675.292520.69190@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hey all, I need some direction help. I have a switch case statementI may not understand your issue correctly, but it sounds as if you are
that is seemingly my only option right now, but its too large and not
easy to maintain the code. Here goes...
I have part descriptions (ie. 3/8" X ____" NYLON ALL-THREAD RODS...or
____" x ____" X ____" ____ WRAPPED MULLION) that I need to replace the
blank lines on. I do a switch on the part id.
I have 53 in all out of the parts list. What fills the blank is
dependent on information specific to the customized product being
built. Getting the information is not a problem...the problem is that
I cannot do any generalization. Almost every part is different and
what information the blank is based on is different for each part. I
have no generalized function aside from the one that fills the blank.
I just do a switch statement and have specialized business logic code
for each part.
I'm sure you can see the problem...what happens if we change a part
description in the system, or add a new part, or remove one? I have to
change the code. This is not the best practice, but I see no
alternative at the moment. Everything is so freaking customizable
here! Please help, any ideas?
embedding data in the code in your switch?
Given that you have 53 + or - part numbers with multiple data fields
associated with each part, can you not use a struct or some other ADT to set
up a description of each part, then use a collection that allows key-value
pairs (part number being the unique key) to manage the structs in memory?
If you need to store the part info between program runs, a file or database
table that can be read into your collection at program start should work.
That way changes to the data are made to the file/table and your code does
not change.
.
- References:
- Switch statement alternative?
- From: Phuff
- Re: Switch statement alternative?
- From: pvdg42
- Re: Switch statement alternative?
- From: Phuff
- Switch statement alternative?
- Prev by Date: Re: Switch statement alternative?
- Next by Date: Re: Application.DoEvents()
- Previous by thread: Re: Switch statement alternative?
- Next by thread: Re: Switch statement alternative?
- Index(es):
Relevant Pages
|