[Tutor] Whats so good about OOP ?
kent37 at tds.net
Sat Mar 12 16:00:24 CET 2005
Mark Kels wrote:
> Hi list !
> I want to know whats so great in OOP...
> I have learned some of it, but I don't understand why everybody like
> it so much...
- One of the great challenges in programming is managing complexity. A program of any size is too
complex to hold in your brain all at once. Techniques for breaking up a program into understandable
pieces are essential. OOP gives you a way to break up a program into self-contained bundles of code
and data that become building blocks for other pieces of the program. OOP lets you create
abstractions that become components or tools for other abstractions.
- OOP enables many techniques for organizing code and reducing duplication. Many design patterns use
cooperating objects. For example Composite, Decorator, Facade, Proxy, Chain of Responsibility,
Command, Mediator, Observer, State, Strategy, Template Method... :-)
> Can anyone give me an example for a task that could be done only with
> OOP or will be much simpler to do with it ?
See this essay for some simple examples:
Most modern GUI toolkits are heavily object-oriented including Tkinter and wxPython. Having a widget
as a clear abstraction is very useful.
Much of the Python standard library is object-oriented. Since Python offers a choice between
object-oriented and procedural style, if a library module is implemented with objects then
presumably the author thought it would be simpler that way.
Of course Python is profoundly object-oriented in its core - strings, integers, lists and dicts are
all objects providing simple abstractions of complex behaviour.
More information about the Tutor