Issue
- Spring empowers POJO based programming.
- It offers support for MVC out of the box
- wires up code in less time.
- How does it support layered architecture?
- provides an abstraction layer to simplify development process(why is this a benefit and how does spring handle this?) How does spring do that? I read a lot of articles talking about the advantages of spring. But none of them explain in theory i.e. in words not code, how spring does that? for example, one of the advantages says it empowers POJO programming? we can do that with plain java too, why is that a benefit or what's the opposite of POJO? Kindly request everyone to address those 3 questions. THanks
Solution
in short:
- spring was created a long time ago. it was probably compared to ejb2 that needed more setup code. POJO vs EJB vs EJB 3 Also spring does support pojos for example as return value in MVC-controllers. pojos dont have external dependencies so your application stays portable (non-functional requirement of an application).
- yes you can easily (my opinion) create web applications.
- at its core spring provides a container in which bean definitions are stored. when a service is requested that needs a dependecy, spring can look up whether it has a bean definition for that dependency, construct an instance of that bean and inject it in that service. That way you dont need to manually instantiate your service.
- for example in web applications spring has abstractions for controllers, services and repositories. typically an application provides controllers so that caller can use your api. controllers should call services that handle your business logic. and services can call repositories that persist your data. that way you have a layered flow: controllers --> services --> repository this has the advantage that when you change e.g. your repository you dont have to make changes to your controllers.
- spring provides many abstractions for common problems out-of-the-box (e.g. spring security) and empowers convention-over-configuration. That way you can reduce boilerplate code. less code -> less probability for a developer to make a mistake. e.g. spring-security-oauth2: you can just set some properties in a .properties file and spring autoconfigures beans that solve the validation of an oauth-token when a user requests one of your controllers.
Answered By - benebo22