Lightweight java and .net architecture
Lightweight java means java without entity ejb (if need 2pc, we need a “generic” session bean).
Why lightweight Java? – One reason is that ejb is not easy to test. A better reason: ejb is not easy to develop, and, it is not necessary.
To replace entity beans, we need OR mapping (the most popular is hibernate), or, JDBC wrapper, in a less “advanced” situation. Even we use JDBC, there is no “dataset” – always “custom class”.
To replace specific business logic session beans, we need façade design pattern with “business delegates” pattern. Java has build-in dynamic proxy, so, this is easy – it is so easy that it can be done in-house.
Regardless ejb or lightweight, Log4j, or the later (1.4 and later) build-in logging, is always used for logging.
By doing the above, there is a clear separation between UI and business logic, so, it does not matter what UI it will use, Swing or Web. There are some UI level frameworks; they are very useful; however, no need to list them here.
Further, the business logic part can be easily unit tested without using mock objects.
You may say that, no mock object means it is low-tech. To properly "release" the high-tech addiction energy (we all are guilty of it; admit it; we are programmers -- it is our duty to be addictive to cutting edge technologies– we just need to find proper ways to “release” it), I strongly recommend you use cglib. For property level “dynamic proxy”, which also means “AOP”, we need cglib. You may ask why we need property level “dynamic proxy”. The answer: for a lot of things, for example, property level logging, property level security, etc. – sky is the limit. Anyway, at least it is a better excuse than "mock objects" to get into the same cutting edge area.
By the way, in .net, cglib corresponds to Castle’s “dynamic proxy”. Also, in .net, there is no build-in high level “dynamic proxy”, so, in .net, we have to use Castle’s dynamic proxy, even for high level (“façade level”) dynamic proxies.
Since we are in the neighborhood of talking about the high-tech addiction, I want to emphasize that lightweight java does not mean low-tech java: (a) it is still J2EE, because technically J2EE includes servlet-based technologies; (b) it still uses session beans ("generic" ones); (c) it can use cglib, aop. Lightweight java is high-tech, and is cool :-)
OK, enough java. I talk about java, because I want to find another way to talk about .net.
I have been in both java world and M$ world for a while; so, I want to point out two important history items. Apparently, it is NOT known by many people, even in Java world. However, it is still extremely relevant in .net -- history tends to repeat itself.
The first one is about stored procedures. Once upon a time, it was "also” extremely popular in java world. I use “also”, because I certainly know it is extremely popular in VB6 and even now in .net. However, after entity bean and OR mapping, stored procedures disappear.
The second one is about using command pattern as the foundation for distributed computing. In Java world, it was "also" extremely popular, before J2EE and in the early days of J2EE. I use “also”, because I know it is the foundation for CSLA, which is a very popular framework in .net. Before J2EE, IBM had a very ambitious project called “San Francisco project”, it was based on command pattern. In the first a few versions of WebSphere (the flagship app server from IBM), command design pattern was prominent; however, it did not last.
Perhaps .net will not repeat the same route; you never know; no crystal balls; let’s wait and see. Regardless, knowing Java’s history certainly makes it more interesting.