Advice on jMonkey naming conventions

Just curious if someone can give me some ideas, I’m making some general scalar & vector fields but I’m not sure how to name them. I want the names to fit with the current naming convention.



The simplest form which is the scalar field, Vector2f->float i named: ScalarField2f. Its kind of simple and looks neat and its obvious what it means.



I currently use VectorField22f for a field from 2D to 2D space. A field from 2D to 3D space is VectorField23f, etc. This is kind of cumbersome though, 2 words followed by 2 different numbers then another sign on top of that. And it gets worse. The different fields needs to be Interfaces. My base-class is currently named: DefaultScalarField2f.



With Vector-fields it gets even worse, needing “DefaultVectorField22f” as a standard class name is just weird. It gets really stupid really quick. “ImageBasedVectorField33f”, the names are almost more complex then the actual objects.



I don’t want to loose any generality, suggestions would be helpful. It’s not on how to code them, its on how to name them. Thanks.

Fields generally start with a lower case letter in Java, also you normally access them via getters and setters and not directly, also when you don’t want to do any processing on them (its no overhead, the compiler is smart). You can create getters and setters with jMP, just right-click the field and select Refactor->Encapsulate field. Believe me when I say that this convention, as silly as it may seem to a C programmer is of great use in java object oriented programming, Naming variables is always a problem, the more you write while coding then better you can read the code afterwards :wink:

Ah I am sorry hehe maybe I was rambling a bit. The fields are not fields as in class-fields, they are classes representing “mathematical” vector fields, to make velocity-fields and such. VectorField22f is an interface, and DefaultVectorField22f a class implementing it, etc. I have made a simple class library of different types of vector-fields, for convenience, but the naming is so hard, they get 15-20 letter names etc. when i try to follow jMonkeyEngines conventions for naming mathematical objects. Like Vector3f is a vector in 3D space with float values etc. I try to name my objects similarly.



Maybe im over-thinking this hehe.

Ah, ok, sorry. I’d say these functions are better kept in static helper classes like FastMath instead of introducing new classes, no?

I’ve always thought its a pity that Java doesnt have properties the way C# has. They make life WAY easier. I dont like the idea of separate getters and setters.

Every java IDE can create the getters and setters for you, with java beans you have the same functionality…

I know but as a programmer, when scrolling through the attributes of a class I find it much easier to select, for instance, Text, than call either getText() or setText(String text). Its a little thing but it annoys me.

Yeah, maybe you try Scala, Groovy and whats all their names, they all have some stuff that is “so much nicer to code with”. Thing is, jME is java, “the C of object oriented languages” :stuck_out_tongue:

ancalagon said:
I've always thought its a pity that Java doesnt have properties the way C# has. They make life WAY easier. I dont like the idea of separate getters and setters.


Up until .NET 3.5 C# and VB didn't have the auto property sugar syntax. You had to specify get and set. You do realize that

[java]string mystring {get; set;};[/java]
in C# really means

[java]
private string _mystring;
public void setMystring(string myval)
{
_mystring = myval;
}

public string getMystring()
{
return _mystring;
}
[/java]

Exactly the same as java.

But I do agree with you that the C# syntax is a lot nicer
scrubalub said:
Up until .NET 3.5 C# and VB didn't have the auto property sugar syntax. You had to specify get and set. You do realize that

[java]string mystring {get; set;};[/java]
in C# really means

[java]
private string _mystring;
public void setMystring(string myval)
{
_mystring = myval;
}

public string getMystring()
{
return _mystring;
}
[/java]

Exactly the same as java.

But I do agree with you that the C# syntax is a lot nicer


Yeah, I know, the compiler sorts out.

normen said:
Yeah, maybe you try Scala, Groovy and whats all their names, they all have some stuff that is "so much nicer to code with". Thing is, jME is java, "the C of object oriented languages" :P


I cant tell whether you are complementing or detracting Java - sarcasm meter broken. Anyway, its a compiler trick that IMHO makes life a lot easier. Much nicer to code with = I can get a lot more done in more time.