Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Book Listing Coding Challenger Implemented - MVP #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vishnu666av
Copy link

OUTPUT:

Home

info

This PR implements the Android Books List Application using a structured and modular architecture, specifically the Model-View-Presenter (MVP) pattern, alongside dependency injection with Dagger and Data Binding for UI updates. This approach ensures scalability, testability, and separation of concerns across the application.

Architecture Overview

  • MVP (Model-View-Presenter): This project utilizes the MVP architecture to separate the presentation layer from the business logic.

  • View: Defines the contract for UI updates, like displaying data or errors.

  • Presenter: Acts as an intermediary that handles UI logic, interacts with the Use Case, and updates the View based on the model's response.

  • Model: Contains business logic and provides data to the Presenter via repository and use case layers.

Classes Overview

  • BooksView: The interface that declares UI update methods (showLoading, displayBooks, and showError) for the Books List screen.

  • BooksListActivity: Implements BooksView, sets up RecyclerView with an adapter and item decorations, and binds UI actions. It utilizes Data Binding to display data and handle view visibility through observable fields.

  • BooksPresenter: Interacts with the View and the Use Case (GetBooksUseCase) to fetch the data. Manages UI state by showing loading indicators and presenting books or errors as appropriate.

  • BooksRepository: Serves as the data provider, fetching data from ApiService. It handles success and failure states for API responses, ensuring that network errors are managed smoothly.

  • GetBooksUseCase: A use case class encapsulating the logic to fetch the books list from the repository. It standardizes data flow into the Presenter.

    Models:

  • BookResponse, BookResults, and Book represent the data structure returned by the API.

  • Isbn and BuyLink capture book-specific identifiers and purchase links.

  • ApiService: Retrofit-based API service that manages HTTP requests, particularly for fetching the list of books.

  • Constants: Holds configuration constants, including the API key.

  • SpacingItemDecoration: A custom RecyclerView ItemDecoration for setting item spacing and drawing separators between items in the book list.

  • MyApplication: The custom Application class that initializes Dagger’s AppComponent to manage dependencies.

Additional Information

  • Dagger for Dependency Injection: This ensures all dependencies are efficiently managed, promoting modularity and testability.

  • Retrofit for Networking: A REST client used for API calls.

  • Data Binding: Simplifies the process of binding UI components to data sources, enabling dynamic updates without manual intervention.

Testing Strategy
This PR includes unit tests to ensure the integrity of the app’s core components:

BooksPresenter Tests: Verifies the presenter's behavior in various scenarios, including:

  • Successful data retrieval, where it updates the view with book data.

  • API failures, where it displays error messages appropriately.

  • Loading indicators, ensuring they are displayed and hidden at the correct times.

Repository Tests: Simulates API responses to confirm the repository correctly handles:

  • Success responses, by returning valid data.

  • Failure responses, by throwing appropriate exceptions.

These tests ensure that the app responds accurately to both expected and edge cases, helping to maintain a high standard of reliability.

For additional details on setup, usage, and architecture, please refer to the README.md file in this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant