Aug. 16th, 2007

andrewducker: (Cutest Kitten)
Yesterday Jack had his final innoculaitons, and we were thus able to introduce him to Denver.

Not that they haven't almost met on numerous previous occasions. They spy each other in the distance, Jack instantly going into "What the fuck is that, and will it play with me?!?!?!?!?" mode, and Denver making a noise not entirely unlike a loudly hissing kettle before vanishing in a puff of black fur.

This pattern continued last night, as we've stopped keeping them apart, letting them instead find their own equilibrium. This equilibrium seems to be about 18 inches - Jack can get that close before the hissing gets particularly ferocious, and he hovers there, meeping in a placatory way until the growling gets too loud, at which point he bounces off around the room for a bit. He keeps coming back though, hoping that Denver will make friends with him.

I'm hoping she does as well, at the very least she's already grown more used to him - standing her ground rather than fleeing instantly. I just wish most of this process hadn't happened on the stacks of 47 boxes next to my bed. At 3am.
andrewducker: (default)
Dead Ringers is one of the reasons I don't object to the license fee. Here they take on House:
andrewducker: (devil)
I don't see ads very often, except when people link to them on YouTube - and I don't even know if this one for Skittles has been shown in the UK. But it's a fantastic mix of Pathos and humour.


More in the same series on the journal of [livejournal.com profile] imaget over here
andrewducker: (Dr Who)
Static methods are fantastic. Static classes even moreso. You can call them from anywhere in a very simple manner, making them useful "Helper" classes. But they lack one very useful trick - they can't be subclassed. If you want a range of helper classes with similar functionality then you either have to put that shared code into a different static class or use a singleton pattern instead.

(And while I don't know how often the singleton pattern is used elsewhere, it's certainly one that I bump into on a very regular basis. For those that don't about it, it's a class that only allows a single copy of itself to be instantiated. For more about them, and guidelines on writing your own see http://www.yoda.arachsys.com/csharp/singleton.html where Jon Skeet gives some useful examples.)

In any case, it's something that's common, too easy to implement badly in multithreaded applications, and the resulting code isn't as pretty as it could be. What I'd like is a new keyword in the language that solves all of these - "singleton".

If a class is declared "singleton" then it should be possible to access its methods directly, in the same way that a method is on a static class. In effect, MySingleton.Instance.MyMethod() would be replaced by MySingleton.MyMethod() - and the compiler would deal with creating your singleton in a safe and efficient way.

Code before:
public class SingletonClass
{
    private SingletonClass(){ }
    public static readonly SingletonClass Instance = new SingletonClass();
    public void MyMethod()
    {
    ....
    }
}
and to call it:
SingletonClass.Instance.MyMethod();


Code after:
public singleton class SingletonClass
{
    public void MyMethod()
    {
    ....
    }
}
and to call it:
SingletonClass.MyMethod();
andrewducker: (Eightball)
Boxes - all stacked against one wall. The word "precarious" may well have been used at some points. Cheers to [livejournal.com profile] eduard_green and [livejournal.com profile] diotina for their assistance.

Jack, on a bed no longer covered in crap. Seems unsure where his assault course has gone.

April 2025

S M T W T F S
   1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23242526
27282930   

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Apr. 23rd, 2025 06:55 pm
Powered by Dreamwidth Studios