January 1st, 2005, 05:40 PM
Could someone explain the basics of OOP and how it works to me? I've gotten a lot of things in python, but OOP is confusing to me... Could someone tell me how to use ect..
January 1st, 2005, 07:55 PM
There are a lot of details to OOP, for which see a good tutorial such as on the Python website, or http://www.freenetpages.co.uk/hp/alan.gauld/.
One way of looking at OOP which helped me is to look at OOP as a way of simplifying a program.
It simplifies a program by breaking it down into sub-programs,usually classes, each of which has its own methods or functions, and its own variables. Then each sub program can interact with other subprograms.
A very long and complex program then becomes a series of simpler, interacting programs. This has two advantages: it makes the code easier to write and to amend, like adding to a chapter in a book instead of diving into a whole book written without any subsections. The second advantage is that classes can be constructed to interact with each other, yo use each others data and methods, in a flexible way which allows the programmer to model the interactions in the real world.
For example, a class could represent a dice, and then other classes could represent players who each take a turn throwing the dice.
Hope this helps, its a bit of an unusual explanation but it was helpful to me. Try the above tutorials, they are pretty good. OOP is much easier than other approaches, especially in Python, which has very simple code anyway. It helps if you can remember that.
Originally Posted by pylon
January 2nd, 2005, 01:23 AM