Jul 30

Keith Short tech talk on how not to fail in the modelling world again

Tech No Comments »

TheServerSide.NET has an interview with Keith Short, one of the principals behind Whitehorse. He talks with Ted about Model-Driven Architecture and UML/CASE tools, why they failed, and why Microsoft isn’t repeating the mistakes of past generations

Keith Short – Manager, Microsoft Enterprise Frameworks and Tools Architecture Team

Keith Short leads the Enterprise Frameworks and Tools Architecture Team at Microsoft. He helped lead design of the Information Engineering Facility from Texas Instruments Inc., now Advantage Gen from Computer Associates Inc. He was later named a TI Fellow and became CTO for Software at TI. He contributed to UML 1.0, and lectures at conferences and seminars world wide. He holds a Bachelors degree in Computer Science from the University of Lancaster, and a Ph.D in Computer Science from the University of East Anglia.

One of the core differences is that Keith’s team doesn’t want to do code gen. He discusses MDA, and what is going on there, and how Microsoft wants to do something different.

Jul 30

Springing forward with Groovy

Groovy, Lightweight Containers, Tech 2 Comments »

We have really been enjoying writing WebWork actions in Groovy. It is a pleasure, and I had a really nice chat with Rod Johnson about how cool it would be to write beans for Spring in Groovy.

Rod then managed to whip up some code that lets this happen, so you could do:

<bean id=”property”
singleton=”false”
class=”org.springframework.beans.groovy.GroovyFactory”
factory-method=”dynamicObject”>
<constructor-arg index=”0″><value>org/springframework/beans/groovy/PropertyHello.groovy</value></constructor-arg>

<!– Reload seconds –>
<constructor-arg index=”1″><value>20</value></constructor-arg>

<!– Property on created Groovy object –>
<property name=”message”><value>hello world property</value></property>
</bean>

Works like a charm :)

We also talked about maybe allowing other languages to be plugged in. Imagine a config such as:

<bean id=”something”>
<script language=”groovy” file=”org/springframework/beans/groovy/PropertyHello.groovy” />

<property name=”reloadSecs”><value>20</value></property>

<property name=”someDI”><ref bean=”SomeBean”/></property>
</bean>

We also talked a little about having Groovy as a config option, and at then Bing Ran emailed the groovy-dev list with a concrete example of how it would look:

import org.springframework.jndi.JndiObjectFactoryBean
import org.springframework.orm.hibernate.LocalSessionFactoryBean
import net.sf.hibernate.dialect.MySQLDialect
import org.apache.commons.dbcp.BasicDataSource
import product.ProductDaoImpl

DataSource myDataSource = new JndiObjectFactoryBean {
jndiName = “java:comp/env/jdbc/myds”
}

DataSource myDataSource2 = new BasicDataSource(”destroy-method”:”close”) {
driverClassName = “org.hsqldb.jdbcDriver”
url = “jdbc:hsqldb:hsql://localhost:9001″
username = “sa”
password = “”
}

SessionFactory mySessionFactory = new LocalSessionFactoryBean {
mappingResources = ["product.hbm.xml"]
hibernateProperties = [hibernate.dialect : MySQLDialect.class]
dataSource = myDataSource2
}

Dao myProductDao = new ProductDaoImpl {
sessionFactory = mySessionFactory
}

The general idea is to use a constructor like structure to describe the wiring of objects.

1. implicit property setting: since we know that an assignment in the Groovy constructor call is to set the property, we save <property> pair, my mind doesn’t need to use any extra energy to interpret it.

2. better list/handling. Groovy list/map construct really shines here, instead of saying:

<property name=”mappingResources”>
<list>
<value>product.hbm.xml</value>
</list>
<list>
<value>customer.hbm.xml</value>
</list>
</property>

I used:

mappingResources = ["product.hbm.xml", "customer.hbm.xml"]

Instead of:

<property name=”hibernateProperties”>
<props>
<prop key=”hibernate.dialect”>net.sf.hibernate.dialect.MySQLDialect</prop>
</props>
<props>
<prop key=”hibernate.someotherkey”>some other value</prop>
</props>
</property>

I did:

hibernateProperties = [
"hibernate.dialect" : MySQLDialect.class,
"hibernate.someotherkey" : "some other value"
]

3. Possible strong type checking: the interpreter, when compile the groovy config , can check if the property settings is match the types. In the xml file, everything is just a bean, and I have to read the class name to “infer” what type of beans they are: a data source, transaction manager, a DAO, an Interceptor, etc. This makes reading the config quite a whirl.

4. Possible tree like structure: instead of:

<bean id=”myHibernateInterceptor” class=”org.springframework.orm.hibernate.HibernateInterceptor”>
<property name=”sessionFactory”>
<ref bean=”mySessionFactory”/>
</property>
</bean>

<bean id=”myProductDaoTarget” class=”product.ProductDaoImpl”>
<property name=”sessionFactory”>
<ref bean=”mySessionFactory”/>
</property>
</bean>

<bean id=”myProductDao” class=”org.springframework.aop.framework.ProxyFactoryBean”>
<property name=”proxyInterfaces”>
<value>product.ProductDao</value>
</property>
<property name=”interceptorNames”>
<list>
<value>myHibernateInterceptor</value>
<value>myProductDaoTarget</value>
</list>
</property>
</bean>

I can do something like this:

ProxyFactory myProductDaoFactory = new org.springframework.aop.framework.ProxyFactoryBean {
proxyInterfaces = product.ProductDao.class
interceptors = [
new HibernateInterceptor {sessionFactory = mySessionFactory},
new product.ProductDaoImpl {sessionFactory = mySessionFactory}
]
}

After we have macros in Groovy we can build configurations that configure huge number of otherwise similarly configured beans such as DAOs:

#def_dao ["dao1", dao1Impl]

#def_dao ["dao2", dao2Impl]

#def_dao ["dao3", dao3Impl]

#def_dao ["dao4", dao4Impl]

The possibility is unlimited.

Now, a good binding of Groovy will not only simplify the config, but probably more importantly, simplify writing Spring beans.

Here is an example:

public class ProductDaoImpl implements ProductDao {
private SessionFactory sessionFactory;
public void setSessionFactory(SessionFactory sessionFactory) {
this.sessionFactory = sessionFactory;
}
public List loadProductsByCategory(final String category) {
HibernateTemplate hibernateTemplate = new HibernateTemplate(this.sessionFactory);
return (List) hibernateTemplate.execute(
new HibernateCallback() {
public Object doInHibernate(Session session) throws HibernateException {
List result = session.find(”from test.Product product where product.category=?”, category, Hibernate.STRING);
return result;
}
}
);
}
}

Here is the same Dao impl in Groovy:

class ProductDaoImpl implements ProductDao {
property SessionFactory sessionFactory;

List loadProductsByCategory(String category) {
ht = new HibernateTemplate(sessionFactory);
return ht.execute {|session|
session.find(”from test.Product product where product.category= ${category} “)
}
}
}

The property and the Closure features make it look a lot cleaner. Groovy could well suited to writing Spring beans: each unit is small and clearly intended. We don’t need too much compiler help to make it work and there is no compile and deploy cycle.

Further down the road, I imagine that macros/annotations can help us build a groovy data access layer that sits on top of the Spring JDBC templates to implement a mean and clean persistent mechanism: no XML mapping files, auto-interfacing (defining the interfaces and impls in the same file), etc.. Would that be cool?

Now we have a strong use case for Groovy!

-bing

All early days, but cool :)

Jul 30

James Strachan does something strange…. he actually talks about what Open Sourcing Java means :)

Java, Open Source, Tech No Comments »

I had a chat with James at JavaOne, and we discussed the whole open source Java topic.

My biggest frustration about all of the talk in the industry has been that it didn’t seem like anyone was giving any actually information on what THEY considered an open source Java to mean.

Why do you want open source Java?
What don’t you like about Java as it stands?
What do you want to open source?
What license?
Who has access / power?

James has thought about the various scenarios that we currently have, in which the current Java model gets in the way. He then has cut to the chase on what would need to happen to help these scenarios out, and the solution ISN’T to open source all of the Java source code, the JVM, etc etc.

He basically wants to create an open source project (JRT) which is the rt.jar. Note that this isn’t a Java brand thing, and would mean that the poor GNU Classpath guys could focus on other things :)

Check it out. What do you think? Why Sun should open source Java and how – a new proposal (not open source Java but JRT)

Jul 30

Tapestry and Real URLs? The killer combo

Java, Tech, Web Frameworks No Comments »

I am a big fan of Tapestry. One of the only items left on my list of “this bugs me” was the fact that I didn’t have the control over the URLs that I want.

I want URLs to say something, and detest any gobble-de-gook. I think it DOES make a difference.

Howard has promised that this feature will be in 3.1, and it looks like someone has done the heavy lifting for him ;)

Identitytheft911.com has written code that allows them to map URLs, so if you go to:

http://www.identitytheft911.com/resolution/crisisresolution.htm

it gets mapped into the normal Tapestry URL:

http://www.identitytheft911.com/app?service=page/crisisresolution

The explanation:

There are 2 parts: generating and interpreting.

To generate the urls, I use custom PageLink and ExternalLink components
that utilize a custom ILink implementation that generate the urls using
the following pattern:

/ .htm
The path-to-page-specification is taken from my application specification.

e.g.

specification-path="resolution/CrisisResolution.page"/>
path-to-page-specification = resolution/
page-name = crisisresolution
generated url = /resolution/crisisresolution.htm

Using lower case page names was done at the insistence of my site
developer…

To interpret the urls, I have a custom Tapestry servlet that is mapped
to the url pattern *.htm.
In my service() method, if the url query string contains “sp” (i.e.
Tapestry.PARAMETERS_QUERY_PARAMETER_NAME), then I generate a Tapestry
external link, if not I generate a page link.

Great stuff!

Jul 30

Archers and Jazz Musicians

Tech No Comments »

Bruce Tate is becoming Mr. Analogy :)

His latest effort talks about Spring and the English Archer. Here he walks us through history, and how great the Brits were with their weapon of choice. Of course in today’s day and age us Brits are only good for losing in most sports that we invented, and following the US like a lap dog (unless you could Hugh Grant’s speach in Love Actually).

Christian Parker throws his hat in the ring with: Software developers are like jazz musicians.

Whenever I hear a Jazz musician interviewed they describe their career in terms of other people they have ‘worked’ with. E.g. Winton Marcellus might say : “early in my career I had the privilege of working with Louis Armstrong, then later I played with Duke Ellington, …”. I’ve never interviewed a plumber, but I wonder if they say similar things, “Yea, I studied under Sal up in DesMoines…”. I honestly don’t know.

Not many software developers seem to think about their craft this way. I’m not sure why. Maybe it’s because we’re just not the social type. Or maybe it’s because software development tends toward an isolated activity; plugging away on your PC in a dark room somewhere.

I’m hoping later in my career I can rattle off a list of names of people I’ve worked with that I respect who taught me things and helped me along in my career. Who knows.

I definitely owe what I have done in my career so far to the people around me. I have learnt so much from the many artisans that I get to work with, and of course those who I interact with through the ether.

This fits nicely with the Programmers are like gardeners analogy. I hope to work in the garden, tend to my code, and learn from the jazz musicians around me.

Jul 29

The Java Hacker Nonsense

Tech 2 Comments »

Paul Graham had an OSCON keynote and people are all riled up about “There are no Java Hackers”.

Mark Watson has got it spot on:

Sure, with Java you give up late binding, continuations, etc. However, the awesome and free tools like Tomcat, Prevayler, SOAP/XML-RPC/REST libraries, incredible development tools like IntelliJ, etc. make using Java a slam dunk for some types of projects.

Popularity in a programming language can be a good thing, and Java definitely has popularity.

I have always respected people’s choice in programming languages and tools. Unlike a lot of people on Slashdot, I think that knocking someone’s choice in programming language is as silly as dissing on their politics, choice of mates, or religion.

Diversity is what makes the world interesting.

Java is a great language, is very useful, has many great developers and minds, and is pushing things in many areas (AOP, TDD, etc).

However, there are many other great languages and environments. One of the more exciting aspects of Java is that fact that it is a platform. There is the JVM, and there are APIs. These have nothing to do with the language itself.

So, if I don’t need a static experience, I can write that piece of code in Groovy/Jython/JRuby/insert your favourite here.

Learning a new language syntax is easy. What is normally hard is groking all of the libraries. Now, we know a lot of Java libraries so we can get up and running fast!

Jul 29

Python for the CLR: Microsoft hires the guy who did it :)

Tech No Comments »

Jim Hugunin has joined the CLR team at Microsoft, and also just released version 0.6 of IronPython, an open source CLR implementation of the Python language.

He has written an interesting paper which focuses on the performance of Python on a VM.

Unfortunately, as I carried out my experiments I found the CLR to be a surprisingly good target for dynamic languages, or at least for the highly dynamic specific case of Python. This was unfortunate because it meant that instead of writing a short pithy paper I had to build a full Python implementation for this new platform to see if there would be any hidden traps along the way. Because performance is such a dominant question for Python on the CLR, the rest of this paper focuses entirely on performance issues and measurements.

The CLR version runs some benchmarks as fast or faster than the native C implementation of Python.

Microsoft keeps hiring bright guys. Why aren’t we hearing that Sun is hiring these folk? Jim was the guy who brought us Jython, so he was playing in our backyard first!

Jul 29

Gavin’s “Lie Of Simplicity”. My goal: Be convenient to do the common tasks, and possible to do the complicated tasks

Tech No Comments »

Gavin has written about The Lie Of Simplicity.

I have found that the balance of making a tool successful is tough as it needs many things:

  • Solves a problem in a new / better way
  • A good learning curve so people can start climbing the hill
  • Be convenient to do the common tasks, and possible to do the complicated tasks

That last one is key for me. EJB-QL makes it easy to do simple things, but IMPOSSIBLE to do anything real. HSQL is still pretty convenient for doing the same simple things, yet gives you the power that you need to do more complicated tasks.

This is where Java actually falls down for me (personally). I don’t find it convenient for doing small tasks, and that is where other languages like Perl/Ruby/Groovy can come in.

It also helps when it is obvious that you have gone from the simple-world into the more powerful world, and is even better if you can encapsulate that ;)

Jul 29

AspectJ and AspectWerkz compared… sort of…

Tech No Comments »

Val is a long time AspectJ user, and dived into AspectWerkz to check out a solution for instance-based cross cutting.

He wrote up a nice little comparison based on his findings:

I have been using AspectJ since the first beta versions and I have always been quite happy with it. However, even though AspectJ excels at type-based crosscutting, I still think that it lacks proper techniques for achieving *true* instance-based crosscutting. JBoss AOP and Spring (which I haven’t talked about in this blog) are said to achieve this goal but I’m not completely satisfied with those solutions. I’m still looking into how AspectWerkz could provide a better solution to my problem. I’ll probably write an update about this problematic in the near future.

AspectJ and AspectWerkz compared… sort of…

One of the criticisms of AspectWerkz was the lack of this(), target(), args() and such. However, Jonas popped up to tell us that they will be supported shortly!

Jul 28

CVS-like Access to a Wiki

Tech 2 Comments »

Have you ever had the problem of “where do I put this?”.

At many places there are a few systems:

  • Wiki: Attach a doc to the Wiki. It is great in that it can be linked to in a nice way, you can grab it from wherever you are etc…
  • Company File Repository: You can put the doc in some remote file repository (folders on a shared samba system, etc). This is shared, but there is no revision control, and if you are offline you can’t get to it
  • Sync’d repository: (E.g. CVS/SVN bastardized to do this). This is nice in that your docs are local, and you can see what is updated etc etc… but folders aren’t the best way to organize things, and there isn’t much metadata

I have tried other work arounds, like having a WikiAttachments directory where I keep everything so I have a local copy. But you don’t know when someone has added things, and it is a pain to keep in sync.

What is there was a way in which I could use cvs/SubVersion to talk to Confluence, and it would all me to sync up and have local copies. In fact, it would be cool to have a sync’d up copy of the entire Wiki so I could run it locally if I was offline!

I guess with tech such as Near-Time Flow and BEA’s vapourware Alchemy, we could get there too…