Wednesday, January 21, 2015

MVC's relation to N-tier architecture (Oldie but goodie)

In a nutshell, they are not the same. The MVC framework mostly forms the presentation layer.

MVC

Model
Could either be the same as the value objects or mapped objects (using such tools as Automapper).

View
Renders the model data in the presentation objects.

Controller
A liaison between the business layer and the view. This thin layer passes the conditions of the requests (querystring or posted values) to the business layer. Once the model (or value objects) are given back from the business layer, the controller passes them to the view for rendering.

N-tier Architecture

Business Layer
This is always the most complex of the tiers and contains business specific logic to execute.
It mostly communicates to the Data layer to populate value objects and pass them back to the presentation layer (through the controller)

Data Layer
This layer is talked to by the business layer but it talks to the database. In some cases contains some logic in the form of either stored procedures or view (in a non-No-SQL sense).

Presentation Layer
If implementing with an MVC framework, then it works with all three parts of the MVC framework.

Thursday, February 20, 2014

Discover your SQL server database table list, count and row count

After restoring some backup of SQL database file, there were dizzying number of tables. Not 20. Not even 50 but close to 20 x 50 tables. I wanted to know the magnitude of the complexity of the database that I’d dealing with.

First I checked for any data constraint issues. Please refer to a previous blog post to do exactly this. Fortunately, none was uncovered in this particular case.

And second I wanted to get a sense for how much data is the database initially populated OOTB when a customer installs this particular software i.e. how many rows of data are in each table of the database.

Friday, February 07, 2014

Getting Started with Fluent Migrator and resolve the listmigrations task issue

In this blog post, the steps it takes to setup a sample FluentMigrator migration classes is explained and in addition the solution to the issue with listmigrations task parameter with FluentMigrator version 1.1.2.1.

1. Create a Class Library Application

2. Add a Reference to the FluentMigrator Assembly
In the Package Manager Console, installed FluentMigrator
                Install-Package FluentMigrator –version 1.1.1.0
                This made a reference to “FluentMigrator.dll” in this project

Friday, January 31, 2014

Uncovering Data Constraint Issues in Your Database

A project of ours included inheriting legacy code and database. The codebase used a mixture of two ORMs: Entity Framework and NHibernate. Through refactoring, we've unified the data access technology to use NHibernate/Fluent NHibernate however it wasn't until the usage of FluentMigrator that I discovered the underlying data suffered from some unchecked constraints/referential integrity issues.

In one of our user stories we set out to trim our data down and provide the following set of data for our integration test project to include:
-          Static Data
-          Configuration Data
-          Dynamic Data


Wednesday, October 31, 2012

How to read the last n% of a large file in C#

Recently we came across the problem of opening a large log file to read only the last few lines of the logs. This log file is a cumulative log file i.e. it had grown to be over 8GB in size. Not even Notepad++ could open it. We could probably find a efficient editor to do this job for us, but decided to read the end of the file ourselves.