Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6959821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:19:22+00:00 2026-05-27T15:19:22+00:00

I have a console app, the central process of which is to get the

  • 0

I have a console app, the central process of which is to get the next line from a DB table, and based on a field value, run one of several bits of code which all return the same type o object. I could have a switch or if statement type arrangement, which does something like (pseudo code):

if exhibitType == "Summary" then AddSummaryExhibit
elseif exhibitType == "Timeline" then AddTimelineExhibit

… etc. Almost like the routing setup in MVC websites. This program does follow an approximate MVC type structure, with each method getting data from a model, rendering HTML based on a .cshtml razor view and appending it to a collection of ‘sections’ that belong to a HTML document container.

Ideally it’d be nice just to add a new method of name x to my project and then allow x to be added as a new value in the db table without having this manually maintained set of conditionalities. I was thinking maybe delegates or somesuch might apply here, but that’s just a thought. Any tips on best practice would be appreciated.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T15:19:23+00:00Added an answer on May 27, 2026 at 3:19 pm

    I believe you are looking for has already been answered here in the thread talking about long switch statements: How to avoid long switch ..need help refactoring

    In effect, you are looking for a gang of four pattern. The patterns that come to mind are the strategy pattern, state pattern and chain of responsibility pattern.

    These patterns can be quite challenging to think about how they would work for your requirements, but its a huge step in a good direction by identifying a need for modularity and that you aren’t getting it from your switch statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a console based c app . I am executing it from c#
I have Java console app, which i want to control from another computer. I
I have a console based c app . I am executing it from c#
I have a console app that performs a lengthy process. I am printing out
As the title states, I have a C# console app which uses interop to
I have a console command line app that use NHibernate . I am trying
I have a c# method in console app X this starts a process; console
I have a console app on the server that I need to run between
I have a console app (written in c#) that is passed various arguments from
I have a console app that will choose records based on if the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.