0% found this document useful (0 votes)
177 views3 pages

Clean_Architecture_Interview_QA

Clean Architecture is a design pattern that organizes code into layers to enhance scalability, testability, and maintainability, focusing on the business domain. The main layers include Presentation, Domain, Data, and optionally Core, with each layer having specific responsibilities. Key concepts include entities, use cases, and repository interfaces, which help decouple business logic from data sources and external dependencies.

Uploaded by

Meet Parekh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
177 views3 pages

Clean_Architecture_Interview_QA

Clean Architecture is a design pattern that organizes code into layers to enhance scalability, testability, and maintainability, focusing on the business domain. The main layers include Presentation, Domain, Data, and optionally Core, with each layer having specific responsibilities. Key concepts include entities, use cases, and repository interfaces, which help decouple business logic from data sources and external dependencies.

Uploaded by

Meet Parekh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Clean Architecture Interview Questions & Answers

1. What is Clean Architecture and why do we use it?

Clean Architecture is a design pattern that separates code into layers with clear responsibilities. It improves

scalability, testability, and maintainability by focusing on the business domain.

2. What are the main layers of Clean Architecture?

1) Presentation 2) Domain 3) Data 4) Core (optional). Each layer has a distinct role.

3. What is the responsibility of the domain layer?

Contains Entities, Use Cases, and Repository Interfaces. It holds business logic and is independent of

external dependencies.

4. Why do we separate the data layer from the domain layer?

To keep the domain independent and make it easy to replace or modify data sources without affecting

business logic.

5. What is an entity in Clean Architecture?

A plain Dart class representing a business object, free from dependencies like Dio or JSON handling.

6. What is a use case and where does it belong?

It defines a business operation (e.g., GetAllProducts) and resides in the domain layer.

7. What is the purpose of a repository interface?

To define a contract for data operations without revealing implementation details.

8. Why do we need the repository to be abstract in the domain layer?

To decouple domain logic from actual data sources and support mocking in tests.

9. Where should third-party packages be used?


Clean Architecture Interview Questions & Answers

Only in the data layer or core layer - never in domain or presentation.

10. What is the role of a data source in Clean Architecture?

Directly interacts with remote APIs or local storage. Converts data to models.

11. What's the difference between a remote and local data source?

Remote connects to web APIs, local uses local storage (e.g., Hive, SQLite).

12. How do you inject dependencies in a Clean Architecture app?

Using tools like GetIt for registering use cases, BLoCs, and services for inversion of control.

13. Why is the domain layer not allowed to depend on data or presentation?

To keep business logic stable and unaffected by UI or data changes.

14. What is an anti-pattern in bad architecture?

Fat UI, tight coupling, using Dio in BLoC, or skipping proper separation of layers.

15. How do you mock a repository for testing?

Use a mock class and simulate return values using packages like mocktail or Mockito.

16. Can you explain the data flow from UI to data source?

UI -> BLoC -> Use Case -> Repository -> Data Source -> API -> back to UI via entity.

17. What's the difference between entity and model?

Entities are domain objects, Models are used for JSON parsing and API logic in the data layer.

18. Where should DTOs be placed?

In the data layer - typically as models handling fromJson/toJson conversions.


Clean Architecture Interview Questions & Answers

19. What's the difference between BLoC and use case?

BLoC handles UI logic and state. Use case executes domain logic (e.g., GetAllProducts).

20. Why is the data layer dependent on the domain layer?

Because it implements domain interfaces and converts models to entities, not vice versa.

You might also like