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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:15:46+00:00 2026-06-02T20:15:46+00:00

This is an open MVC related question and I’m looking for critique and advice.

  • 0

This is an open MVC related question and I’m looking for critique and advice.

brief version:
ViewA is used to view ModelA.
If ModelB extends ModelA and ViewB is used to view ModelB would ViewB inherit from ViewA?

background:

I have created a Graph class, containing an array of vertices and an array of edges.
The vertices have each a n-sized array of integer data.

I also created a GraphViewer class for 2d-Graphs, that simply draws lines for edges and dots for vertices.

Now I decided to create a GraphEditor Class, that is a graph with editing capabilities, for instance it needs to have methods and fields that allow user interaction:
example:
selectVertex – a method that accepts the current mouse coodinates and returns the vertex closest to that point, and
selectedVertices – an array of all vertices selected

I decided that GraphEditor will inherit from Graph.
Because GraphEditor is still a graph only with editing capabilities.

Now I wanted to create a GraphEditorViewer that will need to draw selected vertices in a different color(for instance) and I thought since GraphEditor extends Graph, perhaps GraphEditorViewer should extend GraphViewer, however I find that is not the case since the new class GraphEditorViewer does not ‘view’ regular Graphs.
So I decided to use a ‘has-a’ relationship between GraphEditorViewer and GraphViewer.
That meant that I had to expose a lot of rendering related methods of GraphViewer so I could call them from the new class.

I am wondering if you would go about it differently and what do you think about my choice.

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-06-02T20:15:47+00:00Added an answer on June 2, 2026 at 8:15 pm

    This is of course open for discussion and a matter of subjective opinion:

    Answer:

    If ModelB extends (inherits) from ModelA and ViewA is used to view ModelA, then ViewB should not extend (inherit) from ViewA, reasons:

    1. Not every ModelA is a ModelB, a view that extends ViewA is a specific type of a ModelA view and not specifically a ModelB view.
      ViewB however should expect a ModelB, so inheriting ViewA is not recommended in this case.

    You can however, use a composition (ViewB has a ViewA) relationship and use that to render ModelB as a ModelA and add additional details using more specific functions.

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

Sidebar

Related Questions

This is more of an open question rather than looking for one specific answer.
I found this open question online. How do you process a large data file
In this question I am looking for links/code to handle an IList<OrderLine> in an
I'm trying to open MVC project using VS2010 . I'm opening this project from
My question is somewhat related to this answer - https://stackoverflow.com/a/3458299/1635958 . I am working
This question has to do with the MVC framework and file arrangement conventions within
I realize there are several solutions to this problem. I am looking for advice
I don't know if this is possible. Can I have a mvc controller open
I'm using Extensions for ASP.NET MVC Q3 2011(open source version) with Razor engine and
I have a view in asp.net mvc 3, and I need to open it

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.