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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T18:29:00+00:00 2026-06-05T18:29:00+00:00

I’ve been searching around but can’t find much about this, but would cross-casting from

  • 0

I’ve been searching around but can’t find much about this, but would cross-casting from one interface to another be considered bad design? Here is a sample of the code I’m using:

class IShip {
  // strictly ship_like interface
  // i.e. move, attack, dock, etc.
};

class Sim_object {
  // all game objects are derived from this and represents component in composite pattern
  // get_name()
  // get_location()
  // add
  // remove
  // etc.
};

template<typename T>
class Group : public Sim_object {
  // composite functions
  // add
  // remove
  // display
  // map<T> container;
};

class Ship_group : public Group<IShip>, public IShip {
  // added IShip functionality
};

class Ship : public Sim_object, public IShip {
  // actual ship object
};

Anyway, I’m using MVC where my controller will manipulate IShip objects and depending on if they are composites or leafs, will perform some function. My question is at times I need to go from IShip to Sim_object to get a different interface (requiring a dynamic_cast). Would this be considered bad design/practice? I didn’t really want to pollute the IShip interface just to get access to the Sim_object commands.

  • 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-06-05T18:29:01+00:00Added an answer on June 5, 2026 at 6:29 pm

    Casting generally implies a bad design, unless the casted type is already known in that context. For example, if you have an interface IRenderer that draws textures represented by the interface ITexture and you have an implementation for OpenGL which has an OpenGLRenderer and an OpenGLTexture, casting the ITexture to OpenGLTexture in OpenGLRenderer wouldn’t be a design issue.

    If you really need to cast the IShip to a Sim_object it would be reasonable to think that IShip should actually be a Sim_object.

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

Sidebar

Related Questions

Does anyone know how can I replace this 2 symbol below from the string
I have a jquery bug and I've been looking for hours now, I can't
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
This could be a duplicate question, but I have no idea what search terms
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I don't have much knowledge about the IPv6 protocol, so sorry if the question
Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i

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.