Work Habits

By Haemoglobin
5/29/2010 (revision 3)

Business Layer

alt text

Transaction Script

  • Organizes business logic by procedures where each procedure handles a single request from the presentation.Martin Fowler
  • Benefits: Simple to implement.
  • Negatives: - Danger of code duplication. - Spaghetti code. - A number of transactions accomplishing very similar tasks. - Hard to refactor.
  • Technology:
    • ADO.NET

Table Module

  • A single instance that handles the business logic for all rows in a database table or view.Martin Fowler
  • Benefits: Good visual studio support, easy databinding, database agnostic (choose provider), provides disconnect data modification.
  • Negatives: Database centric API.
  • Technology: .NET DataSet, DataTable, DataRow and DataAdapter structures (typed).

Active Record

  • Focuses on classes representing records in a table (row based view) whereas Table Module focuses on entire tables. But still considered a form of Table Module.
  • The object incorporates both data (column values) and behaviour (methods).
  • i.e an Order class for an Orders table, with a static GetOrders() method that returns a collection of orders, Insert, Delete, Update methods etc.
  • Benefits: Simplicity, vendor support.
  • Negatives: Not as efficient as straight DataSets. Gets complex if the problem domain grows away from the database design.
  • Technology: LINQ-to-SQL and Castle ActiveRecord (built on top of NHibernate, simpler).

Domain Model

  • An object model of the domain that incorporates both behavior and data.Martin Fowler
  • Domain driven design as opposed to data centric design.
  • Completely flexible to model the domain in any way you see fit through object oriented practices, "A web of interconnected objects".
  • A big brother to Active Record and is totally independent of the database.
  • Benefits: Easier maintainability, less code duplication, best way to model a complex system, persistence ignorance with plain old common objects (POCO).
  • Negatives: More work upfront, requires an O/R mapper.
  • Technology: NHibernate, Microsoft Entity Framework or NoSQL solutions such as MongoDB.

Comments

Powered by BlogEngine.NET 1.6.1.0 | Design by styleshout | Enhanced by GravityCube.net | 1.4.5 Changes by zembian.com | Adapted by HamishGraham.NET
(c) 2010 Hamish Graham. Banner Image (c) Chris Gin