Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

"Correct" OOP

Thread view: 
Luc The Perverse - 27 Oct 2005 05:49 GMT
I haven't actually written this yet, I'm just making some plans.  This will
be my second or third "real" project in Java (I don't count tutorials,
experiments, etc.)

Where I get confused is where to put the intelligence, where to put the
drawing algorithms.

CCheckersStyleGameBoard inherits CGameBoardStyle
CChessGame inherits CGameManager
CChessPiece inherits CPiece

(Same thing for COthelloStyleGameBoard, CPenteGame, CPentePiece.)

Obviously the GameManager is going to create the CGameBoardStyle and give it
parameters, Black And White Squares 8 by 8.  It is going to create the
CChessPiece objects and "place" them on the board somehow.

The CGameBoardStyle derived class is going to draw itself, and based on
coordinated determine the size and location of the pieces to be placed on
the board.  Abstract function CPiece.Draw will be called for each piece,
with size and location information passed from the calling CGameBoardStyle
class.  (I feel semi confident about this.)

Now I read that Java doesn't support multiple inheritance.  Does this mean a
class cannot be derived from both JPanel and CGameBoardStyle?  Or is this
where the "implements" keyword comes into place.  (If so it would seem Java
~does~ support some form of multiple inheritance, but only one class can
contain functions which are not purely virtual.)

Well that is my plan - any advice is welcome :)

--
LTP

:)
Benji - 27 Oct 2005 06:08 GMT
> <snip>

I'm going to save Roedy from having to say this (although he won't see my
post since he's got me killfiled... =P), but...OMG, don't put a C in front
of every single class definition.  It's not useful at all.
See http://mindprod.com/jgloss/unmainnaming.html

basically, in java, anything that is capitalized is a class - so the C
is just obfuscation.

Signature

Of making better designs there is no end,
 and much refactoring wearies the body.

Roedy Green - 27 Oct 2005 07:23 GMT
On Wed, 26 Oct 2005 22:49:56 -0600, "Luc The Perverse"
<sll_noSpamlicious_z_XXX_m@cc.usu.edu> wrote, quoted or indirectly
quoted someone who said :

>Now I read that Java doesn't support multiple inheritance.  Does this mean a
>class cannot be derived from both JPanel and CGameBoardStyle?  Or is this
>where the "implements" keyword comes into place.  (If so it would seem Java
>~does~ support some form of multiple inheritance, but only one class can
>contain functions which are not purely virtual.)

see http://mindprod.com/jgloss/multipleinheritance.html

Just make sure you don't muddle in one class the code to draw a pawn
to do logic about pawn move abilities etc.

Make sure you understand the Model/View/Controller design pattern
before you launch into this project. It will be a very good thing if
you can nicely separate your design logic.

http://mindprod.com/jgloss/designpatterns.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.