//Comment This Out

Wednesday, March 30, 2005

Poorly Written Code: Part III

This is another entry in my on-continuing saga of poorly written code. Yesterday, I was working on some code that looped over an Enumeration. An Enumeration, for those non-Java people is not the traditional enumeration (recently introduced in Java 5.0) but a list-like collection that was present in the early days of Java and is kept around for backwards compatibility. Here is how it looped over the Enumeration. if (enumeration != null) { while (enumeration.hasMoreElements()) { if (enumeration != null) { while (enumeration.hasMoreElements()) { // do something } } } } What I ended up doing is converting the Enumeration to an ArrayList (the "favoured" List class) and ended up with the following. if (list != null) { for (Iterator iter = list.iterator(); iter.hasNext(); ) { //do something } }

Tuesday, March 29, 2005

Unjust Deserter

Recently, the Immigration and Refugee Board of Canada turned down the application of Jeremy Hinzman for refugee status. Jeremy Hinzman is an American soldier who went AWOL from his unit in Iraq and came here to Canada with his family. His claim was that if he were to be sent home, he would be court martialed and possibly be incarcerated. In the morning local paper that I read on the bus on the way to work, an immigration lawyer, Guidy Mamann, weighed in on the issue.
What remains unanswered is, from a Canadian public policy point of view, what a foreign soldier is expected to do when faced with having to fight a war he believes to be illegal and which offends his conscience.
Actually, nothing at all remains unanswered. The simple question which the Immigration Board had to answer was, is this person a refugee or not? As is clear as day to anyone with a minimum of common sense, the answer is no. As Mr. Mamman mentions, the Immigration Board took 69 pages to explain why. That being the case, if he is not a refugee, then, legally speaking, he must apply like any other immigrant. Mr. Mamman, being an immigration lawyer, knows this very well. So, what is a soldier expected to do in such a situation? That's not Canada's problem to solve! Besides, I find people like Jeremy Hinzman insulting. They are insulting to me as a Canadian since it makes a mockery of my country's laws by turning it into a political issue. The US is a free country with just laws and a decent justice system, their army included. If someone freely volunteers for the army they should expect that they may be sent to war. And if they do not like that war and go AWOL, then it is their responsibility to face those consequences and stop insulting our collective intelligence by claiming refugee status.
It is clear to me that our leaders do not want to anger our friends to the south who, after all, pick up a big part of the cost of defending our shared continent. Accordingly, they refuse to make and pronounce public policy that defines who we are as a people.
So, that is it, huh? If our political heads do not welcome this person (either by considering him a "refugee" or making up some other provision that will allow him to stay) then we are not defining ourselves as Canadian? Does that make sense? But this is all moot, and Mr. Mamman knows it. If Jeremy Hiznman is not a refugee (which he isn't) then he cannot take refuge here. Period. Political statements will serve no purpose other than to show how anti American those officials are.
Instead, they let a refugee hearing become the arena for public debate of a major social issue. In one corner is a bewildered 25-year-old young man and his counsel. On the other is the minister's counsel, armed with a preliminary ruling that Hinzman is not allowed to challenge the legality of the war. Deciding the issue for the rest of us is a relatively unknown and faceless bureaucrat.
They let it become an arena for a political (no, its not a social) issue? Um, what do you think Mr. Hinzman and his lawyer were doing? Just trying to claim refugee status? No, it was that plus a definite political statement to protest against the war in Iraq. The official website that supports Mr. Hinzman makes this quite clear. Also, his lawyer was not allowed to challenge the legality of the war for two very good reasons. For starters, it is irrelevant. What is relevant is if he is considered a refugee. If he faces persecution or bodily harm if he is sent home, then he should be considered a refugee. Since the US is a free democratic country where one can expect justice, the army included, then he should not be considered a refugee. Whether the war was legal or not is immaterial to that fact. The second reason is that the Immigration Board has no authority nor ability to judge what wars are considered legal or not. The US government is not on trial here.

Monday, March 21, 2005

Shas Differently

With all the buzz around the recent completion of the Daf Yomi cycle, now comes the ultimate in Daf Yomi, the ShasPod. It is an iPod preloaded with every single Daf Yomi shiur in mp3 format. It was also recently lampooned on SNL's Weekend Update where it was jokingly referred to as an OyPod. (Further proof that SNL is not that funny anymore.) Or, alternatively, you can get a cheap mp3 player and download Daf Yomi shiurim for free.

Wednesday, March 16, 2005

Women Pay More than Men

Lorenzo Berardinetti, an Ontario MPP, went shopping with his wife in the Eaton Centre and didn't like what he discovered. He found out that in some cases, women pay more for goods and service than men, especially for things like clothing and haircuts. Now he wants to introduce a bill in Parliament that would: "...make it illegal for businesses to set prices based on what gender their products and services are intended for". This is a bad idea, and in case Mr. Berardinetti wants to know why, I have three words for him: free market economy. I suggest he look it up. I would also suggest that he study some economics and learn about "market value". One wonders how this would even be enforced, assuming his bill ever passes. Will some mindless bureaucrats fix prices? Will they go after just the retailers, the wholesalers, or both? If a retailer bought some women's clothing at a higher price from a wholesaler than men's clothing does the retailer have to charge equal prices? If goods or a service is priced higher for women and there is justification for it, who has to prove it, the retailer or the government? How much would it cost to taxpayers? What total effect would this have on the economy? I'll also bet that in order to meet the requirement of "gender equal prices", businesses are more likely to raise men's prices to meet women's prices rather than lower women's prices to meet men's prices. Fortunately, I believe that enough MPPs will have the minimum of common and political sense to never let this bill pass.

Thursday, March 10, 2005

Wrap Around

Not only is laying of tefillin a Mitzvah, but some say it also makes for a good acupuncture technique. Via Biur Chametz.

Tuesday, March 8, 2005

Poorly Written Code: Part II

I'd thought I'd continue on the theme of my last post and give a few more examples of poorly written code. The following is what I consider a textbook case on how not to program of which I had the misfortune of dealing with last year. In the application I was dealing with, there is a search utility that searchs for accounts based on various criteria (e.g. name, address, postal code, etc.). When the search would be invoked it would call a single method over 1200 lines long!This method was a virtual rabbit's warren of nested if...else code blocks. Within this mess, it would instantiate objects from one of two basic classes. One of these classes had 19 different constructors, the other one had 12. And yes, it used every one of those. It turns out that every time someone had added another search parameter, they added another set of constructors to those classes to accomodate the new parameter (since these classes were originally designed in such a way that the only way to pass in search parameters was through a constructor). By the time I finished rewriting the mess, I had reduced the 1200 line method down to about 150 lines of code and reduced the number of constructors in both classes down to 2. One of my co-workers told me a story last week that at a former job, he was writing code in C. In the code he was working on, he found someone had used a goto statement. This is what he found: if (some argument) { // do something goto a_label: } else { a_label: // do something }