 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
preston Guest
|
Posted: Mon Sep 19, 2005 3:28 pm Post subject: OOP versus Procedural |
|
|
Can someone explain the difference between OOP and Procedural and how it
relates to Delphi.
Since Delphi creates Forms which are objects any procedure / function is
really a method. Yet I've worked on some projects where others have
mentioned their procedural rather than OOP.
Preston
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Mon Sep 19, 2005 5:41 pm Post subject: Re: OOP versus Procedural |
|
|
| Quote: | Can someone explain the difference between OOP and Procedural and how it
relates to Delphi.
|
Well, OOP is based on objects. Procedural programming is based on
precedures / functions ;-)
Delphi is based on object pascal. In fact today the language is called
Delphi, too. So Delphi is an OOP language.
Also read the thread "Evangelizing" started ten days ago (but there were
many threads to similar topics in the past).
| Quote: | Since Delphi creates Forms which are objects any procedure / function is
really a method.
|
Right. But I think it's dangerous only to talk about forms and the VCL.
Delphi is much more. And OOP is much more. Many Delphi beginners do
"procedural programming inside of form classes", which results in god
classes and the functional decomposition antipattern, and which is a big
mistake and not what OOP stands for.
Jens
--
Jens Gruschel
http://www.pegtop.net
|
|
| Back to top |
|
 |
Corinna Guest
|
Posted: Mon Sep 19, 2005 8:14 pm Post subject: Re: OOP versus Procedural |
|
|
I'm still developing my understanding, but for now, I'd have to say that
when you write something as OOP, you focus on designing classes and the
interaction of classes. After that you worry about procedures, functions,
forms, and components. Most Delphi people seem to do it in reverse: what's
the first thing you do when you start a new program or feature? You get a
new unit, open the form designer, and place components. *That* isn't OOP.
:)
When you OOP, the first thing you do is sit down and think. Then you draw a
picture with squares and arrows, and think some more. Then you type. At
some point later, you go to the form designer... :)
Read the various threads here, even if you don't quite understand what
people are talking about, and you'll soon start to get it through osmosis
and brainwashing.
-Corinna
"Jens Gruschel" <nospam (AT) thisurldoesnotexist (DOT) com> wrote
| Quote: | Can someone explain the difference between OOP and Procedural and how it
relates to Delphi.
Well, OOP is based on objects. Procedural programming is based on
precedures / functions ;-)
|
|
|
| Back to top |
|
 |
Trevor de Koekkoek Guest
|
Posted: Mon Sep 19, 2005 8:36 pm Post subject: Re: OOP versus Procedural |
|
|
"Corinna" <schultz (AT) harlingen (DOT) isd.tenet.edu> wrote
| Quote: | You get a
new unit, open the form designer, and place components. *That* isn't OOP.
|
That isn't un-OOP either. OOP is about _how_ you think about developing,
not _whether_ you think.
| Quote: | When you OOP, the first thing you do is sit down and think.
|
You can sit down and think first or not in any paradigm. Just because you
start coding immediately in the form designer does not necessarily mean you
are producing anything less OOP. It might mean that you've done it enough
times to know what you're doing.
-Trevor
|
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Mon Sep 19, 2005 8:42 pm Post subject: Re: OOP versus Procedural |
|
|
preston wrote:
| Quote: | Can someone explain the difference between OOP and Procedural and how
it relates to Delphi.
Since Delphi creates Forms which are objects any procedure / function
is really a method. Yet I've worked on some projects where others have
mentioned their procedural rather than OOP.
|
Delphi (and its root, Object Pascal), like C++, is a hybrid language -
Object Pascal introduced OOP to the earlier Pascal language (~1988). You are
not forced to use *any* object class provided by Delphi, you can do 100%
procedural programming if you really want to (you would created windows and
controls purely via the Windows API) - but it is certainly not recommended.
When you use the designer to create forms and controls, Delphi generates
form and control classes for you, so you are using and benefiting from OOP
to that extent, but that does not make you an OO programmer. To get the most
from OO, one has to think about and design one's own classes - the classes
that actually perform the work in your application, not just the
IDE-generated classes and events. You will invariably hear this referred to
as business classes, or the business domain, and this is where UML and
modelling tools come into play.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
Light is faster than sound, which is why some folks appear bright
before they speak.
|
|
| Back to top |
|
 |
Jim Cooper Guest
|
Posted: Mon Sep 19, 2005 9:18 pm Post subject: Re: OOP versus Procedural |
|
|
| Quote: | Then you draw a picture with squares and arrows
|
You can often skip this step I rarely do this unless I am developing an idea
with other programmers. UML is a nice communications tool, but I don't find it
particularly relevant if it's just me working on the code.
Cheers,
Jim Cooper
__________________________________________
Jim Cooper [email]jcooper (AT) tabdee (DOT) ltd.uk[/email]
Tabdee Ltd http://www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
__________________________________________
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Mon Sep 19, 2005 11:09 pm Post subject: Re: OOP versus Procedural |
|
|
| Quote: | I'm still developing my understanding, but for now, I'd have to say that
when you write something as OOP, you focus on designing classes and the
interaction of classes. After that you worry about procedures, functions,
forms, and components. Most Delphi people seem to do it in reverse: what's
the first thing you do when you start a new program or feature? You get a
new unit, open the form designer, and place components. *That* isn't OOP.
|
I fully agree, and that's what I tried to say. Don't build your
application around your forms. Of course the main form of most Windows
applications has some importance. But IMO forms should be used to
visualize a model, that's the core of the application. Just what you
said: after designing this core, which usually consists of many, many
classes, probably separated into several layers, and after finding
interfaces and structures for interaction, it's time to create a GUI to
visualize your business objects or whatever has to be visualized. It can
be done the other way round, too. But there is the danger of functional
decomposition (in Delphi it often starts with putting business logic
into GUI event handlers), so one has to be extremely careful with this
approach.
| Quote: | Well, OOP is based on objects. Procedural programming is based on
precedures / functions
|
That wasn't meant too seriously (although there is some truth in it).
Answers to my last paragraph probably would be the beginning of a much
better discussion. But then again it's my fault. Why do I write such
statements?
Jens
--
Jens Gruschel
http://www.pegtop.net
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Mon Sep 19, 2005 11:13 pm Post subject: Re: OOP versus Procedural |
|
|
| Quote: | You get a
new unit, open the form designer, and place components. *That* isn't OOP.
:)
That isn't un-OOP either.
|
Right, it *is* OOP. And it is RAD. The other question is: is it helpful?
I think it isn't. At least not for applications that exceed some size.
| Quote: | You can sit down and think first or not in any paradigm.
|
Again that's true. But experience showed me, that thinking sometimes is
helpful. At least I feel better when thinking a bit.
Jens
--
Jens Gruschel
http://www.pegtop.net
|
|
| Back to top |
|
 |
Rudy Velthuis [TeamB] Guest
|
Posted: Mon Sep 19, 2005 11:16 pm Post subject: Re: OOP versus Procedural |
|
|
At 22:36:50, 19.09.2005, Trevor de Koekkoek wrote:
| Quote: |
"Corinna" <schultz (AT) harlingen (DOT) isd.tenet.edu> wrote in message
news:432f1bc6$1 (AT) newsgroups (DOT) borland.com...
You get a
new unit, open the form designer, and place components. That isn't
OOP. :)
That isn't un-OOP either. OOP is about how you think about developing,
not whether you think.
When you OOP, the first thing you do is sit down and think.
You can sit down and think first or not in any paradigm. Just because
you start coding immediately in the form designer does not necessarily
mean you are producing anything less OOP. It might mean that you've
done it enough times to know what you're doing.
|
I prefer to make the GUI first, and then slowly write the code behind it.
That does not mean I don't separate GUI from logic, I do. But I find it
easier to structure my thoughts that way, i.e. beginning from the GUI,
instead of the tedious search for necessary structures and classes. I
find that when I start implementing, I revise my design many times
anyway, so why not start at the (for me) easier side and work top down?
--
Rudy Velthuis [TeamB] http://velthuis.homepage.t-online.de
"The pen is mightier than the sword, and considerably easier to
write with." -- Marty Feldman.
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Mon Sep 19, 2005 11:21 pm Post subject: Re: OOP versus Procedural |
|
|
| Quote: | UML is a nice communications tool, but I
don't find it particularly relevant if it's just me working on the code.
|
But then you more or less have an UML like structure in your mind. In my
opinion UML is an idea to find a common way to visualize what we (good
developers I hope) have in mind. Of course our minds are not the same,
and that's a good thing I think. So what you have in mind probably isn't
an UML diagram. But UML does visualize OOP in some way, and your mind
does visualize OOP, too. If your are a good OOP programmer you probably
won't even notice that. You don't think about it, if you've done it a
thousand times. You do it.
Jens
--
Jens Gruschel
http://www.pegtop.net
|
|
| Back to top |
|
 |
Rudy Velthuis [TeamB] Guest
|
Posted: Mon Sep 19, 2005 11:23 pm Post subject: Re: OOP versus Procedural |
|
|
At 19:41:22, 19.09.2005, Jens Gruschel wrote:
| Quote: | Can someone explain the difference between OOP and Procedural and how
it relates to Delphi.
Well, OOP is based on objects. Procedural programming is based on
precedures / functions
|
One other way to look at it:
OOP sees data as the active item. Data has properties and capabilities in
the form of methods and properties, and knows how to interact with other
data. Data rulez.
Procedural programing sees code as the active item, and data is just
something that is processed by it and passed around. Code rulez.
IOW, in OOP, data is active, while in procedural programming it is
passive.
--
Rudy Velthuis [TeamB] http://velthuis.homepage.t-online.de
"The only rules comedy can tolerate are those of taste, and the only
limitations those of libel." -- James Thurber (1894-1961)
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Mon Sep 19, 2005 11:29 pm Post subject: Re: OOP versus Procedural |
|
|
| Quote: | I prefer to make the GUI first, and then slowly write the code behind it.
That does not mean I don't separate GUI from logic, I do.
|
In practice I think often a mixture of top down and bottom up is used.
You create parts of the GUI, probably without much functional logic
behind it. Then maybe you write some low level classes. Later you put
things together. It's a nice theory to start bottom up, write test beds
for all classes, and build the GUI at last. As long as GUI and logic is
separated IMO it's alright (and of course I know you are not the one I
have to tell this).
Jens
--
Jens Gruschel
http://www.pegtop.net
|
|
| Back to top |
|
 |
Jens Gruschel Guest
|
Posted: Mon Sep 19, 2005 11:36 pm Post subject: Re: OOP versus Procedural |
|
|
| Quote: | OOP sees data as the active item. Data has properties and capabilities in
the form of methods and properties, and knows how to interact with other
data. Data rulez.
Procedural programing sees code as the active item, and data is just
something that is processed by it and passed around. Code rulez.
IOW, in OOP, data is active, while in procedural programming it is
passive.
|
That's a very, very good explaination. At least data seems to be active
in OOP. And from a design point of view that's how you have to look at it.
Jens
--
Jens Gruschel
http://www.pegtop.net
|
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Tue Sep 20, 2005 2:10 am Post subject: Re: OOP versus Procedural |
|
|
Jim Cooper wrote:
| Quote: |
You can often skip this step I rarely do this unless I am
developing an idea with other programmers. UML is a nice
communications tool, but I don't find it particularly relevant if
it's just me working on the code.
|
This is an interesting to me. I was late coming to use UML because I
dismissed it as just more documentation I have to do, but gradually learned
to use it a little for the reason you say - to help me show people ideas on
how I propose things to work. At the same time I have often scribbled
circles and lines on paper for years while trying to gel ideas in my mind,
so I started using a UML tool instead. Now my primary use is precisely for
my own benefit, I found it much more effective than paper and pencil for
helping me work out my classes and relationships. I really only rarely use
it for purposes of documentation or to show clients.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"We've all heard that a million monkeys banging on a million
typewriters will eventually reproduce the entire works of Shakespeare.
Now, thanks to the Internet, we know this is not true." - Robert
Wilensky
|
|
| Back to top |
|
 |
Grandy Guest
|
Posted: Tue Sep 20, 2005 4:34 am Post subject: Re: OOP versus Procedural |
|
|
| Quote: | Delphi is based on object pascal. In fact today the language is called
Delphi, too. So Delphi is an OOP language.
|
That's strange.... there is no problem to work in Delphi without any classes
at all, VCL included. So Delphi is much more then just another OOP language.
And i have seen a number of quite big projects written in Delphi, where the
first rule was "no classes".
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|