Java Coding Style
java.net blogger Malcom Davis comments on why you should use the Sun Java coding style. The first comment is the perfect example of “ego” that he talks about:
Why not adopt the Sun coding conventions? Simple – because they are derived from an antiquated and BAD way of coding.
There are very good reasons why C programmers moved away from the coding styles used by Sun, and the excuse that ‘modern IDEs have code colouring and brace matcing, etc.’ is NOT a good reason to have to rely on it. Gah! Could there be a more reactionary, inflammatory and unsubstantiated comment? How does the poster know what the Java coding convention was derived from. What makes it “bad”? Why is an antiquated coding style not a good thing? Why exactly did C programmers move away from the coding styles used by Sun? What evidence is there that C programmers actually did start of such a coding style and move away from it? What problem does code colouring and brace matching supposedly not overcome? In other words, why should I believe some random comment on a web page which provides no solid argument, no reasoning, no attempt at justification and absolutely no facts? As Malcom noted:
Suprise Inspections
My house mate informed me this afternoon that the land lord would be coming around tomorrow for an inspection. Hilarity is currently ensuing. It random matters of interest: This was interesting – living muscle tissue powered nanodevices – and I was always told to think big…. ant has proved itself much easier to set up multiproject builds than maven which is kind of unfortunate since maven forces you into performing multiproject builds quite a lot. Might have to create a decent maven plugin to handle multiproject builds automatically instead of manually having to set up the reactor. Combining the generated website and producing a combined distribution seems to be the key to this. Obfuscation is evil. I spent all day trying to get it to work for me. Stripping out unused classes (including in dependant libraries) automatically is also evil but not quite as much so. Someone really needs to slap proguard and retroguard around a bit to share some features. Currently proguard has a brilliant config file syntax but renders itself completely useless due to the fact that it can’t handle resources correctly while obfuscating (still good for jar shrinking though) – retroguard on the other hand can’t handle SomeClass.class syntax (which proguard can) and has an awful configuration file syntax (no wildcards). I had to write an ant task to automatically list all the classes in org.apache.xerces since it really doesn’t like being obfuscated. For the record, we obfuscate whatever we can because it noticably shrinks the resulting jar file size by changing things like MyVeryLongMethodName
to a
. Think of it as lossy compression for java classes. Tomorrow I plan to spend most of the day swearing about a bug which is causing our applet to stop repainting after a certain point in time. We only managed to reliably replicate it this afternoon and the process of replication is still pretty difficult. On the plus side, we’re still on track to release the product last Friday. :S
How To Enjoy Having 1 Mouse Button
Sylvain Wallez comments on his new PowerBook hardware and among the good and bad he’s found are a couple of comments that come up a lot but shouldn’t. There’s three problems Sylvain is running into that I want to take a look at:
- No page up/down
- No scroll wheel
- One mouse button The solution for all three problems is to keep your left hand on the keyboard. When you’re typing, keep both hands on the home row (asdfghjkl;), when you use the mouse, slide *both* hands down, your right hand slides down to the track pad and your left hand slides down to sit on it’s “mousing” home row – (fn, ctrl, option, command). You now instantly have access to your second mouse button by pressing down the control key – it’s actually much faster and easier than a real second mouse button because you don’t have to turn your thumb under to reach the second mouse button. Now, the next thing to notice is that on a laptop, moving between the keyboard and the trackpad is a very cheap operation (unlike when using an external mouse), the two things are very close together. This is most noticeable when moving from the trackpad to keys at the bottom of the keyboard – like the arrow keys. So when you need to scroll, flick your right hand up to the arrow keys and suddenly you have access to scrolling and page up/down (fn on the left hand and the up/down arrow). This falls down when your editing documents rather than reading web pages etc because the up down arrow just moves the cursor and not the view (though some programs use command-up to move the view and not the caret) – page up/down still work but are no good for careful positioning. This is *far* better than using the side of the trackpad as a scroll wheel though (at least as far as I’ve found). All this probably takes a bit of getting used to, but once your fingers get used to it you’ll probably find that you don’t miss the scroll wheel or second mouse button. Even when I do have an external mouse plugged into my laptop I use the trackpad because it’s so much closer, faster and easier. If however, I have my laptop out of reach or closed and am using an external keyboard and mouse I’m driven absolutely nuts by the lack of scroll wheel and second mouse buttons. But wait! There’s more! Now that you’ve got your left hand on the bottom left of your keyboard you’re ready to fully appreciate the power of keyboard shortcuts. Ever wonder why undo, cut, copy and paste are Z,X,C,V – they’re right there in the bottom left of the keyboard for easy access. Save is a flick of the fingers away, you can bring up the find dialog while your right hand flicks back up to the keyboard and starting typing immediately. If you’re a command tab junky, that’s close by for you as well, though once you realise just how close the track pad is (and get used to flicking over to it) you probably won’t be so addicted to command tab anyway (but don’t loose the skill, it’s still essential on desktops). Lock your dock down so it doesn’t shuffle around all the time and your mouse becomes the ultimate switching utility (short of rapidly switching between two applications which command-tab is king of). Then start mapping special functions to things command click, shift click, command-shift-click, command-control-click, command-option-click, option-control-click, function-control-click, command-control-function-option-click, oi! How many buttons do you need? :) Oh yes, learn to use the escape key – it will cancel pretty much any dialog and a whole bunch of other things too. Plus with your left hand always on the keyboard, it’s really fast and easy to reach. Now if you haven’t given up on me being a stark raving lunatic yet, here’s the tip that every mac user should know about but much to my surprise don’t seem to. Command-H. Try it! The current application hides instantly letting you access whatever is behind it. Unlike minimizing though, this hides all the applications windows and most importantly they all come back at once if you click the application in the dock or command-tab to the app. You can also use command-option-H to hide all other applications, though I’m not sure why you’d bother. Let me repeat myself in bigger type for those who only skim this far down:
Command-H is your friend. Minimizing is for wimps. Okay, that was a bit antagonistic. I’ll stop now.
Number portability fees
I received my final bill from Optus the other day and in amongst all the crap they send is a notice that from the 15th April 2004 an $8 fee will apply “to any customer who switches their mobile phone number from Optus to another carrier or service provider”. That’s pretty low. The number portability legislation came in to encourage competition between mobile phone providers – effectively breaking down some of the barriers to switching. Now admittedly an $8 fee probably isn’t going to stop someone from switching but it’s still pretty low I think. Fortunately, I changed providers before that fee came in.
MarchFest on the Web
I mentioned earlier that MarchFest was coming up. The website has now gone live. If you’re in Brisbane on the 20th of March why not drop by and check out some of Brisbane’s finest local talent?
Real Estate
Why is it that with such a housing boom going on it’s so hard to find a decent place to rent? My housemate and I are looking for a new place to live, house, townhouse, unit, apartment we don’t care. It just needs to be in a reasonable location (in Brisbane that generally equates to somewhere near the SE freeway, or reasonably close to the city), about 2 bedrooms (one can even be really small), an office and space for 2 cars to park (under cover optional) . The $200 to $250 price point is about right for us. Trouble is, we just can’t seem to find a place that meets even those pretty loose requirements. Well actually we did find one place that looked perfect but it had already been taken. Really frustrating that the real estate agent made me go out there to take a look at the place before they bothered to tell me it was taken too. There’s one other option which has some potential. Have to call the real estate agent tomorrow and find out if it’s taken or not. So, anyone got a place in Brisbane they want to rent to two fine upstanding young business men?
Other things I didn’t know
Continuing on the “things I didn’t know” theme: I didn’t know there was a kext for OS X that let you mount ext2 and ext3 drives. Very nice to discover, now not only can Linux finally read and write HFS+ drives but OS X can read and write linux drives. Kudos to the people involved.
Taking On The Big Wigs
You may remember a few days ago I argued against a comment regarding my GPL vs The World entry. It’s just been pointed out to me that the “MJR” fellow is actually quite well known. I had no idea….
Candirú
Every so often, FARK comes up with something truly wierd. This is one of those times. A fish that reportedly wedges itself in your urethra. What really got me though, was a short, largely hidden quote towards the end:
There are no confirmed reports of deaths or penectomies–several cases of the latter are thought to have run afoul of piranha. Because if there’s one thing worse than a Candir� up your urethra, ‘7;s a piranha biting it off entirely.
Commercial or Opensource
In the comments to my last entry, MJR comments:
Interesting opinion, but harmed by some bugs in the basic ideas. For example, “open source” and “commercial” are not opposites, unless you have some particularly strange definition that you use. At least for the GPL this is completely false. The GPL does not give you permission to sell the GPL’d software. The GPL does state:
You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. This quite clearly doesn’t say: you may sell GPL software. Thus, GPL’d software is most definitely not commercial software even though it may come on a commercial CD. Section 4 then says:
GPL vs The World
With the recent debacle over whether or not the ASF license is compatible with the GPL license, Leo Simmons discusses the arrogance of the FSF and concludes with: So I might as well stick to the MIT license. But the arrogance of the FSF makes me feel very much like giving them the finger and just going with the ASL. Personally I agree. I’ve never liked the GPL as a license, it’s just way too restrictive to be considered “free software”. It’s open software, but not truly free. The Free Software Foundation has redefined the term “free” to suit their purposes, but it’s hard to argue that truly free software is in the public domain. You can literally do anything you want with it without every having to worry about copyright law. The GPL however, uses copyright law specifically to restrict what you can do with the software. Yes, it’s less restrictive the what copyright law allows by default, but that doesn’t mean it’s not restrictive. It particularly annoys me that the FSF feel the need to try and force everyone to use the GPL instead of picking the license that provides the terms they provide. Many people may want to see commercial software using their code – it helps to spread good ideas and opens up job opportunities for them. Personally I think it’s great when companies use code I’ve released, it’s not like I had plans to use the code to make a profit or I wouldn’t have open sourced it in the first place. The other thing that gets me (as Leo pointed out) is that the GPL isn’t compatible with anything yet the FSF expects every other license to be compatible with it. The day I can use GPL code in my ASL licensed projects is the day I give a damn whether or not people can use my ASL code in GPL projects. In the mean time, everyone except those silly enough to use the GPL can quite happily use my code – in open source or commercial work.
XSLT in Context
Well I learnt something new today. All this time that I’ve been doing some extremely funky stuff with XSLT (and I do mean funky), I never actually had the idea of the context node quite right. I discovered this because of a bug I ran into with our updating of XPath expressions that use position()
. Essentially in the XML editor I’m developing, we pick out the XPath expressions in the XSLT used to lay out the data for editing so that as their input values change we can update the result like it was a spreadsheet. When the input values change we identify which XPath expressions need to be recalculated and rerun them (using Jaxen) by passing in the context node from the document we’ve been editing. The trouble hit when we started using position()
because it always evaluated to 0. As it turns out the position()
function counts the position of the current node in the current context, not necessarily it’s position in it’s parent node. So where I’d been passing in a single node as the context, I should have been passing in a set of all the child nodes from the parent and pointing to the appropriate node in the list as the “current” one we’re processing. As it is, it’s still not actually implemented correctly because we always use the parent nodes children as the context but the actual context may have been different. For instance given the template: <template match="item"> <value-of select="position()" /> </template>
The context is actually the list of child elements of the current context node whose name is “item”. It wouldn’t include any text nodes and it wouldn’t include any elements that weren’t “items”. So for the XML snippet: <parent> <item /> <other /> <item /> <other /> </parent>
The context would be the two item
elements, but not the text nodes and not the other
elements. Fortunately, for our purposes the approximation we’re using (all child elements, excluding text nodes) is good enough for what any of our users will need to do and significantly more accurate than anything the visual design accompanying our product will actually produce. I’ll be interested to see if the testing guys pick up on it though.