any framework or tips for multi-tier applications

Christopher Wright dhasenan at gmail.com
Sat Mar 28 14:12:58 PDT 2009


Qian Xu wrote:
> Hi All,
> 
> We are redesigning a system (previously was written in C) using D.
> We use Boundary-Controll-Entity-Pattern.
> To wrap db table to entities is a very time consuming work.
> Is there any framework or tips for multi-tier applications in D?
> 
> --Qian

At times like this, I think of this blog post: 
http://ayende.com/Blog/archive/2008/03/11/Field-Expedients-or-why-I-dont-have-the-tools-is.aspx

You can likely write some mixins to ease the use of Active Record. That 
would be the first thing I'd try. The simplest version I can imagine 
would either not work for relations:

template Member(T, char[] name)
{
    enum Member = T.stringof ~ ` ` ~ name ~ `() { return row.get!(` ~ 
T.stringof ~ `)(` ~ name ~ `); }`;
}


/*
table Foo
	a INT,
	b BIT,
	c TEXT
*/
class Foo
{
    private Row row;
    this (Row row) { this.row = row; }
    mixin (Member!(int, "a"));
    mixin (Member!(bool, "b"));
    mixin (Member!(char[], "c"));
}


More information about the Digitalmars-d-learn mailing list