65 lines
3.4 KiB
Markdown
65 lines
3.4 KiB
Markdown
# SOLID Refactoring Plan for Pipefy Project
|
|
|
|
This document outlines a step-by-step plan to refactor the Pipefy project to comply with SOLID principles. Check off each step as you complete it.
|
|
|
|
---
|
|
|
|
## 1. Preparation
|
|
- [x] Review current codebase and identify major responsibilities in `Program.cs` and `data.cs`.
|
|
- **Program.cs**: Handles configuration loading, user interaction, API communication, JSON deserialization, database access, data comparison, record creation, console output, timer logic, and orchestration.
|
|
- **data.cs**: Contains data models for API responses, business entities, and configuration. No business logic.
|
|
- [x] List all external dependencies (API, database, configuration).
|
|
- **Pipefy API**: Used for fetching and creating records (GraphQL over HTTP, requires API token and table IDs).
|
|
- **Access Database**: Used for reading local records (via OleDb, requires DB path and password).
|
|
- **Configuration**: Loaded from `appsettings.json` (contains DB path, API token, API URL, table IDs).
|
|
- **NuGet Packages**: Microsoft.Extensions.Configuration, Newtonsoft.Json, System.Data.OleDb, etc.
|
|
|
|
## 2. Project Structure
|
|
- [x] Create folders: `Services/`, `Models/`, `Mappers/` (if needed).
|
|
- `Services/`: For service and interface implementations (API, DB, config, business logic).
|
|
- `Models/`: For data models (move from `data.cs`).
|
|
- `Mappers/`: For mapping logic between API/DB and domain models (optional, if mapping grows).
|
|
- [ ] Integrate ORM (e.g., Entity Framework Core) to abstract DB access and ease future DB changes. (Next step)
|
|
- [x] Move or create files as needed for separation of concerns.
|
|
|
|
## 3. Single Responsibility Principle (SRP)
|
|
- [x] Extract configuration loading into `IConfigurationService` and `ConfigurationService`.
|
|
- [x] Extract Pipefy API logic into `IPipefyApiService` and `PipefyApiService`.
|
|
- [x] Extract database logic into `IDatabaseService` and `DatabaseService`.
|
|
- [x] Extract data mapping logic into `IDataMapper` and `DataMapper`.
|
|
- [x] Extract business logic (comparison, orchestration) into `IBusinessLogicService` and `BusinessLogicService`.
|
|
- [x] Remove static business/data methods from `Program.cs` and ensure all logic is in services.
|
|
|
|
## 4. Open/Closed Principle (OCP)
|
|
- [x] Define interfaces for each service (already done: IConfigurationService, IPipefyApiService, IDatabaseService, IDataMapper, IBusinessLogicService).
|
|
- [x] Ensure new data sources or logic can be added by implementing new classes, not modifying existing ones (all main logic is now behind interfaces and DI).
|
|
|
|
## 5. Liskov Substitution Principle (LSP)
|
|
- [ ] Ensure all service implementations can be replaced by their interfaces without breaking functionality.
|
|
|
|
## 6. Interface Segregation Principle (ISP)
|
|
- [ ] Keep interfaces focused and small.
|
|
- [ ] Split large interfaces if needed.
|
|
|
|
## 7. Dependency Inversion Principle (DIP)
|
|
- [x] Refactor `Program.cs` to depend on abstractions (interfaces), not concrete classes.
|
|
- [x] Use dependency injection to provide services to the main program.
|
|
|
|
## 8. Testing
|
|
- [ ] Add or update unit tests for each service.
|
|
- [ ] Ensure business logic is testable in isolation.
|
|
|
|
## 9. Documentation
|
|
- [ ] Update this plan as you progress.
|
|
- [ ] Document new structure and usage in a `README.md` or similar file.
|
|
|
|
---
|
|
|
|
**Progress Tracking:**
|
|
- Mark each step as complete (`[x]`) as you finish it.
|
|
- Add notes or decisions below each step if needed.
|
|
|
|
---
|
|
|
|
_Last updated: May 16, 2025_
|