August 26, 08 by Bryan
This took me a few hours to figure out so I’m logging this here for my own sanity. If you have a bidirectional many-to-many mapping in Hibernate with a join table, the join table is only updated when the noninverse side of the mapping is inserted/updated. In the example below, the join table (pane_specs) is only updated when a spec is saved, not when a pane is saved:
Spec.java
@ManyToMany
@JoinTable(
name = “pane_specs”,
joinColumns = { @JoinColumn(name = “spec_id”) },
inverseJoinColumns = { @JoinColumn(name = “pane_id”) }
)
public List<Pane> getPanes() {
Pane.java
@ManyToMany(mappedBy = “panes”)
public List<Spec> getSpecs() {
August 20, 08 by Bryan
Interesting post at O’Reilly about Perl and how some companies view it as the major problem behind legacy applications. Obviously false but it just goes to show that Perl should be “used by consenting adults” with some semblance of adherence to standards.
http://www.oreillynet.com/onlamp/blog/2008/08/why_corporates_hate_perl.html
July 20, 08 by Bryan
I’m currently maintaining a production application that has given me headaches since I started. It is less than two years old and meets all of it’s requirements, but it’s lack of maintainability has it slated to be rewritten in the next few months. Despite several subroutines that are more than 2000 SLOC I’ve sort of begun to understand the way it is written and how to more quickly make edits to the code. At times it’s made me question my troubleshooting skills but now that I am less frustrated by the app, I’m beginning to wonder where in the development cycle it failed. For all it’s flaws, it does it’s job. Yet it’s a far higher priority to rewrite it than it should be given it’s age and production record. The issue is it takes a long time to make changes and most changes cause unwanted side effects.
First off, there are obviously some general engineering issues that plague this app (note the large subroutines). I’m going to ignore those because although textbook examples of poor engineering practice riddle this app, it should still be clear what the intent of a block of code is. This is the first place it fails: NO COMMENTS. Ignoring all the other problems, if the app was commented it would be 75% easier to maintain and would not require a rewrite so soon.
It seems obvious to me why code comments are a good thing, but I’ve heard arguments against them. The most common is “good code comments itself.” I read a great counterpoint to this from Jef Raskin. Comments not only tell other developers what the code does but why:
A binary search turned out to be slower than the Boyer-Moore algorithm for the data sets of interest, thus we have used the more complex, but faster method even though this problem does not at first seem amenable to a string search technique
Thanks Jef! I would also like to note that it takes far less time to read and understand a block of code than to read a single line comment that explains what the block does. It at least helps identify if this block is the one you are looking for or if you should keep going.
The second major problem kind of falls in line with the first. Evidently there were not any design specs or requirements written for the application. The only thing that is left here is talking to the original stakeholders and trying to figure out what the initial specs were and digging through the many thousands of lines of code to figure out exactly what the current app is doing. Obviously, there isn’t a very good chance that the requirements (the initial ones or what the app has evolved into) will be reconstructed with any degree of exactness.
All I can think of is my first semester in Computer Science when we were all told the worst thing to do when writing an app the worst thing to do is open your IDE and start coding. Turns out they were onto something.
April 04, 08 by Bryan
Much to the dismay of many standards proponents, the OOXML office standard passed the fast track International Standards Organization (ISO) vote last week. For anyone reading this that doesn’t know what this was all about here’s a quick rundown:
Despite the dominant market postion held by Microsoft, some companies had started moving away from using Microsoft Office due to the fact that MS office document formats are proprietary, tying users to MS office. Because of the outcry for open standards, MS decided it would be good to show consumers they are committed to playing nice with everyone else and use an open standard. Of course, there already exists an open document standard, ODF. The problem with using the ODF format for MS is that other products who already use it would suddenly become viable alternatives to the MS office suite. Instead, they proposed their own format, Office Open XML (OOXML).
In true Microsoft fashion and to no surprise of their critics, the OOXML specification was around 10-times larger and infinitely more complicated than the existing ODF format. Despite the problems with this document, Microsoft was able to work “around” ISO rules, and buy/strongarm enough votes to get the specification to pass. A long list of irregularities in the ISO voting process can be found here.
Here’s what sucks:
- Knowing a single company has enough power to pull this off. It makes me skeptical of all politcal processes.
- Once again, a company with questionable (at best) business practices and a dominant market position wins. In an ideal world, objectivity would enter into these decisions somewhere.
- A single company (with a history of exploiting their dominant market share to make it difficult for competition) will now control an entire ISO standard.
- This vote showed some serious flaws in the ISO organization that will likely weaken it’s power and encourage countries to adopt their own standards instead of relying on a newly corrupt international entity.
- As the world seemed like it was getting smaller and working better together than ever before, we revert to allowing a single corporation to decide what is good for us.
Perhaps this is a weakness of capitalism or a call for reexamination of business (and ISO) standards. Either way, it’s discouraging to see an entity with only it’s best interests in mind pull off something of this scale.