Comments (5)
Hmmmmmm ;-)
My opinion:
- in Java 7 you can switch on Strings,
- your approach does not allow to create alarm ids dynamically like you could do with Strings. With Strings I can define alarms using constructed or configured Strings and I can react on them in the trigger method. I don't need to already specify them in the code.
- The string comparison only occurs in the alarmTriggered event. So it is really reduced to the absolute minimum. It is also only necessary if you use more than one alarm per entity class.
So for the advantage of avoiding string comparisons I would give away a lot of flexibility. So I am not convinced right now ;-)
from marteengine.
Hmm, I think your first point is fairly moot (forcing users to upgrade to Java 7 would be a non-starter), but the others are certainly valid. Additionally, if the string is defined in the Java source (and not, say, in an XML file) you would actually be able to use the == operator instead of .equals() in the alarmTriggered line since it would be interned string comparisons...which would be faster. Probably not worth the risk of bugs that might introduce if the string is ever not interned, though ;)
I'll close this for now, but maybe the example can use .equals() instead of .equalsIgnoreCase()? Seems unnecessary...
from marteengine.
I mentioned Java 7 just to point out that you could do a switch instead of ugly "if else" chains as soon as Java 7 is available.
Using == for String comparison is indeed risky :-)
But your point regarding equalsIgnoreCase() is true - it is unnecessary.
But thanks for your input! It's just great to get feedback and see that some people are interested in our stuff!
from marteengine.
thanks for your input from me too! We need to think about this kind of topic, so thanks! :D
About topic, our java for now is Java6 :D and I'll remove equalsignorecase method from example :d Thanks!
from marteengine.
I'm all for creating a nicer API over minor performance gains (premature optimization blah blah), but I feel I had to speak out here. But as @thaaks points out, it really would be a miniscule performance gain.
The game I'm poking around with now isn't so far along that I couldn't switch over to ME (which I may still well do), but...I want to work on features, first! Though the idea of a core base class (Entity) struck me as such a good idea that I actually am incorporating that aspect into my game, and using annotations to drive other aspects (whether to try to render an entity, so far).
from marteengine.
Related Issues (20)
- java.lang.NullPointerException when using setGraphic() HOT 11
- Compiling Help HOT 7
- Collision detection problems (0.2) HOT 8
- World forces the extending class to call super HOT 2
- Any way to delay? HOT 5
- marte engine jar file? HOT 1
- World problem HOT 2
- Tween example isn't working HOT 4
- Renaming sheet parameter width and height in resources.xml HOT 3
- Resource Copies HOT 2
- Background in Starcleaner HOT 5
- World.removeAll() HOT 3
- Entity speed is a Vector2f HOT 2
- default constructor HOT 6
- Problems with the camera HOT 9
- After changing an animation, everything brokes HOT 6
- setAnim() not functioning HOT 3
- resource xml validation HOT 2
- Allow to resort entities HOT 5
- What is an entity? HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from marteengine.