Simon Palmer’s blog

January 19, 2009

Sorting flex Arrays by Date

Filed under: code, Flex — simonpalmer @ 2:11 pm

I have been wanting to figure out a reliable way of doing this for a while, and suddenly the necessity arose for me to do it, so I have a solution. As far as I can tell if you have a date field in an object and an array of those objects, then the results of sorting the array are indeterminate.


public class myClass
{
    public var some_date: Date;
}

var myArray:Array = new Array();
myArray.push(new myClass);

myArray.sortOn("some_date");
myArray.sortOn("some_date", Array.NUMERIC);

The above code (so long as the some_date field was populated) never gave me reliable result for the sort order. I googled in vain for a solution and found a couple, but was never really happy with them. I had a flash of inspiration this morning which is really very obvious now I have done it, but is a nice elegant way of handling this situation.

Basically I add a public getter for a new field which just returns the Date objects time value as a Number, e.g.

public class myClass
{
    public var some_date: Date;
    [Transient] public function get some_date_time():Number
    {
        return some_date.time;
    }
}

var myArray:Array = new Array();
myArray.push(new myClass);
myArray.sortOn("some_date_time", Array.NUMERIC);

This works a treat and gives me reliable sorting results every time.

In case you are wondering why I use [Transient] it is because I am using RPC and remote objects for the connection back to my server and my classes are generally [Managed]. Without the (undocumented) [Transient] metadata some_date_time would be treated as a legitimate field and an attempt would be made to serialise it back to the server across the RPC boundary. This causes a warning to be thrown in the Flex server framework code which clogs up my logs and feels unprofessional.

January 4, 2009

Domain fatigue

Filed under: comment, personal — simonpalmer @ 11:50 pm

There are a few irritants in my professional world and one in particular that bothers me, namely domain squatting. This is done by people who want to exploit their sernedipitous luck at having registered someone else’s name before them and then try to make a fast buck out of it by selling it back to the rightful owner and the only person in the world for whom it has genuine value.

A .com domain is a valuable marketing and branding tool and a key part of a companies online marque. For someone else to be able to swoop in and steal it, just because it is on the web, is frankly ridiculous.

In any other walk of life this behaviour would be called blackmail or extortion, but because the names are available in an apparently free market on a first-come, first-served basis – even if you have spent a hundred years building a brand – it is seen as a tolerable and even legitimate practice. If I happen to have lodged the name CocaCola.com before The CocaCola Company did I would legitimately own the rights to the domain. I can’t help but feel that is morally wrong.

Why are domain names not covered by a branch of the law adjacent to trademarks or even copyright?

I am discovering that this entirely pointless and negative industry stoops even lower. If you trip up in registering a domain name there are people watching – God knows how – who will step in and pinch it from under your nose and then try and sell it back to you above market price. This is an empty, opportunistic, negative, amoral scam. It is tantamount to theft by people who have nothing positive to add to the world of commerce. The perpetrators ought to be hunted down and banned from holding domains.

And it doesn’t stop at domains. Registration of company names is subject to the same corrosive and intellectually and morally bankrupt activity. My startup’s name is Dialectyx Solutions Ltd. It is that because Dialectyx Ltd., which was our original choice, was registered by someone else in the 72 hours between us doing a search and submitting the registration papers. That company name is now registered with a firm of solicitors in a small town about 25 miles away from us. Dialectyx Ltd. does not actively trade.

Coincidence? Hardly.

And right now I wait with baited breath while my latest domain registration attempt lingers in the odd limbo between paying for it and it actually starting to work. According to whois, the domain is still available. According to my registrant I have been billed. Right now I have no idea where I stand. Surely there’s a better way to do it than this? Surely there should be some protection against the shameless scammers who are sitting on valuable corporate assets?

Blog at WordPress.com.