Patterns used in jmonkeyengine

Could you tell about patterns that are used in JMonkeyEngine?
Some examples of Abstract Factory, Factory Method, Singleton, Builder, Prototype

The code is available. The link is at the top of the page.

com.jme.math.FastMath is a singleton.
com.jme3.export.binary.BinaryImporter.getInstance() is a factory method.

Offhand, I can’t think of any examples (in JME) of the builder pattern, though it does make occasional use of java.lang.StringBuilder .

Actually, com.jme.math.FastMath is a utility class (idiom not pattern) and BinaryImporter is a singleton.

I wonder what the motivation for the original question is, though. It’s not useful on face value unless OP is trying to do homework and was tasked to talk about patterns in an open source project or something. Thus my answer to check the code.


JME uses MVC (Model, View, Control) design pattern at the core for implementing your game.
JME’s Spatials are Views, ex: playerNode

JME’s UserData is Model ex: playerNode.setUserData("health", 100);

And JME’s AbstractControls are Controls of your game ex: playerNode.addControl(new PlayerControl());


Another design pattern you can use with JME is ESC (Entity Component System) with help of outer libraries like Zay-ES.

Prototype: actually is your clone method

The Prototype pattern offers a solution. The key idea is that an object can spawn other objects similar to itself. If you have one ghost, you can make more ghosts from it. If you have a demon, you can make other demons. Any monster can be treated as a prototypal monster used to generate other versions of itself.

see: Prototype · Design Patterns Revisited · Game Programming Patterns

There are other patterns to
please take a look at Table of Contents · Game Programming Patterns
which mostly are same in any game engine.

What do you think about this family of classes: - method getDataType();

Do those method a factory method?


Why do you want to know these things? We shouldn’t really be doing your homework for you.

I’m just interesting. I hope you will condescending to me )

I’m not trying to be condescending but this information on its own is not useful at all. So the only reason I could think of for someone wanting to know so badly is that they had a home work assignment for school or something.

Else asking what patterns JME uses is like walking around someone’s house and asking them which objects use electricity. It’s not really useful information. (And actually, that would be even more useful than what you are asking.)


Will it tell you anything useful about JME? Not really. Because you don’t seem to know the patterns well enough to recognize them yet.

Will it tell you anything useful about software development patterns? Not really. There are way better examples of design patterns in the JDK itself. JME at best only uses a very small handful of them and even then often takes short cuts that make them less pure.

JME doesn’t really use any of the patterns you mentioned in a way that makes them good examples.

I understood your opinion. Thank you for this complete answer.

You might be interested in com.jme3.util.SkyFactory .