Tuesday, September 11, 2007

One-JAR

A friend asked if he could produce a single jar file with all required libraries packed inside it.
One-Jar does a good job of it.
It is easy to work with it from Eclipse too, thanks to Fat Jar plugin.

Tuesday, July 17, 2007

Managing user expectations

Managing user expectations is really important skill at every level of your career.

At the beginning of a career, you will most likely to answer the ultimate question of
"How long will it take this to finish ?" type of questions. Your manager will ask this to you.

Later as a consultant you will need to answer same question to clients, or as a manager you will need to come up with an answer for your senior manager.

As an entrepreneur you will need to answer this crucial question for cost estimation and bidding.


How long will it take? and by what percent will it be finished?
Should i put an beta version out and improve it as customers use it?
or wait for an stable 1.0 release?

At the root of all these questions lies the expectation management.

Here are some tips i have been employing when i need to answer how long it will take?

  • Try to judge from previous similar experience, if you wrote down your previous work allocation via time sheets on the average you know how long it will take
  • Do a quick POC type development which will not take more than a few days if possible
  • Do prototyping of important use cases and features, (important being defined by the customer) and try to estimate from that knowledge
  • If there are external stakeholders you can't control, estimate with relativity of their work. i.e It should take no more than a week, after we receive design templates from XYZ.
  • If possible, Slice the project to little periods, try to keep quality, time constant and vary the features. i.e We will work on these features for a month. We may not finish all features but we will keep our quality metrics to this level. If you are not satisfied with our work, you can always cancel the contract.
Note that the last strategy is not for fixed price projects. But it works because contractor will work honest to get the remaining big portion of the project. It shields the bidder from excessive unpaid change requests. And you can morph to fixed price later, after unknowns are eliminated.

Also last one has the nice feature of "fail fast". If a project is doomed to fail, it will fail in the first one little slice..

And during project implementation:
  • Don't present the work you are doing as too easy or too hard. In other words, communicate clearly.
  • Don't ever demo a feature complete UI early, because users will expect much more complex screens at the end. This is physiological. Instead show some cool features and build some excitement.
  • Always safe estimate a little more than it will take, this way you will always finish before time and earn some credits.
  • Never overestimate with a huge margin, next time they will not believe and your estimations will be halved by customer or manager. You will lose credibility once and for all.

What are your suggestions for estimating how long it will take?

Monday, July 16, 2007

Accessing dotted attributes from JSTL EL

One of my friends was in trouble with accessing scope attributes from JSTL expression language.
He wanted to use <c:out value="${myDomain.myObject}"></c:out>, to access an object under the key of "myDomain.myObject"

EL tries to retrieve an object under the myDomain key and then tries to invoke getMyObject() on that object. Obviously that wasnt working.

There is no standart way of accessing such attributes. But if you know which scope your object lives in, you can access like this.

<c:out value="${sessionScope['myDomain.myObject']}" />

A while ago Gavin King blogged about his EE6 wishlist, i add this one to my wishlist...

Using the right DOCTYPE

I have been busy updating the look and feel of an extra-net application.
I was using corporate id guidelines, so it wasn't a very creative process at all.
I have tried to use CSS as much as possible without resorting to tables for layout.

Apparently declaring doctypes is very important for all CSS/layout configuration to work properly.

Wednesday, July 11, 2007

Form design with CSS

I say enough to table based form designs. It is quite shocking to learn that you have to do lots of hacks to get form elements aligned properly across all browsers.
Still the outcome is beatiful.

5 tools you can't live without

Lately I am doing some web application restyling, cssing. I find myself using more and more of these tools.

There are some more useful utilities in the link i have included.

Friday, June 29, 2007

Technical debt

Lately i am paying some technical debts in a project about to go live in a few weeks.
I can easily spot hacked code by following below placeholders.
//FIXME: Some explanation
//TODO: Optimize here if possible
//TEST: Test this condition with respect to x and y.

Functional test reports often point to unreliable piece of code too. Using a bug tracker really helps.

Thursday, June 28, 2007

Earth is small

This post is not about globalization or anything like that.. See it for yourself.

Checked or unchecked exceptions

Every Java developer at one point in her career needs to decide how to convey an exception/error to other layers of application.

Hopefully someone in her organization clearly communicated how exceptions should be handled to her. This is one of the important duties of enterprise architects, mentors, senior developers.

Some would argue that checked exceptions have no place in code, while others argue that there is a place for them.

I find the following piece very informative and balanced.

Here are some key things i hold dear:

1- Differentiate between fault and contingencies. Represent faults with unchecked exceptions.
"Can not connect to server" type errors fall in the category of faults.

2- Try to minimize the use of checked exceptions especially if you are developing an API that will be used by lots of modules/components. Checked exceptions are viral and tend to pollute codebase with unnecessary trycatchfinally blocks.
Remember that you can use try finally block without catching anything in between...
Often times there are other ways of doing it too.

For example following fictitious method throws InSufficientBalanceException if payment amount is larger than account balance.
doPay(Payment p) throws InSufficientBalanceException()

Clients of this method will catch the exception and try to recover from it later.


A much more clean design would be like this.
------
boolean isBalanceEnough(Payment p)
doPay(Payment p) // throws unchecked exception
------

Above API needs to be used in a disciplined strict way. (API is based on a contract.)
------
if(! isBalanceEnough(p)){
// transfer some money from other account
}
doPay(p)
------
Unit tests, code inspections/reviews are expected to spot any misuse of API. Better yet "design by contract" is emerging in Java realm with the advent of annotations.
Then the method signature will look like this.

@pre("
isBalanceEnough(p)")
public void doPay(Payment p)


3- Dont try to shape program flow with exceptions. Exceptions should be exceptional.
Especially input validation shall not be done with exceptions. Because users are expected to put bad input almost regularly and throwing exception on first invalid input is bad practice. Instead collect all validation results and display them at once.


4- Dont ever swallow exceptions without doiny anything.

try{
// do something
}catch(Throwable t){}


Above code will swallow unchecked exceptions too! Welcome to the endless sessions of debugging!!

What are your guidelines for dealing with exceptions and errors in your programs?

Google browser sync

Google browser sync is a Firefox plug-in that continuously synchronizes your browser settings – including bookmarks, history, persistent cookies. Great solution if you are using different computers at work and at home..

Even if you only use single computer, you can use it to backup your browser settings and to restore your open tabs and windows across browser sessions..

A3 process - collaborative, in-depth problem-solving

I have seen A3 process in action.

This one sheet of paper does a lot to tell about the problem/opportunity to all stakeholders.

Don't get me wrong, preparing this little piece of paper is a result of hard work long meetings and careful planning. Yet it is simple, visual and concise.

Here is a template for your consideration.

Enterprise Architects - where do they belong?

Setting up a solid enterprise architecture is pretty important if the company has more than a few of projects under implementation.

With a moving target like programming languages, virtual machine versions, database tools it is important to provide developer teams a solid guide of whats acceptable whats not..


The problem is where do we deploy e.a architects so that they are most efficient and useful?

This article debates that they should be a part of development team.

From my own experience a senior architect or an enterprise architect is best utilized in the proof-of-concept phase of a project. Some would call this period a spike, a phase in which elements of architecture is used in conjunction to minimize surprises later on..

Later as development progresses recurring jobs should be scheduled for architects so that they can monitor/audit the development progress regularly. (Say once a week)

This way an architect could shepherd two or three projects with ease and still can do research and paper work to document best practices and strategies. Besides cross-pollination between projects is very valuable, lessons learnt from one project can be applied to another..

I am not against forming a pool of architects with their own managers etc, just don't let them build their own ivory towers, keep them close to battle-front of development.

One last note, it is a dream come true if at least one senior developer in the team is on par with architects skills and experience..

Wednesday, June 27, 2007

The most succesful language of web

A while ago, i have claimed that javascript was the most successful ubiquitous language of web.
It seems that the fourth edition of ECMA-Scriptwill make sure it stays like that for the foreseeable future.

Here are some highlights of the upcoming version. (From Wikipedia)

  • Classes
  • Packages and namespaces
  • Optional static typing
  • Generators and iterators
  • Destructuring assignment (likely)
  • JSON Encoding/Decoding

I don't see Javascript as a threat to Java language or JVM platform, in fact both languages can collaborate happily if the need arises. In fact thats why Javascript was written in the first place.

javascript and unit tests

With dynamic typed languages, things can go wrong after a few refactorings due to lack of extra information that is available with static typed languages.

Unit/integration tests are expected to cover this front for these languages. It shouldn't be coincidence that the rise of dynamic languages are in parallel with the rise of test driven development/continuous integration (agile/lean)

Two approaches come to mind.

Selenium like tests ( scenario based kinda integration tests)
JsUnit like tests (kinda unit tests)

Traditionally JS testing/debugging was left to alert statements and lots of retries, however i find myself using firebug regularly to inspect and analyze my javascript codes.

Here you can watch the creator of it going through most useful features of it.

Tuesday, June 26, 2007

InfoQ - must follow site...

InfoQ does a good job of highlighting interesting topics, posts from blogosphere.
Here is one example, notice how they add value to story by mentioning
the Apache Lucene Hadoop subproject (which contains an implementation of MapReduce and a HDFS, a GFS-like distributed file system)

Monday, June 25, 2007

YUI and javascript

If you are developing intranet applications you may not feel the heat of cross-browser compatibility, however once you have started working on a world facing web application you have to know and apply lots of details for each browser out there.

Luckily YUI is there for us to help..

Personally i like handpicking javascript code for websites, so you-write-in-your-comfortable-java editor-and-we-will-turn-it-into-javascript approach is no good for me.. (e.g gwt)

YUI helps with CSS, fonts, layout (grids)

And it doesnt stop there, it also gives some components, animations, transitions.. All designed by smart yahoo developers and they actually use it in their own products..

It is low-level (yet functional), extensible and enforcing best practices all along the way.. It is a great start to learn Javascript

Games can be coded in it..

Yahoo provides a set of design patterns as companion too.

With their new CEOs at helm, i would say keeping in touch with developer community with such warm relations can only be a good sign of things to come.

Even google uses it. Nuff said.

Saturday, June 23, 2007

The art of innovation.. Lessons from Apple..

Economist is a higly regarded magazine for me. More on topics of technology, finance and less of world affairs..
Anyway the article l am referring to tells about the key ingredients of Apples' success.

1- Innovation can come from without as well as within.
Remember that Mac OS X is based on the Mach kernel and is derived from the BSD implementation of Unix in NEXTSTEP..

2-
Design new products around the needs of the user, not the demands of the technology. Strive for simplicity...

3- Set the trends yourself, keeping user needs and simplicity in mind. Ignore what market analysts, staticians say for a minute..

4- Fail wisely, learn from past mistakes ..
e.g Music phone developed in conjuction with Motorola failed, iPhone is designed with lessons learnt.

-----
The art of software development can learn alot from the above principles.
Finding the sweet spot of usability/simplicity with complex requirements/workflows is one thing.

Resisting to use the latest/greatest technology for the sake of using one is one thing.(Remember AJAX?)

Short, faster delivery cycles and risk management is one thing (to fail early and wisely)
Lean development practices tell alot about it.

But as a last usual remark talk is cheap, walking the walk is different than talking the walk..
If it wasnt so, we would be seeing more Apples, 37signals, interface21s around us..

Thursday, June 21, 2007

EclEmma

Get code coverage results without waiting for a full Ant build. Use EclEmma inside Eclipse.

JettyLauncher unfortunately does not support latest Jetty version, here is a method to run it inside Eclipse IDE.

Tuesday, June 19, 2007

P6Spy to the rescue

If you ever find yourself trying to use a *reusable* component that is half assed documented, you could attack the problem in many ways.

1- Run unit tests (unit tests tell much more than shit amount of documentation)
2- Read javadoc
3- Inspect database /E-R diagram
4- Endless hours of debugs (assuming you have access to source code)
etc etc

For item 3/4, i highly recommend using P6Spy to log each sql statement. Hibernate/iBatis also has a way of logging sql statements issued. P6Spy proxies jdbc driver and hands over to real driver after logging it to file.

Today i found myself deciphering a DB2 SQLJ based component. JAD is also handy too.

Debugging maven based projects in eclipse

Two links helped me.

http://mahertb.blogspot.com/2006/08/debugging-maven-web-application-with.html

http://docs.codehaus.org/display/JETTY/Debugging+with+the+Maven+Jetty+Plugin+inside+Eclipse

Friday, June 15, 2007

Gems

Today i have stumbled upon typical programmer website. Abject-oriented programming is the next big thing.

Also anyone designing web forms should read LukeW's presentation on best practices of web form design

Thursday, June 14, 2007

Configuring log4j within a Spring env.

Configuring log4j in a web environment is easy. See this and this
However Spring provides no-outof box configuration class. Log4jConfigurer is abstract..

Here is a simple class that initialize log4j for a standalone application.


public class ConcreteLog4jConfigurer extends Log4jConfigurer {
private String location;

public void init() throws Exception {
initLogging(location);
}


public void destroy() throws Exception {
shutdownLogging();
}


/**
* @return the location
*/
public String getLocation() {
return location;
}


/**
* @param location the location to set
*/
public void setLocation(String location) {
this.location = location;
}


}

The trick is to configure this class with an init-method and destroy-method.


bean id="concreteLog4jConfigurer" class="ConcreteLog4jConfigurer" method="init"
property name="location"
value classpath:myLog4J.properties /value
/property
/bean


There are other properties like refresh period etc, that can be exposed too. That is left as an exercise to readers -:)

Wednesday, June 13, 2007

crimson vs xerces

We use iBatis + spring in our projects..
When i tried to launch a testcase in one of our new projects a strange error happened.

SAXParseException: Document root element is missing

Crimson parser that comes default with jdk1.4 is the reason behind it.
jdk1.5 and xerces parses same xml documents fine.
A google search reveals that i am not alone too..

Edit: The root cause was that spring xml was encoded in UTF-8 with high BOM.
When i manually converted documents encoding to US-ASCII (properties->encoding)
three strange characters revealed themselves at the very beginning of file. Deleting them solved the problem. Lesson learned: Sun's Crimson parser does not support BOM markers.

To another laptop

Nvu
Gimp
Structural Analysis for Java
Tortoise SVN
browsers (opera safari firefox)
monetdb5
divx
jetbrains omea
schemaspy + graphviz
Foxit reader
7-zip
mwsnap3
topstyle lite
mozilla thunderbird

These are some of the useful programs i have uninstalled for now.
Moving from dell latitude D505 to Sony Vaio FS series laptop..

Tuesday, June 12, 2007

The most succesful programming language of web

Javascript is the ultimate winner. It is not the most elegant programming language for sure, it has many quirks and bad parts. However it was at the right place at the right time.
It is everywhere
1- browsers (lots of browsers)
2- desktop widgets ala yahoo and apple
3- on your phone Apple iPhone will only support javascript/css combo.

It has some very interesting good parts as outlined by the Douglas Crockford of JSON fame.

As pointed by Mr. Crockford, i am also learning mostly from trials and errors, but that is about to change. Javascript is just not for form validation in my eyes now.

By the way the verifier he talks about can be found here.

Thursday, June 07, 2007

Plugoo

Now we can chat whenever i am online with my favourite IM. Time to communicate...

On other news, i am leaving my current company August 1. I have accepted a challenging position within a big player in telecommunications sector. Lots of restructuring and refactoring projects awaits me. Lots of room for improvements... Wish me luck :)

Saturday, June 02, 2007

SchemaSpy

SchemaSpy can examine a whole database and visualize entity relations. Very nice work.
-----------------------
Do you hate starting on a new project and having to try to figure out someone else's idea of a database? Or are you in QA and the developers expect you to understand all the relationships in their schema? If so then this tool's for you..
-----------------------

Also this week i focus on Struts2 , i started with maven2 archetype and got a working eclipse project in seconds...

I like the way struts2 is open to third party innovation via its plugin architecture

Friday, February 23, 2007

Medieval Islamic tiling reveals mathematical savvy

Just wanted to keep a reference to this article..

Ten Leading Open Source Innovators

Virtualization, linux appliances are hot. Article says, Redhat is positioned better for SOA after JBOSS acquisition?