Wednesday, August 8, 2007

Don't use 'private' EVER!!!

I HATE PRIVATE VARIABLES: THEY ARE LAZY AND DOOMED TO IRRITATE

I see a bug that I could fix by extending something and adding a line of code. But that would be easy and solve the problem so instead I have to copy the source code, create the same package and class name, make sure my fixed version is ahead of the bad version in the class path and then fix my bug in the copied code.

What value did 'private' just provide? NONE! It just added a bunch of work for me to do. Had they simply used default access I could have done as I pleased and not had to worry about it. protected would have been ok too. But no, private makes people feel 'cool' and 'secure' when in fact they've done nothing but irritate people using their api.

If you type private, you are wrong! I don't care if you've got good reasons, they're wrong too!
:P

Tuesday, August 7, 2007

Boo: Still learning the tools

Here's that link again, this time with linkability!

Web Services Explorer hates Timestamp, Date and Time

WebService Explorer is a brilliant tool in Eclipse that auto-generates a UI to make calls agains a SOAP WSDL. The WSDL can be hosted locally, or taken from an active web service. From there you can fill in your data and make a submission to see what happens!

Just don't try using Timestamps or you'll come across validation errors galore. Boo.

But wait! Now you can check out this handy URL about SOAP datatypes and how websphere translates them. Specifically, you can see what the input string needed to pass validation is:

http://publib.boulder.ibm.com/infocenter/dmndhelp/v6rxmx/index.jsp?
topic=/com.ibm.wsadapters602.jca_jdbc.doc/doc/cjdb_attribasi.html

What is Model Driven Architecture?

Why should anyone write getters and setters? I know that it's been made simpler in Java 5, but the whole idea of getters and setters is annoying. Another big annoyance is Object Relational Mapping, but (thank god) we've got Hibernate for that now. Still, you have to write an HBM file for hibernate and you need an object to do that but it helps.

Then you have to worry about the Object XML Mapping. Ug. You could try using JAX-B or another binding technology, but that's not so much fun.

Now you've got documentation to worry about. But now you've got HTML, Java, XSD/XML, and HBM all describing the same freakin' object! That's redundant and boring to write.

The solution:
1) Write your object definitions as XSD using Eclipse:Europa's very nice XSD editor.
2) Use that XSD, to generate EMF which will give you Java objects.
3) Use the Teneo eclipse plugin to generate your HBM objects!
4) Oh! You defined with XSD, so the object to XML mapping is already done!
5) Need documentation? Use the documentation annotations in the XSD and all the code will be commented appropriately! You can even use eclipse tooling to generate beautiful UML diagrams out of the XSD files!

So as you can see, all of this work was driven by the model. Thus, Model Driven Architecture.

(I'll come back and add links to all of these things in later posts where I'll spell out each step one at a time)

Surprisingly Simple Services!

Welcome to my new blog. I'll be using this space to expound on my experiences building SOAP web services using SDO / EMF and Teneo /Hibernate to build remarkably simple SOAP services. In this case I'm using Websphere (because that's the clients target platform) and Eclipse Europa.

I've been building services like this for years even before SOAP was a standard. My old company had an XML language used to communicate between backend and frontend layers with a very rich language. In this blog I'll write about how you can achieve similar and even better effects without having to write the 'drudgery code' that most web services require so much of.