This document provides an introduction to Redux, including what it is, its core principles and building blocks. Redux is a predictable state container for JavaScript apps that can be used with frameworks like React, Angular and Vue. It follows the Flux architecture pattern and is based on three principles - state is immutable, state can only be changed through actions, and changes are made with pure functions called reducers. The main building blocks are actions, reducers and the store.
This document provides an overview of Spring Boot and some of its key features. It discusses the origins and modules of Spring, how Spring Boot simplifies configuration and dependency management. It then covers examples of building Spring Boot applications that connect to a SQL database, use RabbitMQ for messaging, and schedule and run asynchronous tasks.
1) Spring Security provides authentication and authorization services for Java-based applications. It supports various authentication types including form-based, LDAP, and certificates.
2) Core concepts include the UserDetails interface for user information, UserDetailsService for retrieving user details, and the SecurityContext for holding authentication details.
3) Spring Security configuration is done primarily through the security namespace, defining things like the authentication manager, secured URLs, and form login details.
4) Method-level security and JSP tag libraries allow securing controller methods and restricting JSP content.
카카오 광고 플랫폼 MSA 적용 사례 및 API Gateway와 인증 구현에 대한 소개if kakao
황민호(robin.hwang) / kakao corp. DSP개발파트
---
최근 Spring Cloud와 Netflix OSS로 MSA를 구성하는 시스템 기반의 서비스들이 많아지는 추세입니다.
카카오에서도 작년에 오픈한 광고 플랫폼 모먼트에 Spring Cloud 기반의 MSA환경을 구성하여, API Gateway도 적용하였는데 1년 반 정도 운영한 경험을 공유할 예정입니다. 더불어 MSA 환경에서는 API Gateway를 통해 인증을 어떻게 처리하는지 알아보고 OAuth2 기반의 JWT Token을 이용한 인증에 대한 이야기도 함께 나눌 예정입니다.
This document provides an introduction to Redux, including what it is, its core principles and building blocks. Redux is a predictable state container for JavaScript apps that can be used with frameworks like React, Angular and Vue. It follows the Flux architecture pattern and is based on three principles - state is immutable, state can only be changed through actions, and changes are made with pure functions called reducers. The main building blocks are actions, reducers and the store.
This document provides an overview of Spring Boot and some of its key features. It discusses the origins and modules of Spring, how Spring Boot simplifies configuration and dependency management. It then covers examples of building Spring Boot applications that connect to a SQL database, use RabbitMQ for messaging, and schedule and run asynchronous tasks.
1) Spring Security provides authentication and authorization services for Java-based applications. It supports various authentication types including form-based, LDAP, and certificates.
2) Core concepts include the UserDetails interface for user information, UserDetailsService for retrieving user details, and the SecurityContext for holding authentication details.
3) Spring Security configuration is done primarily through the security namespace, defining things like the authentication manager, secured URLs, and form login details.
4) Method-level security and JSP tag libraries allow securing controller methods and restricting JSP content.
카카오 광고 플랫폼 MSA 적용 사례 및 API Gateway와 인증 구현에 대한 소개if kakao
황민호(robin.hwang) / kakao corp. DSP개발파트
---
최근 Spring Cloud와 Netflix OSS로 MSA를 구성하는 시스템 기반의 서비스들이 많아지는 추세입니다.
카카오에서도 작년에 오픈한 광고 플랫폼 모먼트에 Spring Cloud 기반의 MSA환경을 구성하여, API Gateway도 적용하였는데 1년 반 정도 운영한 경험을 공유할 예정입니다. 더불어 MSA 환경에서는 API Gateway를 통해 인증을 어떻게 처리하는지 알아보고 OAuth2 기반의 JWT Token을 이용한 인증에 대한 이야기도 함께 나눌 예정입니다.
배민찬(https://www.baeminchan.com) 서비스의 백엔드 시스템 중 일부가 지난 1년간 어떤 고민과 아이디어, 결과물을 만들어냈는지 공유하려고 합니다. 발표 중 언급되는 용어나 도구에 대해 일반적인 정의나 간단한 설명은 언급되나 자세히 다루지 않습니다. 사용된 도구들로 어떻게 이벤트 기반 분산 시스템을 만들었는지에 대한 이야기가 중심입니다.
This document provides a summary of Git in 10 minutes. It begins with an overview and breakdown of the content which includes explanations of what Git is, how it works, the GitHub flow, frequently used commands, confusions around undoing changes, and useful links. The body then delves into each section providing more details on Distributed version control, local vs remote operations, the GitHub flow process, example commands for undoing changes, and resources for additional learning.
GitFlow is a branching model for Git, created by Vincent Driessen. It has attracted a lot of attention because it is very well suited to collaboration and scaling the development team
마이크로서비스 스타일로 만들어진 시스템을 모노리틱 스타일로 이관한 사례와 함께 스프링을 이용해 모듈형 모노리스(modular monoliths)를 만든 경험을 바탕으로 모노리틱/마이크로서비스 보다 본질적인 문제를 제기하고, 문제 해결을 위한 아이디어와 코드를 공유합니다.
https://github.com/arawn/building-modular-monoliths-using-spring
이 자료는 2019년 KSUG 세미나에서 진행한 "잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다"를 기반으로 몇가지 내용을 추가하고, 전개 방식을 다듬어 조금 더 친절하게 만들어졌습니다.
This document provides an overview of Spring Security including:
I. It distinguishes Spring Framework, Spring Boot, and Spring Security and their relationships.
II. It defines Spring Security as a framework focusing on authentication and authorization for Java applications.
III. It outlines some of the core concepts in Spring Security such as Principal, Authentication, Authorization, GrantedAuthority etc.
The document serves as an introduction to Spring Security fundamentals and architecture.
** DevOps Training: https://www.edureka.co/devops **
This Edureka Git Tutorial explains what is version control system and why Git is the best tool for version control. You will get to learn what is Git through various operations that Git supports. Below are the topics covered in the tutorial:
1. Version Control System
2. Types of Version Control System
3. Version Control System Tools
4. What is Git?
5. Git Features
6. Git Workflow
7. Parallel Development
8. Hands-On
Check our complete DevOps playlist here (includes all the videos mentioned in the video): http://goo.gl/O2vo13
https://youtu.be/_yLt_abcK2w
Angular is a TypeScript-based open-source front-end platform that makes it easy to build applications with in web/mobile/desktop. The major features of this framework such as declarative templates, dependency injection, end to end tooling, and many more other features are used to ease the development.
Angular 7 is a Javascript framework built around the concept of components, and more precisely, with the Web Components standard in mind. It was rewritten from scratch by the Angular team using Typescript (although we can use it with ES5, ES6, or Dart as well).
Angular 7 is a big change for us compared to 1.x. Because it is a completely different framework than 1.x, and is not backward-compatible. Angular 7 is written entirely in Typescript and meets the ECMAScript 6 specification
angular interview questions and answers, angular 7 interview questions and answers, angular interview question, angular interview questions and answers for experienced, angular 7 interview questions, angular 6 interview questions,
angular interview questions, angular 6 interview questions and answers, angular 2 interview questions, angular7, angular 5 interview questions, angular interview, angular 2 interview questions and answers, angular questions and answers
Este documento presenta una introducción a Spring Boot. Explica que Spring Boot simplifica el desarrollo de aplicaciones Spring mediante características como configuración automática, servidores embebidos y empaquetado en JAR. También cubre temas como pruebas, desarrollo web, logging, Actuator y empaquetamiento. El objetivo de Spring Boot es acelerar y facilitar la creación de aplicaciones Spring, tanto web como autónomas.
Explanation of the fundamentals of Redux with additional tips and good practices. Presented in the Munich React Native Meetup, so the sample code is using React Native. Additional code: https://github.com/nacmartin/ReduxIntro
This document contains an agenda and slides for a presentation on Spring Boot. The presentation introduces Spring Boot, which allows developers to rapidly build production-grade Spring applications with minimal configuration. It demonstrates how to quickly create a "Hello World" application using Spring Boot and discusses some of the features it provides out-of-the-box like embedded servers and externalized configuration. The presentation also shows how to add additional functionality like Thymeleaf templates and actuator endpoints to monitor and manage applications.
This document provides a brief introduction to Git, a distributed version control system. It describes what Git is and some of its key features, such as tracking changes to files over time, supporting distributed development, efficient object storage, easy branching and merging, and universal public identifiers. The document also discusses some of Git's internal mechanisms, such as SHA-1 hashes to uniquely identify objects, the index cache, and how commits and branches work.
All 3 Clean Code presentations provide great value by themselves, but taken together are designed to offer a holistic approach to successful software creation. This first session creates the foundation for the 2nd and 3rd Clean Code presentation on Dependency Injection, as it explains expected base knowledge. Why writing Clean Code makes us more efficient Over the lifetime of a product, maintaining the product is actually one - if not the most - expensive area(s) of the overall product costs.
We will dive into the basics of Inversion of Control (IOC) and Dependency Injection (DI) to review different ways of achieving decoupling, using and exploring both: Best Practices, Design and Anti Patterns. This presentation requires knowledge and understanding of basics like DRY, SoC, SRP, SOLID etc. which are building the base for decoupled architecture. However, we will start at the basics of DI and will work towards intermediate and advanced scenarios depending on the participating group.
This presentation is based on C# and Visual Studio 2013. However, the demonstrated patterns and practice can be applied to every other programming language too.
Note: Moving forwards this presentation will be updated with the latest version of the slides for the last event I did the presentation instead of creating new separate slide decks here on SlideShare.
Presentation dates and locations:
2015-10-03 Silicon Valley Code Camp, San Jose, CA
2015-06-27 SoCal Code Camp - San Diego, CA
2015-06-25 Bay.NET South Bay, Mountain View, CA
2014-11-14 SoCal Code Camp - Los Angeles, CA
2014-10-11 Silicon Valley Code Camp, Los Altos Hills, CA
The document describes the problem of needing to run test suites across multiple servers and the limitations of existing solutions. It introduces the Jenkins Multi-Configuration (Matrix) approach as a better solution. The Matrix allows test suites and servers to be defined as "axes" to automatically run all combinations in parallel, avoiding the need to manually maintain duplicate jobs as servers are added. This improves efficiency by completing all runs much faster when using multiple build agents with parallel executors.
멀티 모듈을 이용한 안드로이드 프로젝트 개발이 늘어나고 있습니다.
하지만 모듈을 만들 때 마다 build.gradle의 중복 코드가 생기고 있다는 사실을 아시나요?
이러한 문제를 해결하기 위해 빌드 로직을 효율적으로 관리하는 Gradle Kotlin 컨벤션 플러그인을 소개합니다.
*페이지 마지막에 코드 링크 첨부되어 있습니다.
갑을병정 산업구조에서 갑돌이의 잦은 요구사항 변경 통보를 받아보셨을 겁니다. 사람들에게 받은 스트레스를 풀려고 '그래! 난 개발자닌깐' 하고 자리에 앉아서 코드를 짜는데 반복적인 작업을 하다보면 ‘내가 이걸 왜 하고 있나’ 라는 생각까지 들기도 합니다.
안드로이드 작업을 하다보면 다음과 같은 반복적인 작업을 하는 것을 느꼈을 겁니다.
반복적인 보일러(Boiler)코드를 줄일 수 있는 오픈소스를 소개하고자 합니다.
배민찬(https://www.baeminchan.com) 서비스의 백엔드 시스템 중 일부가 지난 1년간 어떤 고민과 아이디어, 결과물을 만들어냈는지 공유하려고 합니다. 발표 중 언급되는 용어나 도구에 대해 일반적인 정의나 간단한 설명은 언급되나 자세히 다루지 않습니다. 사용된 도구들로 어떻게 이벤트 기반 분산 시스템을 만들었는지에 대한 이야기가 중심입니다.
This document provides a summary of Git in 10 minutes. It begins with an overview and breakdown of the content which includes explanations of what Git is, how it works, the GitHub flow, frequently used commands, confusions around undoing changes, and useful links. The body then delves into each section providing more details on Distributed version control, local vs remote operations, the GitHub flow process, example commands for undoing changes, and resources for additional learning.
GitFlow is a branching model for Git, created by Vincent Driessen. It has attracted a lot of attention because it is very well suited to collaboration and scaling the development team
마이크로서비스 스타일로 만들어진 시스템을 모노리틱 스타일로 이관한 사례와 함께 스프링을 이용해 모듈형 모노리스(modular monoliths)를 만든 경험을 바탕으로 모노리틱/마이크로서비스 보다 본질적인 문제를 제기하고, 문제 해결을 위한 아이디어와 코드를 공유합니다.
https://github.com/arawn/building-modular-monoliths-using-spring
이 자료는 2019년 KSUG 세미나에서 진행한 "잘 키운 모노리스 하나 열 마이크로서비스 안 부럽다"를 기반으로 몇가지 내용을 추가하고, 전개 방식을 다듬어 조금 더 친절하게 만들어졌습니다.
This document provides an overview of Spring Security including:
I. It distinguishes Spring Framework, Spring Boot, and Spring Security and their relationships.
II. It defines Spring Security as a framework focusing on authentication and authorization for Java applications.
III. It outlines some of the core concepts in Spring Security such as Principal, Authentication, Authorization, GrantedAuthority etc.
The document serves as an introduction to Spring Security fundamentals and architecture.
** DevOps Training: https://www.edureka.co/devops **
This Edureka Git Tutorial explains what is version control system and why Git is the best tool for version control. You will get to learn what is Git through various operations that Git supports. Below are the topics covered in the tutorial:
1. Version Control System
2. Types of Version Control System
3. Version Control System Tools
4. What is Git?
5. Git Features
6. Git Workflow
7. Parallel Development
8. Hands-On
Check our complete DevOps playlist here (includes all the videos mentioned in the video): http://goo.gl/O2vo13
https://youtu.be/_yLt_abcK2w
Angular is a TypeScript-based open-source front-end platform that makes it easy to build applications with in web/mobile/desktop. The major features of this framework such as declarative templates, dependency injection, end to end tooling, and many more other features are used to ease the development.
Angular 7 is a Javascript framework built around the concept of components, and more precisely, with the Web Components standard in mind. It was rewritten from scratch by the Angular team using Typescript (although we can use it with ES5, ES6, or Dart as well).
Angular 7 is a big change for us compared to 1.x. Because it is a completely different framework than 1.x, and is not backward-compatible. Angular 7 is written entirely in Typescript and meets the ECMAScript 6 specification
angular interview questions and answers, angular 7 interview questions and answers, angular interview question, angular interview questions and answers for experienced, angular 7 interview questions, angular 6 interview questions,
angular interview questions, angular 6 interview questions and answers, angular 2 interview questions, angular7, angular 5 interview questions, angular interview, angular 2 interview questions and answers, angular questions and answers
Este documento presenta una introducción a Spring Boot. Explica que Spring Boot simplifica el desarrollo de aplicaciones Spring mediante características como configuración automática, servidores embebidos y empaquetado en JAR. También cubre temas como pruebas, desarrollo web, logging, Actuator y empaquetamiento. El objetivo de Spring Boot es acelerar y facilitar la creación de aplicaciones Spring, tanto web como autónomas.
Explanation of the fundamentals of Redux with additional tips and good practices. Presented in the Munich React Native Meetup, so the sample code is using React Native. Additional code: https://github.com/nacmartin/ReduxIntro
This document contains an agenda and slides for a presentation on Spring Boot. The presentation introduces Spring Boot, which allows developers to rapidly build production-grade Spring applications with minimal configuration. It demonstrates how to quickly create a "Hello World" application using Spring Boot and discusses some of the features it provides out-of-the-box like embedded servers and externalized configuration. The presentation also shows how to add additional functionality like Thymeleaf templates and actuator endpoints to monitor and manage applications.
This document provides a brief introduction to Git, a distributed version control system. It describes what Git is and some of its key features, such as tracking changes to files over time, supporting distributed development, efficient object storage, easy branching and merging, and universal public identifiers. The document also discusses some of Git's internal mechanisms, such as SHA-1 hashes to uniquely identify objects, the index cache, and how commits and branches work.
All 3 Clean Code presentations provide great value by themselves, but taken together are designed to offer a holistic approach to successful software creation. This first session creates the foundation for the 2nd and 3rd Clean Code presentation on Dependency Injection, as it explains expected base knowledge. Why writing Clean Code makes us more efficient Over the lifetime of a product, maintaining the product is actually one - if not the most - expensive area(s) of the overall product costs.
We will dive into the basics of Inversion of Control (IOC) and Dependency Injection (DI) to review different ways of achieving decoupling, using and exploring both: Best Practices, Design and Anti Patterns. This presentation requires knowledge and understanding of basics like DRY, SoC, SRP, SOLID etc. which are building the base for decoupled architecture. However, we will start at the basics of DI and will work towards intermediate and advanced scenarios depending on the participating group.
This presentation is based on C# and Visual Studio 2013. However, the demonstrated patterns and practice can be applied to every other programming language too.
Note: Moving forwards this presentation will be updated with the latest version of the slides for the last event I did the presentation instead of creating new separate slide decks here on SlideShare.
Presentation dates and locations:
2015-10-03 Silicon Valley Code Camp, San Jose, CA
2015-06-27 SoCal Code Camp - San Diego, CA
2015-06-25 Bay.NET South Bay, Mountain View, CA
2014-11-14 SoCal Code Camp - Los Angeles, CA
2014-10-11 Silicon Valley Code Camp, Los Altos Hills, CA
The document describes the problem of needing to run test suites across multiple servers and the limitations of existing solutions. It introduces the Jenkins Multi-Configuration (Matrix) approach as a better solution. The Matrix allows test suites and servers to be defined as "axes" to automatically run all combinations in parallel, avoiding the need to manually maintain duplicate jobs as servers are added. This improves efficiency by completing all runs much faster when using multiple build agents with parallel executors.
멀티 모듈을 이용한 안드로이드 프로젝트 개발이 늘어나고 있습니다.
하지만 모듈을 만들 때 마다 build.gradle의 중복 코드가 생기고 있다는 사실을 아시나요?
이러한 문제를 해결하기 위해 빌드 로직을 효율적으로 관리하는 Gradle Kotlin 컨벤션 플러그인을 소개합니다.
*페이지 마지막에 코드 링크 첨부되어 있습니다.
갑을병정 산업구조에서 갑돌이의 잦은 요구사항 변경 통보를 받아보셨을 겁니다. 사람들에게 받은 스트레스를 풀려고 '그래! 난 개발자닌깐' 하고 자리에 앉아서 코드를 짜는데 반복적인 작업을 하다보면 ‘내가 이걸 왜 하고 있나’ 라는 생각까지 들기도 합니다.
안드로이드 작업을 하다보면 다음과 같은 반복적인 작업을 하는 것을 느꼈을 겁니다.
반복적인 보일러(Boiler)코드를 줄일 수 있는 오픈소스를 소개하고자 합니다.
Create-React-App으로 SSR을 구현하며 배운 점 (feat. TypeScript)LanarkSeung
프로덕션 환경에서 클라이언트 사이드 렌더링을 고집하기란 힘든 일입니다. 서버를 통해 웹사이트를 제공하면서도 React의 편리함을 누리려면 서버 사이드 렌더링(SSR)을 구현해야 하는데요. Create-React-App을 그대로 유지하면서 SSR을 구현하는 과정을 보여드리고자 합니다. TypeScript로도 가능합니다!
탑크리에듀교육센터(www.topcredu.co.kr)제공
스프링프레임워크 & 마이바티스(Spring Framework, MyBatis)
19번째 자료입니다. 참고하시어 많은 도움되셨길 바랍니다.
교육 및 수강문의/기타문의사항은 홈페이지(www.topcredu.co.kr)를 통하여 하실 수 있습니다.^^
NHN Forward 2018 컨퍼런스에서 발표한 자료입니다.
http://forward.nhnent.com/
MyBatis로 작성된 예제 프로그램을 JPA로 마이그레이션하는 방법에 대해 설명합니다.
cf.) https://github.com/nhnent/hands-on-labs.java.mybatis-to-jpa
Similar to [2022]NaverMeetup_[Flutter] Dependency Injection과 Service Locator_임태규.pdf (20)
12. 예제 프로젝트 구조
App Bloc UseCase Repository
Main View DataSource
13. 응집도와 결합도
• 응집도(cohesion)
• 모듈 내부 구성요소 간 연관 정도
• 응집도가 높다 ➔ 모듈 내 모든 기능이 단일 목적을 위해 수행됨
• 결합도(coupling)
• 모듈과 외부 모듈의 연관 정도
• 결합도가 낮다 ➔ 모듈이 기능 수행을 위해 다른 모듈에 의존하지 않음
14. class SendOrderUsecase {
final OrderRepository _orderRepository = OrderRepository();
Future<OrderResult> sendOrder(Order order) =>
_orderRepository.sendOrder(order);
}
높은 결합도
15. 예제 프로젝트 구조
App Bloc UseCase Repository
Main View DataSource
16. class OrderRepository {
final LocalDatasource _localDatasource = LocalDatasource();
final RemoteDatesource _remoteDatesource = RemoteDatesource();
Future<OrderResult> sendOrder(Order order) async {
final localRes = await _localDatasource.sendOrder(order);
final remoteRes = await _remoteDatesource.sendOrder(order);
return OrderResult((localRes && remoteRes) ? "SUCCESS" : "Fail");
}
}
높은 결합도
18. SOLID
• Single Responsibility Principle: 단일 책임 원칙
• Open Closed Principle: 개방 폐쇄 원칙
• Liskov Substitution Principle: 리스코프 치환 원칙
• Interface Segregation Principle: 인터페이스 분리 원칙
• Dependency Inversion Principle: 의존성 역전 원칙
➔ 구체적인 대상이 아니라, 추상적인 대상에 의존해야 함
20. class OrderRepository {
final LocalDatasource _localDatasource = LocalDatasource();
final RemoteDatesource _remoteDatesource = RemoteDatesource();
Future<OrderResult> sendOrder(Order order) async {
}
}
abstract class OrderRepository {
Future<OrderResult> sendOrder(Order order);
}
DIP 적용
21. DIP 적용
class OrderRepositoryImpl implements OrderRepository {
final LocalDatasource _localDatasource = LocalDatasource();
final RemoteDatesource _remoteDatesource = RemoteDatesource();
Future<OrderResult> sendOrder(Order order) async {
final localRes = await _localDatasource.sendOrder(order);
final remoteRes = await _remoteDatesource.sendOrder(order);
return OrderResult((localRes && remoteRes) ? "SUCCESS" : "Fail");
}
}
22. class SendOrderUsecase {
final OrderRepository _orderRepository = OrderRepositoryImpl();
Future<OrderResult> sendOrder(Order order) =>
_orderRepository.sendOrder(order);
}
DIP 적용
아직 구체적인 대상에 대한
의존성을 제거하지 못함
38. • 애플리케이션에 필요한 모든 객체를 알고 있는 객체를 만들고, 그
객체를 통해 의존성을 획득하는 방법
Service Locator
App Bloc UseCase
Main View DataSource
Repository
Repository
Impl
누군가
Composition Root
Entry Point
어딘가
Service Locator
39. • Service Locator의 유형
• Static Service Locator
• Dynamic Service Locator
Service Locator
40. class ServiceLocator {
static ServiceLocator? _instance;
final OrderRepository _orderRepository;
ServiceLocator(this._orderRepository);
static void load(ServiceLocator serviceLocator) => _instance = serviceLocator;
static OrderRepository getOrderRepository() => _instance!._orderRepository;
}
Service Locator 구현
41. Service Locator 객체 생성
void main() {
ServiceLocator.load(ServiceLocator(OrderRepositoryImpl()));
runApp(OrderApp(orderBloc: OrderBloc(SendOrderUsecase())));
}
42. class SendOrderUsecase {
final OrderRepository _orderRepository = ServiceLocator.getOrderRepository();
Future<OrderResult> sendOrder(Order order) =>
_orderRepository.sendOrder(order);
}
Service Locator 의존성 획득
47. • 종속성을 숨김
• 단위테스트 어려움
• mocking이 가능하더라도, 전역 메모리 사용하므로, 테스트 후 clear 필요
• 전역 싱글톤 패턴
• 구현 상 전역 싱글톤을 안쓰더라도, 내부적으로 공유 메모리 사용을 피할 수 없음)
• 모든 클래스가 로케이터와 커플링
• Runtime Error
• Locator의 존재를 모르고 생성을 안하고 사용하면 런타임 에러
• 의존 객체를 찾기 어려움
• 내부에 의존성 추가되면 컴파일러가 알 수 없음
• 캡슐화 위반
• 객체 사용을 위한 전제 조건을 알 수 없음
Service Locator의 단점
53. DI와 GetX의 비교 – DI
class OrderApp extends StatelessWidget {
const OrderApp({Key? key, required this.orderBloc}) : super(key: key);
final OrderBloc orderBloc;
54. class OrderBloc {
final SendOrderUsecase _sendOrderUsecase;
OrderBloc(this._sendOrderUsecase);
DI와 GetX의 비교 – DI
55. class SendOrderUsecase {
final OrderRepository _orderRepository;
SendOrderUsecase(this._orderRepository);
DI와 GetX의 비교 – DI
56. class OrderRepositoryImpl implements OrderRepository {
final LocalDatasource _localDatasource;
final RemoteDatasource _remoteDatesource;
OrderRepositoryImpl(this._localDatasource, this._remoteDatesource);
DI와 GetX의 비교 – DI
58. class OrderApp extends StatelessWidget {
OrderApp({Key? key}) : super(key: key);
final OrderBloc orderBloc = Get.find();
DI와 GetX의 비교 – GetX
59. DI와 GetX의 비교 – GetX
class OrderBloc {
final SendOrderUsecase _sendOrderUsecase = Get.find();
class SendOrderUsecase {
final OrderRepository _orderRepository = Get.find();
class OrderRepositoryImpl implements OrderRepository {
final LocalDatasource _localDatasource = Get.find();
final RemoteDatasource _remoteDatesource = Get.find();
64. GetX를 DI Container로 활용하기
App Bloc UseCase
Main View DataSource
Repository
Repository
Impl
누군가
Composition Root
Entry Point
Service Locator
누군가 어딘가
Composition Root
DI with GetX
GetX
어딘가
Get
65. • DI는 원칙과 패턴
• 지금까지 본 DI는 Pure DI
• 외부 라이브러리나 객체 사용 없이 의존성 주입
• DI Container
• 의존성 주입할 모든 객체를 관리하는 모듈
• 역할 (RRR)
• Register: 인스턴스 등록
• Resolve: 인스턴스 제공
• Release: 인스턴스 해제
Pure DI와 DI Container
68. GetX를 DI Container로 활용하기
class OrderApp extends StatelessWidget {
const OrderApp({Key? key, required this.orderBloc}) : super(key: key);
final OrderBloc orderBloc;
69. class OrderBloc {
final SendOrderUsecase _sendOrderUsecase;
OrderBloc(this._sendOrderUsecase);
GetX를 DI Container로 활용하기
70. class SendOrderUsecase {
final OrderRepository _orderRepository;
SendOrderUsecase(this._orderRepository);
GetX를 DI Container로 활용하기
71. class OrderRepositoryImpl implements OrderRepository {
final LocalDatasource _localDatasource;
final RemoteDatasource _remoteDatesource;
OrderRepositoryImpl(this._localDatasource, this._remoteDatesource);
GetX를 DI Container로 활용하기
72. • 장점
• GetX의 Memory Management 기능 활용 가능
• Entry Point에서 가까운 Composition Root에서 의존관계 관리
• 의존관계 tree의 depth가 깊어도, 안쪽까지 객체를 쉽게 전달
• 단점
• GetX에 등록을 잊는다면, 여전히 Runtime Error 발생 가능
GetX를 DI Container로 활용하기
74. class SendOrderUsecase {
final OrderRepository _orderRepository;
SendOrderUsecase([OrderRepository? orderRepository])
: _orderRepository = orderRepository ?? Get.find();
Future<OrderResult> sendOrder(Order order) =>
_orderRepository.sendOrder(order);
}
GetX를 DI Container로 활용하기
75. • 예외적으로 생성자에서 객체 생성해 주입 허용
• 외부에 의존관계 알림
• 테스트 용이
• 객체 주입 용이
• 단, 모든 객체가 GetX 의존성 가짐
GetX를 DI Container로 활용하기
76. • 원인
• 객체를 생성 및 조립한 후 변경이 불가능함
• 한계
• 객체 생성에 Runtime 요소가 필요할 때 대응이 어려움
• 보완
• 추상 팩토리 메서드 패턴 활용
한계 및 보완
77. • 의존성 있는 객체간 결합도를 낮추는 방법
• DI: 생성자 주입, Setter 주입
• Service Locator: 의존성 필요한 객체가 컨테이너에 객체 요청
• Service Locator는 안티패턴이라는 주장 (Mark Seemann)
• Flutter의 의존성 주입 (GetX, GetIT) ➔ Service Locator 방식
• GetX, GetIt을 DI Container로 활용할 수 있음
• 객체 생성에 Runtime 요소가 필요할 경우, 추상 팩토리 패턴으로 보완
정리