Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (539)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (603)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Number of classes  (Read 1622 times)
0 Members and 1 Guest are viewing this topic.
Offline Juriy

Junior Devvie





« Posted 2006-02-01 08:27:59 »

I've got one very simple question.
How does the number of classes in J2ME influence on game speed.

For example I want to make a project that will have 10 classes. But I do not know will it be  good
idea, because it may slow down my game. Of course, I can make the same project using just 4 classes, but
the code in those 4 huge classes would be unmaintainable.

What is your advice about the "optimal" number of classes in J2ME game?

http://voituk.kiev.ua - java tutorials, tips and tricks (Russian)
Offline Anon666

Junior Devvie




aka Abuse/AbU5e/TehJumpingJawa


« Reply #1 - Posted 2006-02-01 13:17:37 »

The number of class definitions has zero impact on execution speed.
Object instanciation is what has a speed impact.
The number of classes does however impact on the memory footprint, and the jar size of your application.

The optimal number of classes is 2.
One that extends MIDlet, and another that extends Canvas.
Offline Juriy

Junior Devvie





« Reply #2 - Posted 2006-02-01 13:55:43 »

Quote
The number of classes does however impact on the memory footprint

What do you meen? Can you explain in more details? Is there any difference for the Mobile
device between 1 class of 10 kb or two classes, 5kb each?

Quote
Object instanciation is what has a speed impact.
The optimal number of classes is 2.
If there is no speed difference I see no reason to put all the code in one class (that extends canvas,
because the one that extends MIDlet does almost nothing untrivial).

For example, when I write for MIDP 1.0 (that doesn't have a game API) I always implement a TileSet class and
Sprite class if there is any animation.


http://voituk.kiev.ua - java tutorials, tips and tricks (Russian)
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Anon666

Junior Devvie




aka Abuse/AbU5e/TehJumpingJawa


« Reply #3 - Posted 2006-02-01 19:56:40 »

Quote
The number of classes does however impact on the memory footprint

What do you meen? Can you explain in more details? Is there any difference for the Mobile
device between 1 class of 10 kb or two classes, 5kb each?

yes, each Class definition has a memory footprint. The actual value is dependant upon JVM implementation and class file structure, however it is typically in the region of a few hundred bytes.

Quote
Quote
Object instanciation is what has a speed impact.
The optimal number of classes is 2.
If there is no speed difference I see no reason to put all the code in one class (that extends canvas,
because the one that extends MIDlet does almost nothing untrivial).

I don't understand what you mean by "MIDlet does almost nothing untrivial".

However, I completely concur, placing all your code in a tiny set of classes is just plain ridiculous - your code will become completely unmanagable.

There are techniques and technologies to maintain the modularity of classes, while still gaining the benefits of having a small number of classes.

Many people use preprocessors, and while this approach will serve you ok for a time - you will eventually require a more advanced approach as preprocessors seriously inhibit debuggers and IDEs like Eclipse.

The more advanced solution is to perform class heirarchy transformation.
Several tools already exist to perform this task, 2 freely available ones are JAX and JOGA.
I can say no more.
Offline Juriy

Junior Devvie





« Reply #4 - Posted 2006-02-02 09:11:23 »

Thank you for your anwer. I appreciate your opinion.

http://voituk.kiev.ua - java tutorials, tips and tricks (Russian)
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (37 views)
2014-12-15 09:26:44

Mr.CodeIt (31 views)
2014-12-14 19:50:38

BurntPizza (62 views)
2014-12-09 22:41:13

BurntPizza (99 views)
2014-12-08 04:46:31

JscottyBieshaar (60 views)
2014-12-05 12:39:02

SHC (74 views)
2014-12-03 16:27:13

CopyableCougar4 (77 views)
2014-11-29 21:32:03

toopeicgaming1999 (138 views)
2014-11-26 15:22:04

toopeicgaming1999 (127 views)
2014-11-26 15:20:36

toopeicgaming1999 (38 views)
2014-11-26 15:20:08
Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!