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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:54:42+00:00 2026-05-14T04:54:42+00:00

I have defined an Event class: Event and all the following classes inherit from

  • 0

I have defined an Event class:

Event

and all the following classes inherit from Event:

SportEventType1 SportEventType2 SportEventType3 SportEventType4

Right now I will only have SportEvents but I don’t know if in the future I’ll want some other kind of events that doesn’t even have anything to do with Sports.

Later, I will want to draw some graphics with info taken from Events, and the drawing logic can be a bit complex. But, for the moment, I think I shouldn’t think of how the drawing will be done and I believe that maybe it’d be better if that drawing part was not put as an integral part of the Event/SportEventX class chain.

I am looking for solutions for this problem. I know I could just make Event have an instance variable(attribute, for the java crowds) pointing to something as an IDrawInterface, but that would make the Event class “assume” it will be later used for drawing. I would like to make the Event class oblivious to this if possible.

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-14T04:54:43+00:00Added an answer on May 14, 2026 at 4:54 am

    Your intent to keep knowledge of the drawing process outside the Event class hierarchy is good.

    A common way to handle this sort of thing in an OO language is the Visitor Pattern.

    If you can’t actually change the Event class to add the accept(Visitor v) needed for Visitor, you might consider using a Decorator or an Adapter. Getting the accept method to vary by subclass might be painful with these though. I’ll think about this a bit more and maybe add further notes tonight. For now, I’ve got to get to work.

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

Sidebar

Related Questions

I will use (again) the following class hierarchy: Event and all the following classes
I have a class called EventConsumer which defines an event EventConsumed and a method
How can I hook up an event to a function name I have defined
I have defined an interface in C++, i.e. a class containing only pure virtual
I have an interface that I have defined in C++ which now needs to
Let's say we have defined a CSS class that is being applied to various
HI all, the following code does not getting executed, the code is class Invoice{
I have an input form, nested within a div, defined like this: <div class=login-input>
I have defined a custom Sharepoint list for special attributes related to a software
I have defined a personalizable property on a web part and I would like

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.