File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Question about design structure. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Question about design structure." Watch "Question about design structure." New topic
Author

Question about design structure.

Joseph Tulowiecki
Greenhorn

Joined: Jun 10, 2011
Posts: 25
I'm creating a j2me game that I can transfer to a cell phone. I am semi -beginner. I know the basic code but what I am not sure about really is the design structure. If I am going to learn how to do this I would like to learn correctly and efficiently so my code will look professional, and code updates will be much easier. I guess this is my question. I don't know how large my classes should be. It seems like I should have many small classes but I've read that that slows down performance. I will give a quick example. The game is just basic pacman. There will be several levels. I have an abstract parent character class for the pacman character, ghost, the little fruit you get points for catching. Then I have a performMove() and updateDisplay() method in this class.
Then I have a seperate Move class and DisplayUpdate class which handles how to move the character depending on which type it is and the same for the display. I don't want to go on and on but doing it this way I'm already up to 10 classes with a few short methods in each class. I'm not finished brainstorming yet but I was wondering had any advice to me. Specifically, advice about the way I should think when I sit down to write a program. Which design structure is best for the given situation and how can I come to this conclusion on my own. I guess I would just like to know what would go through an advanced programmers head when beginning something like this. Any help is appreciated.

(I just got my assosciates degree in computer science and am about to go back for my bachelors. I feel like at the level of school I was at, the professors just pretty much wanted to see a working program and the design structure was almost irrelevant when it came to grading the projects. I know that in the future this lack of knowledge will come back to haunt me and cause a great deal of time loss so I am trying to write something with very clean efficient code for some practice before I go back to school)

Thanks !!
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Hi and welcome to the JavaRanch!

I'm not sure for Java ME but normally many classes don't have a performance penalty. Even if there is, it will be so small that you should program different because of it. If you create classes which have low coupling and high cohesion then it will be much easier to change and fix other performance issues. Generally speaking, don't a structure because you think it might be a performance issue. Just code clean and if you encounter issues run a profiler and identify the problem areas. Then you can focus on those areas. Donald Knuth once said: "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil".

Further just code classes with a high cohesion and create uml diagrams to get an overview. Finally learning how to be a good programmer takes lots and lots of practise so just code a lot and you'll improve as you go.


"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Joseph Tulowiecki
Greenhorn

Joined: Jun 10, 2011
Posts: 25
Wouter Oet thanks very much that was exactly what I was looking for. Much appreciated.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

Glad I could help.
 
wood burning stoves
 
subject: Question about design structure.
 
Similar Threads
OO design - event handling
Want to use OOP on my website
Question about sprite movement
Limiting User Input
This was my idea for a project... I would like some feedback.