introduction repository, ddd and unit test

13
Introduction Repository, DDD & Unit Tests

Upload: hiraq-citra-m

Post on 28-Jul-2015

26 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Introduction repository, ddd and unit test

IntroductionRepository, DDD & Unit Tests

Page 2: Introduction repository, ddd and unit test

Agenda

- Repository- DDD- Unit Test

Case Study : Working on Laravel 5.0

Page 3: Introduction repository, ddd and unit test

Stories

- I want to test the data logic but i dont care the data engine (database)

- I want to test the data engine (database) but i dont care the data logic

automated tests...

Page 4: Introduction repository, ddd and unit test

In Reality

Page 5: Introduction repository, ddd and unit test

Problem?

“ the power of united data logic and database, called ORM “

Page 6: Introduction repository, ddd and unit test

Real problem?

As programmer we have to make sure every single unit should be working properly..

the keyword is -> every single unit of our code

Page 7: Introduction repository, ddd and unit test

Repository

Page 8: Introduction repository, ddd and unit test

Benefit?

- We can test logic without engine- We can test engine without logic- We can test the repository it self

easy to mocking…separation of concerns...

Page 9: Introduction repository, ddd and unit test

DDD

Solve complex needs by modelling the domain

Page 10: Introduction repository, ddd and unit test

DDD Things

- Entity. Unique object- ValueObject. Immutable object

Page 11: Introduction repository, ddd and unit test

Example

Users data that contain their credentials like email, username and password.

In DDD:User is an entity, password can be a ValueObject.

Page 12: Introduction repository, ddd and unit test

Unit Test

1 class 1 responsibility

We should can test each of 1 class without thinking the dependency complexity (replace all dependency with mock)

Page 13: Introduction repository, ddd and unit test

Enough!

SHOW ME THE CODES!