Singleton Frenzy

[ENGLISH]

I've started to build the final class diagrams. Most thigs will stay as they are now, but other are too complex, and must be simplyfied. My goal with this library is to make things easier for the developer.

For example, until now, you could access the engine through the Engine class. To get the graphic engine you should type this:

(GraphicSystem)Engine.getSystem(GraphicSystem.ID)

It doesn't look easy to remember. So the best solution I can think of is to make every subsystem a Singleton because, well, there should be only one instance per subsystem. But it would be nice to be able to access them this way:
GraphicSystem.createMesh(...)
instead of...
GraphicSystem.getInstance().createMesh(...)
Because the calls would be too long. But I would hace to make a static method for each non-static method. I could also replace the getInstance method for something shorter, like just get, or call. Any suggestions?

[ESPAÑOL]

Ya he comenzado a tirar diagramas de clases en serio. Muchas cosas se van a quedar como las diseñé en un primer momento, pero otras creo que han resultado demasiado complejas, y hay que simplificarlas. No en vano mi idea es que esta librería sea sencilla de utilizar.

Por ejemplo, hasta ahora, el acceso al motor era a través de la clase Engine. Para acceder al motor gráfico, había que hacer:
(GraphicSystem)Engine.getSystem(GraphicSystem.ID)

Y no parece algo demasiado intuitivo que digamos. Así que creo que la mejor solución va a ser que cada subsistema sea un Singleton ya que, en realidad, solo va a existir una instancia de cada subsistema.

Pero lo cómodo sería poder hacer:
GraphicSystem.createMesh(...)

en lugar de
GraphicSystem.getInstance().createMesh(...)
Porque las llamadas serían demasiado largas. Pero tendría que hacer una llamada estática para cada llamada no estática. También podría sustituir el getInstance por algo más corto, quizás el get a secas, o call. ¿Alguna sugerencia?

Posted byMiguel Herrero at 3:38 PM  

0 comments:

Post a Comment