14 December 2010

Apache Software Foundation leaves Java Community Process

Quite disturbing news indeed.

Ever since Oracle acquired Sun there was an unspoken tension in the development community. I personally tried to not to pass judgment before Oracle made some steps themselves. It was my sincere hope that Oracle would attempt to preserve most of the process, although I am a realist and I knew corporate interests would surely interfere in some way.

Apache leaving the JCP is a very logical consequence to the results of the vote for the Java 7 and 8 roadmap. The vote itself was openly criticized. Another surprise to me was that IBM seem to have joined forces with Oracle in their crusade against the community process.

I personally can't say anything more than the sources I have cited. As a software engineer I find this a very unfortunate development. Although I've never had good experience working with Oracle products I still hoped that Java would not have the same faith.

It seems that the next logical step would be a fork in the road :) Apache and other supporters (such as Google) could take up the burden of creating and supporting an open source, community friendly version of the JDK. I am personalyl very much tempted to join Project Harmony.

18 November 2010

Webinar: Message-Driven Architecture with Spring

Hurry up and register for today's webinar @ spring source that would discuss topics related to message driven architecture.

More information here.

15 November 2010

OpenFest 2010

OpenFest is coming on the 20th and 21st of November at the Interpred building in Sofia. Access to the event is free of charge.
Check out the program. I'd probably visit these lectures :
* JavaScript Progressive Enhancement и Event-driven architecture
* NoSQL бази от данни – възможности и приложение
* grsecurity на теория и практика
* Модерни програмни езици за Java Virtual Machine

08 November 2010

Premature optimization

I am becoming more and more a fan of code minimalism. I've recently had several tasks that were aimed at "optimization" and "improvement" of the code and encountered the most visible signs of premature optimization ever. Talk about waste of time ...

First of all what is premature optimization? Wikipedia states that:
"Premature optimization is a phrase used to describe a situation where a programmer lets performance considerations affect the design of a piece of code. This can result in a design that is not as clean as it could have been or code that is incorrect, because the code is complicated by the optimization and the programmer is distracted by optimizing."

Not much information there. So what are the most usual signs of premature optimization? Well here is my initial list:
1. Optimizing something that was never an issue in the first place - you have a perfectly working functionality but a decision is made to refactor it to increase it's performance. Consider this - was performance ever an issue? Is this change going to bring any value of for the customer? What is the associated risk with this change? How much time would this change require?
2. Optimizing without clear benchmarking results - there is a hypothetical performance gain but there is no clear evidence that it would help in the specific situation. In this case the questions would be : Is there any physical evidence that this optimization would actually increase the performance? Is the source of this information trustworthy?
3. Optimizing would lead to undetectable performance gains - yes, improving some algorithm to run 2 times faster seems like a good idea, but if the actual difference is for it to run 1ms against running for 2ms would this actually benefit the application as a whole? Another example is improving a script that runs only once at program start up etc. In such cases the main question is if this investment in development is worth the time.

In most cases I've found that the answers to these questions completely change the perspective on whether or not such an optimization is necessary. Don't get me wrong - I am a strong supporter of code quality and optimization. But developers often tend to optimize prematurely and they need to always control these "urges".

Of course on of the most good examples is when the optimization is suggested by somebody without technical knowledge such as a product owner or designer. Sorry guys, I truly appreciate your work, but the thousands of designer forums that suggest always using a single CSS file for any developed web site are just showing what I meant in the first place. No clear evidence (tests with both approaches and comparison results), no exceptions (no single approach is valid for all cases, there are always exceptions) etc. This is just a bad opinion that is circulating throughout the entire web, a rumor that could (in my opinion) easily be proven wrong.

07 October 2010

Thoughts on SCRUM

Scrum is applied in many software companies in Bulgaria some of which I have been given the chance to work for. Such companies include Axway Bulgaria, Software AG, Nemetscheck - Buglaria etc. I also have been able to observe how it is applied in other companies such as SAP, VMWare, Microfocus etc.

Of course adapting the Scrum methodology has presented different challenges for each different company, but there have always been patterns that could be noticed everywhere. I personally believe that adapting Scrum has always been successful, although I took a different amount of time and effort depending on the situation.

Here are some of the typical issues that I have witnessed.

Lack of commitment from the team

Many developers find adapting this technology a "management" decision. Not given enough information and provided with no options it is only natural to react negatively. Scrum is also not the first attempt to change the way developers work and organize their teams. Many have failed and we all know how expensive adapting the newest technological or methodological "hype" has been before.

Ways to counter this effect
I know that developers tend to welcome change with much suspicion and skepticism, but since the methodology actually aims at empowering the team and removing any outside (and inside) obstacles, I firmly believe just about any developer could be convinced in giving Scrum a chance.
Managers that are involved in such changes have to completely understand the methodology and find ways in providing this information in the best way to the people involved in the process. Each person should know why each role is important, what their exact goals are. It is crucial to have a well educated, dedicated Scrum master as this is the person is vital to adapting the methodology in the best practical way. Such a person could help team members understand the process and in the same time adapt the process to the team members themselves.

Lack of commitment from the management

Sometimes the change is provoked from the teams themselves. In such situations not having the full support of the management could be fatal to the overall effort, thus making a team even less productive then before adapting the process. The Scrum methodology is flexible, but it does have some principles that could not be avoided. The team needs empowerment in order to improve itself. It needs to be able to change itself, otherwise the whole idea behind retrospectives and task estimation is useless. The team needs to have some notion of the basic team roles followed otherwise responsibilities would be vague and the overall process organization could not achieve the ideas behind agile development. These and other principles are vital to adapting Scrum and achieving something partial or incomplete could prove fruitless.

Ways to counter this effect
Obviously the management needs to realize that of adapting Scrum requires much effort, the investment of both time and money. There are many papers online on the topic whether or not a company should adapt Scrum and I do not intend to discuss this. The rule that I would recommend following is : either be prepared to commit to adapting Scrum or stick to the methodology that currently works best for you. Scrum is not simply a set of ideas that could be adapted on a case by case basis. It is an agile methodology with a set of principles aimed at making teams much more productive. It is unusually adaptive, but nonetheless it has some basics that need to be understood and adopted.

Various misinterpretations

It is sometimes hard to apply the methodology on a team, especially if the team has been working for years using some waterfall methodology or other ideologically different process. Many of the notions behind Scrum contradict to those of non-agile processes, such as the notion of having a shippable product at the end of each iteration. In such situations team struggle to change their ways and sometimes, not given the proper support and encouragement, they give up halfway before they achieve their goal. Not reaching their goal (such as the example above with the fully shippable code) could both lead to drop in performance as well as drop in moral and loss of confidence in the effectiveness of the process.

Ways to counter this effect
Much of the things I have already mentioned already. The role of the Scrum master is one of the most important ones and needs to be held by a very ambitious, well trained and patient team member. He needs to believe in what he is doing and have the qualities to encourage certain changes. Scrum is all about dynamics and change and this must be his top priority. Management support is also an absolute must. Trainings, lectures, consultants or whatever the team needs - these are all investments that would pay off in times their initial value.

Overall situation

From my perspective of a software developer I think the Scrum process is being adapted fairly well in Bulgaria and the world as a whole. It is building up momentum and perhaps one day it would be the most widely applied. As with any other methodology (or technology for that matter) it is often misinterpreted, partially applied or not given enough credit, but still there are many companies that have achieved both better efficiency and better team collaboration.

21 September 2010

Some comments from various source codes

In case you haven't yet seen this memorable article do check it out. Some examples :

// Dear maintainer:
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
// total_hours_wasted_here = 25

// I dedicate all this code, all my work, to my wife, Darlene, who will 
// have to support me and our three children and the dog once it gets
// released into the public.

// Magic. Do not touch.

// Replaces with spaces the braces in cases where braces in places cause stasis
$str = str_replace(array("\{","\}")," ",$str);

* This method leverages collective synergy to drive "outside of the box"
* thinking and formulate key objectives into a win-win game plan with a
* quality-driven approach that focuses on empowering key players to drive-up
* their core competencies and increase expectations with an all-around
* initiative to drive down the bottom-line. I really wanted to work the word
* "mandrolic" in there, but that word always makes me want to punch myself in
* the face.

,and the famous :
#define TRUE FALSE //Happy debugging suckers

15 September 2010

jQuery for dummies

As I was rudely forced in the the magnificent world of jQuery I needed to find a starting point for understanding it's universe. The question that I am now trying to ask myself is "Is jQuery better than simple JavaScript?". Of course this would be very difficult to establish, mostly due to the fact that jQuery IS JavaScript.

So, coming back to the starting point, the first thing a Java developer like me does is try to find API documentation. I was pleasantly surprised to find out that it is very well organized and most importantly filled with examples. jQuery is off to a good start.

For the most inpatient of my readers you could simply jump into the ocean of plugins that are developed by the open source community. You will find very interesting layout frameworks, as well as a centralized theme management tools and gadgets such as notifications and etc.

At the end of the day I still feel a bit strange. jQuery is undoubtedly a revolutionary extension to the way JavaScript is used. The ease with which one could select elements, transverse over the DOM tree, change the elements themselves and interact with CSS is astonishing. Unfortunately since it is built over JavaScript jQuery exhibits some of it's weaknesses. Debugging is a real hell at times (even if you are smart enough to test on Firefox + Firebug), the lack of typification is confusing and sometimes you just can't understand why for( a in b) is not the same as b.each(function(){}).

I'd still recommend adopting it though if not for something else but for the great community and support.

Tools I used:

* Eclipse (interesting plugins would be Aptana and jQueryWTP
* Firefox and Firebug
* all the sources of documentation mentioned in the beginning

13 September 2010

Java2Days 2010

Java2Days is coming again!

This year's conference would be split into three groups : Mobile2Days, Cloud2Days and Java2Days. The prices are almost the same as last year's. The discount for an early registration is 20% but the end date is 15 of September, so if you are reading this you have no more than 2 days left.

The agenda is published early this year and it looks promising - some topics on HTML5, Spring, OSGi etc.

The event would be held in the International Expo Center (IEC) in Sofia, Bulgaria.

02 July 2010

IE8 opacity adventures

Yet another 3 hours lost in the mindless pursuit of something that is so simple yet so difficult to achieve due to the unbearable compatibility issues presented by the Internet Explorer.

As Microsoft clearly explains:

Unfortunately, the original filter syntax was not CSS 2.1 compliant.

So in order to achieve opacity filtering in IE8 you need to do something like:

.transparentDiv {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
filter: progid:DXImageTransform.Microsoft.Alpha(Opacity=30);
opacity: .3;

Which is not so difficult at first glance. To make this even more compatible with the vast ocean of different browser and filtering implementations I extended this to:

.transparentDiv {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
filter: alpha(opacity = 30) ;
-moz-opacity: 0.3 ;
-khtml-opacity: 0.3 ;
opacity: 0.3 ;

As one might suppose from the first sentence of my blog the adventure was far from over. The style would work wonderfully in case it is applied directly to an IMG. But in my case I was applying it to a link that has the image as a nested element.

Of course all other browsers had no trouble understanding the simple logical assumption that the opacity filter should be propagandized to the nested elements. IE8 had other reasoning though. It DID apply the styles to the link element, but not to the image itself.

So, bottom line, to make it work the style should be applied directly to the element that needs to be styled. In my case that would mean something like:

.transparentDiv .imageClass {
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";
filter: alpha(opacity = 30) ;
-moz-opacity: 0.3 ;
-khtml-opacity: 0.3 ;
opacity: 0.3 ;

Thank you Microsoft, for a time well spent. And as a side note - the "Web developer" plugin is nothing like the Firebug extension. Were you not cleverly integrating your lousy browser into your operating system it would have been forgotten centuries ago.

07 June 2010

TIOBE index

I have came across the TIOBE index recently and was intrigued by the results it showed.

"TIOBE monitors currently 339 different industrial projects all over the world for various multinationals (see our reference list for more details). This is more than 142 Million lines of source code per day."

There is also an interesting chart on the trend of usage of different programming languages :

I will leave the conclusions to you, although I personally don't like some of the trends this research shows.

Thoughts and rants on AJAX

Inspired, in some part, from Guillaume Laurent’s tech blog and How and Why AJAX, Not Java, Became the Favored Technology for Rich Internet Applications.

Have you not had this familiar feeling that what you are doing is not really natural in an architectural sense? If you have ever developed an AJAX web application than you sure have.

AJAX was really very interesting when it was still a hype. As with all other IT hypes it had lots of people talking about it, presenting it in conferences, writing articles and extending frameworks. None of them actually explained the approach from another view than that of the user.

Yes - it is a shiny gadget and makes most of the static / conventional dynamic web site look old and feeble, a thing of the past.

Yes - it mimics the way integrated desktop applications work in many ways.

Yes - it actually does give more options to make a better, more user-friendly interface.

Unfortunately, as it normally happens, people seem to have gotten the wrong idea. RIA is the future. But AJAX is not RIA. AJAX is just a hack we use in the path of transforming the web from a basic request/response interface to a rich, full fledged application.

AJAX is twisting your arms every time you want to do something bolder. AJAX is limited in so many ways that one could easily say we have seen all from AJAX even though it is a relatively new approach.

Of course this is highly theoretical. Should the end-user's computer serve as something more than a terminal for the services offered by the server? Should it do small computations such as field verifications, field recalculation, sorting of table information ...

I personally believe the answer is somewhere in the middle. My personal experience has shown that neither approaches work best.

If there is too much happening on the user computer the application becomes slow, heavy and is heavily dependent on the user's hardware and setup. This is a huge maintenance risk, such problems are very very hard to identify and compatibility is *always* an issue.

On the other side we can't really do everything on the server, even if we have the best platform / hardware. Querying the server for a simple number verification is plain old silly. Do you want to depend on an internet connection for such a simple thing? And what if the user is typing really fast into several fields? This is an enormous amount of server calls for something as prosaic as a string inspection.

Perhaps the future has something much better to offer. I already had some experience with the Flex framework and I think this is a good direction to follow. But for now we must accept and understand the limitations of AJAX and not try to use it as a medicine for each and every illness.

20 April 2010

Deploying custom web services in an OpenCMS container using Axis 1.2

This short manual describes how to generate an Axis 1.2 web service based on a WSDL file and then integrate it into OpenCMS (probably as part of a larger module). Unfortunately the process is not fully automated as the modification to the web.xml file that is required needs to be done manually. All other files could be generated preliminary and deployed with a custom module (the server-config.wsdd file, the web service code, Axis libraries etc.)

Although all the required information was quite hard to gather the actual steps are really very easy.

Generating our web service

I would not go into detail – the Axis 1.2 manual describes the process here

Modifying the OpenCMS web.xml file

This would be our first step. We can’t really avoid this, and I am not sure if it could be done automatically (for instance if we wanted our own module to set up AXIS). I didn’t have much time to research this so I just went with the manual update. All we need is to add these lines and restart the server (assuming that our module deployed the required axis libraries in the WEB-INF/lib directory):

Apache-Axis Servlet




Creating the server-config.wsdd file

The default file is something like:


We only need to put the contents of our deploy.wsdd file (generated in step 1) in the place of the “HelloWorldService” service element.
We than place the server-config.wsdd file in the WEB-INF/ directory (alongside the web.xml of the OpenCMS application).


To access the service we need to visit http://localhost:8080/opencms/services/ HelloWorldService?wsdl, assuming our web service name is set to HelloWorldService

Testing basic Java skils [Q2]

Taken without any changes from Paul Szulc's Blog

I won’t be doing long introductions, let’s just jump right into the code. Check those two classes below:

public class Foo
public int a;

public Foo()
a = 0;

public void add()
a = a + 10;


public class Bar extends Foo
public int a;

public Bar()
a = 2;

public void add()
a = a + 5;

Looks normal, right? Class Bar overrides method add from Foo class, additionally it initialize a variable in constructor. So the question remains, what will following code print on the output when run:

public static void main(String[] args)
Foo f = new Bar();
System.out.println("a = " + f.a);

To make this task easier, I give you 5 possible answers. Only one is correct:

A) a = -2
B) a = 0
C) a = 5
D) a = 7
E) a = 12

And the correct answer is…

B) a = 0

You might say “What!? Anything not 0! I mean I made addition operation at least once. Or have I…”. Well you are right, you made addition operation, but you were adding value to different variable then you thought you were. The devil is in the details. When you create again ‘a’ field in class Bar

public class Bar extends Foo
public int a;


you hide ‘a’ field from Foo class. In Bar class we have actually two ‘a’ fields, but we can only access one: the one that was declared last. In other words we loose access to ‘a’ field declared in Foo class. Now everything should become clear. In Bar constructor we initialize the other ‘a’ field with value 2, then we add 5 to it and so it finally equals 7. But when we are printing the output

System.out.println("a = " + f.a);

we are actually printing the hidden ‘a’ field from the Foo class. Tricky, ain’t it?

The problem lies in the ‘public’ access level of the ‘a’ field. It is almost never good idea declaring your fields as public (beside rare occasions like inner classes\). Also try not to name fields in your child classes with names from the parent class.

15 April 2010

And some engineering humor

Optimist: The glass is half full.
Pessimist: The glass is half empty.
Engineer: Why is the glass twice as large as it needs to be?

08 April 2010

Some management humor

A man flying in a hot air balloon suddenly realizes he’s lost. He reduces height and spots a man down below. He lowers the balloon further and shouts to get directions, "Excuse me, can you tell me where I am?"

The man below says: "Yes. You're in a hot air balloon, hovering 30 feet above this field."

"You must work in Information Technology," says the balloonist.

"I do" replies the man. "How did you know?"

"Well," says the balloonist, "everything you have told me is technically correct, but It's of no use to anyone."

The man below replies, "You must work in management."

"I do," replies the balloonist, "But how'd you know?"

"Well", says the man, "you don’t know where you are, or where you’re going, you expect me to be able to help. You’re in the same position you were before we met, but now it’s my fault."


Some more here http://stackoverflow.com/questions/234075/what-is-your-best-programmer-joke

29 March 2010

Dan Pink on the surprising science of motivation

An astonishing talk on motivation, both fundamentally surprising and scientifically based. Not to mention - very well presented.

20 March 2010

Testing basic Java skils [Q1]

Here is a typical Java interview question - "Are parameters of methods passed by referenced or by value?". And the typical answer I have usually heard is "Objects are passed by reference, where primitives are passed by value". Now lets try and see how this works in the real world.

public class ParameterTest {

public void parameterTester(SomeClass clazz) {
clazz.someValue = "methodChangedValue";
clazz = new AnotherClass();

public static void main(String[] args) {
ParameterTest tester = new ParameterTest();
SomeClass clazz = new SomeClass();
System.out.println(clazz instanceof AnotherClass);

class SomeClass {
public String someValue = "initializedValue";

class AnotherClass extends SomeClass {

Simple question - what would the output be? It is obviously a combination of the following outputs : "true" or "false" and "initializedValue" or "methodChangedValue".

Now if the answer given at the beginning of this article was right, then the object would have been passed by it's reference. If this was true then the output would have to be "true" (since we change the reference inside the test method) and "initializedValue"(because this is the default value of the field). And this would be the wrong answer.

So if we don't actually pass references then we must be passing values (copies) of the objects. If so then the correct answer would be "false"(as the reference should not be changed by what we do in the test method) and "initializedValue" (because even though we modify the value in the test method we actually do it to a copy). And this is again a wrong answer.

The right answer is "false" / "methodChangedValue". The very simple explanation is that:
1. In Java values are always passed as values (both objects and primitives) and these values are copies of the original (thus modifying their values does not reflect the original objects)
2. When passing objects we actually pass the value of their reference. This is where the trick is - we are able to modify the original object, as the reference we are using, although a copy, points to the same object. If we try to change this reference though then the original object stays the same.

Wierd or not, quite a lot of Java developers failed this test when I gave it to them so I decided to put this example in my blog. To be honest I was surprised of the result of the code above myself at first.

15 March 2010

Some findings from the JUnit mailing list

A neat addition to JUnit that can be used for benchmarking : here

* Records execution time average and standard deviation.
* Garbage collector activity recording.
* Per-benchmark JVM warm-up phase.
* Per-run and historical chart generation.
* Optional results persistence in the H2 SQL database (advanced querying, historical analysis).

Intriguing thoughts on how to create mock code that would sustain the test of time : here

Unfortunately I find this article outdated. Especially when one takes into account the mocking frameworks that are currently available. Nevertheless I think the example could describe best how much effort could be lost when unit tests are over-engineered and in the same time how much could be avoided if good mocking frameworks are used.

An interesting, but rather specific discussion on order of execution of tests : here

One of the major new features of JUnit - Categories : here

15 January 2010

Software Engineering ≠ Computer Science

The article is written by Chuck Connell, a software consultant. I stumbled upon it by chance, but I felt I really need to read it. And I was right.

Mr Connell felt the same frustration when starting to work as a software engineer that many of us do just after finishing university. The comfort of well defined rules and logical consistency slowly begins to fracture meeting the harsh reality of uncertain client requirements, estimates that border with a wild guess and the constantly improvised work organization.

Come to think of it the best that the whole engineering society could think of, when trying to create a guideline for work organization, was methodologies such as SCRUM. SCRUM does not really define anything, actually it encourages teams to not get used to a certain style of work - they would rather strive to continuously improve their work. So at best we could only encourage improvement, while we leave behind strict processes such as the Waterfall process.

As the article points out software engineering is made by people and people would naturally avoid abiding well defined processes. Individuality, improvisation, creativity - all of them are best expressed when an individual is acting freely and given the power to take chances and risk. Of course with risk comes possibility of error and with freedom comes the chance of chaos. But if the people involved are urged to improve, if the whole process is wisely managed and directed this would ultimately achieve the best productivity vs. quality ratio.

I'd strongly suggest reading Mr. Connell article. It provides a very clear, analytical view on the subject.

07 January 2010

P2P Conference - 2010

This year's P2P conference would be held again in Veliko Turnovo on the 24th and 25th of April. The last time I visited this conference it proved to be very interesting, filled with lots and lots of young enthusiastic people. It generally involves WEB technologies, but recently it became even broader including topics such as a BlogCamp, a workshop involving practical exercises on various subjects, a "CD throwing contest" and more.

It seems like a very nice event, so be sure not to miss it.

Link to the official web site of the event : here
"Skeleton" program : here