Wednesday, August 29, 2007

Python puzzle this time :-)

First a question for you, what will you get if you execute following code:
i = 0
--i

What is your guess? Will it be -1? Or what else?

Well, today I learned that this is not going to work as I think it would :-)

Of course there's no pre-decrementation operator, there's no post-decrementation, pre-incrementation and post-incrementation also. But if you write:
i++


You'll get invalid syntax error and you'll notice immediately that's something wrong with your code.

In case of --i it's trickier (or ++i) - it works like you would do -(-i), so if i is set to 1, you'll get 1 :-) -(-1) gives you 1.
>>> i = 1
>>> --i
1
>>> -i
-1
>>>

How come I didn't notice this earlier? :-)

Wednesday, August 22, 2007

My Java Puzzle: does order of import statements in Java matter?

Probably everybody thinks that this question is stupid. We all know that in Java the order (sequence) of import statements does not matter at all.

Is it really the case?

Consider the example: (part of my almost original code simplified and renamed)

package demo;

import static demo.WhatThe.f;
import java.util.RandomAccess;

public class Demo {
public void x() {
f();
}
}

class WhatThe implements RandomAccess {
public static WhatThe f() {
return null;
}
}


Do you think it compiles? If you say yes - you are almost right. It compiles well with Eclipse compiler, but every Sun Java compiler fails with the error like this:

demo\Demo.java:14: cannot find symbol
symbol: class RandomAccess
class WhatThe implements RandomAccess {
^
1 error


Why you'll ask: see this bug.
And now if you use Sun compiler, just change the order of imports (swap the first import with the second) and, behold, it works now:


package demo;

import java.util.RandomAccess;
import static demo.WhatThe.f;

public class Demo {
public void x() {
f();
}
}

class WhatThe implements RandomAccess {
public static WhatThe f() {
return null;
}
}


Anybody said the order does not matter?... :)
Today I've lost 2 hours hunting for this problem amongst hundreds of java files and 3rd party jars. If wish to spare you the same...

Regards,

Wojtek

Java Puzzlers

Just in case that somebody does not already encountered this link (e.g. on TSS).

It's worth watching definitely if you are Java man. I wish I could see speakers faces though. During last JavaOne it was one of the serious advantages of this session.

Wojtek

Code like a pythonista

Sent to me by some fellow python coder ;-))

It's an interesting list of tips and tricks you should be aware when coding in python. Something that's not in official guides (or is spread all around). It includes performance tips, clarity tips, intending tips (don't agree with them), etc.

If you're interested in python and use it you definitively should be aware of them.

So, let's code like a pythonista.

Developer abuse

Have you seen it?

Great commercial from ThoughtWorks - yes, this cool consulting company all those famous people work in. And it's shows some twisted sense of humor ;-)))

Thursday, August 16, 2007

Videos that can change your organization

OK, so let me start with a warning - this is not IT related ;-)

This is something very different - this time I'm going to present something on general business (well, most of).

I found it at Seth Godin's blog about marketing. Yes, you've heard that right - on marketing ;-)

It's a set of very interesting videos in which you can see people like Steve Jobs, Guy Kawasaki, Seth himself and others talking about different things.

Some of videos are inspiring, some of them are informing, some of them are funny and some of them are really long ;-))

I haven't watched all of them, only few at this time but I'm making progress :-)

Think it's worth to spend some time on them. Hope you don't mind sharing this with you.

PS
Thanks R for help! :-)

Google World Domination - Next Iteration

Friend of a friend pointed me to a ComputerWorld article about one nice feature in the new Google Desktop - upload of search results to main Google servers, accessible later using the Google account (in polish: http://www.computerworld.pl/news/88924.html).

There are two interesting issues there:
  • Most of people don't read license agreements, release notes, advanced settings etc. We can safely assume that most of people will just install this new version with the "share search results" option set (or what it's name was).
  • Although Google would not abuse or share those results willingly (or would it?), we can envision the RIAA getting a court order to find all those mp3's and avi's sorted by user name.
I used to treat all those privacy freaks with a wink of the eye, but recently I am becoming more and more one of them :-)

Tuesday, August 14, 2007

Bookmarks in Eclipse

Standard bookmarks handling in Eclipse is not so comfortable. Although there is 'add bookmark' command in Edit menu it always pops up annoying dialog box and asks you for bookmark name. There is no standard shortcut for that option but of course you can define your own. The biggest weakness is that you cannot quickly go to selected bookmark with simple keys combination. Instead of that you have to use mouse or keyboard and navigate to separate view and select bookmark from the list. This is real pain for old vi-style editors.

But today I have great news for all of them. I found great Eclipse plugin. After installation you can simply mark line of code with Alt+Number and quickly go back to marked place with Alt+Shift+Number combination. Glory!!!
Moreover:
  • You can change keys combination
  • It works across Eclipse workspace
  • It doesn't affect built in Eclipse bookmarks functionality
Web page: http://etc.to/eclipse_bookmarks_plugin
Eclipse update page: http://eclipse.etc.to/updates/

After installation you have to restart Eclipse to get it work (at least Eclipse 3.2)

Monday, August 13, 2007

Emailwork Reduction Act

Last month I started implementing RSS reader for my day-to-day corporate work. The goal was simple - find out how to reduce the amount of notification emails coming to my Inbox and yet stay informed on all interesting changes.

First I started with selecting the reader - I ended up with Feed Demon. It satisfied my requirements:
  • be cost effective (free or already paid by the corporation)
  • firewall friendly - work both for intranet and Internet sources (this crossed out Google Reader; it was astonishing how difficult it is for open source programs to handle nontrivial proxy settings properly)
  • have reasonable usability - effective UI, summary pages etc.
Then I started to look for areas where using RSS would make my life easier.

First were the usual ones - news, webcomic updates etc (Dear Manager: now I save time by not checking for a new issue every day and limit newspaper usage to header skimming ;-) )

Then came the updates from work-related sources:
  • our Jira tracker (nice thing)
  • 3rd party Jira trackers (even nicer thing)
  • our TWiki web
  • corporation blogspace (yes, there are a few blogs I am interested in)
This might not look like a lot, but it is a good start.

Another issue would be to convince all the email generators in the company to stop spamming and begin feeding. Lets see what we can do about it :-)

Tuesday, August 7, 2007

Agile from perspective of a spry old man :)

I finally had time to watch Tim Lister's session about Agile Leadership recorded at Agile Alliance conference.

It took entire 1 hour, but I think it deserved my time or rather I hope I deserved to watch it :)

This is a very interesting presentation with a lot of knowledge, experience and passion demonstrated by the speaker. And funny for the audience. I recommend watching it - maybe during some boring general meeting or a virtual meeting which you don't feel like participating but you had not guts to decline.

Just to encourage you, here are a few quotes:
"Your real process is what you do if you are under pressure. Anything else is window dressing."
About (initial) requirements: "We start what they [customers] say the want as a warm-up exercise..."
A project manager (woman) involved when some technical problem appeared: "I am not your mother. You are techies! ... That was a morale boost [for the team]".

See and hear it for yourself. Especially if you want to drive agility.

Wojtek

Monday, August 6, 2007

Australians together...

Today (quite late, but there was weekend...) I read that Atlassian has just acquired Cenqua.
I cannot say I am astonished: both companies demonstrate the same spirit (openness to their customers, open-source-like software development style) and resulting products from it (web-based, lightweight, highly practical and affordable tools).

I wonder if the growth of the company will not destroy this aforementioned spirit which I like a lot. It's one thing to have such attitude in, say, 50 or even 100 person company. Another thing is to maintain when your company exceeds 200, 500 or 1000 guys. I wish them all the best - maybe the will prove that the bigger does not necessarily mean slower, opaque and more rigid. My experience unfortunately proved something different.

Another thing: Just accidentally I learned that CEO of Atlassian is Mike Cannon-Brookes. Till now I've known this guy just as one of Atlassian people - active in JIRA as Atlassian developer, often posting their help and comments to various forums and even coding some cool staff (e.g. JIRA charting plugin). I must say I am impressed. I almost forgot about times where a boss of 100 person company still know how to (and want to) code... Even though he is only 27.

Now read the story here and either laugh because you don't believe in such articles (full of buzz worlds and hype) or be lost in reverie.

That enough as far as paeans about Atlassian are concerned. One could say I am somehow affiliated with them. No - I am not. Just part of my job includes administering and customizing one of their product at the company I work for.

Wojtek

P.S. Maybe there will be some "celebration" discount for former Cenqua tools for Atlassian customers ... :)

Pylons - first impressions

If you didn't hear there's a new python framework called pylons.

It's aimed to be a competitor for django or ruby on rails. Last week I played with it a little bit - read some docs, did some tutorials.

My first impression was really positive - pylons tries to utilize already existing products in python world, they don't invent new things on their own (as django does). With clean design and python as a backend I thought it could be useful for me.

But it seems that pylons it's still in early stages of development - there are some documents that address basic stuff. But then I tried to add something crucial for me - authentication and authorization to tutorial application.

I was surprised that it didn't work :-) I found authkit, read about. I downloaded some still-in-development-version that was supposed to be usable (the old version was to different compared to documentation to try with it). So I managed to get a login page (after a lot of time struggling with documentation and code). But I didn't manage it to work - I could authenticate but I was redirected to wrong page.

I tried to issue a bug report but issue tracker wanted me to login. I managed to found credentials that allowed anonymous users to issue bugs but when I tried to use them the issue tracker responded with error. Just great! I mailed administrator but got no response for few days.

That gets me thinking if all those frameworks are usable at all. Maybe it's better idea to stick to some known, maintained (and maybe not so great and easy to use) Java framework.

What do you think? Is there anything stable and usable on the market that's not on Java or .NET? By usable I mean - easy object persistence, MVC, web support (dynamic flows, AJAX, web authentication and authorization with pluggable security providers), easy to use and learn, with good deployment model (production ready web servers), web services support (SOAP, REST)? Anyone? Point me into the right direction and I'll follow :-)