<rss version="0.92">
  <channel>
    <title>the corner office</title>
    <link>http://www.thecorneroffice.org/blog</link>
    <description>tech posts at the corner office</description>
    <copyright>Colin Pretorius</copyright>
    <item>
      <link>http://www.thecorneroffice.org/blog/plink/2008/07/080711-2323.html</link>
      <title>July reckoning</title>
      <description><![CDATA[<p>
It's July. Cue ohmywordit'shalfwaythroughtheyearalready type comments. Ohmywordit'shalfwaythroughtheyearalready. Hard to believe (I think I say that every year). I look back over the last 6 months and I'm not sure what I've accomplished.
</p><p>
What new technologies have I been working with this year? More Spring, CXF, and a dose of distributed systems type stuff. Good fun - not much that's bloggable, but fun nonetheless. I've finally come to terms with Maven2 and decided it's not bad. When I first started using it, I couldn't think up enough horrible things to say about it, but I've reached the point where I prefer using <a href="http://m2eclipse.codehaus.org/">m2eclipse</a> over traditional Java projects in Eclipse.
</p><p>
At home, I've fluffed around a bit - frustratingly so I'll admit. I wanted to whip up something that would make it easier for me to ply my trading trade in Eve. In the end, the trading app tail wagged the tech hobby dog. I backed-and-forthed and experimented with different things for ages: Eclipse RCP, plain SWT, Swing, web, wxWidgets, and everything between. I finally settled on wxWidgets and C++. I was fiddling with some complicated JFace widget one night and decided there and then that I just wasn't going to waste any more time on Eclipse RCP. Good luck to those who can make it do good things - I just think it's too much effort and frustration. Eclipse is a great IDE, but I've lost all interest in seeing how the <a href="http://en.wikiquote.org/wiki/Otto_von_Bismarck#Disputed">sausage is made</a>. Regardless of the flavour, Java GUI programming and I do not get along. I've now made peace with that fact.
</p><p>
That was a month or two back. As I've said before, I like wxWidgets. Its API just feels like it has far less bullshit. GUI toolkits weren't meant to fully occupy the agenda for 2008, but I've wanted to get comfortable with <em>something</em> - comfortable enough to bolt a UI onto whatever itch I'm scratching, so to speak. So I'll carry on with wxWidgets and C++ - 2008 was supposed to be the year I got my hands dirty with C++ again anyway - and then move onto my original <a href="http://www.amazon.com/UNIX-Systems-Programming-Communication-Concurrency/dp/0130424110">planned</a> <a href="http://www.amazon.com/Unix-Network-Programming-Addison-Wesley-Professional/dp/0131411551/ref=pd_bxgy_b_text_b">diversions</a> in a few months' time. 
</p><p>
Ironically, the past 2 months have been the busiest on the work and Real Life front, and the going is slow. But at least I have a sense of direction again, and for a stretch I found myself thoroughly depressed at how much time I was wasting when I didn't have that.
</p>]]></description>
    </item>
    <item>
      <link>http://www.thecorneroffice.org/blog/plink/2008/05/080528-0137.html</link>
      <title>Grouping classes</title>
      <description><![CDATA[<p>
I was looking at some sample code today, and found a Java file with about 5 classes in the file - one public, and another 4 default-scoped classes. Although it's perfectly legal, my experience is that you hardly ever see this in production code. You'll see enough inner classes, member and static, often a healthy dose of anonymous inner classes (and almost never a local class), but bundling a number of classes into a Java file? It just doesn't happen. 
</p><p>
I wonder why that is. I suspect it has a lot to do with how people work with IDEs. In the old days when crazy people coded  Java in Notepad or vi, it might have made sense (and been more convenient) to have multiple classes in the same file (it's common enough in C++ code). With an IDE like Eclipse, and using something like the Package Explorer, files are the top level of abstraction within a package, and I think developers make an easy file = class equivalence.
</p><p>
Arguably, multiple classes in a file allows an extra level of organisation, logically grouping related classes. Whenever I want to do that, though, I favour inner classes. I can scope the classes more tightly, and associations are more explicit. The down side is you can lose some encapsulation. To be honest, I just never think about anything other than class-per-file with inner classes as needed. So is there a place for multiple classes in a file? Is this a useful but much-neglected feature in Java, or does it hurt readability for developers who don't expect to see it? Not sure...
</p>]]></description>
    </item>
    <item>
      <link>http://www.thecorneroffice.org/blog/plink/2008/05/080501-2354.html</link>
      <title>CXF, log4j, silly mistakes</title>
      <description><![CDATA[<p>
If you were using CXF, and wanted all the logging output to be handled by log4j, you'll probably have Googled for an answer and come across <a href="http://www.techper.net/2008/01/30/configuring-cxf-logging-to-go-through-log4j/">this excellent post</a> which explains how to configure CXF to use log4j. And you might duly create the necessary file in <code>src/main/webapp/META-INF</code> or the like and then spent a lot of time debugging CXF's <code>LogUtils</code> class trying to figure out why it isn't picking up your config change.
</p><p>
Only then might you realise that the post in question is indeed correct, and explains exactly what you need to do: put the string <code>org.apache.cxf.common.logging.Log4jLogger</code> into a file named <code>META-INF/cxf/org.apache.cxf.Logger</code> in the classpath. <em>In the classpath.</em> And then you'll go doh! Muppet! A web app's META-INF directory isn't in the classpath, and your mind is making a connection which isn't there. You should be putting the file into <code>src/main/resources</code> directory, or whereever else in your classpath. Classpath dammit, classpath. And you might feel embarassed at having made this silly mistake, but you'd only be human. And I think <a href="http://www.jnd.org/">Donald Norman</a> would be on your side.]]></description>
    </item>
    <item>
      <link>http://www.thecorneroffice.org/blog/plink/2008/04/080423-1326.html</link>
      <title>Norton Internet Security can kiss my antivirus</title>
      <description><![CDATA[<p>
Norton Internet Security 2007 rolled over and died on my XP partition recently, and Norton's website recommended upgrading to NIS 2008, which I duly did. And immediately regretted it.
</p><p>
First gripe, is that Norton decides to add an anti-phishing component to Firefox, adding a big ugly toolbar which steals real estate and chomps even more resources, and no obvious way in any of their byzantine configuration screens to disable it. I don't really want phishing protection - I don't think I'm in the at-risk demographic, but Norton seems to think I'm too stupid to look after myself.
</p><p>
You could just hide the toolbar (View &gt; Toolbars &gt; Hide...), but there's still a rotten little dll in your Firefox folder, getting in the way, chomping memory and doing dog knows what else. If you delete the file, NIS apparently just puts it back. Via <a href="http://kev.deadsquid.com/?p=663">this post</a>, the best thing to do is close Firefox, delete <code>coFFPlgn.dll</code> from Firefox's components directory, then create an empty file of the same name, and mark it read only.
</p><p>
Bah.
</p>]]></description>
    </item>
    <item>
      <link>http://www.thecorneroffice.org/blog/plink/2008/04/080414-0006.html</link>
      <title>Oh yes</title>
      <description><![CDATA[<p>
Got my letter in the post this week, and when the University gets around to dishing out the little certificates, I'll be the proud holder of a BSc Honours degree in Computer Science, with distinction. Jolly good of them!
</p><p>
Part of me would love to study further, but UNISA's suggested Masters topics and research specialties weren't too interesting to me, and and studying through a UK university would just be too damned expensive. That, and with this being only the fourth year since I left high school in 1990 that I haven't been studying something or the other, I'm enjoying the freedom too much. Maybe next year ;-)
</p>]]></description>
    </item>
    <item>
      <link>http://www.thecorneroffice.org/blog/plink/2008/04/080403-2244.html</link>
      <title>C++, Windows, and late nights</title>
      <description><![CDATA[<p>
As I was saying... the joys of C++ on Windows. The easy choice should be VC++. To date I'd used Visual Studio Express 2005. As far as compiler and debugger go it's great and headache-free. The problem is, as a Java developer, you're sooo spoiled by your IDEs that VC++ is a little bit long in the tooth, in comparison. Where's my refactor-rename? Where's my real-time syntax checking? Where's my comment auto-completion? Why is IntelliSense so hit and miss? Why is 'find all references' so clunky? Why can't I F3 an include file? Why can't I link my navigators and editors? Where's my refactor-rename, dammit!
</p><p>
Enter Eclipse CDT. I last used it in 2006, and I used it on my Gentoo box. It was sluggish, but gcc and gdb and all the groovy tools Just Worked, as you would expect on a Linux system. I was rather keen on giving it a bash on Windows.
</p><p>
The problem is that CDT on Windows boils down to one of two choices: cygwin's gcc or MinGW's gcc. Early on I decided to go with MinGW. Opinion on newgroups was that it was the easier and less treacherous option. Alrighty then... if my experience over the past month is anything to go by, I feel <em>really</em> sorry for the poor buggers trying to wire it all up with cygwin. MinGW was tricky enough.
</p><p>
Admittedly, there is <a href="http://wascana.sourceforge.net/">Wascana</a>, a free all-in-one package which mostly works, but I couldn't get Wascana and wxWidgets working nicely, and eventually, I just gave up and rolled my own MinGW/MSYS/wxWidgets environment. It took a while to get that working, but work it finally did. 
</p><p>
My impressions: CDT is nice. It has a lot of Eclipse goodness, a familiar interface (for a Java dude like me), its managed make tools take a lot of the drudgery out of building projects, and it's a lot faster and more functional than I remember it. The only let-down is the underlying tool chain. MinGW's half-Unix half-Windows schizophrenia is bad enough, but its overall integration into CDT is a pain. On top of that, MinGW is a dodgy old version of gcc that churns out bloated code (like, insane bloated, occasionally), and its debugger is old, spews out all sorts of crap when you least expect it, and is apparently buggy as hell. In short, it's just more pain than the IDE is worth.
</p><p>
I would have tried a pure cygwin setup, but apparently cygwin's debugger doesn't play nicely with CDT either.
</p><p>
So in the end, I've gone back to Visual Studio. I'm pretty sure CDT is going to rock if I go back to spending more time in my Linux partition, but for now, it's VC++. Oh well. I believe VC++ 2008's got refactor-rename...
</p>

]]></description>
    </item>
    <item>
      <link>http://www.thecorneroffice.org/blog/plink/2008/04/080403-0054.html</link>
      <title>GUI apps</title>
      <description><![CDATA[<p>
Techie ramble... as I mentioned a while ago, I've been at something of an impasse when it comes to picking a Hobby Technology of Choice. I'd promised myself that this would be the year of revisiting C and C++, and finally finishing my slow progress through a few Unixey books I spent lots of money on, once upon a time.
</p><p>
Then I went and re-subbed to Eve Online. Suddenly I found myself wanting to whip up GUI-based apps. In Windows, for now, but cross-platform for if/when I'm able to play Eve on Linux. The problem is, what to use? So many options... I started digging around. Didn't take long before I nixed WinForms (not cross-platform), Gtk (I really don't like Gtk), Qt (apparently great but fairly complex), Swing (I really really don't like Swing), and web-based (I want thick client GUIs). In the end, it came down to two options: SWT/JFace or wxWidgets.
</p><p>
SWT/JFace - I did a fair amount of RCP hacking last year. The toolkit is OK, and I like the look and feel, but if you're going to use SWT you really want JFace for more oomph, and you may as well be using RCP if you're using JFace. I wasn't blown away by RCP development - powerful concepts but still tedious for a lot of development. In terms of tooling, the Eclipse Visual Editor project is still struggling, but I got it working and it looked OK-ish for whipping up simple forms.
</p><p>
WxWidgets - I used it for a university project late '06/early '07, and quite liked it. Cross-platform, clean and accessible API, but powerful. Nice-looking visual editors, free and proprietary, so one doesn't need to hand-code everything. 
</p><p>
Language choice becomes the final rub. If I want to get things done right now, it's Java or C++, because those are the languages I'm most comfortable with. (C# also appeals, except that I'm not excited about WinForms or Gtk#, the only two real C# GUI options).
</p><p>
SWT means Java. Downside is I promised myself I wouldn't do Java at home. Living in a JVM, I could start dabbling with, say, JRuby or Groovy as well though. An upside is I could re-use a lot of Eve-specific code I've already written, and I could quickly get through tricky bits of code in the language I'm most proficient in. 
</p><p>
If I go with wxWidgets, I'd start out with C++, which isn't the most productive way to write GUI apps anymore, but the additional complexity would be offset by the thrill of being able to use the <code>-></code> operator again. I'd be accomplishing my goal of using more C++ this year, and I could easy start playing around with the various other wxWidgets bindings (Ruby, say) when I'm good and ready.
</p><p>
I'm leaning towards Java, but I've still not made up my mind, entirely. I've been playing a bit with both, not making huge progress with either, but sort of enjoying stuffing around. 
</p><p>
Next instalment: CDT versus Visual Studio - the joys of C++ development in Windows.
</p>

]]></description>
    </item>
    <item>
      <link>http://www.thecorneroffice.org/blog/plink/2008/02/080213-0031.html</link>
      <title>I cannot set a waypoint to the same location twice</title>
      <description><![CDATA[<p>
Aaah, fire up some way-old Tangerine Dream for atmosphere, undock from the station and point my trusty old Condor at the stars...
</p><p>
Nice to be back on Eve Online. Luckily for me, my old character was still on the server, waiting for me, my EveMail, skills, assets, dosh, the lot. So apart from a black hole of about 9 months of missed skill training, I've just picked up and carried on as if I'd never left. 
</p><p>
Not entirely, though. The game itself has gone through some large expansions since I last played... a lot of new features and content that I still know very little about. The way coolest change isn't an in-game feature at all though, it's the addition of an external API. Armed with a unique authentication key, you can now query an API server and get a ton of character and game-related XML data in response. Combined with static game data which is exported regularly and made available for download, you can build some useful and powerful applications. There seems to be quite a lively 3rd party tool community, with a lot of open source code and some nifty-looking little apps. (Oddly enough, none in Java though).
</p><p>
That brings me to something of a cross-roads. My old web based market app is still there, with lots of potential improvements with the API. Frankly, a lot of it was so organic and spaghetti-ish that I'll probably end up rewriting a lot of it. If I'm going to do that, is it worth sticking with Java? My early Eclipse RCP efforts were inspired by wanting to add features to the market app that weren't easy on a web app (at least with my ham-fisted UI skills). Having done a bit more RCP development, I'm not so excited about that. I could do a Swing app but that doesn't excite me either.
</p><p>
This ties into something I mentioned at the beginning of the year. As much as I love Java, I spend all my working hours with Java, and I'm in the mood for something different when I get home. I really wanted to spend more time with C++ this year, but C++ isn't really a solid or productive choice for a desktop app circa 2008. The question, then, is what? Stick with Java, even though I don't like Java UI development much? C#? If so, .Net or mono? WinForms or GTK? (since Eve apparently runs on Linux as well, now). Alternatively, go completely exotic and learn something like Python and one of the many Python UI bindings? Still not sure.
</p>]]></description>
    </item>
    <item>
      <link>http://www.thecorneroffice.org/blog/plink/2008/02/080210-2202.html</link>
      <title>It ain't funny</title>
      <description><![CDATA[<p>
In the good old days, the netspeak word 'lol' meant 'laugh out loud', as in ha ha. An expression of laughter a little more reserved than lmao or rofl.
</p><p>
I've noticed over the years though, that it's changed a bit... and on forums and the like, it's just as likely to mean 'nervous laugh' as anything else. As in 'my car just got stolen lol' or 'would you like to go on a date with me lol' or 'I just found out I got crabs lol anyone know a good doctor?'
</p><p>
It's silly.
</p>]]></description>
    </item>
    <item>
      <link>http://www.thecorneroffice.org/blog/plink/2008/02/080208-2358.html</link>
      <title>Slow code</title>
      <description><![CDATA[<p>
There's an interesting article on Artima called <a href="http://www.artima.com/cppsource/how_to_go_slow.html">How To Go Slow</a>, listing a number of performance crimes (mainly geared towards C++ apps). The first section is on complexity, with a pretty graph of asymptotic orders. Somewhat apropos given that I just wrote an exam on the subject this morning. Yes, using bubblesort is a programming crime of the worst order, and quicksort is faster on average, but I couldn't help thinking 'ah, but you could avoid the degenerate quadratic behaviour of quicksort in the ironic case where the collection is already sorted by considering a merge sort (if you could handle the linear additional space requirements), or an accelerated heapsort, both of which provide n log n performance in both average and worst cases...' I'll be over this affliction by Monday, I promise.
</p><p>
Some of the issues, while valid, are less relevant for your average Java/J2EE developer. You generally don't need to know or care how your data is being sorted, just let the API do it for you. (*)
</p><p>
In Java/J2EE apps, ignoring the cost of many slow, bloated frameworks and libraries you've perhaps chosen or been forced to use, you can probably get away with looking at 4 things to boost performance, (and in this order of severity):
</p>
<ol>
<li>hitting DB, network, or file system more than you need to</li>
<li>hitting contended synchronized code more than you need to</li>
<li>doing string manipulation more than you need to</li>
<li>hitting maps and complex data structures more than you need to (especially when combined with #2)</li>
</ol>
<p>
Am I missing anything?
</p><p>
Nothing is ever a replacement for actually having cold, hard profiler and load data to pin-point performance problems, but if you're looking to speed your app up, you can't go far wrong if you start looking at 1-4 above. The biggest performance bottleneck of most server-side apps isn't a lack of l33t performance coding and optimising, it's just doing work you don't need to. 
</p><p>
Of course, I'm copping out a bit. The definition of 'need to' varies from programmer to programmer. Some programmers will jump through all sorts of hoops and complicate things in the interests of performance, others will do all sorts of inefficient things to keep their code abstracted and/or clean. Excluding obviously redundant processing, somewhere in the middle is a balance, and therein lies the skill and art, &c &c.
</p><p>
(*) <em>according to the Javadocs, it's a modified mergesort for Lists and a modified quicksort for arrays... I had to look.</em>
</p>]]></description>
    </item>
  </channel>
</rss>

