April 2008 - Posts

Today I answered a question saying use A XOr (A And B).  Then I thought, well isn't that the same as A And Not (A And B).  Now I knew there is a simplification because of the double A and both And's but I honestly couldn't remember all my boolean algebra back from my circuits days. (seems I just don't use it that much <g>).  So for my own reference, I've got my "Circuits, Devices and System" text book out, and I'm going to attempt to translate the theorems into VB rules.

Communication Rules:
A Or B = B Or A
A And B = B And A

Association Rules:
A Or (B Or C) = (A Or B) Or C
A And (B And C) = (A And B) And C

Distribution Rules:
A And (B Or C) = (A And B) Or (A And C)
A Or (B And C) = (A Or B) And (A Or C)

Absorption Rules:
A Or (A And B) = A
A And (A Or B) = A

DeMorgan's Theorems:
Not (A Or B) = (Not A) And (Not B)
Not (A And B) = (Not A) Or (Not B)

So applying DeMorgan's theorem, to A And Not (A And B) we get A And ((Not A) Or (Not B)) and then the distribution rule we get (A And Not A) Or (A And Not B) Since A And Not A is 0, the result is A And Not B.  Much simpler :)

As to  A XOr B, it is defined as (A Or B) And Not (A And B).  I'll leave it as an exercise for the reader to deduce  A And Not B from A XOr (A And B)

Filed under:

Latest TOIBE analysis shows VB on the up ! VB 11.7 %, C# 3.8%

with 4 comment(s)
Filed under:

Over the weekend I switched my main machine to Windows 2008 and started playing with Hyper-V.  I updated the RAM and threw in another hard-drive (man that stuff is so cheap at present !).  I've got both Vista and Windows 2008 (different drives) on the machine, and even though Windows 2008 and Vista are the same kernel, Windows 2008 feels noticeably faster.. plus it has hyper-V.  (note: Vista 32 bit, 2008 is 64 bit so there may be some difference there)

Hyper-V comes with a nice console (a bit like VM Ware <g>).  It relies on system level drivers as well as a few services. The services you can turn off until needed, but the drivers you can't.  And this causes the first point of angst for me... Sleep gets disabled.

Hyper-V's drivers disable Sleep for the main machine.  You can't change this or toggle it which seems incredibly silly.  Surely if you aren't running Hyper-V, your system should have it's natural capabilities in tact.  At present the only work around is to install and uninstall the Hyper-V role (you don't loose your settings when doing this thankfully !), but this requires a reboot, and a fair few minutes.  I really don't understand why the Hyper-V team didn't at least make it switch-able when Hyper-V is not running.  Until they fix it, I think they should be made to walk/run to work rather than drive to make up for the carbon credits they are costing the world ;)

The next annoyance was XP had to be XP SP3 for the hyper-V extension to be installed which was required to get the network running.  Of course without the network I couldn't download the SP3 onto the virtual machine (VM), nor could I do a network share etc.  Hyper-V doesn't have folder sharing like VPC, and doesn't support removable devices like USB keys.  So the only option I had was to burn a DVD (or create an ISO and mount that).  This just seems incredibly silly.  Getting files onto and off a Hyper-V machine is a major pain. It would be nice if it was like a physical machine where you can just plug in a USB drive

Finally, the display adapter for the VMs kind of sucks.  It's a "Microsoft VMBus Video Device", which has a whopping 4MB memory ;)  Obviously this means Aero doesn't work, and for testing any graphics intensive (or playful) application, Hyper-V won't do the job.

Other than that, hyper-V seems good.  For development testing other than graphicic intensive applications, the big deal breaker is disabling sleep

In putting together some virtual machines for testing on hyper-v, I was amazed and disappointed to find that Microsoft is NOT pushing out the .NET framework any more.  On Windows XP, windows update offers only .NET 1.1 and 2.0.  Vista includes 3.0.  So why is it that Microsoft will push out 2.0, but not 3.0 or 3.5 ?  Why isn't 3.0 and 3.5 being offered to XP, and why isn't 3.5 being offered to Vista ?

with 1 comment(s)
Filed under: , , ,

If you read section 12.2 of the Common Language Infrastructure (CLI) Partition II document, you'll see the following part in regards to interface implementation:

If there are any virtual methods in the interface that still have empty slots, see if there are any public virtual methods, but not public virtual newslot methods, available on this class (directly or inherited) having the same name and signature, then use these to implement the corresponding methods on the interface.

The key thing to note here is the "or inherited" part.  This means for example, you may have a something like ToXML member of an interface, which is well suited into factoring into a base class .  The CLI allows for this by requiring the member match by name and signature.

This is where the interface is implied.  This important aspect is being left out of the proposed re-appropriating of VB's existing explicit interface syntax.

with 3 comment(s)
Filed under: ,

I was just reading a work around for timestamps with LINQ or WCF, and I must be stupid, but I just don't get it. In fact, ever since dotnet came out mapping timestamp to a byte array or SqlBinary, I never got why they did that.  Timestamp is 8 bytes, so why not just map it to Int64 or UInt64 and for nullable timestamp columns map it to Int64? or UInt64?

Is there some reason why .NET maps it to a SQLBinary type even though we know it's a fixed size not a variable size ?

Filed under: , , ,

One of the many things I love about VB is it's explicit interface mapping.  It's the beauty of declarative coding that not only allows for flexible mapping but also makes the code explicit.  You don't need to know the intimate details of a given interface to work out which methods it actually maps to, because the member declaration explicitly states it.  Let's say for instance you have an interface that has a Foo method such as  Foo(gizmo).  And in your code you have Foo(sprocket), Foo(Of T)(T), Foo(gizmo, gadget) as well as Foo(gizmo) .  You of course know which one gets called via the interface don't you ?  Well yes in VB as it stands today you do.

So explicit interfaces are a good thing.  There are however times you want implicit interfaces, that's why they are on my feature request list (item 11). Consider the case where you have code generation and you want those generated members in your class to form the interface contract. Today in VB you can't do that in the partial class as you can't over write the generated members.  So there's a mismatch there, and implied interfaces would fix that problem.

What Paul Vick is suggesting however goes beyond just fixing that issue, it instead breaks the IDE and code reading experience by making Implements no longer mean that the members are implemented explicitly, and also adds silly restrictions on to what can be implied and what can't, causing yet another set of problems. Even just the simple task of typing Implements IFoo becomes complicated as the IDE would have to ask you if you want to define that explicitly or implicitly.  Code maintenance would also become more of a nightmare as you wouldn't know if explicit or implicit is being used (at least not from the class declaration)

The biggest issue with the Implements keyword re-appropiation is that it risks breaking existing code. Paul suggests a limitation be placed on VB to get around this issue, that being that no base class members can be part of an implied interface.  So what we have here is an oversight in the original language design of VB.NET, and rather than break that, and rather than introduce a new keyword, the language would be "forever more" crippled in regards to implicit interfaces : You'd never be able to refactor a common method into a base class without risking breaking an implied interface.  This fragile tenure which is meant to fix an issue of designer generated code not interacting well with your code, relies that that designer generated code doesn't have any of those methods in a base class.

Or to put it simply, re-appropriating a keyword usually is a bad thing, and this definitely applies here.  I doubt this will change though as I know I have definitely raised this very issue with the VB team before, and in regards to implicit interfaces, I know, as my feature request list lays testimony to, that I have suggested what I believe is a clearer syntax that doesn't have the crippling side effects Paul's re-appropriation would have :

Class Foo
Implies IComparable(Of Int32)

Non breaking, not limited, and a much cleaner experience in the IDE

Oh, and while I'm talking about interfaces, I sure wish they would put relaxed interface implementation on the table.  Erik seemed to get it when I talked about it, but I think he's moved onto to democratising the cloud these days :)

with 2 comment(s)
Filed under: ,

Obviously Paul thinks just because he used one of my photos and then said nice things about my photos, that I'll probably link to his demo of synclinq in silverlight.  ;)

Filed under:

If you open Visual Studio 2008, you'll notice that the start page for VB hasn't been updated since December 4th, 2007.  Strangely enough the VB team's blog still seems to be used from time to time.  Hopefully someone's just asleep at the wheel over at Microsoft and this might get fixed.  It really shouldn't have gone for over 4 months before anyone noticed !!!!

In the meanwhile, change the feed to the Visual Studio feed, or my feed if you like ;)

with 3 comment(s)
Filed under: , ,

As I write this I'm looking out the window into my veggie garden where the rosellas are having a feast on the sunflowers again. There was so much activity around my sunflowers and tomatoes (probably an exquisite combination for the birds... actually sounds quite nice really, but probably nicer lightly roasted/grilled ;) ) I decided to take a few photos.

Rosella in the orchard:

crimson rosellas eating my sunflowers:

Red Wattle bird. These guys love tomatoes, apples and pears .  They are called "Red" because of the red things (called wattles) on their neck.

And a magpie. These guys are mainly meat eaters:

Of course, my favourite little birds like the blue wren and the wagtails etc, weren't to be seen while I had the camera... maybe next time ...

with 4 comment(s)
Filed under:

What is up with Apple Computers ?  Now they are taking GreenNYC to court because they use an apple as their logo.  What's next, they'll be telling me I can't refer to any of the individual apples in my orchard as an Apple, instead I must call them Malus domestica ?  I think the term "malice" more aptly describes Apple computer's attempt at taking a natural symbol and trying to claim it as their own.  Will New York slogans all have to be renamed from "big apple" to "big Malus" ?

Filed under:

Why do they make it that we need to get up at 3AM to set the clocks back to 2AM ?  Is it so when you go back to sleep you get to have the same dreams again ?  And what about those poor shift workers ?  Imagine if your shift finished at 4AM, then as you see  3AM come around the clock goes back to 2AM.... bummer !    Now imagine if they instead changed the clocks during the day (like any sane person would do) ... Let's say the change time was 1PM.  You'd go for lunch, at 12 or so, and then just as you were winding up lunch and about to get back to work, it's lunch time all over again ! :)  And in the case of daylight savings starting, you'd come back from lunch and it'd be 2PM !! :)

Sounds much better than getting up at 3AM just to change your clocks .

Oh, and don't forget to change the batteries in your smoke alarms !!!

with 2 comment(s)
Filed under:

I'm in utter disbelieve that people don't automatically know the 1962/63 cult classic film, "the day of the triffids"

with 1 comment(s)
Filed under: ,

Well April first pranks have come and gone.  Google, the fun company, had lots of hilarious April 1st pages and sub sites on their web: Virgle colony to Mars, Moon base work centre, new google anytime scheduling; all really well done :)

Microsoft on the other hand seemed relatively sedate.  I can imagine the company line email that must have gone around saying no outward facing pranks or similar.  Still there was a kind of funny video on Channel 9 that added beeps over what people said, one blogger attempted a Windows 9 joke, and Chuck posted some really awful VB code that did ReDim Preserve inside a loop etc but then he killed the blog post :(

About the only half decent prank MS did was the OOXML Appears to Win post. ;)

Has all the fun gone out of Microsoft and been replaced with "corporate responsibility" ?

Filed under: ,

March was a month of extreme weather.  The first two weeks were record highs. This really brought on the tomatoes.  Then the last two weeks were colder than usual, and had a bit of rain.  The rain put out the nearby tyre fire:

I think the smoke helped ripen the tomatoes and give them that  kind of BBQ flavour.  But the rains were good.  I stopped watering the garden as I got plenty of inflow from the nearby tip.  A year or two ago, they lined the dams around the tip, around the same time as they got that medical waste contract.  Since then the plastic liners mean that water doesn't get wasted, and when there's a good downfall I get lots of run-off :)  The veggies seem to be bumper crops from it !

But it all hasn't been this good.  There was some damage to one of my fences just before the rains came.  I guess it must have been hoodlums having too much to drink the night of the meteor shower.  I went to fix the fence today, and it's  bigger job than I thought.  But it gets worse. They seem to have introduced some weird kind of weed into the garden. I haven't seen it before, kind of like a tropical plant, very tall.

The leaves seem to make the funniest noises even with the lightest of winds, a strange clicking noise.  I was going to pull them out today, but I must be allergic to them, as I got some pollen in my face and it's really irritated my eyes.  Feeling really sleepy, so perhaps it will all be right in the morning.

More on the garden soon .... I hope.

with 3 comment(s)
Filed under: