Thread: OO Design

    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0

    OO Design


    As someone fairly new to OO programming, I was wondering how more experienced programmers follow the design process. As an example, let's say you want to code a simple tetris game clone in Java or Python, how do you go about determining which classes to define and whether it makes sense to declare some as abstract classes, etc.

    Letting my inexperience show, I would identify the following classes:

    1.) Screen or playable area on screen
    2.) A square
    3.) A shape (consisting of more than one square as in 2.)
    4.) a keyboard key (should this even be a class?)
    5.) Some text (title, scoreline, etc.)

    How will you approach this design?
  2. #2
  3. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,663
    Rep Power
    1945
    I answer regarding my knowledge about java.

    1. 2. and 3.
    - This should be ok.

    4.
    - In java, you will implement a Listener on the part that require user action. In this case teh gamearea in 1.
    With a (simple) game like this, I don't think I would create a class for it.

    5.
    Regarding text like the titel, i would place this in the gamearea
    You could argue whether there should be created a Player class to keep score and that kind.
    Similar to point 4. i doubt it will give any extra benefits, except from a learning POV.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2010
    Posts
    4
    Rep Power
    0
    Thanks for your reply. I must say that deciding what to make into classes is the biggest stumbling block for me to get into OOP
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    3
    Rep Power
    0
    Thanks..it is really great information about the OO classes which helps me to solving many problems related to java..It also helps in web design .

IMN logo majestic logo threadwatch logo seochat tools logo