Why not abstract fields?

You can do what you described by having a final field in your abstract class that is initialised in its constructor (untested code): abstract class Base { final String errMsg; Base(String msg) { errMsg = msg; } abstract String doSomething(); } class Sub extends Base { Sub() { super(“Sub message”); } String doSomething() { return … Read more

new keyword in method signature

New keyword reference from MSDN: MSDN Reference Here is an example I found on the net from a Microsoft MVP that made good sense: Link to Original public class A { public virtual void One(); public void Two(); } public class B : A { public override void One(); public new void Two(); } B … Read more

Defining an abstract class without any abstract methods

Of course. Declaring a class abstract only means that you don’t allow it to be instantiated on its own. Declaring a method abstract means that subclasses have to provide an implementation for that method. The two are separate concepts, though obviously you can’t have an abstract method in a non-abstract class. You can even have … Read more

Why does this C++ snippet compile (non-void function does not return a value) [duplicate]

This is undefined behavior from the C++11 draft standard section 6.6.3 The return statement paragraph 2 which says: […] Flowing off the end of a function is equivalent to a return with no value; this results in undefined behavior in a value-returning function. […] This means that the compiler is not obligated provide an error … Read more

How do I call a dynamically-named method in Javascript?

Assuming the populate_Colours method is in the global namespace, you may use the following code, which exploits both that all object properties may be accessed as though the object were an associative array, and that all global objects are actually properties of the window host object. var method_name = “Colours”; var method_prefix = “populate_”; // … Read more

Usage of @see in JavaDoc?

Yeah, it is quite vague. You should use it whenever for readers of the documentation of your method it may be useful to also look at some other method. If the documentation of your methodA says “Works like methodB but …”, then you surely should put a link. An alternative to @see would be the … Read more

Git – how do I view the change history of a method/function?

Recent versions of git log learned a special form of the -L parameter: -L :<funcname>:<file> Trace the evolution of the line range given by “<start>,<end>” (or the function name regex <funcname>) within the <file>. You may not give any pathspec limiters. This is currently limited to a walk starting from a single revision, i.e., you … Read more