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

  • Home
  • SEARCH
  • 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 593019
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T15:48:03+00:00 2026-05-13T15:48:03+00:00

Say you have an abstract base class Task which is a task a user

  • 0

Say you have an abstract base class Task which is a task a user can complete. There are two concrete Tasks: SimpleTask and ChecklistTask. What if you wanted the (ASP.NET) UI to show a different control based on which type of Task it is?

In WPF you could use DataTemplates, but what is a nice way to do it in ASP.NET? We are trying to avoid a switch statement by the way. We have other pieces of code with long switch statement which started out small, but grew in time. That’s what we’re trying to avoid.

Is there a design pattern for things like this? We can’t let the Task classes ‘know’ the UI classes because they’re are domain classes. Or is a switch statement the best we can do (if necessary hidden in a seperate ‘factory’ class)?

  • 1 1 Answer
  • 3 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-13T15:48:04+00:00Added an answer on May 13, 2026 at 3:48 pm

    Something, somewhere, has to know how to map the Task subclass to the UI control. Period. The only question is where to put this knowledge.

    1. The Task itself
    2. A class that can use data retrieved from the Task to find an appropriate control
    3. The code that actually gives the Task out (why can’t it give the UI control instead?)
    4. Some code that maps the Task class to the UI control, possibly via attributes and reflection.
    5. Some other kind of metadata.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have an abstract class Base, of which another abstract class Subclass extends.
Let's say I have a Java class abstract class Base { abstract void init();
Say we have a class inheriting from two base classes (multiple inheritance). Base class
Say we have an abstract base class IBase with pure virtual methods (an interface).
Say I have a abstract base class and I want to have a pure
Let's say I have an abstract parent class called shape, and that there are
As you can see in the code below, I have an Abstract Base Class
Let's say I have this base class: abstract public class Base { abstract public
Say I have an abstract base class BaseClass . I'd like to give it
Lets say I have an abstract base class with a pure virtual that returns

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.