Kortsoft

Friday, December 23, 2005

Spring Framework 2.0 M1 released: "El comienzo de la nueva temporada de Spring está aquí: Spring Framework 2.0 M1.

Bájatelo

Características nuevas incluidas:

  • Configuración XML simplificada y extensible

  • Nuevas funcionalidades de AOP muy potentes. Integración con AspectJ

  • Facilidades asíncronas JMS mediante message-driven POJO's

  • Spring Portlet MVC, un framework para JSR-168 Portlets

  • y mucho más...


(Se mantiene la compatibildad hacia atrás al 100% con Spring 1.2 y continúa siendo ejecutable en Java 1.3 o mayor)

Wednesday, December 14, 2005

'Pimp My Shirt' Sample Application: Puedes encontrar aquí una aplicación de ejemplo usando Spring Web Flow y algunos conceptos complejos de Spring MVC (subida de ficheros, data binding avanzado, redirect-after-post, etc...).
La aplicación fué presentada en la Spring Web Tier Session por Erwin Vervaet y Alef Andersen en JavaPolis 2005

Tuesday, December 13, 2005

AnemicDomainModel by Martin Fowler

This is one of those anti-patterns that's been around for quite a long time, yet seems to be having a particular spurt at the moment. I was chatting with Eric Evans on this, and we've both noticed they seem to be getting more popular. As great boosters of a proper Domain Model, this is not a good thing.

The basic symptom of an Anemic Domain Model is that at first blush it looks like the real thing. There are objects, many named after the nouns in the domain space, and these objects are connected with the rich relationships and structure that true domain models have. The catch comes when you look at the behavior, and you realize that there is very little behavior on these objects. Indeed often these models come with design rules that say that you are not to put any domain logic in the the domain objects. Instead there are a set of service objects which capture all the domain logic. These services live on top of the domain model and use the domain model for data.

The fundamental horror of this anti-pattern is that it's so contrary to the basic idea of object-oriented design; which is to combine data and process together. The anemic domain model is really just a procedural style design, exactly the kind of thing that object bigots like me (and Eric) have been fighting since our early days in Smalltalk. What's worse, many people think that anemic objects are real objects, and thus completely miss the point of what object-oriented design is all about.

Now object-oriented purism is all very well, but I realize that I need more fundamental arguments against this anemia. In essence the problem with anemic domain models is that they incur all of the costs of a domain model, without yielding any of the benefits. The primary cost is the awkwardness of mapping to a database, which typically results in a whole layer of O/R mapping. This is worthwhile iff you use the powerful OO techniques to organize complex logic. By pulling all the behavior out into services, however, you essentially end up with Transaction Scripts, and thus lose the advantages that the domain model can bring.

One source of confusion in all this is that many OO experts do recommend putting a layer of procedural services on top of a domain model, to form a Service Layer. But this isn't an argument to make the domain model void of behavior, indeed service layer advocates use a service layer in conjunction with a behaviorally rich domain model.

Eric Evans's excellent book Domain Driven Design has the following to say about these layers.

Application Layer [his name for Service Layer]: Defines the jobs the software is supposed to do and directs the expressive domain objects to work out problems. The tasks this layer is responsible for are meaningful to the business or necessary for interaction with the application layers of other systems. This layer is kept thin. It does not contain business rules or knowledge, but only coordinates tasks and delegates work to collaborations of domain objects in the next layer down. It does not have state reflecting the business situation, but it can have state that reflects the progress of a task for the user or the program.

Domain Layer (or Model Layer): Responsible for representing concepts of the business, information about the business situation, and business rules. State that reflects the business situation is controlled and used here, even though the technical details of storing it are delegated to the infrastructure. This layer is the heart of business software.

The key point here is that the Service Layer is thin - all the key logic lies in the domain layer. He reiterates this point in his service pattern:

Now, the more common mistake is to give up too easily on fitting the behavior into an appropriate object, gradually slipping toward procedural programming.

I don't know why this anti-pattern is so common. I suspect it's due to many people who haven't really worked with a proper domain model, particularly if they come from a data background. Some technologies encourage it; such as J2EE's Entity Beans which is one of the reasons I prefer POJO domain models.

In general, the more behavior you find in the services, the more likely you are to be robbing yourself of the benefits of a domain model. If all your logic is in services, you've robbed yourself blind.

Penrose 0.9.8 Released, adding Persistent Cache: "The Penrose team is proud to announce the 0.9.8 release."
Penrose es un servidor de directorio virtual. A deiferencia de un servidor de directorio, uno virtual no gestiona los datos por si mismo, sino que traduce dinamicamente las peticiones que recibe en operaciones de otros protocolos o modelos de datos como una base de datos relacional.

AJAX and Java: Toolbox


Robert Cooper
Nov. 29, 2005 09:43 AM
Permalink

After monkeying around with some DIY Ajax stuff, I started looking at some of the emerging tools out there. Please forgive me if I don't mention [insert project name here]. Honestly, I have played with a number of them. No, I haven't put all of them completely through the motions. However, there are a few that I think are pretty great.

Target Audience: Pretty typical Struts developer looking to enhance functionality without radically redefining the way she builds software.

Ascendancy: Order of invasiveness to your app.

AJAXTags


AJAXTags is a simple JSP taglib that offers some nice functionality. It is not a framework. It is not a methodology. It is, simply, a handful of app-friendly tricks that you can stick into your application. They have a nice demo page demonstrating each of the tags. There is a nice "sliding doors" CSS tabset, an autocomplete widget and a bean-bound table (imagine that :P). If you are like me, a lot of this is stuff that you have built by hand already, but having some standard tags for it is handy.

Taconite


Taconite uses the word "framework", but I wouldn't go that far. The short version is it is a tool that simplifies (a) making your XmlHttpRequest call and (b) gives you server-side markup that controls basic insert parameters.

For instance: If you want a button to append something to the bottom of a content area:

<script>!-- function foo(url){ var ajaxRequest = new AjaxRequest(url); ajaxRequest.sendRequest(); } //--></script>

<button onclick="foo('runButton.action?id=bar');">
</button>



Then your JSP for runButton would have:

<taconite-root space="preserve">
<taconite-append-as-children contextnodeid="idOfNodeToAppendTo" parseinbrowser="true"> </taconite-append-as-children></taconite-root><div style="font-weight: bold; color: orange;">

Taconite says: Hello World!!!

</div>

</taconite-append-as-children>

</taconite-root>


Of course, with some clever breaking up of JSPs, it is not hard to use the same content set for an AJAX and Non-AJAX version of your app.

Direct Web Remoting


The Zipperheads have a nice intro to this. This is the most invasive of anything here. This is basically an easy way to expose a service bean to a web client through JavaScript directly. If you are like me, and tend to build your business services with Axis SOAP in mind, you will find it nearly brain-free to re-expose them as a DWR "JavaScript Service".

Moo.fx


This is just some chrome for your app, but its not bad and is a small and noninvasive way to give your app some polish. It is a set of nicely animated transitions and visibility controls. They have some fancy demos, but if you look at the test page you can see all the individual functions laid out pretty well.

Robert Cooper is an independent Java developer in the Atlanta area, working with J2EE technologies and web/web service projects.

Presentation: POJO development with Spring and Hibernate at SDForum Java SIG in Palo Alto: "Start: 2005-12-06 06:30

End: 2005-12-06 10:00

Timezone: -14400


Description:


Chris Richardson will present 'Overview of POJO development with Spring and Hibernate' at SDForum Java SIG in Palo Alto on December 6th.  Read more about this event here.  Chris is a developer, architect and mentor with over 20 years of experience and is the author of the forthcoming book 'POJOs in Action.' "

Monday, December 12, 2005

Microsoft's AJAX toolkit: "Omar Shahine has a great post about FireAnt, Microsoft's AJAX toolkit which they are using for the Hotmail rewrite.

It sounds fairly similar to DWR in the Javaworld, which I have raved over before.

Speaking of AJAX, I came to the sudden realisation this week that AJAX programming can actually be easier than conventional web programming. It's true that tool support for AJAX still sucks, but that is sometimes compensated for by the fact you get to ignore the traditional problem with webapps: the lack fo state.

Transitions between the two programming models are the tricky bit - for instance if you want an AJAX control to be in a particular state when a page loads then you either need to setup defaults for it (which is nasty if the defaults have to change depending on the state of the application), or have an page-load event to trigger updates to the control. Neither option is particularly elegant. "

java.util.concurrent.Executors: "I think java.util.concurrent.Executors (and related functionality like Futures) is one of the best features of JDK 1.5.

One small feature I'd like, though - a newCachedThreadPool(int nThreads) factory method that combines the features of newCachedThreadPool() and newFixedThreadPool(int nThreads). It would create a thread pool that creates new threads as needed up to the number specified by nThreads reusing previously constructed threads when they are available.

This functionality is available directly in java.util.concurrent.ThreadPoolExecutor, but a factory method would be delightful. Surely I'm not the only person who would find a thread pool with a max limit on size that shrinks after use more useful than either a FixedThreadPool or an unbound CachedThreadPool?"