What's Wrong with this Code? [ programming/ ]
What's wrong with this Java snippet?public class Actions implements ActionsFactory {
public Actions() {}
//...
public static synchronized Action deleteProject() {
Action a = new ProjectAction(
ActionProvider.COMMAND_DELETE,
NbBundle.getMessage(Actions.class, "LBL_DeleteProjectAction_Name"),
null,
null );
a.putValue(Action.ACCELERATOR_KEY,
DeleteAction.get
return a;
}
//...
}
First correct entry wins a chockie bar ;-)
Technorati Tags: netbeansrcp, java, smellycode
Boolean Illogic [ programming/ ]
Why do Java programmers hate the boolean XOR operator?Is it that they are just generally ignorant about the full-eval boolean operators in general? You know, the operators that look like &, | and ^. Perhaps its that most Java developers are under the impression that they only operate on bits, an are ignorant of the fact that they operate on booleans (and Booleans with that fucking horrible autoboxing/unboxing nonsense.)
I know that 99 time out of 100 we prefer the early-out operators && and || for their efficiency, but a simple ^ can save a hell of a lot of unreadable and less-understandable if-then-else logic. For example, I've just refactored (somebody else's code)
if( check ){
if( !user.isAnonymousUser() ) doStuff();
}else{
if( user.isAnonymousUser() ) doStuff();
}
which I find nasty as hell to be sure is doing what it's supposed to, into
if( check ^ user.isAnonymouseUser() ) doStuff();
Much easier to understand, no?
Twitter [ programming/ ]
Twitter looks vaguely interesting. Not too much. Not enough for me to bother with it. I think it's very Flavour Of The Day.But it does suit one thing I've had in mind for a while... the idea of a "stream of consciousness" blog sort of thing. Essentially a blog where I can just post a line or two or three, without all the formality and palaver of Subject lines, Categories, Tags, etc. In a nutshell, Twitter,but without the 140 character limit, and hosted on my own server as part of my own infrastructure.
Maybe I'll just write it....
<i>I need another development project like I need more holes in my head. Only two major development projects on the go at the moment, and a couple of minor ones.</i>
Etude Progress Report [ programming/ ]
The Etude project is making some progress. Jason is working on the front-end UI in GWT; I'm building back-end management and server-side functionality. Yesterday I put in Client-management UI and today finished it off with User-management. All in straight JSP/Servlet logic. Ugh. Horrible, messy stuff.The object-model for the project is also a mess -- a sign of my lateness in getting involved on that side of things, I suppose, but we're leaving all alone for now with the aim of cleaning it up later. I know we'll end-up paying for that decision somewhere down the line! But for now the goal is to get a functional Version 1 out, and some paying clients signed-up. Once there's cashflow we can justify the time and effort to make the codebase more habitable.
I guess my next objective is to ensure that the scheduler end of things gets tested...

Wizzards [ programming/ ]
Programming software is Magic.
I don't mean that there's something mystical about it, nor that it is intrinsically inaccessible to ordinary people. Nor (I emphatically add) do mean that it is like Magic. In every aspect I can think of, the act of Programming software meets all the criteria for performing Magic. Magic in the Swords and Sorcerers or Unseen University sense. "Alakazam!" and the Prince turns into a Frog. "Shazam!" and you're whisked away to a far, far place at high speed.
Just look at the facts: We (programmers) write programmes -- spells -- in arcane and cryptic symbol languages unknown to the common mob. Get the slightest part of the spell wrong, and, at best, it fails utterly to do anything. At worst it runs amok and fearful consequences ensue -- fires, floods, loss of money and even life! Get it just right, in every teensy, tiny, ball-aching, nit-picking detail2, and Lo! out of nothing, stuff happens in the real world. Gold changes hands. Trains run on schedule. Music plays and Feyries dance1.
Where nothing was before the spell was cast, something comes about solely because of the spell. That's Magic.
And, just like in the fantasies where Wizards keep pet Dragons and dribbly candles set atop skulls are the acme of interior decoration, programmers frequently work at odd hours, with intense, monomanic concentration bordering on the inhuman. And, like the traditional Wizardly Schools, programmers are admitted to different schools of various arts and degrees. So we have Clerics -- programmers content to churn out the boilerplate code needed to keep the wheels of commerce (and most web applications) running, but lacking any true proficiency with martial weapons of higher degree; Monks -- who eschew the use of particular weaponry but, ninja-style, willingly embrace whatever comes to hand as combat fodder; Wizards -- capable of serious Magic, but forget their spells once cast, capable of wonderful stuff, but doomed to repeat it -- with minor variations -- time after time; and then there are the Sourcerers -- Masters of The Source3 whose code is so elegant and expressive, so parsimonious and pretty as to make brave Programmers weep with envy and admiration.
No, you can not deny. Programming really is the realisation of the ancient idea of Magic. Say the Magic Spell and Change Reality.
[1] Well, anybody who wants to dance, I suppose, really.
[2] ...and My God, there's an inordinate amount of crappy detail that all has to be Just So!
[3] Waves to Ken, Doug, Dave, Jason, Paul, Johan, Bob, Brian, John and several dozen others...
Quartz Crystal [ programming/ ]
A very trying couple of days... Faced with a job that cries out for a decent scheduler (polling feeds), I turned to OpenSymphony's Quartz. I mean, the ads look so good: Robustness, recoverability, scalability, blah, blah.First hint of warning I should have paid attention to was a couple of developers' names that I long associate with Doomed Pieces of Shit. But it all still looked so good. Until I got closer to the code. Quartz? Quartz Crystals for accuracy? More like Crystal Meth! Documented methods that mysterious fail to exist. Examples that aren't. I thought the JavaDoc got generated from the source, no? I guess we have here the penetrating stench of Configuration Mismanagement.
Then you enter a twisty little maze of undocumented dependencies. You will use Commons Logging. You will use a bunch of J2EE stuff, even though you application is a simple standalone with no hint of J2EE awfulness in sight.
No. After a day or so of hacking at this steaming turdpile my brain feels like so much oatmeal porridge that I can't even work even work up enough bile for a decently vitriolic blog post. For me, one of the surest signs of a dying opensource project is when their wikis and forums are filled with spam because nobody can be bothered to disallow Guest users from posting; when the version-control system shows six checkins in the past six weeks.
I'm outa here in favour of Doug Lea's concurrency stuff. What a pleasure by contrast. I'll live without clustering for now...
Technorati Tags: quartz, scheduling, opensource
Object-Relational Event [ programming/ ]
At long last EoD SQL 1.0 is out! Congrats to Lemnik on this achievement. But what is lurgy?EoDSQL is an Object-Relational bridge -- an small library for getting (Java) objects in and out of relational databases. It is not an OR Mapper; that task is left to the developer. You get to specify how (Java) data elements correspond to which database columns handraulically, using annotations[1]. Not only that, but, as developer, you get to write all the SQL, too! Good! For me this is one of the best features of EoDSQL. EoDSQL will never mess with your highly tuned SQL, will never get between you and your database. I confess to finding myself far more comfortable with this sort of lightweight approach to the much-lamented "OR impedance mismatch" problem than other approaches I've seen to date.
The upshot of all this lightweight deliciousness is that it is screamingly fast! Way faster than any of the heavyweight OR tools I've seen. And Lemnik is talking about implementing a compile-time tool to make it faster yet.
I have to confess to some bias, though: I was so impressed with the thing that I ended-up writing the tutorial for EoDSQL, so I'd welcome feedback on it, either here, or on the project's mailing list.
Technorati Tags: object-relational, mapping, ORmap, programming, java, database
Netbeans Collab Modules [ programming/ ]
Installed the Netbeans Developer-Collaboration Module yesterday, and gave it a trial-run together with Jason. Wow!The chat-client is pretty standard; not much to say there. The only thing we both disliked was that you have to use "Control-Enter" (or "Alt-N") to send your text rather than plain "Enter". Probably we could reconfigure the keybindings somewhere...
But! The ability to drag a file, folder, Java package or, indeed, entire project into the collab area, and then have both people (and presumably everybody in the chat session) simultaneously able to edit the same files, seeing each other's edits live,... pretty cool.
The real OhMiGod Factor was when Jason hit "compile" on the shared file, to have it compile on my PC (since the original file came from there,) with both of us seeing the compile output. Very, very cool!
We were speculating about some alternative form of development setup where all the code (and docs, web-pages, and other project components) get stored in a wiki-like (auto-versioned, of course) system so that its not just one developer's PC that gets to do the work... Just daydreaming, really. For now.
If you're working in Java, C/C++ or Ruby, and you work with other faraway developers (even occasionally -- the dowload is only a couple of meg) you owe it to yourself to explore the Netbeans Collab stuff. I am pretty sure that what we're seeing now is only the start.
Technorati Tags: netbeans, ide, development, collaboration
