Thursday 9 December 2010

Beg for permission to use your money

In recent times, everyone and his poodle have been analysing "the Wikileaks matter" from just about every angle. Is Wikileaks doing the right thing? Is Assange guilty of a sex crime?

Who really owns your money?

One matter which did not get the coverage I believe it deserved, is the decision by PayPal, Visa and Mastercard to "stop processing payments" to Wikileaks.

Little by little we are getting used to viewing our credit/debit cards as simply another way of making a payment - a more convenient way, and one which lends itself well to online or remote payments. This decision by these three companies highlights a major difference between these cards and ordinary money however: someone else, other than yourself, has the right and the power to decide who you're allowed to pay.

With cash, you need nobody's approval to give your money to someone. You just take the money out of your pocket and give it to the other person. Nobody else is involved. You need nobody's permission, and nobody can stop you. Until recently many of us thought that cards and accounts like PayPal were, essentially, a more modern version of the same thing.

Then came Wikileaks. And Wikileaks did something unpopular to a number of important people. Neither the organisation nor its founders or employees were actually charged with committing a crime. There was no court order requiring banks to freeze their assets. Instead, several companies decided unilaterally to prevent you from giving your money to this organisation. Not just you of course, but everybody. Luckily, Wikileaks has substantial support, and it's very unlikely that it will be brought down by this underhanded tactic. But it does raise the question - how much power do credit card companies have over our lives?

A company which depends entirely on online sales can be wiped out by such companies. All they have to do is block them from receiving money from everyone.

Not only that, but these companies can completely control what you spend your money on. Of course this rarely happens, since the more you use their services, the more money they make. However, there should be no more control over how we use our money than if we were using cash - at least not based on a decision by a corporation.

The shady world of banking

I wonder, is it a pure coincidence that all these companies decided to stop payments (and in some cases, actually steal donated money) came right after Julian Assange declared that the next released documents would involve a major bank?

In an interview with Forbes on the 30th of November, Julian Assange said that one of the next targets will be "a major American bank". On the 4th of December, PayPal blocked all donations to the site. This was followed on the 6th December by Mastercard, and the 7th December by Visa.

All sites claimed, of course, that they were doing this because Wikileaks was engaging in illegal activities. This doesn't explain why all three companies had been happy to handle donations to Wikileaks right up to the point that Assange announced that he'd be exposing skeletons in the financial sector.

Since the "official explanation" is sticking in my throat, I decided to come up with some speculations of my own. Theory number 1 is that "a major American bank" gently reminded Visa, MasterCard and PayPal that they are in the same boat, and if a big fat passenger falls overboard off a small boat, the resulting instability could get others wet as well. Theory number two is that, if "a major American bank" is discovered with its hand in the cookie jar, it might also be discovered that the other kids were giving it a hand to reach the jar in return for some of the cookies.

In short, this decision may have done just as much to damage the reputation of the banking and electronic money industries as the documents themselves (which will be leaked at any cost anyway).

Saturday 14 August 2010

Yet another victim of our fireworks

I am deeply saddened by the news about the death of another person as the fireworks factory he worked in blew up. Unfortunately, I am not surprised. Four out of forty fireworks factories blew up since the beginning of the year. To me such statistics are shocking, but every time this happens, after a couple of weeks of letters and speeches and memorial services, everything goes back to "business as usual". Nothing changes. No new rules, no new safety procedures, making it just a matter of time before the next factory explodes.

Other countries have fireworks factories but I seriously doubt that they get 10% of their fireworks factories blowing up in a year and do nothing about it. What are we doing wrong? We've had four fireworks fatalities (in 40 factories) compared to 10 road fatalities (for 300,000 cars - up to end of June). That does not include non-fatal accidents like 13 year old boy hit in the eye though he was behind the "safety barrier", or the burning of the golf club at Marsa, and several accidents that go unreported.

Where fireworks are concerned, I wouldn't even know which end goes up, but I'm sure that something can be done to prevent this kind of accident from being almost a regular event.

Friday 6 August 2010

"Verbal harassment" lawsuit could backfire

In The Times today there is a report about "the first local case of verbal sexual harassment at the workplace" - a company had to pay €2000 after a male employee made a joke/comment with sexual connotations to a female colleague.

I don't know enough about this specific case to comment about the incident - for all I know this may have been the latest in a long series of verbal abuse always directed at the same person, or the woman in question had made her feelings clear about such kinds of joke and been ignored. The manner in which such a comment was made is also relevant - jokes can be made with malice or could be just a light hearted attempt at humour.

My main concern is about the many people who are considering this as a precedent which should apply to all cases where male workers make any kind of sexual joke or comment to female workers. If this is the case, I think the situation could backfire.

If someone is selecting people for a job, will they now weigh the added risk of lawsuits against the company when they're looking at a female applicant's CV? Because let's face it - the likelihood of a similar lawsuit being instituted by a man is much smaller.

Equality is all well and good, but the last thing that is needed for women in the workplace is to put out the message that employing women is an added liability to the company. Harassment is wrong, and employers should indeed put a stop to any that is going on - not because of lawsuits but because it is harming some members of their staff. On the other hand, we should avoid going to the other extreme where any kind of joke made to, or in the presence of, a woman is a risky business. That could easily turn into a situation where employers avoid having women on the team, or where the team feels safer excluding female colleagues from conversations - or even that the very presence of women has caused a damper on workplace relations.

Wednesday 14 July 2010

Creating methods with named parameters and default values in Java

Have you ever had a situation where one of your methods had many different arguments, and it became difficult to keep track of them, or to provide multiple versions of the same method with different parameters, trying to cover all commoon combinations?

In such cases you might have envied languages like perl or python which allow you to specify default values for your parameters, and let the caller specify parameters by name, thus providing parameters in any order.

Now, technically Java can't do that kind of stuff, but with some imagination, the varargs parameter type, and the new import static, we can come very close.

Goal

Our goal is to create a single method that accepts all the following calls.
go();
go(min(0));
go(min(0), max(100));
go(max(100), min(0));
go(prompt("Enter a value"), min(0), max(100));
All the bits below fit within one class. The actual names of the enum, methods etc. are up to you.

Step 1

Create an enum for all the parameters that your method will accept. Give the enum an instance variable for the (optional) default value, and set it in the constructor.
static enum OptionName {
  min (0),
  max,
  prompt;

  private final Object dflt;
  private OptionName(Object dflt) {
    this.dflt = dflt;
  }
  private OptionName() {
    this.dflt = null;
  }
}

Step 2

Create a simple class that contains one enum and one object. Give it a constructor to set these two values.
public static class Option {
  private final OptionName name;
  private final Object value;
  private Option(OptionName name, Object value){
    this.name = name;
    this.value = value;
  }
}

Step 3

Create a set of static functions, one for each OptionName, each returning an instance of Option.
  public static Option min(int value) {
    return new Option(OptionName.min, value);
  }
  public static Option max(int value) {
    return new Option(OptionName.max, value);
  }
  public static Option prompt(String value) {
    return new Option(OptionName.prompt, value);
  }

Step 4

Create the method. The parameters should be a varargs array of Options. Immediately place the parameters into a Map. The following example first sets all the default values, then overwrites them with the passed-in values. Once that's done, you'll have a map keyed by the OptionName enum, which you can query for the values you'll actually use in your method.
public static void myMethod(Option... opts) {
  EnumMap om = new EnumMap(OptionName.class);
  // first set the defaults
  for ( OptionName on : OptionName.values() ) {
    om.put(on, on.dflt);
  }
  // then overwrite them with the values passed in.
  for ( Option op : opts ) {
    om.put(op.name, op.value);
  }
        
  Integer min=(Integer)om.get(OptionName.min);
  Integer max=(Integer)om.get(OptionName.max);
  String prompt = (String)om.get(OptionName.prompt);       
  // do something with min, max and prompt; remember 
  // to check for nulls.
}

Using it

In the calling class, use the "import static" syntax to import all the static methods we defined in this class.

You can then call myMethod using a comma-separated list of method class to those static methods that will serve as parameters.

Sunday 25 April 2010

The Identity Question

In a letter to The Times, Ray Azzopardi argues that "Our true identity as Maltese has to be linked to our Christian roots". Nothing could be further from the truth.

Whenever one refers to "roots", one is implying a beginning, and it's obvious even from the Bible's account of Paul's arrival here that Malta and the Maltese had their own distinct identity well before the Christian faith even reached our shores. Throughout our history, we have retained our identity even during times when this faith practically disappeared from these islands.

If I had to choose a characteristic that identifies us as Maltese, I'd have to choose the Maltese language. Nothing distinguishes us more from any other nation. Even expatriates maintain the language alive in their adopted countries because of this very reason. In centuries of foreign rule by the Knights, the French and the British, we retained our language - often using it to distinguish ourselves from "the outsiders". Within Malta, people who can't speak Maltese are considered to be foreign residents, irrespective of what their passport or ID card says.

Throughout our history there have always been people who are not Catholics, or even Christian, yet are entirely Maltese. There is evidence of a Jewish community in Malta since before Paul's arrival, making it probably the oldest surviving religion in Malta, though it has not done so continuously. Today there are many Maltese who are Muslim, Hindu, or have no religion at all.

The national anthem is quite irrelevant in determining our identity. It was written by a priest, so it's hardly surprising that it contains references to God. It also refers to "min jaħkimha" - a reference to the British governor of the time. Hardly meaningful today.

I'm surprised that Mr. Azzopardi attributes "our generous and altruistic nature" to Paul's Christianity when the Bible points out that Paul himself was surprised by the natives' "uncommon kindness". It seems that our friendly nature is part of our pre-Christian identity, and has survived 2000 years later. Nor were they "our Christian values" that kept us struggling for independence, since most of our foreign rulers shared that faith.

Mr. Azzopardi asks a loaded question when he asks why we are passing on "a secular and narrow vision of our society" to the next generation. Actually, we are passing on a secular and more open vision of our society. A secular society is one in which each individual has the right to his own faith - or none at all, but the govern remains separate, thus not discriminating against - or in favour of - anyone based on their religion. A nation when one can apply for a teaching post in a government school without being asked to confirm whether they are Catholic first. A nation where the church and the state are separate.

What would our life be like if we did not have this separation between church and state? You can look at Iran or Saudi Arabia as an example of what happens when religion and government are in the same bed. Condoms - and indeed any other form of contraception - would be illegal. Going to mass on Sunday would be compulsory. Unwed mothers would be in prison. Marriage between Catholic and non-Catholic would be prohibited by law, and unmarried couples living together would be harshly punished. Do not make the mistake of thinking that these things only happen in Muslim countries. Not only does our history show otherwise, but even now, fundamentalists in the USA and other nations constantly seek to use the laws to make such impositions on the whole population.

Thankfully, we are already partly secular, but more needs to be done. Religion should be a personal matter even if 99.9% of the country adhered to one faith. Certainly it should not be something for the government to be involved in, nor for our laws to control. A secular society is the foundation for a better future.

Sunday 7 February 2010

Carmelo Cutajar's letter "Ample Proof of God" (The Times, 6th Feb) reminded me of an anecdote by that inimitable author, Douglas Adams. He compared this idea to some water that wakes up one day and finds itself as a puddle on the ground. As it examines the hole it finds itself in, it is
amazed - the hole fits the water staggeringly well! So well in fact that it seems designed to fit the water. It must have been created by an intelligent designer explicitly for that water to be in.

Similarly, we look at the world around us and it seems amazingly perfect for us - the right temperature, the right atmosphere to breathe, the right duration of day and night, the right plants to eat. It seems so perfect that we might get the feeling that it was made for
us.

It's actually the other way round. Just as it was the water that conformed to the hole in the ground, we find our planet so perfect because life has been evolving for billions of years to survive within the conditions provided by the earth. If earth's gravity had been more, or less, then we would have evolved to live and move around in it. If the entire earth had been hotter we might have evolved better cooling systems and a resistance to skin cancer, whereas if the earth
were colder we might even today still be sporting a thick shaggy fur coat.

We have only just begun to detect the presence of planets outside our solar system, so we have as yet no way of knowing how common or rare our type of planet is. For all we know, earth-like planets might be quite common indeed. Even if only one in a million planets would suit
human life, that still means billions of such planets. Also, since the only type of life we know about is that found on earth, we have no idea what planetary conditions would allow the development of life in its broadest sense. We've already had to alter our perception of
"life-sustaining conditions" since we've found life that can exist at extremely high temperatures, a toxic environment and bone-crushing pressure near underwater volcano vents, and below freezing in the Antarctic. Other forms of life might exist in conditions far beyond
what we consider suitable.

Sorry to disappoint, but this is not proof of any deity.

One ought to ask oneself - if there is a God who is so anxious for people to believe in him, and given the doubts that exist (including other religions claiming that theirs is the one true god), wouldn't it be much easier for that god to simply settle the matter once and for
all and give final, undeniable proof of who is right? Surely an omnipotent being can do that.