java - What is the difference between a layer and a component? -


my major development framework java spring framework. have write service layers, controller layer, dao layer, repository layer , on. there thousands of tons of layering. think component based development approach become more productive layering. spring calls every java beans component. think there should major difference between component , layer. layer passive component active. component fires events, call life cycle callbacks methods , actively handle task. on other hand layer gives abstraction. fundamental difference between layer , component?

concepts of layer , component different, don't replace each other. layer abstraction. abstract business logic database interactions, or http endpoint handlers. layer consists of components. there may multiple components in layer.

let's continue concrete examples. have user , group entities in system. have necessary endpoint handlers both, named usercontroller , groupcontroller. these components , form endpoint handler layer. business logic, you'll have userservice , groupservice. these components , form service layer. same goes database layer userrepository , grouprepository components.

if mean use full-stack components, in case layers condensed handlers. means usercontroller implements getting request, applying business rules, , accessing db. structure hard test , hard maintain. after point, code gets messy , hard deal with. there no unit tests, there integration tests test everything. there no option change database access method, may want use in-memory repository implementation test purposes technique not allow it. in all, layered architecture may seem complex @ first, comes handy in long term.

p.s.: if mean other components, please leave comment, can continue discussion.


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -