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

TASK-1: Major refactor to implement design patterns #1

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

Conversation

andrewgos
Copy link

@andrewgos andrewgos commented Oct 2, 2024

What

Major refactoring to implement design patterns:

  • Repository pattern: to manage data access layering and promote SRP
  • Builder pattern: to generate school hierarchy
  • Composite pattern: to handle the previewing of the entities

Technical Decisions

  • While building the school, the courses and users are looped separately to avoid redundant loops
  • Directory aren't separated by Domain folder to avoid over-engineering the project structure
  • Local file name data.json is stored in a constant instead of environment variable as it is a read-only at the moment

Future Improvements

  • Normalise data.json to have separate "enrolments" to make it more modular and easier to maintain. It will be simpler without the need to loop through users every time we want to get enrolments. Plus, it will help if we migrate to databases and make it easier to work with ORM tools too
  • Introduce containerisation for the Dependency Injection (at the moment its all through lib.php)
  • If the complexity of the models arises, consider using Factory pattern
  • Add identifiers to the users data (ie. IDs)
  • Store the data source access data.json to be an environment variable

Tests

  • Unit tested ✅
    Screenshot 2024-10-02 at 7 56 34 pm

  • Manually tested the CRUDs ✅ (screenshots are the read-all)

    • school.php
      Screenshot 2024-10-02 at 7 58 00 pm

    • courses.php
      Screenshot 2024-10-02 at 7 58 19 pm

    • users.php
      Screenshot 2024-10-02 at 7 58 38 pm

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