[Tutor] Whats so good about OOP ?

Alan Gauld alan.gauld at freenet.co.uk
Sun Mar 13 01:34:58 CET 2005


> 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 ?

Anything that can be done in OOP can be done without it.
But OOP makes many things easier.

But OOP only really becomes useful in bigger programs. If your biggest
program is less than 100 lines of code then you probably haven't hit
the kinds of problems that OOP solves. Between 100 and 1000 lines you
increasingly hit problems of complexity, name collisions ( two things
with the same name), and writing nearly identical code lots of times.

By the time you get over 1000 lines all of those problems are
compounded
by the fact that you can't actually keep all the details in your head
anymore! Objects help bring some sanity to the procedings.

Finally, once you get your head around the concept of objects being
like little independant programms communicating via messages then they
start to fit certain types of problem very well. THe classic case is
the GUI with each window, doalog box, button, menu etc being
independant objects, but with a lot of common functions and a lot
of inter-communication. When you coule that to the event-driven
style of most GUI toolkits then events translate easily into
inter-object messages and OOP becomes a very natural way to program
GUIs.

HTH,

Alan G
Author of the Learn to Program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Tutor mailing list