We will then create our BO, following similar steps to build the DAO. Obviously, we must invoke the DAO BO to solve the data access. The most important obstacle to overcome at this stage will invoke the Dao. For now, build it directly with the familiar "new." We will be something like:
- ProvinciaDao ProvinciaDaoImpl provinciaDao = new ();
Do not worry if BO code seems to be just a "we" in this class stands the business logic, and for this simple interface does not take any further action. Remember to create the corresponding test with the different test cases.
Once completed, we then BO and DAO functional. The DAO is a dummy, but service business is perfectly functional for use. That is, a team of a top layer could continue to work with this implementation until the real and final implementation is available. However, let's review the recent implementation of our BO: it has an interesting problem. Let's review again how we are getting our Dao instance:
- ProvinciaDao ProvinciaDaoImpl provinciaDao = new ();
This line represents a serious problem for our BO. In a layered architecture, we assume that such a claim unknown layer layer implementation service provider (so as to be independent of implementation). But here, our BO knows explicitly the implementation of the Provincial Dao ... in fact, is doing a "new" in this implementation!
Further, we have another problem, this time in our test unit. Remember, we said that a unit test "isolate" the kinds of dependencies. However, the test of our BO depends on the operation of the DAO: DAO implementation if fail, we fail BO too. In fact, without the implementation of the DAO is not possible to test our BO. In summary, we have two major problems:
- The BO test is not unitary.
- Bo knows the implementation of DAO. You can not easily change the implementation in the BO.
Bookmarks