Design problem - Abstract or Interface


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Design problem - Abstract or Interface

Hybrid View

  1. #1
    Join Date
    May 2005
    Posts
    6

    Design problem - Abstract or Interface

    I am making a graphical application for a class. The problem is simple in that i need to create an array that stores a bunch of circles, but only if they don't intersect with a previous circle. This part is easy; however, I wanted to expand the functionality to allow for more shapes(like a square to be drawn). What in your opinions should i design it as. Either a interface or an abstract class - both seem to work and yet don't. Thanks for any help in this matter.

  2. #2
    Join Date
    Feb 2004
    Posts
    541
    I think this depends on your exact usage. If this class will only ever be used to draw shapes then an abstract Shape class seems appropriate, with a method called something like draw() (among other things) that it could call.

    If you want it to be able to draw anything, things that are otherwise unrelated, then an interface called Drawable (or something similar) would be appropriate. This would again have a method called draw() etc that would be used to draw it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center