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

Refactor FileUpload class by extracting file management and database operations #131

Open
gelycot opened this issue Oct 27, 2023 · 0 comments

Comments

@gelycot
Copy link

gelycot commented Oct 27, 2023

The FileUpload class currently has multiple responsibilities, including managing files and performing database operations. This leads to a violation of the Single Responsibility Principle (SRP). To improve code maintainability and readability, we should consider refactoring the class by extracting these responsibilities into separate classes.

  1. Extract File Management:

The FileUpload class is responsible for handling file uploads, deletions, and URL generation. To enhance code organization and maintainability, we propose creating a new class, FileManager, to handle all file-related operations. This separation of concerns will make the codebase cleaner and more comprehensible.

Proposed Changes:

Create a FileManager class that encapsulates file upload, deletion, and URL generation.
Modify FileUpload to use the FileManager class for file operations.
2. Extract Database Operations:

The FileUpload class currently interacts with the database directly. To adhere to the SRP and improve code modularity, we recommend creating a separate class, DatabaseManager, to handle database operations.

Proposed Changes:
Develop a DatabaseManager class that manages interactions with the database.
Refactor FileUpload to utilize the DatabaseManager for database-related tasks.

By implementing these changes, we aim to make the codebase more maintainable, testable, and in line with the principles of good software design.

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

No branches or pull requests

1 participant