anonymous classes — usage

* Usage: GUI. Event handlers and listeners
* Usage: threads.
* Spring callbacks in templates
(See other posts on sample codes for both.)

anonymous static and non-static classes are routinely used inside static/non-static methods to create a thread and start it.

–> concurrency developers had better get thoroughly familiar with the basic rules of anon classes

Fwd: career planning – next 5Y c2010

update… I feel if last job is a small no-name company (without a much higher salary), then it would affect my “image” for next job search.

See also post in 610610

Over the next 5 years, though i want to stay in a big bank for many years, circumstances might force me to change job every 1-2 years. Aiming to grow stronger in 3 areas.

Brank) leadership job title in big banks — a door opener and a little halo. When job market declines, employers have too many candidates, they prefer known brands.

T) keep my technical skills relevant — I realize every time I change job, technical skill requirement is always (at least one of) the biggest factor. A lot of tech interviews and quizzes are non-trivial[1]. If we stop doing hands-on work with current technology, we will weaken and become obsolete.

F) mainstream financial domain knowledge esp. security trading. This would open up a lot of high-worth job opportunities. They are not open to me now due to my limited mainstream financial experience. Maybe i
don’t need such a job — i can read up and pretend to have, say, risk analytic experience?

For my next (2? 3?) job searches in the next 5 years, I’m unlikely to apply to PM or business analyst roles. Technical is my strength.

[1] Rarely do i get an easy tech interview on wall street.

synchronized static init block@@

I vaguely remember a static init block can have “synchronized”. I guess 2 threads might (in theory) run the block concurrently.

But each classloader (and all its ancestors) can only load a class once, so i guess the 2 threads will load the same class into separate class loaders that aren’t in parent-child@@

hidden this._target field in a delegate Instance

As stated else where on this blog, an “item” in a delegate inv list holds nothing but 2 pointer fields. sheds light on one of them —

Internally an “item” stores its target in a private field named _target.

Normally, public property Target just returns a value of _target. For static delegates though, _target contains a reference to the delegate instance itself. “Get” accessor of Target makes a quick check, and if _target references a delegate Instance (likely to be itself), returns null.

3 ways to instantiate the same c# delegate Type

In c++ or java, you can instantiate a class Animal many ways, like
Animal myCat; // exactly like declaring an int variable
Animal myCat(2); //age
Animal* myCat = new Animal(“kit”);

C# delegate is more complicated. has a concise list of about 5 different ways to Instantiate a delegate Type. Extremely insightful. Among other things, it reveals that in the instance method case the delegate Instance must “remember” the target

public delegate string FirstDelegate (int x); // type declaration.
// The following two creation expressions are equivalent,
// where InstanceMethod is an instance method in the class
// containing the creation expression (or a base class).
// The target is "this".
FirstDelegate d1 = new FirstDelegate(InstanceMethod);
FirstDelegate d2 = new FirstDelegate(this.InstanceMethod);

// Here we create a delegate instance referring to the same method
// as the first two examples, but with a different target.
FirstDelegate d3 = new FirstDelegate(anotherInstance.InstanceMethod);

// This delegate instance uses an instance method in a different class (and 
// obviously different target),
// specifying the target to call the method on
FirstDelegate d4 = new FirstDelegate(instanceOfOtherClass.OtherInstanceMethod);

// This delegate instance uses a static method in host class containing
// the creation expression (or a base class). Target is NULL for ALL static
FirstDelegate d5 = new FirstDelegate(StaticMethod);

// This delegate instance uses a static method in a different class
FirstDelegate d6 = new FirstDelegate(OtherClass.OtherStaticMethod);