Data Access
DAO (Data Access Object)
Also known as TDG (Table Data Gateway), it is a Table oriented pattern. (Oriented to Database a table)
This pattern is intended to interact with your Database tables and return table records.
Repository
Mediates the Domain Layer and the Data Layer (Persistense).
It purpose is to persist Domain Objects and return either Aggregates or Domain Objects.
Gateway
A way to obtain data from a external system.
ORM (Object Relational Mapper)
The ORM responsibility is to MAP the database to the domain.
In ORM, the model class mirrors the database table.
Usually only primitive types, since they come from the database.
Registry
A well known object (known by all), useful for locating other objects/services.
Registry
Pattern is very important for Dependency Injection
.
Serves basically as a Dependency pool.
Implementing using Singleton
Use it anywhere on the code to, provide (create) and inject (get) other class instances (dependencies).
Example (without decorators
)
decorators
)This
Will be substituted by
In the main.ts
we instanciate and provide to the Registry
all the classes we want.
At the Signup.ts
for example we will grab the UserDAO
instance created in the main.ts
. And as you can see, no classes had to be passed to the constructor as parameter.
Example (with decorators
) (in typescript
)
decorators
) (in typescript
)The same example above, will be substituted by:
Last updated