I was going to post a thread but I guess this is probably a better place for it. I think I learn better by doing so to learn python I decided to just kick off with a few projects and use stackoverflow [a lot]. None of them have been finished but I wrote them in a really noobish innefficient procedural way. Since then I have discovered the concept of OOP and watched as many beginner vids as I could find on the subject. The problem I am having is I can't seem to get my head around how I would implement OOP as a solution for one of my projects.
The main project I started was to scrape and process 'play by play' (although we wouldn't really call it that here in the UK) soccer data from the bbc website. Obviously the code is a huge mess as the data is so messy and variable to begin with. But I actually got it to work pretty well. Some games the number of shots were out by 1 or corners out by 1 but I ended up with a script that could give me a DB containing all subs made, all yellow and red cards, all penalties scored and missed, all corners, all goals, all shots on/off target. I think this is why I can't get my head around using an OOP approach - I ended up with so much different data and just muddled along in order to handle it.
I guess what I am after is either:
- some tutorial somewhere which details a more practical use of OOP than creating a person and giving him a dob and a surname.
- a good example of some code that would help me understand
- or most preferably just someone to give me an example in terms of my project of how OOP could/should be used.
A sample of the play by play (text commentary) is here -
http://www.bbc.co.uk/sport/0/football/21992293 - near the bottom of the page.
My approach was (after finding the teams, squads and game urls) was to go through the text commentary element by element stripping the the time and using that and then searching for key words such as goal, corner, etc. I am at work at the moment but I could post a the code if necessary (not sure anyone would understand it as it was such a mess and before I recognised the necessity of comments)
I am pretty sure if I could get my head around this I could write it, but for some reason this is a huge mental block for me.
/noob