Skip to content

Refactored so endpoint details are managed in-controller #1

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

Merged
merged 2 commits into from
Oct 30, 2023
Merged

Refactored so endpoint details are managed in-controller #1

merged 2 commits into from
Oct 30, 2023

Conversation

ssddanbrown
Copy link
Contributor

👋 Hello, I was playing around with the codebase, using this wonderful little app to learn some dart/flutter.

The big if/else blocks, and different arrays, caught my eye when browsing since they looked like something that might be tricky to manage over time, with references as strings in multiple places.
As a little task to learn dart, I thought I'd have a go at implementing an alternative option to managing the endpoints/name of the controllers, so that details only have to be managed in a singular place in a somewhat abstract way.

This PR changes things up so that the controllers themselves manage their name and provided methods.
There's then an Endpoints class that manages things at a high level, with a list of controllers.
With this setup, additional endpoints can be added all within the controller. No changes to others files are needed.
If there's a new set of endpoints (with a new controller), it just needs to be added to the array Endpoints class.

Seems to work from my quick bit of testing in an Android emulator. Have tried to keep everything else (including the endpoint/category order) the same as before. Thought I'd create a PR after doing this in-case you'd like this kind of setup.
Please don't feel any pressure to merge this PR though if you're not fond of this approach, this kind of thing can be a matter of preferences, and this is your project. I'm just happy to have learnt some dart via this process.
Also, I have no clue on dart/flutter conventions, so I may not have followed them. If I've done anything you don't understand, feel free to ask.

This changes the setup of things so that controllers manage meta-details
like the endpoint category name and the methods provided, rather than
those being managed in other parts of the app.
This prevents the need of managing references of these details across
other files in the app, since these details can be accessed dynamically
and programatically via the controllers.
An Endpoints class handles references to all controllers and the high
level actions to access the information of these.
@chris-devel0per
Copy link
Owner

Hey Dan,

Thanks a lot for looking into this! I was actually trying to achieve something similar to what you've coded, but I only spent a few hours on it, mainly focusing on the API functions. Your PR is a big help, and I'll give it a try. Once I've tested it and everything seems good, I'll go ahead and approve this PR. Appreciate it!

There was a wrong link. It linked to the image gallery
@chris-devel0per
Copy link
Owner

It looks good! Except for one little wrong url. In the chapter controller. I fixed it!
THANK FOR YOUR NEW VERSION! I LOVE IT!

@chris-devel0per chris-devel0per merged commit b80f0d6 into chris-devel0per:main Oct 30, 2023
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.

2 participants