Chapter 2. Let's Build a Simple Application

The title of the chapter says Let's Build a Simple Application, but that is not entirely true. What is true is that we are going to start building an application. This chapter sets the foundation for that. So, in this chapter, I am going to introduce you to the application that we are going to build as we progress through the book.

However, just knowing the application is not enough in my opinion. In order to make sure that you make most out of this book and stay on track while your training shoes are still on, I am going to take you through my development setup and talk about various tools that I will be using. If you try out the sample code from this book and stick to the versions of tools mentioned in this chapter, then you can be assured that things will go smoothly. However, this does not mean that you must use the tools that I am using and the versions that I have installed in my environment. Most tools in the .NET ecosystem these days are backward compatible, so if you happen to have a lower version of some tool, never mind. As long as you know how to use the tool, we are in business.

Besides tools, I will also give you a brief introduction to the methodologies, particularly Test-driven Development (TDD), that we will be using throughout the book. If you are new to TDD, then do not worry because I am not going to use any knowledge beyond what can be called basic.

So, let's get started!

Explaining the approach used in learning NHibernate

Before we actually talk about the application, I thought I will write about the overall approach that I will take to teach you NHibernate.

In this chapter, we will define a simple problem statement. The aim is to implement an efficient data access layer for our problem using NHibernate as we progress through the chapters in this book. In this process, you will learn about important NHibernate features and apply them to an actual software problem at the same time. When we finish the book, we may not have addressed the complete data access requirements of our problem, but we will have implemented the solutions for important aspects of the problem with a certain level of detail. This level of understanding and some experience should set up to build any kind of data access solution using NHibernate.

It may seem disconnected to jump from the problem statement to the data access layer directly, so my first step is to come up with a domain model that captures the core concepts of our problem domain. I will try to follow the guidelines from Object-oriented Analysis and Design (OOAD) and Domain-driven Design (DDD). Both are much specialized areas of software design and explaining them in detail will be another book in itself. So, I will try to keep it to a level sufficient to build a simple domain model for our problem in the right way.

As we go on building our data access layer, we also need a way to validate the correctness of our implementation. Since we are going to build it brick by brick, a lot of times, we will need to go back and change something that was previously implemented as we learn more about NHibernate. While we change things, we need a way to make sure that our changes have not altered the outcomes or have broken a feature that was working previously. We will use TDD to implement our solution. If you have already used TDD, then you will know what I am talking about. If you are new to TDD, then do not worry. TDD is not very difficult to master, and for the kind of work that we are going to do around TDD, you do not need to master the art. We are going to write simple tests that validate the behavior of our data access layer. We will then use NHibernate to build the missing pieces and make our tests pass. I will make sure that I give you enough explanation of the code that I am going to present.

For most part of this book, the solution will be implemented in the form of a class library supported by unit tests to validate the correctness of the code. Towards the end of the book, we should be able to look at the complete solution and understand how NHibernate is used in real-life applications.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.137.7