[Tutor] OOP purpose
Sean 'Shaleh' Perry
shalehperry@attbi.com
Tue, 02 Apr 2002 10:33:46 -0800 (PST)
On 02-Apr-2002 Cameron Stoner wrote:
> Hi all,
>
> What is the purpose of OOP? Why would you use it instead of just modular
> design? I am having trouble finding the need to use it in my projects.
>
OOP is just another way to think about programming. It gives us humans a way
to think about the abstract nature of our code.
In some places it makes a whole lot of sense. For instance GUI coding.
Windows, buttons, titlebars, the mouse. These are all real objects. It
follows then to treat them as such.
Think about a file? It is a thing, you can describe it.
OOP in part is about letting the objects contain the smarts. file.readlines().
The file object knows how to retrieve its contents and give you a list of
them. It does not matter if file is really a rfc822 message, a text file, or a
parsed XML object. You think "I want the lines in the file". In procedural
coding, you would need:
read_xml_lines()
read_database_lines()
read_rfc822_lines()
etc. So you have separated the data from its controller.
Modular programming is part of OOP. In a way, the modules in strict modular
programming are simple objects.