shw0471 / mvp_designpattern_practice Goto Github PK
View Code? Open in Web Editor NEW안드로이드 MVP 디자인패턴 연습
안드로이드 MVP 디자인패턴 연습
일단 Model이라는 개념에 대해서 헷갈리는 부분이 많을 것이라 생각하는데,
내 생각에는 Presenter로 데이터를 전달하기 전 처리하는 모든 과정 (데이터 접근(서버, 로컬db, preference 등), 캐싱) 에 해당하는 부분이 Model이라 생각함
그래서 View, Presenter와는 다르게 더 많은 계층으로 구성될 수 있음. 우리 회사 같은 경우에는 Data access, 캐싱 계층이 Model에 포함됨
그렇기 때문에 사용하는 방법으로는 Interface를 통해서 콜백을 생성하는 것, model의 getList를 호출할 때 그 인터페이스를 Presenter에서 구현하여 넘겨줘서 콜백 방식으로 하는 것이 베스트일듯.
Realm.init()은 프로그램 실행 때 한번만 호출해주면 되기 때문에 모델에서 안해도 될듯, 그리고 Presenter로 context를 넘겨주면 추후에 테스트 코드를 작성하기 힘들어짐. 왜냐면 Context는 안드로이드 프레임워크에 종속적인 개념이기 때문에 Presenter로직을 테스트할 때 방해물이 될 가능성이 높음
이건 개인 취향차이라고 할 수 있는데. 개인적으로는 Contract에 모델을 포함하는 것은 어울리지 않다고 생각함. 위에서 말한 것 처럼 하나의 화면, 기능에 종속적인 개념이 아니라서. 하지만 인터페이스로 직접적인 의존성을 만들지 않는 습관은 테스트나 유지보수에 좋으므로 Contract에서 인터페이스를 빼는 작업만 해도 좋을듯.
아래 링크는 MVP를 설계할 때 좋은 자료
https://www.youtube.com/watch?v=ooMT69xOiKI
아래는 MVP와 테스트 코드를 작성하는 방법, TDD프로세스를 사용한다는 것은 품질높은 코드와 유지보수성을 높이는 가장 좋은 방법
https://www.youtube.com/watch?v=avcKY-_3gus
public interface View {
void setRecyclerView(List<Human> humanList);
void addRecyclerView(List<Human> humanList);
}
setRecyclerView, addRecyclerView 허허... setHumanList 이런게 어울릴듯
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.