SyntaxHighlighter

Tuesday, April 14, 2009

Brilliant!!!!

(Udi Dahan) Make Roles Explicit!!!
I happen to catch this talk on my lunch break today. And it's simply brilliant. For some it may seem obvious, but for me... the light bulb definitely went off. Lately, I've been going through the design pattern books again... even took out Refactoring by Martin Fowler for review. Even though they make sense I've always had trouble implementing it in a brown field project. I'm currently faced with a few projects at work right now. One is a major project that I'm maintaining, and the other is actually a green field project that I'm also working on. It's exciting because it's a WPF application that hosts a 3D Model viewer made by the folks over at Autodesk.
It's COM but it's still cool. My job is to parse the 3D model for data and surface it in WPF.
Their are a lot of moving parts... such as... XLinq,Xceed Datagrid, LINQ2SQL, SQL, custom DWF parser (to parse DWF files), 3rd party COM API (Autodesk), Log4net, IOC, MVP, etc.
So it certainly can get quite confusing quite quickly. Having an over arching strategy to help manage complexity is key. After watching the video, it became clear and now I'm continuing the green field project in this specific manner. Make Roles Explicit!!!!

Thanks Udi,
-Develop with passion

Monday, March 16, 2009

Functional Programming Is In Me!

The next book I'm going to buy will be Don Syme's Expert F#.
This guy is like the Anders Hejlsberg of C#. He even brought generics to C#, and since he created F# in MSR (Microsoft Research in Cambridge) I figured he's the best person to learn from.

This past weekend was supposed to be the weekend to brush up on the latest version of the Micro Framework (3.0) so that I can finally start building the medical device/application for monitoring my heart levels, and Download the latest CTP of F# and start writing some basic applications with it. Unfortunately, the wife wanted to go to IKEA and buy some hard wood flooring for her office/ballet studio. Since we consider ourselves to be fairly savy IKEA DIY people... we decided to give it a try. Man did I under estimate that project... not only did it take all weekend, but I had to buy new power tools at the local Home Depot. It took all day and night on Saturday plus Sunday morning to complete the room. I'm never doing that again. However, the floor turned out great and the wife is happy to dance on hardwood instead of carpet. :-)

Unfortunately, it wasn't until 2am on Sunday before I was able to get to the Micro Framework updates. Still the same though, some API changes but mostly the same. I just need to find a wearable device that I can port the framework too. At the moment I'm simulating as much as I can through the emulator... so far that's been a good experience and it's very similar to the compact framework stuff. As for F#.... well... after I saw this video I had to immediately download the bits and start playing around. I have to say... that I'm digging F#. It's worth playing with it just for the interactive window in VS2008 alone. To be able to write code, highlight it, and run it with out building or compiling is cool!

I need to run down to B&N after I get off work and pick up the book for more in depth fun. :-)

-Develop with Passion

Wednesday, February 11, 2009

Object Databases in .NET

I'm probably going to get a lot of push back on this... especially from DB guys I know( Douglas, Thom, Glenn, you know who you are). :-)
Anyway, I've recently discovered db4.0... this is a really good object database implementation.
So good... that is supports T-SQL and LINQ. It's file based but the speed is impressive. Now... I'm not saying that this is finally the end of databases, but it's a good start for any small apps like mine that don't need the overhead of a powerful db platform like SQL/Oracle. I think it's wise to use a technology like this for small persistence scenarios... for instance, in my day job I deal with lots of calculations, estimating, etc. Quite a few of the calculations are calculated on the fly which initially takes a while depending on the state that the user left the application. So instead of dismissing persistence in this scenario and paying the cost for calculating rows and rows of data, I can store it all in a light weight, 1 .dll, 1 file, database of calculated values.


Below is an attempt to give you a better idea with out having to download the free stuff. :-)

using System;
using System.IO;

using Db4objects.Db4o.Query;
using Db4objects.Db4o.Tutorial;

namespace Db40Examples
{
public class Example1
{
public static void Main(string[] args)
{
IObjectContainer db = Db4oFactory.OpenFile("Path to filename here");
try
{
StoreFirstPilot(db); //create
StoreSecondPilot(db); //create
RetrieveAllPilots(db); //read
RetrievePilotByName(db); //read
RetrievePilotByExactPoints(db); //read
UpdatePilot(db); //update
DeleteFirstPilotByName(db); //delete
DeleteSecondPilotByName(db); //delete

}
finally
{
db.Close();
}
}

public static void AccessDb4o()
{
IObjectContainer db = Db4oFactory.OpenFile("Path to filename here");
try
{
// do something with db4o
}
finally
{
db.Close();
}
}

public static void StoreFirstPilot(IObjectContainer db)
{
Pilot pilot1 = new Pilot("Michael Schumacher", 100);
db.Store(pilot1);
Console.WriteLine("Stored {0}", pilot1);
}

public static void StoreSecondPilot(IObjectContainer db)
{
Pilot pilot2 = new Pilot("Rubens Barrichello", 99);
db.Store(pilot2);
Console.WriteLine("Stored {0}", pilot2);
}

public static void RetrieveAllPilotQBE(IObjectContainer db)
{
Pilot proto = new Pilot(null, 0);
IObjectSet result = db.QueryByExample(proto);
ListResult(result);
}

public static void RetrieveAllPilots(IObjectContainer db)
{
IObjectSet result = db.QueryByExample(typeof(Pilot));
ListResult(result);
}

public static void RetrievePilotByName(IObjectContainer db)
{
Pilot proto = new Pilot("Michael Schumacher", 0);
IObjectSet result = db.QueryByExample(proto);
ListResult(result);
}

public static void RetrievePilotByExactPoints(IObjectContainer db)
{
Pilot proto = new Pilot(null, 100);
IObjectSet result = db.QueryByExample(proto);
ListResult(result);
}

public static void UpdatePilot(IObjectContainer db)
{
IObjectSet result = db.QueryByExample(new Pilot("Michael Schumacher", 0));
Pilot found = (Pilot)result.Next();
found.AddPoints(11);
db.Store(found);
Console.WriteLine("Added 11 points for {0}", found);
RetrieveAllPilots(db);
}

public static void DeleteFirstPilotByName(IObjectContainer db)
{
IObjectSet result = db.QueryByExample(new Pilot("Michael Schumacher", 0));
Pilot found = (Pilot)result.Next();
db.Delete(found);
Console.WriteLine("Deleted {0}", found);
RetrieveAllPilots(db);
}

public static void DeleteSecondPilotByName(IObjectContainer db)
{
IObjectSet result = db.QueryByExample(new Pilot("Rubens Barrichello", 0));
Pilot found = (Pilot)result.Next();
db.Delete(found);
Console.WriteLine("Deleted {0}", found);
RetrieveAllPilots(db);
}

Of course no example would be complete with out LINQ....


public static void StoreObjects(IObjectContainer db)
{
db.Store(new Car("Ferrari", (new Pilot("Michael Schumacher", 100))));
db.Store(new Car("BMW", (new Pilot("Rubens Barrichello", 99))));
}

public static void RetrievePilot(IObjectContainer db)
{
IEnumerable result = from Pilot p in db
where p.Name.StartsWith("Michael")
select p;
ListResult(result);
}

public static void RetrievePilotByCars(IObjectContainer db)
{
IEnumerable result = from Car c in db
where c.Model.StartsWith("F")
&& (c.Pilot.Points > 99 && c.Pilot.Points <150)
select c.Pilot;
ListResult(result);
}

public static void RetrievePilotUnoptimized(IObjectContainer db)
{
IEnumerable result = from Pilot p in db
where (p.Points - 81) == p.Name.Length
select p;
ListResult(result);
}



So far it's proven to be a quick way to get persistence up and going in my app with out all the worrying about "is my schema right?" kind of questions in my head. It's definitely going to be something I'll try to incorporate in to my unit tests in the future.

-Develop With Passion

Gearing up for Mix09

It's official!!! I'm heading to Mix09 in Las Vegas next month. Luckily, I was invited by a blue badger. Since this is my first Microsoft Conference ever (outside the road shows and free msdn events) I'm definitely going to live it up. Get swag, get some questions answered and come back to Seattle with some new tricks and better approaches. Since I've been heavily involved with Silverlight2 and WPF I've been getting the old designer/animator bug in me again. :-)
It's nice to break out my old 3D stuff and Flash stuff and refresh the skills enough to reuse them in a .net application. I honestly never thought I'd type that, but it's true. The latest application that I'm working on is for a High School in Eastern Washington(as I mentioned in a previous post). The app is entirely silverlight2 and c# and is heavy on the animation side. I wanted to build an IPhone like experience for the application. Since it needs to appeal to teenagers, I figure eye candy like that had to be done. So far it's working out(for the most part). I'm constantly second guessing myself on the transitions from one screen to the next. I want full control over this, so that I can ease in and out anyway I want. Thus far I've been using Nikhil code base as a guide, but I still think there should be a better way. So hopefully I'll learn something about that at mix.
Also... the backend story of the application is not traditional by any means. I'll speak more on this in a later post, but the concept of object databases (at least in my mind)has taken on a whole new meaning.

-Develop With Passion

Monday, January 19, 2009

What's up with this economy?

The economic issues have certainly had an effect on me. I've been dev'n like there's no tomorrow. I've done many projects both small and large lately(Silverlight2 & WPF) that have had a tremendous impact on my career and family. In keeping with the last post I'm still very much in full swing to getting my business off the ground. I've changed the name which reflects more of what services I offer and less on products that I've built (classic rookie mistake), and I've used quite a bit of earnings to put back in to the business ( productivity tools, frameworks, and new hardware).

Currently, I've scaled way back on projects due to a new gig I recently received last year.
It's a great company so far... I've been loaded with a new Dell Precision m6400 quad core/8 gigs of ram notebook. I've been brought on to lead them in to the next generation of end 2 end construction project estimation software. I'll be leading yet another port/re-write of a 2.0 Winform in to a 3.5 WPF application . This one is already turning into a whopper of project. The design is out of wac in a lot places, there's a massive amount of coupling due to the developer building the app as if it's one big API. It sort of resembles the old View/Mediator pattern which is so opposite to the way things are designed now. Sigh...

On the flip side of that I'm building a online training module for a friend of the family.
She's on a board of directors for a high school in eastern Washington, so the module needs to appeal to teens. Of course it's going to be in Silverlight2. :-)

Hopefully that will lead to funding which will allow me to market it to other schools (hopefully).
First things first though... I gotta get a killer UI for it. That will come from a kick ass design studio I found(and worked a silverlight gig for) in Seattle. They will build the UI and I will make it come to life. :-)

Until next time (not two months from now)
-Develop with passion