February 19th, 2010
public class LazyFactory {
private Object oUnsafe;
private Object oSync;
public Object get() {
Object o = this.oUnsafe;
if (o == null) {
Object notNull = crateNewIfNeeded();
oUnsafe = notNull;
return notNull;
} else {
return o;
}
}
synchronized Object crateNewIfNeeded() {
if (oSync == null) {
oSync = getExpensiveNewInstance();
}
return oSync;
}
/** Don't call this too often! */
Object getExpensiveNewInstance() {
try {
Thread.sleep(500);
} catch (InterruptedException ignored) {}
return new Object();
}
}
Unless I’ve done something stupid:
- oSync is only ever read/written inside a synchronized block which guarantees only one expensive object will be created, and that the value of oSync will always be visible between Threads.
- oUnsafe may be written to 100 times because the changes written by one Thread aren’t seen by another according to the Java Memory Model, but the worst that can happen is a Thread encounters synchronization.
- I am assuming that non-volatile writes are eventually propagated and visible by all threads, and that when this happens the Object can be got without even synchronization.
Posted in Programming | No Comments »
December 1st, 2008
Posted in rubbish | 1 Comment »
November 23rd, 2008

Happy Birthday Phillums!
Posted in Phil As | No Comments »
October 6th, 2008
Posted in Phil As, rubbish | No Comments »
September 18th, 2008
Posted in Phil As | No Comments »
August 18th, 2008
- It is not acceptable to ban users from using their ‘Back’ button.
You can be sure that when a user reaches a page they don’t want they will hit the back button on their browser. There are so many shortcuts to this: ‘delete’ on windows, Apple and [ on mac and some people even have a button on their mouse that sends the browser back in the history. By the time they have pressed their favourite Back button by reflex their frustrated mind hasn’t even had *time to remember* that they aren’t supposed to use it because you issued a small warning in 9px font-size underneath your Ads By Goooooogle.
Think about why a user has used the back button. If it is a multi-part form (pain in the damn arse) they probably want to change a value submitted on a previous page. And why not? If this potentially invalidates data that they have entered in a latter form make sure it is checked when the form is submitted. Failure to bother with this is just damn lazy and irritating for the user.
You cant be sure if the back button will load the page from cache (correct behaviour) or the server – however far before the birth of Jesus you set the page expiry time – so handle both cases. See: the ‘if’ statement (all languages).
Worst offender: Barclays iBank online banking. Using the back button logs you out. Bastards.
- It is not my job to work out what your site/product/opinion is about.
You have got all day to design your homepage. Remember that I DON’T CARE who your team is, what awards you’ve won, who your sponsors are, what server farm you prefer or that you have a cat named Geoff who is probably better at pleasing your wife than you are. If your site is software, explain what the software does that I can’t do already; then make it easy to download. I don’t want to have to go through thirty steps choosing mirrors in Sourceforge or hunt through source trees for the most recent version. Have a Download link that takes up at least half the pixels of the homepage which links directly to a .tar.gz file which I can then right-click on and paste in to wget or 100% compatible. The MOST irritating thing is having to provide keystrokes of any kind to download your software. I am only ever going to enter the email address dev@null.com and the name Yu R. Dicks for this. If this fails I am not going to download it.
- Flash intros are the most irritating thing you could possibly put on your website.
I do *not* want to watch your 1500Kb flash bullshit load while I wait to find out whether Google was correct and that your poxy site was the one I was after. Standard Google search user algorithm: Put a deliberately vague search in the google bar; Open the first thirty results in their own tabs, find what you were looking for in the first three; Force quit the entire program to get rid of the remaining twenty-seven erroneous tabs that have each started their own 32kbit Madonna WMA with Flash intro and have hence reduced your quad-core beefcake workstation to a capacitor with series resistance.
I guarantee that while your lavish animation wastes valuable oscillations of my TFT pixel-control transistors 90% of your users are desperately searching for the skip intro link you shitting-well better ‘av provided. If you haven’t provided this and the skip button is in the Flash animation itself then I hope both power supplies deliver 185V direct to the pitiful silicon excrescence you call your server.
Lesson: The web is fast-paced; people on a mission typically view a couple of entirely different sites in the space of ten seconds. However ‘cool’ your flash intro looks nobody can be bothered to watch it. (Let us not deal with the case where your entire website is Flash.)
- Don’t tell me that your website looks best in Firefox or at a resolution of 800×600
Looks better in Firefox? Maybe true, but I couldn’t give a damn shit what your favourite browser is. I bet you are the kind of teenager who uses FrontPage to design his shit family homepage complete with scrolling marquee tag and pink background and yet in every thread on slash-dot about web standards extols the virtues of open-source and how Microsoft is an evil monopoly with their ‘non-standards compliant bloatware’. I am NOT going to change my resolution just so I can say “Oh yeah, they have used absolute positioning and tables with the constant cell widths contrary to all published advice and it does actually just fit in the 763 pixels not absorbed by the ghost of the scrollbar on the exact version of Internet Explorer built into their version of FrontPage” because to change the resolution on a computer is a task that is the internet-complexity equivalent of firing and re-hiring a department full of employees on maternity leave.
- Get off your damn soapbox
I don’t care if your site is valid XHTML, syntactically correct HTML version 3.2 or beautiful error-free DHTML 1.3. I don’t want to know that your CSS is tab-aligned and reads like a novel by Roland Merullo or that over a 9600 baud modem your website downloads in 8.2 milliseconds leaving enough bandwidth for your fanny-liberal telnet session to refresh your ASCII-rendered Star Wars film at 65fps. I care that when parsed by the first web browser invented by the Aztecs running on a machine that can only address a screen 45 pixels square drawn on a wall in sprayed tricolour shit your website looks identical to the latest in-house build of Internet Explorer 8.432b rc12 with strict mode taking a random value between 10 and I Don’t Care.
I thank you.
Posted in Programming | No Comments »
August 1st, 2008
In the beginning God created the heavens and the earth.
Proved. Brilliant.
Give, and it shall be given to you. For whatever measure you deal out to others, it will be dealt to you in return.
‘xcept if you’re Jesus.
The end.
Posted in Rants | No Comments »
June 16th, 2008
Things I, as an educated subject of Her Majesty am tired of in 2008:
- The Weather
- Generic acts of autocratical tyranny
- The fact that the Starbucks ‘bar and grille’ in Fulham Palace road fails to purchase enough croissants every single day – a croissant is probably 8p wholesale (I don’t know I’m not a corporate buyer) but they sell them for £29.99 so if they bought a box of 500 and threw most of them against the WALL they would STILL make a profit – but no, they are INCOMPETENT and buy only FOUR per day which means the smug women comparing the size of their babies every morning get through all four of them before I’m even there (you know who you are, yes you called your child Oswold, well done, very middle-class etc) and hence I have to eat a DISGUSTING piece of ‘granola bar’ CRAP which makes me almost violently sick
- The JCR which fails for a similar reason to Starbucks ‘bar and grille’ because if you fail to take your lunch before the quality-food cutoff at 12.05pm every day after which they have sold ALL food worthy of consumption by a mammal then the entire selection is some ABOMINABLE ‘Full of Beans’ POO which isn’t even a flavour of sandwich and a ‘Cheese Feast’ which is unspeakably foul, who the hell would have a cheese feast anyway that’s not even a thing, and the only thing left is one small red sliver of dying dragon’s tongue that they have the effrontery to call pizza and which you wouldnt eat unless it was your desire to wake up enslaved by a parasitic stomach worm unable to tell the difference between soft brown earth and the delicious lining of your abdomen.
- Middle-class people, who when buying their skinny mocha-frappa sugar-free static void synchronized latte with a vanilla shot and a pink decorative umbrella insist upon it being ‘Fairtrade’ and hence their entire obligation to the third world is complete and they can have a loud and smug conversation about how good their farts smell that everyone has to listen and drive their series of World War II tanks home smug in the knowledge that they are perfect citizens.
- Pedestrian crossings
- Blunt razor blades
… but the MOST irritating thing in the whole world, even more irritating than the worthy contenders above is:
Posted in Rants | 1 Comment »
March 9th, 2008
Posted in Rants, Uncategorized | No Comments »
December 25th, 2007
<voiceover> In this new series, the three Hustlers – confidence trickster Alexis Conran, scam artist Paul Wilson and ’sexy swindler’ Jessica Clement – demonstrate some of the biggest, most outrageous scams ever… so you’ll know what to look out for, and how to avoid being scammed yourself.
<voiceover> Paul has applied for a job at a local restaurant. Little does the owner know that he is just pretending to be a restaurant waiter, and is in fact a confidence trickster. He is skilfully conning the restauranteur out of £6 an hour. Lets see if he can out-earn fellow trickster Alexis?
<voicover> A busy urban street in west london. Not much is going on here, or is it? Alexis is walking down the road with an umbrella and is being filmed from inside a cereal packet at a low angle. He is on his way to a curry house to order a delicious meal for two. But instead of eating the meal, he skilfully extracts the energy stored in the hot food and uses it to charge his mobile phone. He pays for the meal and departs, leaving the naive restaurant owner to realise what has happened.
<voiceover> Jess has dressed herself as an ordinary supermarket legume. This man is going to buy her and take her home; and when he does she will steal his identity.
<voiceover> Jess is pretending to be the indigenous population of northern Greenland. She is enticing nearby countries to trade with her, and in just six hours she has managed to earn herself a tidy seven pounds – all of which is tax free. Admittedly this is less than Paul working fraudulently at the restaurant. Would you have been fooled by this all-too-common stunt?
<voiceover> Paul is appearing in court for murdering and killing a mother and her four children. But little does the judge know that while the court is in session Jess has stolen the ornate brass doorknobs from the closed courtroom doors. On the street these will each fetch £14.
<voiceover> some closing rhetoric
[enough]
Posted in rubbish | 1 Comment »