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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:22:46+00:00 2026-05-11T19:22:46+00:00

I am writing a simple graphic editor for a university project using C#. I

  • 0

I am writing a simple graphic editor for a university project using C#.
I created a hierarchy where every type of shape – circles, rectangles, ellipses, … – are inherited from a base class Shape, it contains a shape color as a protected field.


public abstract class Shape {
        protected Color color;

        public Shape(Color c) {
            color = c;
        }

        public Color FigureColor {
            get { return color; }
            protected set { color = value; }
        }

        public abstract void render(Bitmap canvasToDrawOn);

        public abstract void unrender(Bitmap canvasToDrawOn);

        public abstract void renderPrototype(Bitmap canvasToDrawOn);
    }

The idea is that I want every type of shape to encapsulate it`s geometry part, for example:


public class TwoDPoint: TwoDShape {
        Point2DGeometry point;

        public TwoDPoint(Color c, Point2DGeometry p): base(c) {
            point = new Point2DGeometry(p);
        }

public struct Point2DGeometry {
        Int32 x;
        Int32 y;

        public Point2DGeometry(Int32 X, Int32 Y) {
            x = X;
            y = Y;
        }

        public Point2DGeometry(Point2DGeometry rhs) {
            x = rhs.Abscissa;
            y = rhs.Ordinate;
        }

        public Int32 Abscissa {
            get { return x; }
            private set { x = value; }
        }

        public Int32 Ordinate {
            get { return y; }
            private set { y = value; }
        }
    }

Ellipse class will encapsulate EllipseGeometry, etc.
Is it a good decision in terms of OO design, and if it is, may be it is the better idea to create a parallel hierarchy of this geometry-only types?

  • 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-11T19:22:46+00:00Added an answer on May 11, 2026 at 7:22 pm

    I think the answer is yes, because it follows along in the track laid down by the venerated MVC pattern.

    Another advantage is that it gives you the option of swapping out graphics libraries without having to rewrite all those base geometric classes. Use an interface to make that even easier to do.

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

Sidebar

Related Questions

I'm writing a simple graphics engine that draws textures on the screen using OpenGL
I'm working on writing simple unit tests for a Rails 3 project, but I'm
How long does it take for an experienced Windows programmer to learn writing simple
I'm writing a simple OpenGL application that uses GLUT . I don't want to
I'm writing a simple app that's going to have a tiny form sitting in
I am currently writing a simple, timer-based mini app in C# that performs an
I am writing a simple checkers game in Java. When I mouse over the
I am writing a simple database with web access. I have previous experience with
I'm currently writing a simple .sh script to parse an Exim log file for
I am writing a simple Python web application that consists of several pages of

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.