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

Making the project more object oriented? #14

Open
surister opened this issue Oct 3, 2018 · 7 comments
Open

Making the project more object oriented? #14

surister opened this issue Oct 3, 2018 · 7 comments

Comments

@surister
Copy link
Contributor

surister commented Oct 3, 2018

The project is looking good bit it's getting a bit big, maybe instead of wrapping everything in functions we can start playing with some classes, that'd make the code insanely more tidy

@Pringleman83
Copy link
Owner

This is something I'm only just learning about so I don't think I could contribute much yet. If you want to try some things out though I'll create a branch for it and learn from what you do.

I was considering having a league class where each selected league would be an instance of it. The class could have special functions then to compare teams, return top scoring teams, lowest scoring teams etc.

I'd be interested to know how you'd plan to approach this and what your ideas are.

@Pringleman83
Copy link
Owner

I'm continuing my learning of object orientated code today and I'm beginning to understand how it will really help to keep all relevant code together. This is definitely something that needs to be implemented.

While I'm learning, I've started writing a class for a set of predictions. The idea I have is that each prediction that is generated will be added to the prediction set. The class will have all the methods necessary to process the information. I've written some basic code to visually display all relevant information (including stats), an alternative display method that just produces the predictions, and methods for adding and removing predictions. I would also write methods for exporting the list to excel, html, json and text.

It's gonna be a task to introduce this approach to the whole project, but it's definitely better to do it sooner rather than later.

I still think I'm going to do the fixture scraper first, but after that, I'll see how much I can work towards this issue.

@surister
Copy link
Contributor Author

surister commented Oct 5, 2018

That sounds sweet, I'll help you as much as possible.

@surister
Copy link
Contributor Author

surister commented Oct 5, 2018

This is something I'm only just learning about so I don't think I could contribute much yet. If you want to try some things out though I'll create a branch for it and learn from what you do.

I was considering having a league class where each selected league would be an instance of it. The class could have special functions then to compare teams, return top scoring teams, lowest scoring teams etc.

I'd be interested to know how you'd plan to approach this and what your ideas are.

Yeah create a branch called _experiment or something like that and we can settle some foundations

@surister
Copy link
Contributor Author

surister commented Oct 8, 2018

I think it'd be better if the experiment branch was empty, making the project more object oriented is basically rewriting the codebase in a different fashion (we'll copy paste a lot) but I find it easier having a blank canvas

@Pringleman83
Copy link
Owner

Pringleman83 commented Oct 10, 2018

Fully agree. I've deleted most of the files. I've started an 'idea' of how it could work (class_sample.py), but I'm only just learning OOC, so it might not be the best approach.
Feel free to add to it or write up some alternative ideas.

@Pringleman83
Copy link
Owner

I've written a couple of classes. One for Leagues and one for Teams. I've complicated things slightly by linking the classes. When a new Team object is instantiated, if necessary a new League object is instantiated too. Checks are performed to see if a League object already exists.

Both classes have class dictionaries keeping links to all League and Team objects. This means all objects are iterable, can be linked to other objects (like a one League to many Teams relationship) and checked for existence.

It's a little complicated (for me at least), but it should help to simplify related code.

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

2 participants