Talk:Translation Guidelines
From JQuantLib
Contents |
Naming convention
We have to agree on whether variable and method names should be replaced by java conventions or whether we use the original c++ names. Eg. should accessor/setter methods always start with get/set, should member variables end with "_" or not asf.
proper translation of virtual/final
- c++: foo() --> java: final foo()
- c++: virtual foo() --> java: foo()
- c++: virtual foo() = 0 --> java: abstract foo()
note about final as method parameters
"The keywork final means that a certain variable cannot be changed". clarification: the handle cannot be assigned to another value inside the method body. but you can change the state of the object. The only similarity between c++ mFoo(const Foo& cfoo) and java mFoo(final Foo jfoo) is that both forbid to do something like jfoo = new Foo(); cfoo = Foo;
nevertheless you can invoke any member methods of jfoo. invoking member methods on cfoo will throw a compiler error unless the invoked method is declared as const.
Java vs C++: inheritance, constructors and interfaces
Unclear Statements, or ambiguous statements
1. Please Help clarify as this statement is unclear.
Maybe a change you've just done is inserting a regression to stable code, which is very bad :(
2. from Strategy the discussion of virtual vs abstract could be clarified; Virtual really means late binding or run time binding, whereas in java abstract means 'Late Implementation'. This is actually a very complex point, in java there are 2 ways to make methods Non-Virtual 1. make them private, 2. make them 'static' otherwise ALL java methods are virtual.
| virtual || abstract || The keyword virtual means "not-final", meaning that the method can be overriden. It cannot be translated directly to abstract in Java: you have to judge yourself whether abstract should be applied or not.
3. Unclear Paragraph; I started to clarify.
It's a good opportunity to reinforce your understanding of the object model. For instance, if you believed that this class is extended from a certain base class, but then you realize that there's a pointer around and fields are being accessed via this pointer. Imagine that, after some analysis, you discover that this class not only extends a certain base class, but also has an association or composition to objects of that same base class. obviously, this understanding is critical for your translation.

