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 926703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T19:43:38+00:00 2026-05-15T19:43:38+00:00

I tend to have a class to describe a general concept and subclasses to

  • 0

I tend to have a class to describe a general concept and subclasses to describe variances in that concept. For example, Polygon <|– {Rectangle, Triangle, etc.}.

However, I often find I have various representations of these hierarchies. For example, I want to keep the graphical representation (eg, a QPolygon), or the physical representation (mass, centerOfMass), etc. separate from another representation I have.

In my case, I have a hierarchy of purely-data objects (Command <|– {WaitCommand, UnknownCommand, etc.}) and I have a matching GUI representation for each of the data classes (WaitCommandPanel, UnknownCommandPanel).

My problem is that once I construct the data representation I need to make the leap from the data to the GUI.

Given a list of data objects, I want to be able to construct the corresponding GUI elements but keep the two representations separate.

One [lousy] solution would be for each Command to have the ability (ie, Command::getPanel()) to return its GUI representation. I don’t like this because my data classes now have representation code in them.

The other solution (which I’ve adopted for the time being) is to do a lookup. That is, when initiating the GUI, given a list of Commands (the generalization), the function determines what object to create based on its specialized type. I don’t like this either.

Any suggestions?

  • 1 1 Answer
  • 4 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-15T19:43:39+00:00Added an answer on May 15, 2026 at 7:43 pm

    IMHO, neither data class no rendering class have a responsibility to make a decision about which renderer to use for a given data object. I do prefer your second option. I usually use a map that maps data-type into a renderer class. Also note that such mapping is context specific (web rendering will use different renderers from destop app, or fitness context).

    Such mapping can be constructed automatically, for example using attributes (in .Net) or maybe naming convention (in Lua). Or using external XML-config file.

    Summary: somebody have to make that decision, and according to SRP neither renderer nor data object shall be responsible for that. Such logic is application-context specific, and as such should be ‘above’ both of those actors (i.e. renderer and data).

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

Sidebar

Related Questions

I've found myself that I tend not to have private class functions. If possible,
I have heard that web-based chat clients tend to use networking frameworks such as
We have found that with our memcache some keys tend to be lost. To
I tend to have this redundant naming in case classes: abstract class MyTree case
I have a very classical class which contains buttons and label, etc... : @interface
I have following class that returns number of current Request per Second of IIS.
I have two methods that are overloads of each other public class Car {
I have a class that needs to be sortable in a couple of different
I have a class that processes a 2 xml files and produces a text
I have currently implemented a custom ViewGroup class, that attempts to position items (buttons

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.