Tuesday, June 29, 2010

Data Access Layer

Data Access Layer created. Repository pattern:


Database objects:
  • Algorithm (immutable)
  • BoughtStock (immutable)
  • PlusMinus (enum)
  • CurrentStock (immutable)
  • StockHistory (immutable)
  • StockHistoryArchive (immutable)
  • StockTransaction (immutable)
  • Database (immutable)

Database repositories:
  • IRepository interface
  • Repository
    • Find
    • FindComplex
    • FindAll
    • FindAllComplex
    • Insert
    • InsertComplex
    • Save
    • Delete
  • IStatementFactory interface
Table specific repositories:
  • TableDeleteFactory implements IStatementFactory
  • TableInsertFactory implements IStatementFactory
  • TableSelectionFactory implements IStatementFactory
  • TableRepository extends Repository

Database factories:

  • IReaderFactory
    • ProcessList for retrieving lists
    • ProcessRecord for retrieving one record
  • TableFactory implements IReaderFactory
Example:
    public Algorithm FindById(int id, Database database)
    {
        Algorithm algorithm = new Algorithm();
        algorithm.setId(id);
        return Find(algorithm, new AlgorithmSelectionFactory(), new AlgorithmFactory(), database);
    }

No comments:

Labels