Spring Framework
Spring Framework
1. Overview
Check how to improve the reusability of SW, the Relationship between design pattern and framework, and Spring framework Components.
1.1 Plain Old Java Object (POJO)
Objects which are no need to inherit specific parent or environment but only JVM. So MyServlet which extends HttpServlet and runs on Web Container is not POJO.
1.2 Portable Service Abstraction (PSA)
Separate complex low-level implementations, which are transaction, OXM, exception managing, and usage through interfaces.
1.3 Aspect-Oriented Programming (AOP)
Separate business logic and general concerns, so easily managing common concerns
1.4 Inversion Of Control / Dependency Injection (IoC/DI)
Offer environment for making extensible object through dynamic external configuration
2. Reusable Code
2.1 Copy And Paste
2.1.1 Pros
Easy to implement
2.1.2 Cons
Need to replace all when correlated codes are changed
2.2 Method Invocation
2.2.1 Pros
Only modifying method contents don't affect other classes
2.2.2 Cons
Coupling Problem: If the method signature is changed, all classes using this method are affected.
2.3 Class Inheritance
2.3.1 Pros
Easily propagate methods changes into children only that changes methods signature
Easily encapsulation relationship between classes like parent and children
2.3.2 Cons
Changing the method signature of parent need to propagate into all of succeed children
2.4 Aspect-Oriented Programming (AOP)
Separation of Concerns: Cross-cutting concerns
2.4.1 Pros
Separate common concerns such as logging and transactions from specific business logic Independently
No need to modify business logic for applying and changing common concerns but only business logics
2.4.2 Cons
Hard to implement without Framework support
3. Relationship between Design Patten and Framework
3.1 Design Pattern
The reusable solution to a commonly occurring problem within a given context in software design
3.1.1 Motivation
Minimize changes for changes of logic for changing requirements
Making code general and intuitive that enhances cooperation within the dev teams
3.2 Framework
An abstraction in which software providing generic functionality, which is non-business functionality such as security, authentication, and transaction, can be selectively changed by additional user-written code, thus providing application-specific software.
3.2.1 Motivation
Reduce implementation of non-functionality on every boot project
Can be focusing on Functional requirement such as business logic
Offer solutions for repetitive and common problems
3.2.2 Spring framework features
Container
DI Support
AOP Support
POJO Support
Transaction Support
Persistence Support
3.3 Spring framework Components
3.3.1 Spring Core
Basic Container of Spring Framework
BeanFactory exist in this module
3.3.2 AOP
Support Spring AOP
3.3.3 Spring ORM
Support Persistence API such as MyBatis, Hibernate, JPA
3.3.4 Spring DAO
Abstract Layer of JDBC. Support JDBC, Exception management, Transaction management through AOP, etc.
3.3.5 Spring Web
Support Web application. Also, support Integration with other frameworks such as Webwork, Struts, and so on.
3.3.6 Spring Context
BeanFactory Extensional. Support application life cycle events, validation, I18N, etc.
3.3.7 Spring Web MVC
Support to separate Application logic and Web application logic
3.4 Relationship between design pattern and framework
The design pattern is core features in a framework and framework offer advanced features based on design pattern. The design pattern gives some guidelines for project architecture but not offering implementation. But framework offers libraries based on design patterns and some structure for implementation of some functionality. So developers can easily use design patterns through the framework.
4. Framework Components
4.1 Inversion of Control (IoC)
Inversion of Control is a principle in software engineering by which the control of objects or portions of a program is transferred to a container or framework. The container will create the objects, wire them together, configure them, and manage their complete life cycle from creation till destruction.
Contrary way against to traditional program's procedure
By injecting the beans, which are managed by Spring container, support IoC
Spring manages beans through metadata such as XML
4.2 Class library
Offers Some parts of the implementation of Spring which are semi-complete. The difference between Library and Frameworks is where is the control of the procedure. Libraries should be invoked from developers, but frameworks are invoking the classes made from developers.
4.3 Design pattern
5. Types of framework
Functionality Framework MVC Spring MVC, Struts 2, Webwork, PalyFramework ORM Mybatis, Hibernate, JPA, Spring JDBC AOP Spring AOP, AspectJ, JBoss AOP DI Spring DI, Google Guice Build and Library management Ant + Ivy, Maven, Gradle Unit Test JUnit, TestNG, Cactus Javascript jQuery, AngularJS, Node.js
6. Reference
https://www.youtube.com/watch?v=yoQwdSEGoK0
https://www.youtube.com/watch?v=j5WlADp5f
https://www.dineshonjava.com/spring-aop-tutorial-with-example-aspect-advice-pointcut-joinpoint/
https://dzone.com/articles/implementing-aop-with-spring-boot-and-aspectj
https://en.wikipedia.org/wiki/Software_design_pattern
https://en.wikipedia.org/wiki/Software_framework
https://www.tutorialspoint.com/spring/spring_ioc_containers.htm
https://www.baeldung.com/inversion-control-and-dependency-injection-in-spring
https://jinpyo900.tistory.com/55
from http://demyank.tistory.com/505 by ccl(A)
댓글
댓글 쓰기