.NET refactoring, DRY. double inheritance, data access and separation of concerns

Story story:

So I got stuck on the architecture issue for the last couple of nights on the refactor I played with. Nothing important, but it bothered me. This is actually an exercise in DRY , and an attempt to bring it to such an extent that the DAL architecture is completely dry. This is a completely philosophical / theoretical exercise.

This code is partly based on one of the @JohnMacIntyre refactoring , which I recently convinced him on a blog about http://whileicompile.wordpress.com/2010/08/24/my-clean-code-experience-no-1/ . I changed the code a bit, as I tend to keep the code one level lower - usually to see how much extra mileage I can get from the concept ... anyway, my reasons are pretty much irrelevant.

Part of my data access level is based on the following architecture:

abstract public class AppCommandBase : IDisposable { }

This contains basic elements such as creating a command object and cleaning up after uninstalling AppCommand. Of all my base base objects.

abstract public class ReadCommandBase<T, ResultT> : AppCommandBase

, - , , . , , .

abstract public class ReadItemCommandBase<T, FilterT> : ReadCommandBase<T, T> { }

- , , , , ( .

public class MyTableReadItemCommand : ReadItemCommandBase<MyTableClass, Int?> { }

, , , , IDataReader - , .

ReadList...

abstract public ReadListCommandBase<T> : ReadCommandBase<T, IEnumerable<T>> { }
public class MyTableReadListCommand : ReadListCommandBase<MyTableClass> { }

, List , (, PageStart, PageSize, Sort IEnumerable) DataObject ( , ).

:

, MyTableReadListCommand, MyTableReadItemCommand. , -, , , , .

, , , - . , , .NET , ?

, ... , .

- , , , DropBox http://dl.dropbox.com/u/3029830/Prototypes/Prototype%20-%20DAL%20Refactor.zip. DataAccessLayer.

P.S. , .

, .

+5
5

. ReadCommandBase.

IDatabaseResultParser. ItemDatabaseResultParser ListDatabaseResultParser, ReadCommandBase (, , ).

IDatabaseResultParser.Value(), , T.

( / .. ..), , . . NHibernates IResultTransformer, , (, , , IDatabaseResultParser).

.

, ...

  • AppCommandBase - , , , , , .
  • - , , , , .
  • , //, , . , , sql , ( #).

, IDatabaseQuery/IDatabaseCommand/IResultTransformer =)

+4

, , , " ", / . , , ​​ . .

....

- , , " " "" . , , tree. , . .

, , , , : SQL "item" "list". , , , . , " " - , : , . . , , .

, -, #, #. , " ", , .

+1

, . , , . , .

0

, - ... .NET , ..NET , DRY.

, , , dom , , , . - , ( ).

, , , , , , MI, , , .

, . , .

0

, #. , : mixin, trait (pdf) (# research -pdf) ( perl 6). # ( ) ( , ).

mixin #, .

The Oxygene ( download ) language (a Pascal object for .NET) also has an interesting function for delegating an interface , which can be used to create all this delegating code for you.

0
source

All Articles