Skip to content

Continuous Integration

Concentrate on commits rather than on merge ?

Advertisements

IIIrd attempt at Scala

Inspired by : http://jaxenter.com/busy-java-developer-s-guide-to-scala-thinking-with-ted-neward-45242.html

So, rather than doing a helloworld and TOC study, I will try to understand why is it getting so much attention from the programming world. I will see the forums and communities to understand how it feels like working with scala.

*one line expression can give you results. (Verbosity) but isn’t that going to increase complexity?
*everything is expressions and not statements.
*every value is an object and every operation is a method call (No Primitives) but what about reference passing and memory blot?
*Functions as first class objects. Thereby, It is possible to pass functions as arguments, to store them in variables, and to return them from other functions.
*pass functions around as they are full time members of the language now(Higher order functions) but do we need them anyways?

OK… Scala is not just a functional language but a hybrid.

Concurrency and parallelism : more interesting here.

Going further now:
No static here for methods or fields. Use object to create singleton directly.
Imports are a little different. *{asterisk} is valid scala identifier so use _{underscore} . It can also import static members directly.
Methods taking one argument can be used with an infix syntax.
Functions can be anonymous like classes in java. Functions without name .. ding !
Method overriding from a super-class is ok. It is however mandatory to explicitly specify that a method overrides another one using the override modifier, in order to avoid accidental overriding. Compile time error.

Trip to Taiwan

Trip to Italy – 2013

My first trip to Italy, May 2013

Fest testing for swing

This has been an exciting experiment around using a ten+ years old legacy swing UI and adding Fest fixtures around it to do integration testing.

When you planning to code cover such voluminous code base that is very dynamic with 100+ devs working on it, you need to come up with some framework around which the whole thing will evolve.

Swing EDT (Event Dispatcher Thread)

Access to a (visible) Swing component has to occur in the event dispatch thread.

EDT violation: All rendering should happen on the EDT thread at all times.
EDT protection: We should not dump application logic on the EDT. Avoid long lasting tasks on EDT

Swing Worker
Event Dispatcher Queue
SwingUtilities
invokeLater
assert EventQueue.isDispatchThread();
SwingUtilities.invokeAndWait()

We should believe that a “good” Swing widget would support:
proper layout handling
threading
data-binding
focus management
keyboard control
error handling
persistent preferences
pluggable look and feels
accessibility
Dnd+Clipboard
keyboard shortcuts
internationalization

Java Dynamic Proxy

A Basic proxy entails an surrogate object that is inserted between client object and real target object to add more functionality or extra operations or access control. A proxy typically acts as a intermediary or go-between. They can provide for :
– Synchronization
– Authentication
– Remote Access
– Lazy Initialization
– Logging

This is not to be confused with Decorator which is delegation through composition!

Dynamic proxy takes the idea of a proxy one step further, by both creating the proxy object dynamically and handling calls to the proxied methods dynamically. All calls made on a dynamic proxy are redirected to a single invocation handler, which has the job of discovering what the call is and deciding what to do about it.
Code artefacts involved:
java.lang.reflect.InvocationHandler
invoke() method of InvocationHandler
java.lang.reflect.Proxy
Proxy.newProxyInstance() : to create a proxy object, we need to pass a classloader, a list of interfaces the proxy needs to implement and implementation of InvocationHandler.