Balsamiq Mockups In Action

Balsamiq Mockups In Action

The Mockup

The WPF Version(First Cut)

Http://www.balsamiq.com/products/mockups

Taaz

Via Justine, I tried out Taaz, here are my results(click to enlarge):

Joking aside, try uploading your own photo, there's a slick little process you have to go through to identify the points of your eyes, lips, hair line, etc, it's really pretty cool.

OK...no more wine for me today.

Object.ConvertTo

Is this bad?

public static class ObjectExtensions
{
  public static T ConvertTo(this Object @this)
  {
    return ConvertUtils.ChangeType(@this);
  }
}
1
2
3
4
5
6
7

Testing the usage looks like this:

[Test]
public void ObjectConverter()
{
  Assert.AreEqual(1, "1".ConvertTo());
}
1
2
3
4
5

ChangeType was stolen from http://aspalliance.com/852.  That looks like this:

public static class ConvertUtils
{
  public static object ChangeType(object value, Type conversionType)
  {
    if (conversionType == null)
    {
      throw new ArgumentNullException("conversionType");
    }

    if (conversionType.IsGenericType &&
      conversionType.GetGenericTypeDefinition().Equals(typeof(Nullable)))
    {
      if (value == null)
      {
        return null;
      }

      NullableConverter nullableConverter = new NullableConverter(conversionType);
      conversionType = nullableConverter.UnderlyingType;
    }
    return Convert.ChangeType(value, conversionType);
  }

  public static TResult ChangeType(object value)
  {
    return (TResult)ChangeType(value, typeof(TResult));
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

 

Inside HyperActive

I'm finally getting around to documenting how to use this thing.  HyperActive is a tool I wrote to help generate Castle ActiveRecord classes by inferring details from a database schema. 

Hyperactive uses my SchemaProber to read a database schema, and the Dominator helps with generating the code. 

Step 1: Download the Code

The latest release is 1.3.1.9 and can be downloaded here.

Step 2: Create the HyperActive Config File

Here is a config file for setting up HyperActive to run against the Northwind database running on your local system:


    
        
        
        
        
        	
        	
        		
        	
        	
        		
        	
        	
        
    

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

Things you need to provide.  namespace, all of your generated classes will be contained in this namespace.

outputpath is where the generated files will be saved; it can be relative to your project or absolute, in the config above I've chosen to go with a directory relative to my project's root.  I like putting generated files into their own directory.  Most of the time I generate partial classes and into the Data/Generated directory and then if i choose to extend any partial classes, I'll put those in the Data directory.

Basetypename indicates what generic class the generated classes will subclass.  There are several ways of handling this, most of the time I use ActiveRecordBase or ActiveRecordValidationBase.

Components...

I ended up rolling my DI Framework.  Mostly it was because I needed to minimize dependencies on other frameworks but also because I wanted to see what it takes to make a my own dependency injection tool.  It was fun, brings up a good point though, how do you do dependency injection without having to also include Ninject, Windsor, StructureMap, or whatever the cool framework of the day is.

The different components that can be swapped out, are the NameProvider, SchemaProvider, and the ActiveRecordGenerator implementation.  There are some included in the HyperActive assembly or you can roll your own.

Step 3: Setup Visual Studio External Tools

I have directory located at C:\lib where I put common libraries that I reference alot.  Assuming that the HyperActive and hactive assemblies are located in that directory you can set up an external tool in Visual Studio with the following configuration:

Step 5: Got Database?

I know this works with the Northwind database.  You can download my script from me here or grab the installer from codeplex or use your own database.

Step 6: Set Up Your Solution and Generate!

I'm going with a picture is worth a thousand words. Here's what the solution looks like before code gen:

After code generation, we'll have this:

The generated Products class looks like this:

//------------------------------------------------------------------------------
// 
//   This code was generated by a tool.
//   Runtime Version:2.0.50727.3053
//
//   Changes to this file may cause incorrect behavior and will be lost if
//   the code is regenerated.
// 
//------------------------------------------------------------------------------

namespace HyperActiveNorthwindSample.Data {


  [Castle.ActiveRecord.ActiveRecordAttribute("Products")]
  public partial class Products : Castle.ActiveRecord.ActiveRecordBase {

    private int _productID;

    private string _productName;

    private string _quantityPerUnit;

    private System.Nullable _unitPrice;

    private System.Nullable _unitsInStock;

    private System.Nullable _unitsOnOrder;

    private System.Nullable _reorderLevel;

    private bool _discontinued;

    [Castle.ActiveRecord.PrimaryKeyAttribute(Castle.ActiveRecord.PrimaryKeyType.Identity, "ProductID")]
    public virtual int Id {
      get {
        return _productID;
      }
      set {
        _productID = value;
      }
    }

    [Castle.ActiveRecord.PropertyAttribute("ProductName")]
    public virtual string ProductName {
      get {
        return _productName;
      }
      set {
        _productName = value;
      }
    }

    [Castle.ActiveRecord.PropertyAttribute("QuantityPerUnit")]
    public virtual string QuantityPerUnit {
      get {
        return _quantityPerUnit;
      }
      set {
        _quantityPerUnit = value;
      }
    }

    [Castle.ActiveRecord.PropertyAttribute("UnitPrice")]
    public virtual System.Nullable UnitPrice {
      get {
        return _unitPrice;
      }
      set {
        _unitPrice = value;
      }
    }

    [Castle.ActiveRecord.PropertyAttribute("UnitsInStock")]
    public virtual System.Nullable UnitsInStock {
      get {
        return _unitsInStock;
      }
      set {
        _unitsInStock = value;
      }
    }

    [Castle.ActiveRecord.PropertyAttribute("UnitsOnOrder")]
    public virtual System.Nullable UnitsOnOrder {
      get {
        return _unitsOnOrder;
      }
      set {
        _unitsOnOrder = value;
      }
    }

    [Castle.ActiveRecord.PropertyAttribute("ReorderLevel")]
    public virtual System.Nullable ReorderLevel {
      get {
        return _reorderLevel;
      }
      set {
        _reorderLevel = value;
      }
    }

    [Castle.ActiveRecord.PropertyAttribute("Discontinued")]
    public virtual bool Discontinued {
      get {
        return _discontinued;
      }
      set {
        _discontinued = value;
      }
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113

Step 7: Take It For A Spin

So to test out our generated code, I added a nunit test fixture that just does a simple query for a specific product.  That code looks like this:

using System;
using System.Configuration;
using Castle.ActiveRecord;
using Castle.ActiveRecord.Framework;
using HyperActiveNorthwindSample.Data;
using NHibernate.Criterion;
using NUnit.Framework;

namespace HyperActiveNorthwindSample
{
  [TestFixture]
  public class SmokeTests
  {
    [TestFixtureSetUp]
    public void TextFixtureSetup()
    {
      IConfigurationSource source =
        ConfigurationManager.GetSection("activerecord") as IConfigurationSource;
      ActiveRecordStarter.Initialize(typeof(Products).Assembly, source);
    }
    [Test]
    public void CanGetOneProduct()
    {
      Products product = Products.FindOne(Expression.Eq("ProductName", "Chai"));
      Assert.AreEqual("Chai", product.ProductName);
    }
  }
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28

Thoughts and Caution

OK. So the caution part of this has to do with how I do databases. HyperActive, in it's current form, supports how I and my co-workers slash colleagues currently develop databases.  This may differ drastically from the way you the reader develops against a database.  I almost always use sql server 2005+ and identity columns. HyperActive will most likely puke on schemas that have tables with non-identiy column primary keys.

HyperActive is not as flexible as it needs to be. Frameworks should be easy to extend if you are not the orginal developer.  HyperActive is easy to extend if you are me or really bored and feel like working through the framework's source, so to that end I need to refactor and simplify.

So anyway, there it is, I may have some more posts on this, but I have better ideas on how to improve it, so I might spend more time doing that.

The Code

Get it all right here http://panteravb.com/downloads/HyperActiveNorthwindSample.zip.

Unit Testing NHibernate and Castle ActiveRecord With SQLite

NOTE: This is about a topic that is NOT a new concept, only new to me.

As I'm working through incorporating S#arp Architecture ideas into my own architecture strategery, today(well, starting yesterday) I made the transition to using SQLite for unit tests.

There's not alot to add to the code I scraped from the web.

I started with using straight up ADO.NET and trying to create a table, do an insert, and query it. Then I moved into some code based on Ayende's post here to get NHibernate tests working.  I then moved on to Brian Genisio's ActiveRecord testing sample to get ActiveRecord testing under way.  Way cool. 

Here's my test test project.  It should work straight out of the gate, but lemme know if it doesn't(it's a 2.4 meg download, VS2008 SP1, latest code from Castle trunk).  I've included the SQLite .NET wrapper downloadable from here.

Sock And Awe

This is awesome: http://play.sockandawe.com/

Eva's a Bitch

This is Eva:

5 rounds of the following, 40 minutes max:

750 meter row

30 Kettlebell Swing(wmv)(2 POOD)

30 Pull ups

I only got 3 rounds.

This is my hand after Eva got through with me.  At least I didn't puke after the workout...

There Will Be Porn

I'm a fan of Zed Shaw.  He has nothing to do with .NET or anything I do on a daily basis but reading or listening to him rant about whatever has given me some good ideas for stuff I do or wanna do. 

Anway, he's got this farewell to Ruby and Rails thing.  INFOQ recorded his goodbye presentation at RubyFringe entitle There Will Be Porn.  It's about 49 minutes long.  I made it through the first half before skipping around to the end.  The last 5 minutes or so discussing what he'll be doing next was the most interesting to me. 

S#arp Architecture

S#arp Architecture has been receiving alot of attention recently.  Today, with some colleagues, we went through that architecture, the reference solution and the northwind sample app. 

I've only spent today reviewing the code but already it smells of CSLA.  Anyone who's had had the displeasure of working on a CSLA project will understand why "smelling like CSLA" is not a good thing.

For me, the biggest use of the S#arp Architecture is to give me ideas on how to improve the architectures I create.  I've already started  a new architecture based on some ideas from the S#arp solution.  Even CSLA gave me ideas;however, they are ideas on what NOT to do, like use CSLA(did I mention I don't like CSLA?)

Anywho, expect more on this since we're digging through and refacturing existing code based on these ideas.

-25

The temp right now in Fort Collins is -15, and the windchill makes it feel like -25.  For anybody wondering, -25 degrees is really fucking cold.

John Bonham Tribute

This girl rocks(she's on the drums):

I Love To Jerk And I Cannot Lie....

I ended up with 109kg(240-ish pounds), I was stoked.

70 WPM

Ya, I'm cool.

I Got Schmapped!

How cool is this. This flickr photo of me running the Boulder Boulder 10k in 2006 found it's way into Schmap for Boulder events.

Like My Screen Snaps?

I use WinSnap from NTWind Software to take screen snapshots.  It adds the nice little things like drop shadows.

It sits in your systray waiting for you to hit CTRL + PrtSc, and then gives you options of hitting the entire desktop, only one application, or even a region.  It's worth checking out, they have some other cool tools too worth takin a look at.

What Kind Of A Blog Is This Anyway

According to http://typealyzer.com/ I am this type of blogger(I really wish it was a cooler picture):

58 WPM

I took Pete's typing challenge and decided to practice my webcam in a screencast technique, so here's me typing 58 words per minute, and yes, I will break 60wpm with no errors mby the end of the weekend :)

Whoops, How'd That Get Past QA?

I'm on a project right rewriting an old winform app.  One of the dependencies we're removing is this app server that has to be run prior to starting the winform.  Once it's started, all you need to do is type /exit to stop the app server. 

 
Author: , 0000-00-00