How to create classes based on requirements or functionality

I am struggling with class design. Sometimes I think that everything I've read about class organization, class diagram and class design may not apply to a specific project. I want to create a Snake game in Java using MVC or MVP architecture.

There are some requirements:

  • Snake and snake food must be drawn on the screen
  • The current game account should be displayed
  • The snake must move with the arrow keys
  • The food must be grouped so that each group has a certain number of dots and colors.
  • The speed of the game should be determined by the value of the threshold.

The question is how to organize the classes (with methods and "everything") according to these requirements? Maybe someone has a book or link suggested via tutorial or examples.

Please can you share your rule of thumb for creating and organizing classes in this example?

+3


source to share


1 answer


Here is an example of a simple clone for a Snake game in Java that you can refer to for ideas on how to structure things.

Since you are requesting a book recommendation, I would recommend a book that has helped me a lot with fun object-oriented analysis and design. He teaches you by solving real problems step by step. This is completely different as it doesn't follow the typical stream of technical books on the subject. It looks at progressively more complex problems, pointing out potential problems and explaining important concepts along the way.



The book called Head First OOA & D . I recommend it because it is an easy (and sometimes fun) read, with a lot of samples in Java and also has a game example. So be sure to check it out! Even outside the context of your problem, I think you can benefit from it as I did.

Good luck!

+2


source







All Articles