How MVP Architecture Streamlines Android App Development in Suning+ Project
This article explains why the Suning+ Android app adopted the MVP pattern, details each layer's responsibilities, showcases the project’s multi‑layer structure, directory layout, and code snippets, and demonstrates how MVP reduces coupling and accelerates iterative development.
Why Use MVP Pattern
The Suning+ app faces rapidly changing business requirements and complex logic, which cause frequent UI and backend interface adjustments during development and testing. MVP helps decouple the view from the model, minimizing code changes and easing both developer and tester workloads.
What Is MVP Pattern
MVP, a Google‑originated design pattern, separates View (V) and Model (M) functions. The View handles user interaction and UI rendering, while the Model processes data. Communication between them occurs through the Presenter (P), which acts as a bridge.
MVP Pattern in Practice
In the Suning+ project, MVP was chosen to address the need for modularity and rapid iteration. The architecture includes distinct layers: frontend UI, business logic, data handling, runtime services, business framework, foundation framework, and the Android system layer.
Suning+ App Project Structure
The overall project architecture is illustrated in the diagram below, highlighting the separation of concerns across seven layers.
Directory Structure
The MVP‑based directory for the shopping‑cart confirmation page includes:
model – data processing.
presenter – business handling.
task – network requests.
ui – UI pages.
util – module‑wide utilities.
view – view‑refresh callbacks.
Overall Logic Design
Using the shopping‑cart screen as an example, the article presents class and sequence diagrams that clarify the roles and interactions of MVP components.
Code Implementation
M Layer (Model)
Network requests are encapsulated in separate Task classes. For the order‑confirmation page, a model interface (PSCShopCart2DataSource) is defined, and its implementation (PSCShopCart2Repository) invokes the Task to perform the request.
P Layer (Presenter)
The Presenter moves business logic out of Activities/Fragments, acting as the bridge between Model and View. A base presenter (PSCBaseActivityPresenter) is extended by all Activity presenters, and PSCActivityNetTask handles network callbacks and lifecycle‑aware loading indicators.
V Layer (View)
All Activities inherit from SuningActivity/SuningFragment, which bind and unbind the Presenter automatically. The IView interface defines callbacks that the View implements to receive data from the Presenter.
Conclusion
The MVP architecture effectively decouples UI, business logic, and data layers, reducing code modifications when requirements change and speeding up iteration. While MVC, MVP, and MVVM can all achieve functionality, the choice should be driven by the need to encapsulate change, promote module independence, and lower maintenance risk.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Suning Technology
Official Suning Technology account. Explains cutting-edge retail technology and shares Suning's tech practices.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
