Installing DBFit for SQL Server

I’ve been using DBFit on several projects recently, and I’m really pleased with the results. If you’re not familiar with DBFit, it’s a set of Fit fixtures that allows Fitnesse tests to execute directly against a database, without you having to build a separate connector. This post shows you how to get started with DbFit with the least amount of pain.

We practice Test Driven Development at ext.IT and while TDD is a pretty mature discipline in most modern programming languages, it’s still not widely practiced in the database world. We’ve had some success in the past using TSQLUnit, but I prefer DbFit because you can use it to write Unit Tests as well as Acceptance Tests. In addition, Fitnesse allows you to add additional colour in the form of documentation to truly turn your acceptance tests into an executable specification.

One thing that doesn’t (at least to me) appear to be clear from the documentation is that to install DbFit to test a Microsoft SQL Server database, you can simply install Fitnesse, and then install FitSharp. The advantage of doing this, compared to installing DbFit from sourceforge is that you will be working with the latest and greatest versions of Fitnesse and FitSharp. The current instance of DbFit on sourceforge uses a Fitnesse build from 2008.

Here is a high level overview of the installation steps (more detailed information including troubleshooting steps is available at each of the links below):

  1. If necessary, install Java 6 from here: http://www.java.com/en/download/index.jsp
  2. Install Fitnesse from here: http://fitnesse.org/FrontPage.FitNesseDevelopment.DownLoad. As it mentions on the downloads page, just download fitnesse.jar, into the folder in which you’d like to install it  and type java -jar fitnesse.jar -p 8080 (where 8080 is the port number you’d like to use to run fitnesse from – usually port 80 is taken by other stuff on your machine) at the command line. Fitnesse will unpack and install itself.
  3. If necessary, install .NET framework 3.5 or 4.0 from here: http://msdn.microsoft.com/en-us/netframework/aa569263
  4. Install FitSharp from here (choose the correct version for your version of the .NET framework): https://github.com/jediwhale/fitsharp/downloads. To install FitSharp, create a folder under the folder into which you installed Fitnesse (I name mine FitSharp) and unpack the installation files into this folder.
  5. Once you’re installed and up and running, follow the examples in the DbFit Reference to see how the whole thing works.
  6. One additional tip is that if you’re following the Hello World example in the DbFit reference, use the following text instead of the one they document in Step 2: Setting Up the Environment. This will correctly point you to the location of your FitSharp installation files and use the Microsoft SQL Server flavour of DbFit:
!define COMMAND_PATTERN {%m -r fitnesse.fitserver.FitServer,"FitSharp\fit.dll" %p}
!define TEST_RUNNER {FitSharp\Runner.exe}
!define PATH_SEPARATOR {;}
!path FitSharp\dbfit.sqlserver.dll

I’ll be posting some further information on using DbFit as an executable specification that includes acceptance tests, for Unit Testing and performance testing, as well as showing you some of the ways we’ve organized our test suites to make them more maintainable and easier to understand. Happy Database Testing!


Bob’s Report – The cost of redundant processes

Have you ever been in a situation where you wondered where the original business requirement came from?

“Bob’s report must be produced every Monday morning by 10am!”

  1. Mary extracts the data from the database
  2. Bill adds the data to a spreadsheet and applies some pivots to massage the data
  3. Sue looks at the report and makes sure there are no errors
  4. Harry applies some text to the report and finishes off the formatting, then emails the report to Bob
  5. Bob looks through the 200 unread emails in his inbox and tries to prioritize them. In the end he glances at “his” report for 30 seconds and thinks nothing more of it.

Where did the requirement for Bob’s report come from? Lets look at the history behind this requirement.

1996 – A new application is implemented for tracking the sale of widgets

1997 – Jean the head of sales has the requirement for a sales report for her weekly meeting with the CEO at midday on a Monday. She describes her requirements to the business analyst implementing the application. The format is decided and the process to produce the report is documented and discussed with the parties involved

2005 – Jean leaves Widgets inc. for a new position at another company. Bob is employed as head of sales. The CEO and Bob decide that they are going to meet on a Wednesday every other week to discuss the sale of widgets.

“Bob’s report” (originally Jean’s report) hasn’t been reassessed since 1997. Since 1997 Widgets inc have changed personnel and business processes have been updated. Technology has changed since 1997 and the process of producing Bob’s report should be much easier with a more modern approach (automated processing with Microsoft SQL Server Reporting Services, Business Objects, Cognos and many more). What’s more, four people have spent hours of time on a Monday morning producing a report for the past 6 years and it is not even read!

Solving the problem

This may be an extreme example, but I can guarantee you will have come across a similar scenario either in the organization you work in or in other organizations if you are a consultant like me. In so many cases we hit a wall when we ask the question, “Why do we need X?” Many times the reason is political, but in some cases it is purely because of a historical requirement and no one is prepared to ask the question. As it turns out, Bob is unaware of the effort that goes into producing his report; if he knew he would stop this process or refine the contents of the report so that it is more useful.

As consultants or business analysts we are always likely to have to dig deeper until we can find the truth. One method that can be useful is to follow the “5 Whys“:

The 5 Whys is a questions-asking method used to explore the cause/effect relationships underlying a particular problem. Ultimately, the goal of applying the 5 Whys method is to determine a root cause of a defect or problem.

Quite often we find that the problem is several levels deep. Using the 5 Whys technique can help to get to the root cause of a business problem rather than the apparent problem on the surface, or even worse a problem that has not been identified.

As consultants our hardest task can be getting to talk to the right people. How can we reach our goal in a reasonable time without upsetting too many people? Here are some rules we can follow:

  • Set expectations up front. You want X number of hours time from people in the relevant areas of the business. You want to be able to speak to them in a reasonable period of time.
  • Speak to the right people. You are not likely to get a lot of the CEO’s time, but if his or her input is likely to help ask for their time. Be prepared with targeted questions where possible:
    • What reports do you currently receive? Do you use the data in these reports?
    • What do you use this data for?
    • What information is not made available to you that you would like to see?
  • Don’t accept the answer “that’s just the way it’s done”. Use the 5 Whys to dig deeper until you find the real reason for a requirement.
  • Stick to your guns!

Remember, getting down to the root cause will benefit the organization you are working for. They may be throwing thousands of dollars per year away on Bob’s reports.

Show them the numbers – it’s results that matter

On a recent project one of our customers had some questions about the project’s progress. The project was a mid-size systems integration between Oracle Financials and Onyx CRM for a Fortune 500 company.

As with many large companies, there were several business units and people with interest in the project, and also as with many large companies, people had several other projects to deal with and were not attending the daily standups or weekly progress meetings.

I began to hear that there were some concerns about the project progress from some of the management team and a concern that we were spending too much time writing tests instead of code.

This came as a big surprise to me: from the perspective of the team working on the project on a daily basis (both customer and ext.IT), we were sailing along with no problems. We were providing the usual artifacts such as status reports which showed how we were tracking against estimated hours and when our code complete date would be, and all of this was tracking well against our original estimates, so to hear that people were unhappy was a big shock.

I called a meeting with all of the stakeholders and as soon as I invited all of the stakeholders I realized two things:

  1. This meeting would be the first time in the whole project that all of the stakeholders had been in a room together.
  2. While we had discussed our approach during the initial engagement, we hadn’t held a project kickoff with all of the stakeholders to discuss our approach to building software.

Both of these items were my fault, but here I was, several months into the project with an unhappy customer, so I thought I would address it in this meeting.

I put together a short presentation which discussed our approach to building software, including brief descriptions of how we perform iterations, test driven development, automated acceptance testing, retrospectives and other benefits to the way we build software, and why we considered our approach to be best practice.

Almost as an afterthought, I ended the presentation with a couple of slides showing our project status. This was an afterthought because everyone at the meeting was a recipient of the weekly status report containing the same information. I created one slide comparing our original project estimates (before we had detailed requirements) to our detailed estimates (once requirements were fleshed out) and to our actual hours so far on the completed features, and another slide showing our defect count and comparing it to another of the customer’s internal projects that they had build without the benefit of automated tests.

Once the meeting started, it was clear that I didn’t need any of the slides about our approach. We spent a few minutes discussing the original estimates against the actual time taken for completed features: everyone was happy with the job we had done in estimating against the original high-level requirements. We also discussed how we were tracking on the hours left: again, everyone was satisfied with the results. Finally, we spent five minutes comparing the low defect count on our project (with a high level of test automation), compared to some of the customer’s other projects (without unit tests), and everyone was satisfied with this too.

There wasn’t a single question about our approach, and ultimately no-one in the higher echelons of the customer’s business cared about the minutiae of our approach, nor were they interested in why we thought our approach was best practice.

They simply wanted to see the results of our approach.

In retrospect, this might seem obvious, but the best way to convince anyone that your approach to doing something is practical and pragmatic, is to do it and measure it against other approaches. People don’t care about dogma, or why you think something should be the best way. Only by showing people the numbers and measuring the effectiveness of your approach can you truly show that your practices are effective.

To conclude: After this meeting, the project was delivered successfully without any more concerns from the customer. We were one of several projects integrating with Oracle and we were the only project to deliver on time and under budget, with a very happy customer!

How do I manage changes to the Onyx Employee Portal UCW?

With Onyx CRM version 6.0 and Consona CCM 7.0, you have a great feature called UCW (UI Configuration Workbench). There are several benefits to using the UCW. The Onyx Employee Portal 6.0 Technical Guide lists the main ones as:

Ease of configuration: UCW provides WYSIWYG configuration of many areas in OEP, enabling you to configure, compile, and test your configurations, including changes to user navigation and form presentation and behavior.

Custom OEP pages for different teams: Using UCW and OEP Profiles, you can configure the same OEP page differently for different teams in your organization, enabling profile-based user navigation and page presentation and behavior. You can apply your UCW configurations to one or more custom UIs (accessed via the related OEP profiles) or to all custom UIs at once (using the baseline UI accessed with the Global profile).

Upgradeability: When you configure OEP using UCW, you ensure that your UI configurations will be upgraded to the next version of OEP without requiring you to rewrite or re-implement your modifications. Customizations that are implemented outside of UCW, however, are not automatically applied when OEP is upgraded.

However, while the technical documentation has some best practices and tips and tricks, what isn’t well-documented is how to work with the UCW so that you can more effectively manage your UI changes. This post will show you how to split your UI changes into layers.

Following the approach I am about to describe has the following benefits:

  • Several developers can simultaneously work on different UI features at the same time (in different developer environments) without causing any dependency issues or needing to “check out” or lock files.
  • Changes to one area of the UI can be deployed without worrying about changes in other areas.
  • Splitting the changes into layers means that you can “throw away” or remove whole areas of customizations without needing to manually edit the global delta xml files or delete your changes through the UI.

How does this work?

It’s very simple. When you make changes in the Onyx / Consona UI, the UCW framework is tracking those changes and adding all of your actions to one file called global_delta.xml. This file is found here:

EmployeePortal\ucf\data\layers\active

By default, all of your changes live in this file, whether they are changes to the company edit screen, the incident edit page, or the powerpage. This is undesirable and means that all of your customizations have dependencies and only one person can work on UCW at a time, even if you have several development environments, so it’s best to break up the work into custom layers.

Before your start, please add your Onyx UI files to source control! There are many choices and a lot of them are free. We use Assembla’s hosted Subversion repositories.

To add a custom layer, follow these steps:

  1. Navigate to EmployeePortal\custom\ucf\data\layers.
  2. Create an empty folder with your layer name. For example, if you want to add a layer for the company powerpage, name this folder companypowerpage.
  3. Navigate to EmployeePortal\ucf\data\configuration.
  4. Add the path to your layer to the layers.xml file. Set the sequence number so that this comes before the active layer and after the onyxvalidation layer. Adjust the sequence number of the following layers. In the screenshot below, we have added two custom layers: one for the company powerpage and one for the company edit screen.

Layers

The first time you edit your new layer:

  1. Navigate to EmployeePortal\ucf\data\layers\activeensure that this is empty!
  2. Make your changes to the layer you are configuring.
  3. Move (not copy) the global_delta.xml file that has been generated in the ucf\data\layers\active folder back to the folder you created within custom\ucf\data\layers

Each subsequent time you edit your new layer:

  1. Navigate to EmployeePortal\ucf\data\layers\activeensure that this is empty!
  2. Move (not copy) the global_delta.xml file within custom\ucf\data\layers over to the ucf\data\layers\active folder
  3. Make your changes to the layer you are configuring.
  4. Move (not copy) the global_delta.xml file that has been modified in the ucf\data\layers\active folder back to the folder you created within custom\ucf\data\layers

That’s it! Now you can effectively separate all of your Onyx UI changes into a more manageable structure.

The Fuss about Test Driven Development

There has been a lot of debate about the benefits, or otherwise, of Test-Driven Development (TDD). In this short post, I will attempt to enumerate some of the benefits, and show that practicing TDD means that your code becomes an asset to the business, instead of a liability. I will also point you to a few resources that will help you get started with TDD.

What is Test Driven Development?

Most people have heard the term Test-Driven Development (or TDD), but not everyone seems to understand what it means, so we’ll start with a brief definition:

Test-driven development (TDD) is a software development technique that relies on the repetition of a very short development cycle: First the developer writes a failing automated test case that defines a desired improvement or new function, then produces code to pass that test and finally refactors the new code to acceptable standards.

The Four Rules of TDD

Robert C. Martin, wrote a famous blog post that defined the three rules of test driven development.

  1. You are not allowed to write any production code unless it is to make a failing unit test pass.
  2. You are not allowed to write any more of a unit test than is sufficient to fail.
  3. You are not allowed to write any more production code than is sufficient to pass the one failing unit test.

While Bob mentions refactoring as part of the TDD cycle in his post, I think it’s important enough to be its own rule. So rule 4 reads:

4.  You should refactor your code once the tests pass.

It’s a technique that needs to be witnessed and practiced to really be used effectively. The steps are very small, with each cycle lasting perhaps five minutes at most. This means that you make lots of tiny steps towards your goal throughout your day, but each step is a “mini-milestone”, because once you get to the Green bar (or to the step where all of your test are passing), your code is in a known good state. This makes it simpler to return to that good known state via the undo button if you take a wrong turn and can’t get the next test to pass. This is a really refreshing change from spending hours in the debugger trying to figure out where you went wrong!

There are many productivity benefits to TDD that outweigh the additional time taken to create the tests. These include working code, less time debugging and a suite of automated regression tests that can be ran at any time. In addition, the tests allow us to change, or refactor the code without fear of breaking it.

One final point before I move on to discuss how to get started: TDD generates unit tests, but unit testing is not the same as TDD! In TDD, the tests come first, before the code they are testing and are automated. In unit testing, the tests typically come after the code, and are not always automated.

Code Katas

Given all of these benefits, it should be a no-brainer to decide whether or not to adopt this practice. And yet, there have recently been some debates about its effectiveness. I’m not going to recount these debates here, as my philosophy is “just do it”. If you want to know if TDD works, but you are worried about the amount of time it would take to investigate, then follow the kata approach. Wikipedia defines a kata as:

Kata (型 or 形, literally: “form”) is a Japanese word describing detailed choreographed patterns of movements practised either solo or in pairs.

While katas are most often associated with martial arts, it has also become a popular phrase for working with code. Again, from Wikipedia:

Code Kata is a term coined by Dave Thomas… A code kata is an exercise in programming which helps hone your skills through practice and repetition.

If you are interested in learning about TDD and code katas, simply set aside a short amount of time each day and start to experiment. To get you started, here are a few resources:

In addition, you should really beg, steal or borrow (or alternatively, just buy) these books:

In the future, we’ll be posting articles about different unit testing frameworks and techniques; until then, good luck getting started with TDD!

Is your consulting code an asset or a liability?

Overview

When you hire consultants to build software for you, how do you know if the code is worth the money you pay them?

Consulting code (indeed, any custom code) should be an asset to your business, but unfortunately, many times it’s quite the opposite.

Consulting code can become a liability. Lack of tests and poor quality, buggy code can leave you, your code and your pocket book in worse shape than before the consultants arrived (and usually with little to no recourse).

Untested code has no business value

Years ago at the Agile 2006 conference, one of the sessions was “Delivering flawless tested software every iteration”, delivered by Alex Pukinskis. The catchy name attracted a big audience and it was standing room only.

During this presentation, Alex made the following statement:[1]

Untested code has no business value

This struck a chord with me, because at the time I was working for a company that was trying to transition to agile, but many of our practices still hadn’t changed. We were (okay I was) still breaking the build and still expecting the QA team to find our bugs for us. We weren’t consistently doing TDD, we had no automation of the build acceptance and we were not practicing continuous integration. I could go on, but I’m sure you get the idea.

The “aha” moment for me was the concept that the quality of the code, and a lack of defects was my responsibility as a professional developer. It was my responsibility to ensure that no defects were passed to QA. Of course, I know that software cannot be perfect, and there will be defects, but my attitude towards defects changed after that talk. Defects should be unexpected. Defects should be unusual. Defects should be prevented, not found.

No Bugs

The attitude that defects should be prevented, not found, can be summarized in the “No Bugs” philosophy.

James Shore recently published the full text of the No Bugs section from his excellent Art of Agile book. He summarizes the text in 99 words:

Rather than fixing bugs, agile methods strive to prevent them.

Test-driven development structures work into easily-verifiable steps. Pair programming provides instant peer review, enhances brainpower, and maintains self-discipline. Energized work reduces silly mistakes. Coding standards and a “done done” checklist catch common errors.

On-site customers clarify requirements and discover misunderstandings. Customer tests communicate complicated domain rules. Iteration demos allow stakeholders to correct the team’s course.

Simple design, refactoring, slack, collective code ownership, and fixing bugs early eliminates bug breeding grounds. Exploratory testing discovers teams’ blind spots, and root-cause analysis allows teams to eliminate them.

Asking the right questions

Now you are probably expecting some sales pitch from me at this point to say that you should hire us because we’re great. Well that’s not the point of this post (although you should, and we are). The point of this post is that the next time you are talking to a consulting firm or hiring a developer[2], ask them about their definition of code quality and how they ensure it. By simply asking a couple of questions you should be able to determine whether they are all “smoke and mirrors” or if they will add value to your business. For example, you might ask:

  1. What is your definition of quality code?
  2. How do you ensure your code is bug free?

The answer to the first question should mention practices like the Law of Demeter, coding standards, refactoring and adherence to the SOLID principles.

Although unsettling, it is okay if the answer to the second question is “I‘m never 100% sure my code is bug free” (particularly if they mention Gödel’s proofs). However, they should quickly follow up with, “I make bugs less likely by practicing test driven development, peer reviews (or pair programming), automated acceptance tests and adherence to coding standards and good design principles.”

If they can answer those two questions to your satisfaction (and follow through by demonstrating these practices when building the code) then they might know what they are talking about, and actually give you value for your money.

  1. I’m not sure whether Alex was quoting someone, but googling that precise phrase returned zero results, so I’m attributing it to him []
  2. For more information on hiring developer team members, read http://jamesshore.com/Blog/Alternatives-to-Certifications.html []

Heilmeier’s Catechism – a checklist for software projects

Speak & SpellUntil recently, I am ashamed to say that I had never heard of George Harry Heilmeier. A recent retweet by Roy Osherove on Twitter soon had me digging for more information.

It turns out that not only was Mr. Heilmeier  a pioneering contributor to liquid crystal displays, he was a Vice President (and later CTO) of Texas Instruments during the time they produced the mighty Speak and Spell.

Mr Heilmeier’s Wikipedia page lists an amazing amount of awards, including the National Medal of Science  and the IEEE Medal of Honor, but that’s not what sparked my curiousity.

What was interesting to me about Mr. Heilmeier was a series of questions anyone should be able to answer when proposing a research project or product development effort. These questions are known as Heilmeier’s Catechism.

Here is Heilmeier’s original list of questions:

Heilmeier’s Catechism

  • What are you trying to do? Articulate your objectives using absolutely no jargon.
  • How is it done today, and what are the limits of current practice?
  • What’s new in your approach and why do you think it will be successful?
  • Who cares?
  • If you’re successful, what difference will it make?
  • What are the risks and the payoffs?
  • How much will it cost?
  • How long will it take?
  • What are the midterm and final “exams” to check for success?

When I read this list, it struck me that these questions could easily be adapted as a software project checklist.

With some small tweaks in language, this list becomes a standard project checklist that any consulting organization should work on with their customers to answer when deciding whether or not to go ahead with a project:

Project Checklist

  • What is the underlying business problem we are trying to solve with this project?
  • What happens today? Is this problem worked around with manual processes?
  • What’s new in this approach and why do we think it will be successful?
  • Who are the project stakeholders?
  • If we’re successful, what difference will it make?
  • What are the risks and the payoffs? How can the risks be mitigated?
  • How much will it cost?
  • How long will it take?
  • How will we measure progress on the project? How do we know we’ve been successful?

What about your organization’s project approval process? Does your company use Heilmeier’s Catechism to decide whether to give a project a green light? What other questions should be asked before starting a project?