1

While writing a data mapping function (import from csv (using TextFieldParser) to table), I used the sql table structure to generate the boilerplate C# code that creates the datatable and populates it (4-500 lines of code) reading from the string array that the TextFieldParser returns. Now I am considering creating a table that contains the meta-information and C# code that processes that directly.

Having it as a table will make it more flexible in the future (if the app lasts long enough, the data that gets imported will almost certainly change), on the other hand it is unlikely to have major changes, adding or removing a column or two at most.

Which would be easier to maintain?

  • 4
    There isn't enough information here about your specific project to make your question meaningfully answerable. The only reasonable answer to your current question is "it depends." – Robert Harvey Dec 6 '14 at 19:24
  • Also, for what it's worth, check out FileHelpers. The author has already done a pretty good job doing what your describing. – Robert Harvey Dec 6 '14 at 19:26
  • Saw your edit. What prevents you from simply re-generating the boilerplate code if the SQL table structure changes? – Robert Harvey Dec 7 '14 at 17:00
  • @RobertHarvey: I was thinking in terms of someone else picking it up. I haven't encountered a lot of people that do their own code generation, data driven seems a bit more common. – jmoreno Dec 7 '14 at 18:23
  • Code generation occurs in UI designers, object-relational mappers, Reflection accelerators, domain-specific languages, and anywhere you'll find a mapping, import or conversion function. It's much more common than you think it is. – Robert Harvey Dec 7 '14 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.