Archive for the ‘Java’ Category

MS Paint Revolution And Java

Saturday, August 18th, 2007

This is just too funny:

I really like the part where the girl asks “can we thin out the line?”, and the other guy says dismissively: “No”.

This also got me thinking about similar projects in Javaland, JSF anyone :)? What is your MS Paint in Javaland?

Get your web sites ready…

Thursday, June 28th, 2007

I was watching Steve Jobs keynote and during the keynote Steve was showing off a new widget in the new Mac OS X Leopard version called Web Clip. Here is a video demonstrating it:

And then it hit me. Web sites (and as a result the developers) have been having a lot of problems with syndication (RSS) causing difficulties both in terms of scalability and bandwidth for web sites that expose syndication (the refresh intervals on rss readers). Now, with Apple providing a web clip widget, and probably many other widget system will follow shortly after, our web sites are going to have to handle much more frequent and bigger load. Note, with RSS there are relatively simple solution, but with Web Clips there is no option to load only part of the web site, and every web clip refresh causes the whole web page to download. Also, different than RSS, there is no option to turn it off as MSDN did with RSS.

Naturally, current JEE web sites won’t be able to handle such load without caching. But as noted many times, just caching does solve the whole problem. With web clips (different than RSS), the rate of cache misses is going to be very high.

So, when such web clips widgets are going to come out, web sites are better to get ready for it. The load on a typical web site is going to grow exponentially and developers will need to find a way to solve this (remember, there is no way to turn this off!). This is, in part, what we at GigaSpaces have been working on and thinking about with our latest release, especially with our OpenSpaces solution, but it should be on all of our minds how things like that are going to be handled and solved.

p.s. And I am not even talking about the iPhone and what it brings to the table (in terms of more web enabled devices) or Ajax.

Spring One - Code Organization

Friday, June 22nd, 2007

Juergen Hoeller is talking about code organization:

Packages

Defining packages is surprisingly not simple. The first cut is always trivial, the problem starts when new unexpected new requirements, and how do you fit it into existing structure. The JDK is a mess in terms of dependencies: java.lang, java.util, and java.io. It does not make a sense now, but you can see how it happen if you take the JDK history into account.

A typical scenario: package B uses things from package A. Now, you identify a piece of code that you could reuse in package B from package A. Now, suddenly, you introduced a cycle dependency. It is very simple to introduce such cyclic dependencies since it is hard to notice when working within the same compilation unit.

There is a central rule here: Packages should have (at most) one-way dependencies between each other!. It means that you have a clear architecture and in particular no circular dependencies. Good example is java.lang and java.util, another one is Hibernate with lots of cyclic dependencies between packages. A counter example: Spring does not contain a single package cycle.

Why are one-way dependencies so important? Once the code evolves and more and more cyclic dependencies happen (usually a slow process) you get to a code base that is very hard to maintain. Small changes can very easily propagate to the entire system. You can also not very easily reuse it anymore, for example by taking the package out into a separate build module.

A simple rule of thumb: avoid cyclic dependencies. Many times requires creative refactoring. Usually it is simple the refactor out a common utility into a separate package. Some times you have to create a more fuller package that both A and B uses, like a core package.

Module

Assembly of packages into conceptual modules. The creation of modules is a creative process with no clear hard engineering guidelines on how to do so. Generally, modules follow some consistent guidelines, such as multi-tier separation (often unnatural since it does not match conceptual boundaries). This is not what we are talking about here, we are talking about conceptual boundaries such as account management and not web tier. Another option is isolation of specific dependencies into their own modules (JDK 5, Hibernate), this is still not is called conceptual guidelines.

Desirable characteristics of a modules are low coupling (to other modules) and high cohesion (within the module). Modules are conceptual unit as much as a source management & deployment unit.

Modules should not have cyclic dependencies as well. Layering is essentially a logical view on the package structure. The essence: Establish natural conceptual boundaries in your code base!. Very challenging and more of an art then science. Breaking down to high level modules is simple, the medium level modules are the hard ones.

Moving Forward …

The hardest challenge is evolving the code as well as the architecture over time.., without letting the code deteriorate. It is very easy to let the code deteriorate, which is the main reason why many times a code is thrown away and written from scratch.

Once a need for refactoring shows up, make sure you refactor it as soon as possible. It will get harder and harder to refactor it as time passes. This becomes really hard with large code base and large developer base. Make sure you enforce refactoring rules so people will do them.

You should have closely related modules under the same source tree. This allows for much simpler refactoring (no need to change build process, …). And when things that are easy, developers will tend to do them mode willingly.

Tradeoff between backward compatibility and architectural quality. Many times there is no option to perform refactoring as it will break backward compatibility. Backward compatibility is not always just APIs, it is also semantics that a module exposes. A strict 100% backward compatibility will probably mean that it will not allow for sustaining architectural quality level. Nevertheless, there is (almost) always a better solution than compromising on architectural quality (for example, a creative internal refactoring that allows to preserve compatibility as well as well defined package dependencies).

Of course, some things cannot change easily: package names in the public API. Try hard to get those right upfront!. If you cannot find another clean way out, do not be afraid of deprecation, or even breakage of backward compatibility in some corners!. A good example is Hibernate for example with its Session interface which is a “god interface” that basically do everything. Spring does not have a god interface, and is a decomposed system.

Example: The evolution of Spring

Origins data back to 2001. First public release as download on Wrox website in late 2002. First public release as open source project in mid 2003. Went 1.0 final in early 2004, implying backward compatibility guarantees.

The original code base had core (bean factory), MVC, and Jdbc. In the process several significant sub system were introduced such as: AOP, ORM, … . Over the course of time significant changes had been done within the sub packages, but up to 1.2 there was hardly any backward compatibility breakage.

Spring code base has been increasing a lot during releases. Faces many code evolution challenges: broad public API, used by applications. Sophisticated SPI, used by advanced applications as well as sister products and third-party frameworks. Even within internal code Spring strives for backward support.

Loosely coupled packages with well-defined interdependencies: org.sf.util, org.sf.core, org.sf.beans, org.sf.aop. No cycles allowed. This is why you have Bean Post Processor for example. Internal decomposition proved useful as it became very useful for external users as well.

A special challenge: global configuration. Low coupling through dependency injection. Spring 2.0 XML namespaces: namespaces discovery at runtime. This has been done so the core container won’t know about aop and other aspects. This also proved useful for external extensions with specific namespaces.

Another problem is third party libraries: Hibernate 2.1 -> 3.0 -> 3.1 - > 3.2 evolution. Many changes between each releases and within Spring it tries to work will all versions. So in Spring 2.0 there is support for 3.0, 3.1 and 3.2. Mainly uses reflection checks to verify the Hibernate version.

How do you make sure that there is no architectural violation. Manual analysis only gets you very far, so Spring uses several tools. The main one, since 2003, JDepend. Now, starting to use more richer tools such as SonarJ (commercial).

An example of SonarJ is performed. Analyzing original Spring source with zero cyclic dependency. Now, changes one of the core beans classes to check for AOP from the aop package. Once this is done, SonarJ identifies it and shows an error for cyclic dependency.

An analysis of Hibernate is done now :). Roughly the same lines of code. Hibernate has crazy numbers. Any random class you take in Hibernate will depend on 730 other classes where in Spring the number is 52. What it tells you is that Hibernate is one big module with extreme high cohesion.

Spring One - GWT

Wednesday, June 20th, 2007

Bram Smeets talks about Google GWT.

Introduction to what Ajax is. Ajax = DHTML + Remoting (not necessary Javascript, it can be flash as well for example).

Problems with typical Ajax development: JavaScript is not easy (and many times new), Browser incompatibilities (JavaScript/Dom manipulation, working in xml, XmlHttpRequest), Browser history.

How do you overcome them? Use a framework. Another problem is that there are many frameworks out there. Many of them fix part of the problem. DWR for remoting, Dojo for widgets, … .

Introducing GWT, the holy grail for web development?. It is Googles answer. They develop web applications too and they try to answer how should a Java developer write a sexy, web application? The answer: In Java.

What is it? An architecture for developing rich internet applications. Concept similar to Swing / SWT (but it is centered around HTML and CSS). Uses Java to Javascript compiler.

Benefits: Quick responses to actions (Ajax), Browser compatibility, requires no browser plug-in or JVM (for example, Flex requires flash plugin), manages browser history, and keyboard navigation, one language for server and client side, used the power of Java IDE, OO code and UI components, really simple RPC, easily integrate with existing technologies (such as Spring, JSF, Script.aculo.us), Open Source (Apache 2), [Shay: and do the dishes for you while you watch the last Sopranos episode].

GWT features: Has partial emulation of JRE for JavaScript (java.lang.*, java.util.*), Shell for debugging and testing UI code, UI widget library / DOM utilities, simple browser to server RPC mechanism, Native JavaScript support (JSNI).

Bram is doing a demo of a simple application with a button and a label. All the code is in Java. You can run it within a hosted mode with a GWT console. You can debug your Java code very easily by running the GWT console in debug mode (Bram uses intelliJ, me like!).

Browser to server RPC. Ajax calls wrapped as RPC styles calls (implemented for you in a similar manner to Spring remoting). Servlet / Spring based servers side. It is Asynchronous, so you use callbacks to get back the results. Uses proprietary wire format (for performance reasons), can use JSON as well. What can be serialized?: primitives, String/Date, and any Java type (as long as it is serializable).

Some drawbacks: No Java 5 support on the client side. RPC services have to implement RemoteService tagging interface (the service layer is now dependent on GWT library). User defined types going over the wire have to implement IsSerializable tagging interface.

Some solutions: Use GWT specific service facade. Use DTO and DTO converters ([Shay: not nice at all]).

GWT 1.4 new features: Size and speed optimization, deployment enhancements (modularize RPC mechanism, just reference xxx-nocache.js, cross site scripting), Widgets and Library enhancements (New widgets - RichTextArea, SuggestBox, Splitters), Benchmarking subsystems, no need for IsSerializable, can just use Serializable, and much more… .

Tips and tricks: Use a skeleton application to get started. Use an IDE plug-in to enhance productivity, use obfuscated as the output format (especially in production), create reusable components / widgets (look whether someone else already created one, use Composite base class to hide internals), Secure your server-side calls / URLs using Acegi, use Google Gears for offline applications, define your own AbstractAsyncCallback (for centralized error handling).

Conclusion and benefits: Remain in Java domain (debugging, unit testing), browser anomalies abolished, cleans separation of (static) web content / dynamic GWT code and server side code, Open Source, aggressive caching, code optimization. Has a lot of momentum.

Spring One - Keynote

Wednesday, June 20th, 2007

Rod Johnson is on stage now. First talking about Spring .NET (in a fricking Java conference!) and brought up Mark Pollack on stage showing off Spring .NET simple usage with AOP, declarative transactions, web services. The demo went well though Rod thought that the demo was showing .NET and Java interoperability, but instead it was showing plain .NET default web service client.

Rod talks about the recent VC investment in Interface21, describing it as an analogy of having a really strong cup of coffee ([Shay: does Interface21 needs more wakening to do?]). Talks about what can you do with $10m?: Some examples: eradicate fire ants from Australia, buy chemical weapons detection and protective clothing in Canada, and some more obscure examples. So, with Interface21, the goal is …, wait for it …, invest in Spring and Spring portfolio.

Rod states that Open Source is not about being free, but about providing quality software. Two key values in Spring is simplicity and power, and the mission is to continue and do just that. Spring won’t go and get into areas that are perfectly ok, but will get into areas that are not easy/simple to use. ([Shay: anybody wish to venture a guess?).

Rod now goes over how widely Spring is used. Very high job demand. He compares “spring and java” and “jboss and java” and shows that Spring has overtook JBoss.

Spring has set the bar high, with Forrestar and some other source stating the quality of Spring. Rod thanked Jurgan Holler for this. So, where does $10m goes? Most of it will go into continue and maintain the quality of Spring. A dedicated development centers with dedicated developers investing time in different Spring components / portfolio. You will see x2 increase in Spring Web, x3 increase in Spring core.

Rod talks about “The Eclipse Effect”. Java IDE world has two solutions, Eclipse as the major one, and intelliJ IDEA where they keep innovating and keeping Eclipse honest ([Shay: let the Sun people start to cry about Netbeans]). He now compares IDE world in the past where there were several IDEs, but they were of low quality. And now with Eclipse IDE, which is dominant in the market, people who invest things in Eclipse immediately get into a wide market (for example by writing Eclipse plugins). Now the analogy to Spring, where Spring is becoming such an environment as Eclipse for third party development.

Major players are: BEA - use Spring internally within WebLogic10 where every EJB and other Java EE component is also a Spring bean. Oracle Fusion middleware is built on top of Spring (oc4j, Oracle Coherence, JDeveloper, …). GigaSpaces - version 6 has “native” support for Spring pojo programming model ([Shay: I guess he talks about what I have been up to :)]). Rod talks about GigaSpaces OpenSpaces remoting which is based on Spring Remoting and provides exactly the same “look and feel” simply with exporting virtualized services (that can handle fail over and load balancing). [Shay: He seems to spend a lot of time on this, a bit of an ego boost since I wrote it :)]). IBM and certify Spring on WebSphere ([Shay: exactly what you would expect from WebSphere and the red tape way of thinking, certifications galore]).

Now, my battery is dead which always reminds me of this scene from True Lies:

Javaland “fakesteves” II

Monday, June 11th, 2007

Here are more Javaland fakesteves. I decided to try and post a few of this entries now and then (due to user demand :) ). I added a “fakesteve” caption contest this time, so give it a shot and I will post the best ones.

James Strachan

fakestrac (James Strachan)

Dude, I invented 43.41% of OS Java. Have you heard of it?

I love the word ‘Active’, I love using it. I hate the word ‘jelly’.

Announcing ActiveActive

After several years of development I am announcing a new Open Source project called ActiveActive (code named OpenSorcerer). ActiveActive is a Java library that when executed creates a new Open Source Java project. It requires no parameters, no configuration, just execute and use it. The project has gone through many tests over the past years on the unsuspected Java crowd and I finally managed to nail down most of the bugs. One of the latest features of ActiveActive is when run it will automatically add the project to Apache Incubator and add myself as its mentor. It even has a tagline: ActiveActive, a project so nice, they named it twice.

Caption contest

James Strachan and Charles Nutter

Okay, this one is myself and Charles Nutter going at it. Have at it and I will post the best ones.

p.s. There is no doubt that I win hands down on being original, he just added a J while I invented the coolest Java open source name.

Marc Fleury

fakefleury (Marc Fleury)

Dude, I invented JBoss. Have you heard of it?

I love getting rich on other people backs. I hate to share.

Hidden footage from Oracle talks

I have a friend (french, what else?) that works at Oracle security. He sent me some pictures from Larry Ellison office room during the JBoss acquisition talks:

Larry Ellison

I don’t remember Larry doing that face, in fact, I don’t remember Larry even being in the room. Do you think it has to do with this picture of myself (taken at the exact same moment)?

Dr Evil

Had my Dr Evil costume that day, still my favorite one that I use almost each day now.

JBoss employees hate me, I hate you more!

Just read this. Money quote:

“Marc was a lightning rod,” Shaun Connolly … “People may have been hesitant to approach us in the past because of that, who have been absolutely reaching out to us now to figure out how we can work more closely,” he said.

I wonder if it has to do with the fact that I got all the money out of the Red Hat deal. In your face Shaun and Rickard (I could not resist myself).

Cameron annoys me

Well, Cameron responded to my witty and excellent post on my other blog. Money quote:

So mon père, if I survive a couple months, will you start to wonder if I was on to something?

Well, first Cameron, you don’t have to impress me by speaking my language. Second, I am not angry with you for closing a deal with OraLarry that I failed to close. With OraLarry I simply chose not to bend over. You will need a lot of lubricants to survive there a couple of months.

I give such great talks

I gave this talk not so long ago. I really don’t understand why this presentation didn’t make it to Presentation Zen. I nailed it with the costume and nobody even noticed that I came unprepared and hammered. I sure as hell know how to put up a show.

Namaste Steve

Friday, June 8th, 2007

Well, FSJ went ahead and called me a nerd. I guess he can call me a fool as well for using his operating system and still waiting for Java 6. Namaste Steve.

p.s. Didn’t your company buy my company?

Javaland needs some “fakesteves”

Thursday, June 7th, 2007

I have been reading fakesteve for quite some time now. This blog is hilarious, and I have been thinking that people should start “fakesteves” for Javaland figures (or at least until Hani gets back to blogging more often).

So, to get things moving, here are some of my suggestions for “fakesteves” (all in good spirit mates!). There are many others but I will leave it to another post. If you have any other suggestions, please leave them as comments, I will post another blog with the best ones.

Rod Johnson

fakerod (Rod Johnson)

Dude, I invented frigging Spring. Have you heard of it?

I love POJOs, hell, I invented them!. I hate people who say Spring == XML. Spring Portfolio.

We want to serve you better

Now, with the recent $10M investment in Interface21 (and Spring), we can serve you, the user, better!. We have been doing extremely well for the past few years, but not enough to make us filthy rich. The investment will not change anything with Spring and Interface21, in fact, we actually managed to be the only company with VC investment that is not pressured by VC. Larry and Sergey, eat your hat.

We now have a portfolio!

I have been saying for ages that we are not just Spring, and now I can prove it!. Enter, Spring Portfolio. With such stars such as Spring OSGi (yea, I know nobody use OSGi, but we have the power now to hype anything!), Spring WS (we can make web services simple!, oh wait, maybe not), Acegi Security - soon to be rename Spring Security (very secure in making your security configuration so cryptic nobody would want to mess with it), and a good sense of humor. Ohh, and we are not going down the same path as evil JBoss, honest!.

Gavin King

fakegavin (Gavin King)

Dude, I invented frigging ORM (ahem, Hibernate). Have you heard of it?

I love RDBMS. I love to map things to them. I hate stupid people posting on my forum.

Great new screensaver!

I just saw this picture and simply had to revise it! My colleagues at Jboss suggested that any application that uses Hibernate should display it by default. I couldn’t agree more.

Toplink Seal (Click Me!)

I hate Mike

Just read this at Jira Mike. I already posted a response, but the most important part of it is this:

Yes, some guys at JBoss are arrogant, me included. Speaking only for myself, one of the things that made me so arrogant was having to put up with years of this kind of sniping and lecturing from people I had counted as friends. Every time I read a blog like this one, I get more arrogant. But y’know what - I ain’t goin’ nowhere, and it doesn’t seem like the JBoss hataz are going to get any quieter, so therefore you guys are just going to have to learn to deal with arrogance. Sad but true.

I sure as hell know how to kick ass!

Matt Raible

fakeraible (Matt Raible)

Dude, I invented frigging Appfuse. Have you heard of it?

I love shinny software, I get distracted by them. I hate, ammm, I hate…, nothing!.

Coding six days straight, no sleep

I have been coding for the last 6 days straight. It started with a very simply feature adding another logging statement in Appfuse. I then got distracted and thought maybe we should change the usage of commons logging so I went ahead and searched for other logging frameworks finding out there was slf4j but almost nobody uses it I then thought maybe we should allow users to change the logging level using web services and searched for best web services implementation I looked at xfire axis and many more resulting in the understanding that I need to upgrade to a newer JEE spec searched for best implementation to start working on but after several hours remembered that most appfuse users still run on the previous version tried to integrate the WS solution into maven but found out that the installation is now 1.5G and is bigger than vista then thought that I need to try another operating system so installed Ubuntu spent a few hours fixing the wifi in order to be able to download all the maven jars and build appfuse. managed to do it. Now, what did I started with …

Compare X and Y java libraries

I spent the past few days trying to compare X and Y java libraries. X is really nice and has a small installation and passed my 0.3 milliseconds install rule, Y was also really nice and passed my install rule. X has a really nice feature allowing you to simplify your development and a very active mailing list and Y has a really nice feature as well with very active forum. The developer behind X is amazing and gives very good talks and I had really good time drinking beer with Y developer. Now, which one should you choose? You thought I will give you a hint, no way hose!

Update your RSS readers

Sunday, June 3rd, 2007

I added this blog feed to feedburner so update your rss readers to this link

Grails and Compass

Friday, June 1st, 2007

Maurice Nicholson has been making amazing progress with Compass and Grails integration. The simplicity of adding search support for any Grails application has been simplified tremendously and it seems like more and more features are added each day.

If you are interested, check out Grails Searchable Plugin.

As a side note, it seems like more and more users are starting to express interest in Compass Mapping domain model, and the ability to provide Compass with an already constructed mapping model that is built not necessarily using one of Compass mapping options. This has been added to the latest Compass 1.2 M2 SNAPSHOT.