Tuesday, April 29

Hallelujah - Resharper 4.0 has Inline Method

FINALLY.

After long anticipation and many many rants about its absence, it appears that Resharper 4.0 has the INLINE METHOD refactoring. (At least the nightly build i have installed (ReSharperSetup.4.0.775.22) seems to have it)
NOTE: I was able to find a small mention of it in the EAP Notes

I've been happily refactoring the crap out of some code using it. What would have taken me a good morning to do without it, was accomplished in seconds. IMHO, attempting to refactor code without this refactoring is "PANTS" (to steal a phrase from my British collegues).

The other plus is that i can throw away the attempt at creating this refactoring as a resharper plugin. Since i have not seemed to be able to put any time together to work on it, its extra nice to see it made it into 4.0

Happy Day.

Wednesday, February 20

BDD follow up

With the recent alt.net uk conference having some good conversations on BDD, thought i'd share this post from Elizabeth Koegh for those that haven't seen it.

very good resource

Technorati tags: ,

Wednesday, February 13

Behavior Driven Development

At the recent Alt.NET UK conference, one of the topics that received a fair bit of conversation and debate was Behavior Driven Development and Test Driven Development. Specifically whats the difference? And is the difference just semantics?

To me, the differences are just semantics but its those semantics that make it such a valuable approach.

A recent post from Dan North sums it up pretty good:

My goal as a developer is to deliver a system that behaves in a particular way. Whether or not it has tests is an interesting metric, but not the core purpose. “Test-driven” development will cause me to have lots of tests, but it won’t necessarily get me nearer the goal of delivering business value through software. So you can use goal-oriented vocabulary in your development process as well as your code to help maintain perspective on what you are trying to achieve.

The true benefit comes from finding an alternate way of thinking/approaching/communicating the problem.

This is an area I'd like to see the .NET community improve in.
There tends to be too much focus on a new tool or new framework being the solution to a given problem, which ultimately leads to misuse or use without understanding.

It's important to remember that the tool should not be the solution to the problem, it should support solving the problem.

Technorati Tags: ,,

Monday, February 11

Alt.Net UK

I had the opportunity to attend the Alt.Net UK conference the other weekend. All in all, I am definitely glad i took the time.

Ian Cooper, Alan Dean and Ben Hall deserve a lot of credit for putting in the effort of organizing and for both RedGate and Conchango for backing the event. They did an outstanding job providing a hassle free environment for those participating.

The best thing about this conference was its focus on discussing better ways to do things, sharing experiences and NOT a lot on Microsoft bashing.

Sessions ranged from conversations on REST architectures to BDD to how to unit test a database. I could attempt to give summaries of each i attending but rather than do that i will just point you to here. This was another great initiative of this conference. Using a wiki and asking participants to help populate information in one place so a more broad audience can benefit and reference is a great idea.

While I am in no way an expert on the subject, I attempted to lead a session on Evolutionary Database Design and how to use tools such as dbdeploy.net to simplify following that style. But I was happy to see the session follow the open spaces concept, and shift to what those attending wanted to discuss more specifically. Some very interesting conversations around how a one click deployment type upgrading of a database could work in a non networked/very locked down environment. It resulted in a "not so sure how that'll work" answer but definitely presented a good challenge to debate. The other nugget i took away was the interesting idea of treating a stored procedures as an immutable object.

While the open spaces concept struggled a little bit, I still think it is the right way to host this type of conference. It was clear that it was a new concept to many and that led to a somewhat passive participation with a few strong personalities dominating the conversations. I expect the next one will benefit a lot from the learnings of the first.

If i happen to be lucky enough to attend the next one, i plan to.
And if you have the opportunity to attend a similar event, I highly recommend it.

Technorati Tags: ,,

Tuesday, January 22

Resharper - Inline Method

While most of the time my experience as a developer has been in the .NET stack, I've had the opportunity on a previous project to step into Java for 7 months. This gave me the opportunity of working with IDE's such as Eclipse and IntelliJ that have strong support for refactoring.

I've since returned back to the .NET side and have been found wanting.

Resharper is a crucial piece to the productivity of any .NET developer working in Visual Studio, but there's just some things missing. I won't even go into the really big ones.

One simple, small one in particular has been driving me absolutely bonkers lately:
No support for Inline Method

What makes me truly sad is that i see no indication that the next version (Resharper 4.0) looks to include this.

Can anyone answer why?
Is it significantly harder to implement in Resharper than in IntelliJ?

But I can't really blame JetBrains. That'd be likely biting the hand that feeds me. Deep down I actually blame a colleague of mine for being too good at what he does. He never should have shown so many different ways of safely refactoring code using that refactoring knowing that I'd miss it so. He knows who he is. No scotch for you.*

*note the sarcasm before the flame storm.

Tuesday, January 15

Using DBDeploy.NET

To get dbdeploy.net up and running on a project is relatively straightforward.

First thing, if you haven't already downloaded dbdeploy.net, get it from here
I try to keep unnecessary files from being committed to the source control repository, so extract the downloaded zip somewhere (like your desktop) and we'll pick and choose what is needed from there to add to our project.

I tend to follow a project structure similiar to this:


So the first step is to copy the dbdeploy.net\bin folder from the desktop into a tools\dbdeploy folder:

Next we'll want to setup the location we keep all our db related scripts.
In the working directory, add a db folder and below that also add a deltas folder. For dbdeploy.net to work, your database requires a schema version table, so from the dbdeploy.net\scripts folder from the desktop, select the appropriate sql based on the database being used and copy it to your db folder: I also usually keep the database creation script at this location:

Finally, its time to modify our nant build file to include tasks for the db related work.
(Note that i'm omitting some things to reduce the noise, so if something is unfamiliar let me know)

Use of the sql task from nantcontrib is required so ensure you have that available in your tools and import it at a global level in your build file as so:

<loadtasks assembly=""tools\nant\contrib\NAnt.Contrib.Tasks.dll"/>

Add a folder to hold the automated builds
upgraded script.

<target name="init" description="initial compilation setup">
<mkdir dir="${build.dir}"/>
<mkdir dir="${build.dir}\db"/>
</target>


Then a task for creating the database:

<target name="db.create" depends="init">
<echo message="create database" />
<sql connstring="${connection.string}"
source="db\createDatabase.sql"
output="${build.dir}\db\createDatabase.out.txt"
delimiter="GO" delimstyle="Line" print="true" batch="false" />

<echo message="create db deploy change log table" />
<sql connstring="${connection.string}"
source="db\createSchemaVersionTable.mssql.sql"
output="${build.dir}\db\createSchemaVersionTable.out.txt"
delimiter="GO" delimstyle="Line" print="true" batch="false" />

<call target="db.upgrade" />
</target>

And finally, the task for upgrading the database:

<target name="db.upgrade" depends="init">
<loadtasks assembly="tools\dbdeploy\Net.Sf.Dbdeploy.dll" />
<echo message="upgrading database to latest version" />

<!-- creates the script -->
<dbdeploy dbType="mssql"
dir="db\deltas"
dbConnection="${connection.string}"
outputFile="${build.dir}\db\db-upgrade.sql"
undoOutputFile="${build.dir}\db\db-upgrade-undo.sql" />

<!-- applies the script -->
<sql connstring="${connection.string}"
source="${build.dir}\db\db-upgrade.sql"
output="${build.dir}\db\db-upgrade.out.txt"
delimiter="GO" delimstyle="Line" print="true" batch="false" />
</target>


I also usually add a task to handle undoing the changes.

<target name="db.upgrade.undo">
<sql connstring="${connection.string}"
source="${build.dir}\db\db-upgrade-undo.sql"
output="${build.dir}\db\db-upgrade-undo.out.txt"
delimiter="GO" delimstyle="Line" print="true" batch="false" />
</target>


Thats it. Infrastructure done.

Assuming your existing build all target is something like this:
<target name="all" depends="clean, init, compile, test, dist" >

To make that recreate the database on each build:
<target name="all" depends="clean, init, compile, db.create, test, dist" >

Or if you only want to upgrade on each build:
<target name="all" depends="clean, init, compile, db.upgrade, test, dist" >

We're now set up to follow a more evolutionary database design, with each additional database change needed being added as a file in the db\delta folder. Remember, the only rule is to follow a naming convention around these scripts. Each file needs to begin with a number, one higher than the previous one.



NOTE: for a good post on using the java version of dbdeploy see Pramod Sadalage blog here

Monday, January 14

DBDeploy.NET

Taken from www.dbdeploy.com:

dbdeploy is a Database Change Management tool. It’s for developers or
DBAs who want to evolve their database design - or refactor their
database - in a simple, controlled, flexible and frequent manner.

While the java version of dbdeploy has received accolades over the past year, I'm curious how many people are aware that there is a .NET port (available here).

How many people are currently using it? How many would like to be?

I know there is limited documentation or examples of using the .NET version available and have been toying with the idea of doing some posts on how to use dbdeploy.net on a project.

Anyone interested?

(note: expressing interests strongly increases the likelihood it will happen)