Re: Switch statement alternative?



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

I may not understand your issue correctly, but it sounds as if you are
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.

.



Relevant Pages

  • Re: Change Text to Memo
    ... Sorry I didn't initially mention that the database is elsewhere. ... Switch a given table field to Memo ... Function SwitchFieldType(sDb As String, sTableName As String, sFieldName ... Dim sSQL As String ...
    (microsoft.public.access.modulesdaovba)
  • Re: same old "Data has been changed error message", way around this?
    ... form, closing the database, finding or moving to another record, setting the ... Im searching for records, viewing results in a listbox, ... -Wants to run a report of only SOME of the matching records, ... Ideally I would just switch this ...
    (microsoft.public.access.formscoding)
  • Re: Detecting Rogues from the wired side
    ... If you can get mac addresses from CAM table on the client switches (snmp ... Think about scenario where someone first plug the small switch and then ... Something which collects all these MAC's or internal database + ... Download FREE whitepaper on how a managed service can ...
    (Pen-Test)
  • RE: on/off option
    ... When i open page1 i have two links; one link will open asp pages viewing ... need to create some kind switch. ... I have created table in sql database, but you saying i don't have ... > For how long do you want to enable and disable access? ...
    (microsoft.public.frontpage.programming)
  • Some fields randomly not updated in INSERT and UPDATE
    ... I have 30 clients using this program. ... is happening in each client's database. ... and only once or twice will it not insert correctly. ... Blanks get inserted ...
    (microsoft.public.sqlserver.server)