I want this now….

mms://wm.microsoft.com/ms/msnse/0409/23062/Gavin_Bierman/gavinbierman_0001_56K_110K_300K.wmv

Posted in .NET | 2 Comments

The Powder Of Sympathy

Around 1700 – A Royal Committee was formed to gather ideas and a prize of £20,000 was offered to the person who could determine longitude at sea.

One suggested method was that a mysterious substance called “powder of sympathy” if rubbed on a bandage taken from a wounded dog would cause the dog to howl in pain, even if the dog were hundreds of miles away from the bandage. If this were done in England at a predetermined time every day, then the dog’s howling would give the navigator a daily time signal. Of course if the ship were traveling on an extended journey, the dog would have to be re-injured to keep the wound fresh. Luckily for the dogs, this scheme didn’t pan out

Posted in Faster Than Light, Quantum Mechanics | Leave a comment

mutable in C++

I’ve gone back to some refactoring for a few days to solve a problem that has been annoying me for a while. The solution is found in some C++ arcana that I always used to avoid due to porting issues, but now feel confident to try as I have not encountered a bad C++ compiler in a few years now.

Some ‘const’ member functions (those that only want to read and not write to an object) need to make innocuous changes to data members (e.g., a Set object might want to cache its last lookup in hopes of improving the performance of its next lookup, or lock access to an object via a lock object which is a member).

When this happens, the data member which will be modified should be marked as mutable (put the mutable keyword just before the data member’s declaration; i.e., in the same place where you could put const). This tells the compiler that the data member is allowed to change during a const member function.

If your compiler doesn’t support the mutable keyword, you can cast away the const‘ness of this via the const_cast keyword – but this is very very evil and bad things will happen if the moon is in the wrong phase and the cock crows four times. Seriously don’t try it – it will ruin your life. Very few C++ compilers don’t support the mutable keyword. Instead of using const_cast, better to “#define mutable” de-const your conflicting member functions and go through const-chain-reaction-hell till your compiler stops screaming at you.

[Update]

You can’t do this – but I wish you could – only because it would make my scummy design neater.

class MwLockedAddressExclusiveList : public mutable MwIPCCriticalSection  

But really this is an issue with the design. A mutable interface does not make much sense and it would be better that I just add that MwIPCCriticalSection  to MwLockedAddressExclusiveList as a mutable  member. So this is more of a problem of my bad design. I am clearly violating the rules of “HAS-A” vs “IS-IMPLEMENTED-IN-TERMS-OF” and “IS-A”

When designing a class hierarchy, you may face a decision between inheritance (IS-A, IS-IMPLEMENTED-IN-TERMS-OF ) vs. the containment/composition/layering/aggregation (HAS-A) relation.

For instance, if you are designing a  Radio class, and you already have the following classes implemented for you in some library:  Dial, ElectricAppliance.

It is quite obvious that your Radio should be derived from  ElectricAppliance. However, it is not always obvious that  Radio should also be derived from Dial.

How to decide?

You can check whether there is always a 1:1 relation between the two, e.g., “do all radios HAVE one and only one dial?” You may realize that the answer is “no”: a radio can have no dial at all (a transmitter/receiver adjusted to a fixed frequency) or may have more than one (both an FM dial and AM dial). Its always important to use your imagination to fully flesh out the possibilities. 

Hence, your  Radio class should be designed as HAS Dial(s) instead of being derived from it (IS-A) . Note that the relation between  Radio and ElectricAppliance is always 1:1 and corroborates the decision to derive  Radio from  ElectricAppliance as a Radio IS-An ElectricAppliance.

When you write software, you deal with two worlds. You deal with the world you want to model, the outside world. You also deal with a world that exists only inside the software, which involves just getting the code to work. HAS-A corresponds to something in the real world. A Radio HAS Dials or a Person HAS Friends. HAS-A corresponds to the application domain. IS-IMPLEMENTED-IN-TERMS-OF never exists in the real world; it is part of the implementation domain. So you couldn’t say a Radio IS-IMPLEMENTED-IN-TERMS-OF Dials. A Radio HAS Dials. But you could say the Radio IS-IMPLEMENTED-IN-TERMS-OF a List of Components. There’s no List in the real world. The List only exists inside the software. So HAS-A is a relationship between classes that exists in the application domain. IS-IMPLEMENTED-IN-TERMS-OF is a relationship between classes that exists in the implementation domain.

There are several schools of thought of this – much like schools of kung-fu. I subscribe to the following.

If you find yourself describing relationships as “HAS-A” Then you want to use simple composition and aggregation

If you find yourself describing relationships as “IS-A” Then you want to use public inheritance. You want to declare to the world that it conforms to a certain aspect of your model.

If you find yourself describing relationships as “IS-IMPLEMENTED-IN-TERMS-OF” then you should use private inheritance. You want to give an object an ability or behavior in the process of implementing it – You want how you did it to remain secret so that if you change your mind, nobody will notice.

It is generally thought that protected falls into its own area and nobody has yet figured out how to use it a way that conveys any useful semantic meaning that gives a programmer that happy-feel-good -rush that you get with everything in its place and a place for everything. One possible interpretation is “a combination of IS-IMPLEMENTED-IN-TERMS-OF and IS-A  but for ‘my derived classes only'” – This has the effect of controlling the degree of polymorphism. Using protected can make reading the relationships within your code ambiguous – but it does have its place in the C++ pantheon of model glue.

I should have listened to my Mother’s advice and become a brain surgeon.

http://www.devx.com/tips/Tip/5809

http://www.artima.com/intv/meaningP.html

http://www.parashift.com/c++-faq-lite/

http://cpptips.hyperformix.com/cpptips/prot_inher2

 

Posted in C# | Leave a comment

Nanotech Visuals Rides Again

Some of my old rave visuals is being used in an episode of a local TV show called. “All Saints“. I am being told I am getting a credit – which will make a change from the last production that I was a technical consultant on. At least I got to have dinner with Keanu 🙂

Posted in Music & Art, Nostalgia for Misspent Youth | Leave a comment

I've Read That Java Has Just Overtaken Cobol As The Most Popular Language

“I’ve read that Java has just overtaken Cobol as the most popular language. As a standard, you couldn’t wish for more. But as a medium of expression, you could do a lot better. Of all the great programmers I can think of, I know of only one who would voluntarily program in Java. And of all the great programmers I can think of who don’t work for Sun, on Java, I know of zero.”

….

“If Microsoft used this approach, their software wouldn’t be so full of security holes, because the less smart people writing the actual applications wouldn’t be doing low-level stuff like allocating memory. Instead of writing Word directly in C, they’d be plugging together big Lego blocks of Word-language. (Duplo, I believe, is the technical term.)”

http://www.paulgraham.com/gh.html

Posted in Uncategorized | 3 Comments

Cough Cough…

I soldier on.

Favorite new word. ‘syntagma‘.

Designing a new nifty data structure to enable efficient & fast construction of optimal combined lexical and LALR syntax parse tables from a context free grammar. Fun thinking time ahead. I’m going to sit down with a large sheet of fine paper and a 2B pencil and a few glasses of wine and make a good session of it.

Who Blogs The Bloggers?

Blogs are almost what the world wide web was supposed to be as defined by Dr Bush’s good idea and TBL‘s good implementation. Now that we have a million screaming opinions – what we really need is a search engine that lets you gather a group of blogs together as a single dataset and then interrogate what they say as a trend.

eg.

“Do they believe in God?”

“How much do they know about the law?”

“Will they vote for me if I  go to war against Iran?”

Posted in XPath | 4 Comments

A Very Old Sig (circa 1997)

— James Mc Parlane 
The Evil Brotherhood of Mutants Graphics/Video Dept of R&D ALIFE
  Voice +(61-2)9660-4174 fax 9699-9888 Data  +(61-2)####-####
             C/C++ source nanoTECHno  33.6k !warez
       PC/AMIGA/NEWTON Loosely Coupled Super Computing Project  
      Biological Computing Division http://www.biocomputing.org 
            Set Top Industries http://www.set-top.net 
               Natural Computing  http://www.ncom.com   
                Zen Multimedia http://www.zenmm.com
 
http://www.ebom.org = Free Internet Access For Electronic Artists
 
“Back off man, I`m a scientist” * WILL CREATE ARTIFICIAL LIFE FOR FOOD *
       Ph`nglui mglw`nafh Cthulhu R`lyeh wagh`nagl fhtagn!
Posted in Nostalgia for Misspent Youth | 1 Comment

Sickness and Housekeeping

First conjuntivitis brought home by number one son… then the flu has gotten me again.. a week spent with little brain. Got a new desk. Everything looks better now than it used to. Defragged my HD. Hope this will stop the XP jitters and lockups.

Back to bed now.

Posted in Meta-Narrative | Leave a comment

Sick for two weeks now.

Been coming home and going right to bed so no time for any fun coding. Spent the weekend at parents in law’s house so no work done this weekend.. It was so damn cold in Sydney that I would have just spent the weekend in bed anyway. Been putting my down time to good use and thinking heavily.

Facorite new word. ‘lexeme

Posted in Meta-Narrative | Leave a comment

On the mend..

Tickle Tickle.. cough cough..

Sadly my last antibiotic consumed yesterday so I now exist without the support of modern medicine.

An all-nighter at work.. I’ve cut my compulsory 1 hour of coding a day down to 15 mins. Still making progress. Working this weekend. My time poverty should resolve for the better on Tuesday.

Posted in Meta-Narrative | Leave a comment