I’ve been waiting for this update for VS 2008 SDK for VS 2008 SP1.  The link I got fro ma msdn blog post was wrong, so here’s the link to the download page.

http://www.microsoft.com/downloads/details.aspx?FamilyID=59ec6ec3-4273-48a3-ba25-dc925a45584d&DisplayLang=en

Enjoy.

with no comments
Filed under: , ,

Davy Brion posted about how events can keep object references alive.  In C# to rid yourself of this issue you have to manually unwire any event handler you wired.  In VB, it is a lot easier, all you have to do is use WithEvents and set the variable to nothing. This code is the VB version of Davy’s sample:

 

Public Class Publisher

   Public Event MyEvent As EventHandler

 

   Public Sub FireEvent()

      RaiseEvent MyEvent(Me, EventArgs.Empty)

   End Sub

 

End Class

 

 

Public Class GoodSubscriber

   Implements IDisposable

 

   Private WithEvents _publisher As Publisher

 

 

   Public Sub New(ByVal publisher As Publisher)

      _publisher = publisher

   End Sub

 

 

 

   Private Sub _publisher_MyEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles _publisher.MyEvent

      Console.WriteLine("the publisher notified the good subscriber of an event")

   End Sub

 

 

 

   Public Sub Dispose() Implements IDisposable.Dispose

      _publisher = Nothing

   End Sub

 

End Class

As long as the variable is declared as WithEvents any event wired up via declarative event handling will be unwired when the variable is set to Nothing.

This is yet another subtle but important example of how declarative coding styles can lead to more robust code.  The above example is minimal, but when you get many events and many objects raising events, the cleanness of the VB way of handling it becomes even more important.  Or in other words in C# you have to make sure you unwire each and every event, in VB you use declarative events syntax and VB handles it for you ;)

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

 

Via Nancy’s blog, I saw the link about Apple’s claim for accessibility features on the iPhone.  Have a look at this picture of their claimed “Giant font for Mail messages


 

Maybe they could have made the picture a bit bigger, but if you have good eye sight you might notice that it appears you have to scroll to read each line then scroll back.  That’s just plain shameful design .

with no comments
Filed under: ,

In case you haven’t seen it, Microsoft is releasing tools for WPF out of cycle as part of the WPF toolkit. Current release includes a CTP of a Data Grid, and a Date Picker and Calendar is planned.

with no comments
Filed under: , , , ,

As I looked out the window this afternoon I spied a young joey out of the pouch.  They’re like puppies, full of energy.  Of course by the time I grabbed the camera and went outside he was back in the pouch (no-where to be seen). Definitely does seem early this year compared to last year.

Hopefully I will get some photos of him/her soon.  Oh, and when I walked towards the roos today, the buck got mighty defensive, standing up tall on his tail.  I was so focused on taking a picture of the joey I didn’t even think to take of picture of that.  I’m kind of hoping he doesn’t do that next time ;)

with no comments
Filed under:

Check out the msdn subscriber homepage.  S

 

P1 for Visual Studio 2008 English is about 830 MB… downloading at present

 

:)

 

Then I can install SQL 2008 :)

with no comments
Filed under: , , , ,

Lucian has kicked off the conversation on generic variance in VB , so I thought I’d write a few posts outlining my perspectives on the subject… the first of which is this one, and what better place to start than to question whether or not it is really needed……

Generics came to .NET after the base framework and languages were implemented.  It was very much a bolt-on approach.  As such there was and still is an impedance mismatch between conventional concepts of polymorphism and generics. As I posted previously, I had raised this is issue with Anders and other language experts back at the 2003 PDC (at which time Anders suggested using a language other than VB or C# <g>). Fast forward to today, and this issue is now being looked at, but now I find myself questioning if it is really needed, or is the fault the mismatch of the original framework. 

Let’s take Lucian’s example :

Dim args As New List(Of ConstantExpression)
args.Add(Expression.Constant(2))
args.Add(Expression.Constant(3))
Dim y = Expression.Call(instance, method, args)

 

This code fails because the Call method is defined as :

 

   Public Shared Function [Call](ByVal instance As Expression, _
                                 ByVal method As MethodInfo, _
                                 ByVal arguments As IEnumerable(Of Expression)) _
                                 As MethodCallExpression

 

But if it was defined as follows then the code would work:

 

   Public Shared Function [Call](Of T As Expression) _
                                (ByVal instance As Expression, _
                                 ByVal method As MethodInfo, _
                                 ByVal arguments As IEnumerable(Of T)) _
                                 As MethodCallExpression

 

 

So where exactly is the problem ?  The simple rule is if you want polymorphism (read as “generic variance”) in your code, then you need to expose the types as generic parameters not as concrete types.

That is, the above is solved by better API design and some simple refactoring.  This in fact solves 90% or more of all the cases I have seen.  The one place where you can’t do this is when the type is late bound and defined only as Object (more on this in a future post no doubt ;))

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

This post has been sitting in my drafts for a while, so I thought I should post it, mainly because I want to talk about this and generic variance and arrays in more detail in the days ahead.  The reason this post was put on hiatus was I was waiting for my article on arrays to appear in Visual Studio Magazine, as that deals with many of the details as to why this works ;)

 

Have you ever wanted to cast a List(Of Customer) to a List(Of BusinessBase), where Customer Inherits BusinessBase, only to find that you can't... well you can ;)

 

This extension will return an IList of BusinessBase for an input of a List(Of Customer).  Be aware it is the underlying array, so you will need to get the actual count from the original input.

 
   <Runtime.CompilerServices.Extension()> _
   Function ToIList(Of T, TBase)(ByVal list As List(Of T)) As IList(Of TBase)
      Dim fi = GetType(List(Of T)).GetField("_items", Reflection.BindingFlags.Instance Or _
                                                      Reflection.BindingFlags.GetField Or _
                                                      Reflection.BindingFlags.NonPublic)
      Return CType(fi.GetValue(list), IList(Of TBase))
   End Function

 

 

And a quick test:

 
 
Module Module1
 
   Sub Main()
      Dim myApples As New List(Of Apple)
      myApples.Add(New Apple With {.Name = "Golden Delicious"})
      myApples.Add(New Apple With {.Name = "Red Delicious"})
      myApples.Add(New Apple With {.Name = "Granny Smith"})
 
 
      Dim fruits As IList(Of Fruit) = myApples.ToIList(Of Fruit)()
 
      For i = 0 To myApples.Count - 1
         fruits(i).Name = "Fruit : " & fruits(i).Name
      Next
 
      For Each a In myApples
         Console.WriteLine(a.Name)
      Next
 
      Console.WriteLine("finished")
 
      Console.ReadLine()
 
   End Sub
 
 
 
   <Runtime.CompilerServices.Extension()> _
   Function ToIList(Of T, TBase)(ByVal list As List(Of T)) As IList(Of TBase)
      Dim fi = GetType(List(Of T)).GetField("_items", _
                                         Reflection.BindingFlags.Instance Or _
                                         Reflection.BindingFlags.GetField Or _
                                         Reflection.BindingFlags.NonPublic)
      Return CType(fi.GetValue(list), IList(Of TBase))
   End Function
 
End Module
 
 
 
 
Class Fruit
 
 
   Private _Name As String
 
   Public Property Name() As String
      Get
         Return _Name
      End Get
      Set(ByVal value As String)
         _Name = value
      End Set
   End Property
 
 
End Class
 
Class Apple : Inherits Fruit
 
End Class
with 4 comment(s)
Filed under: , , , , ,

If you have Visual Studio 2008 installed, you can’t install all of the SQL 2008 bits because of shared components for Visual Studio 2008.  SQL 2008 wants to use Visual Studio 2008 SP1 components and that might/will break your Visual Studio 2008 setup.  Good news is SP1 for Visual Studio is said to be available on MSND subscriber downloads after August 11th.

This COM based dll hell though surely has wider implications.  What of those who developed for Visual Studio Extensibility and have their own Visual Studio shell  ?  Oh the joys of shared COM components. ;)  Memories ……

with no comments
Filed under: , , ,

I downloaded the SQL 2008 Upgrade Advisor. When I tried to install it I got this :

 image

 

It says a “Windows service pack” , yet Windows Update tells me my system is up to date.  Well it might help if I read the download’s system requirements ;)  What I needed to do was install windows Installer 4.5

Strange it isn’t listed on Windows Update/

Apologies to all as I have been slack in filtering out the spam, and replying to comments.  Hopefully I’ve caught up now :)

with no comments
Filed under: ,

 

Although it’s the midst of winter, some of the fruit trees are already in blossom (wild pear above).  I still have a LOT of pruning I should try to get around to.  I’ve also decided that I will try to plant one or two new fruit trees every year, to help build diversity, plus it’s a lot easier than do mass plantings all at once.  This year I bought two peach trees, an Elberta and a Red Noonan. While I was at it I grabbed a Valencia and a Navel orange tree.  It’s pretty marginal here for oranges, but I couldn’t resist ;)

 

The veggie patch is pretty quiet. Celery, silverbeet, carrots, beetroot for the harvest at present, broad beans still promising to have some pods, but nothing yet.  I planted some garlic which is growing well, and will plant potatoes soon.

This is one of the flowering climbers I planted this year, with it’s first flowers.  Hopefully, eventually it will cover the wire fence :)

 

 

Elsewhere in the garden, the proteas are coming into bloom:

 

This one is one of the first I planted:

 

This is the first flower I have seen on this little plant I planted a couple of years ago. It struggled through the drought, but is doing well now.  Only one flower on it this year:

 

The Drynandra is also in bloom, and making a great comeback. The giant yellow tail black cockatoos almost stripped the plants completely last year.  Seems they did a great job mulching them, and no doubts they’ll visit again this year ;)

 

Another paler pink protea is also in flower:

and has lots more about to open:

 

The wattles are getting even more intense (see last month’s photos) .  There’s seas of yellow across the countryside. Here, the tree lucerne is also in bloom, adding a snowy effect :

 

As I took these photos today I also caught a few of the local birds.  You’ll need to look at the larger versions fro the little birds. This is a Spotted Pardalote. Hard to get a good photo of:

 

And this guy is a Red-Browed finch.  Click on the photo to see the large version:

 

And of course the Crimson Rosellas had to get in the photo :

And the magpies are pretty active at present.  I think they may be breeding:

There were plenty of other birds as well including Kookaburra, what is probably a Satin Bower bird, some other finches and robins I hope to get some photos of in the coming months :)

 

The weather has been mixed. Some nice days, a few heavy frosts and some decent rains.  July was good for rain, but we are still way down for the year.  I glanced at some historical figures, and the closest pattern I noticed was 1937, which ended up having heavy rains around the end of the year, instead of the usual mid-year rains (more tropical than temperate).  More rain would be good.

Oh, on a site I check for weather reports I noticed it said only 60 or so more days till day light savings begins again. :)

with 2 comment(s)
Filed under:

It seems apparent that with computers as we currently know them, processors are now set to scale out not up.. that is, clock speeds aren’t rapidly growing, and certainly not doubling every year or two, instead the number of processors on a chip is.  As a case in evidence, 2 or 3 years ago, my PC’s were all single CPU, then a bit over a year ago I bought my new desktop PC and it was a dual core.  And as of a few days ago I swapped that dual core out for a quad core.  For me, the number of cores/CPU’s is clearly doubling every year or two, but clock speed itself isn’t that much faster.

So what that means for computing is the emphasis is on parallel or concurrent computing. As such, we need to look at the fundamentals and see if they are designed for the task.  Iterators don’t look like they are.

If you consider an iterator primary task of getting the next element, then look at how it does it, you should observe a major design flaw… the operation is not atomic. An iterator’s implementation is IEnumerator or IEnumerator(Of T), and IEnumerator require you to first call MoveNext then read the Current property.  If you allow multiple threads to use the same IEnumerator, then you could get a call sequence such as MoveNext, MoveNext, Current, Current, which would skip one item and repeat the next one.  So IEnumerator is not well designed for threading.  This is a known design limitation, but rather than address that, languages like C# have implemented their iterators to be a different iterator per thread.  That is they not only recognise the limitation but they also enforce it.

Going forward, perhaps we need a new IEnumerator class.  In the good bad old days that would be called IEnumerator2(Of T).  IEnumerator2 would make iterating a single method call that would return a Tuple(Of T, Boolean).  It could extend IEnumerator, but it would be difficult to enforce thread safety to the IEnumerator interface. The problem that language like C# would then face is do they risk breaking existing code by returning the same enumerator to different threads ?  Well no they would have to provide an IEnumerable2.GetEnumerator as well, so it would be possible to have the same class used for both single instance per thread and shared class across threads.  As such, then the code that calls the iteration, the For Each loop, would then have to indicate whether it wants to do so using parallel or single threaded.. this would probably surface in the languages such as the For Parallel instruction on a loop.

So maybe iterators aren’t fundamentally flawed, they just currently have a lot of limitations which can and hopefully will be addressed  as we venture more into the world of multi core :)

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

Today I bought an Intel Quad Core Q6600 to replace my old Dual Core.  I was amazed at how easy it is to swap processors.  The box I was upgrading was an old Dell Dimension E520 .. when I say “old” I mean more than 12 months and hence out of standard warranty <g>  

First step is to identify if you can upgrade. I searched the web for my model along with Q6600 and found success stories on Dell’s forums.  I then checked the Intel site where you can select multiple processors and compare the chipsets and all looked good. So I bought the Q6600, which are pretty cheap at the moment :)

The Dimension E520 has a better heat sink and fan combination than what came with the Intel Q6600, so I kept my old heat sink, giving the base a wipe over and a clean with isopropyl alcohol.  Removing it for cleaning was a breeze, only two screws holding it onto the motherboard then it hinges off the processor. I also gave the case and heat sink a blast of compressed air to remove the dust that was in there. 

Removing and swapping the processor is really easy… you just push the wire clip out and up, and the retaining brackets lifts off the processor chip. The chip just lifts out, no prying or tools needed. It’s so easy I feel ashamed I haven’t done it before ;)  (but then again I generally replace systems, not parts).  A quick squirt of heatsink gunk, slap the heatsink back on, and everything was done.  A quick check with SIW.exe showed the temperatures are good too :)

And now the fun begins !!  With 4 cores I can start playing more seriously with parallel (concurrent) programming.  2 cores wasn’t enough really, and although 4 is just the start, it should be enough to run basic tests :)

with no comments
Filed under: , ,

I really like the preview pane in explorer in Vista, but it doesn’t have previews for a lot of text based files registered.  You can of course write your own or download and install some other preview filters, but personally I find a text preview is all I generally need.  So I re-use the existing Text preview handler and apply it to a range of file types including batch files, .bat, xml, .reg files, .vb and .cs files etc.   Just copy and run the following .reg file

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\.xml\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

[HKEY_CLASSES_ROOT\.reg\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

[HKEY_CLASSES_ROOT\.cmd\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

[HKEY_CLASSES_ROOT\.bat\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

[HKEY_CLASSES_ROOT\.VBS\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

[HKEY_CLASSES_ROOT\.vb\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

[HKEY_CLASSES_ROOT\.vbproj\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

[HKEY_CLASSES_ROOT\.cs\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

[HKEY_CLASSES_ROOT\.csproj\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

[HKEY_CLASSES_ROOT\.sln\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

[HKEY_CLASSES_ROOT\.snippet\ShellEx\{8895b1c6-b41f-4c1c-a562-0d564250836f}]
@="{1531d583-8375-4d3f-b5fb-d23bbd169f22}"

I was reading Kathleen’s post about what a C# developer needs to know about VB and thought I should clarify the bit about Booleans converted to numerics.  A Boolean in VB when converted to an integer type numeric, will be zero or the bitwise Not of zero.

This table summarizes the value of True when converted to integer types using VB’s built  in CType operator, or specific operator:

Type CLR Type Hex value Decimal specific operator
Byte Byte &HFF 255 CByte
Short Int16 &HFFFF -1 CShort
Integer Int32 &HFFFFFFFF -1 CInt
Long Int64 &HFFFFFFFFFFFFFFFF -1 CLng
SByte SByte &HFF -1 CSByte
UShort UInt16 &HFFFF 65535 CUShort
UInteger UInt32 &HFFFFFFFF 4294967295 CUInt
ULong Uint64 &HFFFFFFFFFFFFFFFF 18446744073709551615 CULng

 

As you can see, the Hex values are all bits set.

It’s up to you if you use the more succinct specific operator, such as CInt(value), rather than CType(vale, Int32).  I tend to use Cint.  I do go out of my way to use CUInt … I’ll let you guess why ;)

For C# people, living in a world devoid of such niceties, you can continue to rely heavily on the Convert class, even if the result is incorrect as far as bitwise representation goes ;)

And for more insight into operators in VB, see my article in Visual Studio Magazine.

with no comments
Filed under: , , , ,

(photo courtesy of wikipedia)

 

As software architects today we are faced with an increasing dilemma of do we design our application to have stairs or ramps.  In building terms, stairs can make a grand visual presence, but provide no access for those in wheel chairs.  Wheel chair access is often only tacked on as an after thought, and only as required by the relevant local legislation.  Consider the Lincoln Memorial, and it’s grand stairs. Where’s the ramps ?  It wasn’t designed with that in mind.

As we architect our software monuments, we have conflicting forces. Rich mouse interaction and animations, versus accessibility. Designing for both is hard, so it often gets put off to the “afterwards” pile, where accessibility might eventually be retro fitted.  That then becomes a cost in dollars and time, that tends to be cut.  The result is it becomes too expensive to provide accessibility features for the sake of employees.  So as we focus on the beauty of building our stairs and grand entrances, we effectively discriminate against large sections of the potential workforce. 

It’s ironic that computer software, probably the leading technology with the ability to provide access for many people who are otherwise disadvantaged in what work they can do, is tending to discriminate more as we “advance” the “user interface” . When M.L.K stood on those stairs and told of us of a dream for the future, he obviously had bigger issues on his mind than those stairs and the discrimination they caused, but part of that dream was that all people be treated equal.

It’s not easy. It’s a difficult task.  We may not achieve it overnight, but if we all try a little bit, we can get there.  Next time you start building stairs, please stop and consider the ramps.

with 2 comment(s)
Filed under: , ,

 

The wattles are in splendid bloom at present. (above planted in 2005).  The orchard is all quiet except for many awaiting pruning jobs.

The veggie patch is over wintering nicely, with carrots, beetroot, silverbeet, celery, bok choi and lettuce all for the picking at present.  Still waiting on the broad beans to pod.  And the pumpkins in the shed are keeping well, although I did toss a couple out as they got soft spots.

While I was weeding in amongst the self sown broad beans, I noticed some potatoes had also grown wild.  I think they are old Kenebecs I grew many many years ago. They are a nice addition in winter :

 

 

This year I decided not to plant the lemon grass in the garden as it has completely died and rotted over winter the last two times.  So I’ve kept it in a pot in the glasshouse, and so far so good.  All going well, I’ll divide it in spring and plant some in the garden next year, and keep one growing in the pot:

 

 

It’s also that time of year one thinks about planting more trees.  I bought 100 tube stock of wattles and banksias and the like:

 

I’ll be planting them out maybe next month or so.  I was looking back at the history (blogs are better than keeping a diary <g>) and of the ones I planted in 2005, not that many survived. The later planting in 2004 was much more successful.  But the planting in 2004 I did bucket water regularly over that summer, whereas the 2005 planting I didn’t water as much, and they were planted in hard to grow spots, plus the wallabies and kangaroos ate a lot of them.  Maybe because of the on going years of low rainfall, they’ve attacked the plants more, or maybe because they now identify the tree guards with food <g>

To show you what I mean, I had bought this really nice advanced banksia which I was going to use to replace some of the old proteas that had died.  I watered it and left the pot out over night, and this is what the kangaroos left me:

 

 

They stripped it back to the stalk. 

Today as I was taking these photos, the local family of roos was on the western lawn. In this picture, six of the seven have joeys in the pouch. I’ve seen a few peek out and have a look around.  I think I’ll need to get more inventive over the tree guards I use this time around.

 

 

Of the earlier plantings, some of the plants are doing really well. These eucalypts were planted in late winter, early spring 2004, and now are bout 15 foot tall:

 

And some of the wattles, also planted in 2004 really brighten up a winters day:

 

 

 

The weather:  June was very mild and relatively dry.  I think it was about half the usual rainfall and a couple of degree Celsius above average.  But July has ben cold (back to normal), and we’re starting to get some decent rains.  A lot of the country is in dire need of water, with towns not that far North of here being down to less than 10% of storage in the middle of winter which is the wet season here.  You know it is dry when people welcome the rain in winter.  Fingers crossed this year the drought breaks, there’s a lot of kangaroos and plants at stake.

 

 

 

 

 

 

 

with no comments
Filed under:

with no comments
Filed under:

I noticed these fellas in the front paddock today, and thanks to some very helpful people over at birdsinbackyards.net, identified them as Bassian Trush.  If you go to the fact page on them , there’s even a bird call you can listen to.

 

with no comments
Filed under:
More Posts Next page »