Dan Byström’s Bwain

Blog without an interesting name

Birthday present

Posted by Dan Byström on October 15, 2007

An art map with dedication by Don Rosa… wasn’t THAT a cool present?

Thanks, Roger & Kerstin. 🙂

Posted in Uncategorized | Leave a Comment »

The åäö Ghost Strikes… AGAIN!

Posted by Dan Byström on July 25, 2007

Just when I thought we were out of the dark ages… something hit me right out of the blue.

During the summer something strange has happened, which I suspect happened because of some Microsoft security update. That is at least more probable than an ill-willing gnome in my machine fiddling with some bits. But you never know.

What has happened is that the

System.Windows.Forms.Application.ExecutablePath

property all of a sudden returns an incorrect result if the path contains a “non-ASCII” character like our swedish charaters åäö!!!

Replacing it with a

System.Reflection.Assembly.GetExecutingAssembly().Location

fixes the problem.

Demonstration:

  1. Fire up a new windows forms project and add “MessageBox.Show( Application.ExecutablePath );” to the default form’s constructor.
  2. Compile and place the exe in a folder called “c:\Our Application”.
  3. Run and you get “C:\Our Application\WindowsApplication1.exe”.
  4. Now rename the folder to “c:\Vår Applikation”.
  5. Run and you get “C:\V�r Applikation\WindowsApplication1.exe”. Where the “�” character is #65533.

The scary thing is that this behavior just changed over night.

Posted in .NET, Uncategorized | Leave a Comment »

Construction

Posted by Dan Byström on July 3, 2007

Currently our new house is being built.

I must admit I wasn’t prepared for the vast amount of decisions we had to do. Kitchen stuff, bathroom stuff, tiles, tapestries, electrical work, colors, doors, flooring, …

How are we supposed to know exactly what we want before actually having lived in the house first in order to get a feeling for what will work and what should be changed?

When I complained about this to a friend he told me that there’s actually a name for my annoyance: Big Design Up Front!!!

All these years we software developers have been told that we have so much to learn from the building industry. All of a sudden I’m not sure that’s true at all.

Maybe we should teach the building industry some agile practices? 🙂

Posted in Uncategorized | Leave a Comment »

It’s a girl

Posted by Dan Byström on June 11, 2007

and she came to us at 09:17 as of today.

 

Posted in Uncategorized | 1 Comment »

Relocating II

Posted by Dan Byström on June 4, 2007

Jaha. Så har jag då flyttat från Göteborg tillbaka till Smålands djupa skogar. Ett år tog det att övertala Anette att flytta med.

Nu kan man ju fråga sig om det var en god idé att flytta ifrån "Sveriges framsida", men svaret på den frågan fick jag i nedanstående mejl från min gamle högskoleklasskamrat Bertil Thorén.

Göteborg är Göteborg, dvs en av Sveriges mest konservativa småstäder (läs bonn-håla). Nu vet jag att du inte är intresserad av fotboll men exakt hur gammaldags och bakåtsträvande Göteborg är år 2007 förstår du nog trots allt av följande lilla historia.

Igår (28 maj 2007, inte 28 maj 1947, ja det behövs poängteras) var det fotbollsmatch mellan stadens två stora fotbollslag, IFK mötte GAIS på den stora stora arenan Ullevi. Reklamen för matchen hade varit massiv i både tidningar och tv. Över 30 000 personer tog sig Ullevi för att beskåda matchen, de flesta var moderna människor med stort fotbollsintresse som bara har en vag aning om Göteborg som gammal hamnstad.

Okey, nu har du fått en bakgrund till scenen.

Nu har man alltså 30 000 personer som publik och innan matchen börjar är det brukligt med lite lätt underhållning för att få upp stämningen och få alla att trivas. Halmstad har vid större matcher fått Gessle att spela några låtar, Djurgården har engagerat Willy Craaford och andra klubbar har haft små jippo matcher eller utmaningar mellan äldre stjärnor. GAIS har använt både gamla punk-bandet Attentat och Håkan Hellström, båda kända för sina GAIS sympatier.

Vad har då IFK (som var ansvarig för spektaklet) ordnat fram ? Jo men visst, goda glada käcka göteborgsjävlarna har skramlat fram Legatokören. En kör bestående av 20 pensionärer varav 4 dragspelare som ytterst fantasilöst spelar "Engelska flottan har siktats vid Vinga" och andra liknande alster. Behöver jag säga att stämningspåverkan var marginell?

Göteborg behåller därmed ohotad förstaplatsen på listan över "vi vill inte vara med i det moderna samhället" och eftersom spårvagnstrafiken kommer byggas ut ytterligare samtidigt som inga nya väger eller broar planeras känns denna placering som fullständigt säker.

Skulle någon ort mot förmodan hota tätplatsen har Göteborg dock några ess i rockärmen,  förslagen om att ta bort vägar i centrum och istället gräva fram gamla kanaler kommer då definitivt  få alla andra att ge upp.

Bitterheten i texten ovanför har naturligtvis ingen som helst koppling till det faktum att GAIS förlorade matchen med 1-0 på grund av en feldömd straff.

Tack Bertil – om jag någon gång tänker att jag borde stannat kvar i Göteborg ska jag bara läsa ovanstående text igen. 🙂

Posted in Uncategorized | Leave a Comment »

Enums and Me, part zero

Posted by Dan Byström on April 17, 2007

enum Why
{
  Does,
  It,
  Not,
  Work,
  The,
  Way,
  I,
  Want
}

I have tried to make friendship with .NET Enums for years now, with varying result. My first mishap with them was that I desperately wanted to treat all enum values in the same manner by passing them “by ref” to a function (or I would have been happy with treating them just as integers, as could be done in VB6).

For example, I would have liked to be able to write this:

public void sampleFunction( ref Enum x )
{
}

Why why = Why.Not;
sampleFunction( ref why );  // illegal -- won't compile

If you wonder, my sampleFunction is part of a serialization scheme and when the enum is stored in XML I just want to treat it as an integer.

What I currently must do is:

public int sampleFunction( int x )
{
}

Why why = Why.Not;
why = (Why)sampleFunction( (int)why );

This is so ugly that it makes me wanna puke. If you can find a better way – please let me know! (Maybe I could use pointers, but that would require me to compile with /unsafe – and that is a road I don’t wanna travel again.)

There is another case when it would have been preferable to have an “enum base class” and that’s when you declare generic classes:

class myGenericClass<T> where T : enum  // no can do

This won’t work either and after googling around a little I know for a fact that I’m not the only one who misses this. The closest we can get seems to be:

class myGenericClass<T> where T : struct, ICompareable

Another thing that has also troubled me is how to map enums to the UI (most notably ComboBoxes). But lately I have arrived at a solution that’s really promising. Not perfect yet but promising. That will be my next post. Stay tuned.

Posted in Programming | Leave a Comment »

Zip tip

Posted by Dan Byström on March 3, 2007

Have you ever thought “it would be a good thing if my application could store this data a ZIP file”? Either in order to save space or to bundle several files into one (or both). But then you have hesitated because you realized you’d have to go out and buy an expensive ZIP compression/uncompression library and then learn how to use it (and maybe encounter some bugs or discover some unwanted side effects or…) and so you’ve dropped the whole thing.

If so, this must mean that you haven’t found SharpZipLib yet! It really is great! And OpenSource on top of that!

Moving data in and out of a ZIP file is a breeze, and it works completely with streams so you can, for example, work with MemoryStreams if you don’t want to work with disk based files. Highly recommended!

Some sample code that scans a ZIP file for two particular files and processes some data:

using ( FileStream fs =new FileStream( strZipFile,FileMode.Open,FileAccess.Read ) )
using ( ZipInputStream zis = new ZipInputStream( fs ) )
   
while ( (theEntry = zis.GetNextEntry()) != null )
       
switch ( theEntry.Name.ToLower() )
        {

            case
"upgrade.bin":
                abyteUpgrader =
new byte[zis.Length];
                zis.Read( abyteUpgrader, 0, (
int)zis.Length );
                break;
            case "upgrade.txt":
                byte[] ab = new byte[zis.Length];
                zis.Read( ab, 0, (
int)zis.Length );
                string s = Encoding.Default.GetString( ab );
                if ( Regex.IsMatch( s, @"\d{4}-\d{2}-\d{2}" ) )
                    fFoundNewVersion = s.CompareTo( strMinimumDate ) > 0;
                break;
        }

Posted in Programming | Leave a Comment »

Nerds in Snow

Posted by Dan Byström on January 26, 2007

Episode IV: "The nerds discover Rubber Duck Typing"

Last week I teamed up with forty computer nerds from all over the world at Arosa in Switzerland. This was the fourth time Jimmy Nilsson‘s Software Architecture Workshop was arranged, this time organized by Beat Schwegler from Microsoft. This is an invite only event, and the people who turn up are not any stereotype introvert single minded nerds. On the contrary, this was a bunch of highly social alpha geeks with sky high IQ who also managed to drink the hotel dry of beer. And then there was me.

Some things I learnt in Arosa:

  • Virtually everything (at least as long as it can be seen on a computer screen) is in some way a DSL (Domain Specific Language).
  • If you do something without putting that much effort in it – and it still works – then you’re being agile.
  • You can do pair programming on your own. You just need a rubber duck to discuss your programming with. If the duck talks back you’re in trouble I guess, but when the duck takes over the keyboard, it will effectively be performing Rubber Duck Typing.
  • Most people would just shake their heads to the things that makes a nerd laugh.

Well, that’s not exactly what I learnt… but I like to take arguments to their extreme for a quick sanity check. An argument that still holds true at the extreme points may be worth checking up further. And it’s more fun this way – see last point. 😉 DSLs were one of the most discussed topics and while undeniably powerful, I’d very much like to see a somewhat more narrow definition of what they are. And no, I didn’t imply that agile is about laziness. Really. Honestly.

Some links I promised to provide:

Posted in Uncategorized | Leave a Comment »

Jukebox

Posted by Dan Byström on December 19, 2006

I finally managed to get my jukebox page off the ground!

Posted in Uncategorized | Leave a Comment »

Blahonga!

Posted by Dan Byström on October 26, 2006

Today I’d like to celebrate a ten year anniversary.

Today it was exactly TEN years since my old friend Magnus Timmerby (MTI) entered the Hall of Fame of my vdQix game as number one. Since then he has dropped a few places (well, 71 places to be exact), but anyway… it can’t believe it was TEN YEARS since I wrote that applet!

Come to think of it… don’t you think that remarkably little has happened with the web since then? Better tools and more innovative ways to spread viruses… but apart from DHTML finally taking off thanks to Ajax/Atlas one would have believed that more would have happened during such a (in computer terms) vast period. Of course, if you’re a M$ junkie like me, you may be very exited by XBAP, which sounds incredibly cool.

Posted in Uncategorized | Leave a Comment »