Thursday, March 24, 2005

Re: Transaction Model Choices

Dan, are you referring to two phrase locking or two phrase commit? If my memory is not failing me, the two phrase locking refers to the database locking model which ensures serializable transaction. While the two phrase commit is referring to how distributed system can collectively make a decision. It can be used for distributed transaction, but not limited to that.

Technorati Tags:

Sunday, March 20, 2005

Sir, am I hired

If I were interviewed by SKI_BUM and given days to think it through, my answer would be as following.

Pick one or more Java API's/Class libraries and critize them (both good and bad). I don't know about you. I can never remember the appropriate IO classes to use to read/write a file. Granted, the use of decorator pattern in the Java IO libraries makes it very flexible and powerful and all that. But for mundane tasks, such as reading text file, it is awkward to use and too complicated to remember. A set of routines handling common tasks in one liner fashion as in Ruby and Python would make developers' life easier and save everybody's trouble to write his own FileUtil.

How do you participate in a team? A productive team doesn't automatically appear when you throw bunch of people together. It only grows as a result of conscious effort by management and an encouraging environment. It takes two to make up a team. So I will make you a deal. I promise I will be a good team player if you work hard to grow it.

If you have a problem in the team, for example a design problem that you can't agree on, how do you usually solve the problem? I used to believe naively that design problem should be argued purely on technical merit and reasoned with rational. That is why my view did not go through even if it was later proved to be right.

Now I am wiser. When dealing with people, even if they are tech people or even geek, we can never ignore the politics at play, or the sociology as said in the Peopleware. I am working on my HTWFIP skills.

When you design a system, what are your objectives (for instance do you care most about performance, the users, etc.)? Simple to use, good default, and easily extensible.

What books on software or programming have you read lately? In the last month, I read Programming Ruby: The Pragmatic Programmers' Guide, Second Edition, Peopleware : Productive Projects and Teams, 2nd Ed. and Advanced Bash-Scripting Guide.

Ruby is the language I plan to learn this year. Bash is something I found myself in need at work. I read Peopleware because I realized, only recently, that tech skills alone is not enough to be a good developer.

Refactoring: Improving the Design of Existing Code, The Pragmatic Programmer: From Journeyman to Master and Design Patterns are the first three books I read when I first started my programmer career 4 years ago and they are on the top of my reading list. But did not read those lately.

How do you keep up with what's going on in the industry? Following Pragmatic Programmer's advice, I try to read a book every month and learn a new language every year. In addition, I read blogs to keep on top of industry news.

What's your experience with design patterns, refactoring and test-first development? There was a period right after I finished Design Patterns book, I could not help myself to refer to a design pattern when discussing code. Now however, after it sinks in, I find myself seldom talk about it anymore. It just blends in.

Although Refactoring is about improving the existing code, I tend to use it as my coding guideline and strive to write good structured code in the first place. With more and more tools supporting automatic refactoring, it is not as important to know how to do a particular refactoring by hand as to understand why a particular refactoring is needed.

I spent last year working on a Swing application and I find it is really hard to write unit testing for it.

How do you design in UML? Do you design everything in details and the code mechanically afterwards? I don't design in UML. I use UML as sketching, as Martin Fowler suggested. I cringe whenever people suggest detailed design in UML. Firstly, I don't believe you can thought of every design detail without actually writing the code. So detailed design upfront means surprise and more surprise when actual coding starts. Secondly, unlike programing language, UML is ambiguous, people tend to interpret differently.

What's your attitude towards code standards, best practices, etc? I think every team should follow a minimum set of code standards, one page at max, so that team can easily review others' code. I have my preference in coding standard but I am not religious about it. I think code standards is a mutual agreement grow out of team members rather than imposed by management.

How do you feel about learning new API's? It is the nature of our business that one has to keep oneself updated. If a new library or framework improves my team's productivity, I am certainly all for it. However I also learnt over the years to be caution of marketing propaganda. That means I will evaluate a library on my terms rather than market hype.

I skipped two questions regarding to what I am working on as my boss won't be too happy to find it here.

Technorati Tags: , ,

Monday, March 14, 2005

WYSINWYG

The javablogs pre-processor script works out pretty well. There is just one little problem -- it refuses to ignore this particular site. I used all kinds of permutation on the site name as ignore trigger and still not working.

It was only this morning when I noticed the entry is the first line in the ignore configuration file, I realized it must be due to BOM. Sure enough, save the ignore list in "UTF8 no BOM" format solves the problem.

This is not the first time I was bitten by the BOM. Yet it took me couple of days to connect the dots. I think the difficulty arise from mismatched paradigm. When I look at a text file in a text editor, I tend to believe WYSIWYG -- what you see is what you get. While text editor, trying to be helpful, hides the BOM from the view, hence WYSINWYG.

Ruby script to pre-process javablogs daily feed

screenshot

If you read Javablogs, you may be aware that there are many blogs written in languages you don't understand. I have long been searching for a way to filter those out.

Since Javablog puts the site name in square brace at the end of the feed title, it is conceptually easy to filter out feed by pattern matching its title. The problem is that few RSS readers support such operation. NetNewsWire 2.0, the reader I use, supports smartlist. Like smart playlists in iTunes, smart lists display news items based on rules that you set up. However, smartlist only covers half of what I want, the pattern matching part. Since I can not specify what action to take on matched item, I have to perform filter out manually -- by marking all (of my "Junk" smartlist) as read. To add salt to injury, the smartlist doesn't always work since the NNW2 is still in beta. I was troubled for the past few months.

Then it suddenly draw on me last night -- why not write a script to pre-process the feeds? Considering that I have been using script to grab Javablogs all along, it is surprising I did not think of this early.

While writing the script tonight, more ideas came along. The resulting script does following:

  • ignore news items of which the title contains any of ignoring texts you specify. Ignored item is removed from RSS content.
  • highlight news items. Append "(*)" to the item title so that you can easily set up rules for those items in your RSS reader.
  • alert. Very often, people republish their Blog and results in the entire site archive shows up in the feed. I consider it a anormaly if the number of entries for a site exceeds 10.
  • process log is generated as a news item.

I am happy now.

UPDATE: append "(-)" to the alerted item title. handle empty line in the configuration file.

Technorati Tags: ,

Tuesday, March 08, 2005

Find changed files

Recently I often need to find out what files are different between CVS branches. Because we have CVS tags such as $Id in the source code header, it results in GUI diff tools thinking every source file is changed.

Time to drop to terminal. I use the following command to generate a list of changed file name.

diff -Naur --brief -x CVS -x *.class -x ".*" -I '^[ \t]*\*' source-dir target-dir | awk '{print $2}' > diff_file_list
The interesting option is '-I ^[ \t]*\*', which ignores any line change starts with "*".

Learning Bash

On more than one occasion last week, I found myself in need of a quick thrown together shell script. In the sprite of sharpening the ax, I studied the Advanced Bash-Scripting Guide. After learning the capability of Bash scripting -- string manipulation, loop and conditional structure, I realized many chores I used to write in Python/Ruby can be easily done in Bash.