Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Re-factoring
Message
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Title:
Environment versions
Environment:
C# 4.0
OS:
Windows 7
Network:
Windows 2003 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01577083
Message ID:
01577178
Views:
74
This message has been marked as a message which has helped to the initial question of the thread.
>One quick question - what would you use if you have 10 string columns (starttime1, starttime2, etc.)? I need some sort of the collection here, I am thinking about a dictionary of fields, but want to learn better alternative.
>

Since it looks like your code is running a loop across those fields, I'd probably create a List<DateTime> for them. That way I could just reference them by an index. A dictionary is really meant for when you want to do lookups by a "name" or some other unique key. You could do that by setting the key to "starttime1", "starttime2" but honestly that's just code you don't even need; an index into a List will work just fine.

I know you've gotten other feedback, but for porting VFP code to .NET I actually found it was easiest to convert the code almost as-is (I even just paste the VFP code into a comment in .NET). Then I'll start translating - that helps me to understand what the heck the code is supposed to do. Depending on what I'm doing I may decided it's easier to replace the VFP code with a stored proc. (or a view), especially in sections of code that do a lot of queries, then queries on the results of those queries, etc.

I also start refactoring the code like you're doing by looking for sections of code that may repeat themselves, or for sections of the code I'm finding difficult to understand - or even just read because of a lot of visual noise like your code that keeps casting DataRow fields to the correct type. The real trick is to keep refactoring it until it's cleaned up and not just stopping after the initial conversion (since that code is going to be REALLY ugly, probably really slow, and a maintenance nightmare).
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform