Main Page | Report this Page
Computers Forum Index  »  Computer - Object  »  Can I have Interface & Inheritance together for same...
Page 1 of 2    Goto page 1, 2  Next

Can I have Interface & Inheritance together for same...

Author Message
...
Posted: Tue May 05, 2009 9:18 pm
Guest
my draft idea..

[InterfaceProduct]
-int Sample
+SampleMethod

[Product]
-Price
+GetPrice

[Seat]
-SeatNo
+GetSeatNo

[Room]
-RoomNo
+GetRoomNo

[Order]
- Array<Product>

and i was thinking..

why i use inheritance:
- because I have an [Order] class which need to include [Product] as
part of the field/property inside, which could be any of the product
type.

why i use interface:
- because I not sure the future customer will introduce more products
into the system, which I should be ready to extend the system?

but, is it valid? is that a good OO design? many thanks!
 
Phlip...
Posted: Wed May 06, 2009 1:54 am
Guest
Quote:
why i use interface:
- because I not sure the future customer will introduce more products
into the system, which I should be ready to extend the system?

but, is it valid? is that a good OO design? many thanks!

Never write speculative code. Instead, write lots of unit tests on your
existing behavior.

When the future actually arrives (in the current climate "IF" it arrives!),
you will be ready with minimal code and lots of tests, so you can easily
introduce an interface, if your customer indeed introduces more products.

However, if they ask for a different feature, then your interface WON'T GET
IN THE WAY. Keeping your codebase as light as possible, while it grows in
features, is mission-critical.

And if you can find a real reason with the _current_ feature requirements to
introduce the interface, go for it! It's just that some of us are starting
to realize that unit tests are much more important than proactive
designing...
 
...
Posted: Wed May 06, 2009 8:15 am
Guest
On May 6, 5:54 am, "Phlip" <phlip2... at (no spam) gmail.com> wrote:
Quote:
why i use interface:
- because I not sure the future customer will introduce more products
into the system, which I should be ready to extend the system?

but, is it valid? is that a good OO design? many thanks!

Never write speculative code. Instead, write lots of unit tests on your
existing behavior.

When the future actually arrives (in the current climate "IF" it arrives!),
you will be ready with minimal code and lots of tests, so you can easily
introduce an interface, if your customer indeed introduces more products.

However, if they ask for a different feature, then your interface WON'T GET
IN THE WAY. Keeping your codebase as light as possible, while it grows in
features, is mission-critical.

And if you can find a real reason with the _current_ feature requirements to
introduce the interface, go for it! It's just that some of us are starting
to realize that unit tests are much more important than proactive
designing...

Wow nice, that's something I never think of.

OO is still new to me, lots more to learn here.

Thanks!
 
H. S. Lahman...
Posted: Wed May 06, 2009 11:02 pm
Guest
Responding to s.i.g...

Quote:
my draft idea..

[InterfaceProduct]
-int Sample
+SampleMethod

[Product]
-Price
+GetPrice

[Seat]
-SeatNo
+GetSeatNo

[Room]
-RoomNo
+GetRoomNo

[Order]
- Array<Product

and i was thinking..

why i use inheritance:
- because I have an [Order] class which need to include [Product] as
part of the field/property inside, which could be any of the product
type.

I wouldn't use generalization when a simple association will do. Why
would an [Order] intrinsically have a [Product] as part of its
definition? Products are not orders; they are associated with orders.
The association instantiation determines which particular Products are
associated with a given Order instance.

BTW, note that your notion of [Order] is a pure 3GL construct. It is not
even implementable in OOA/D because object attribute ADTs must be
scalars. So the closest you can get to expressing your order in OOA/D is
the '*' in

1 R1 identifies *
[Order] ------------------------- [Product]

OTOH, in practice it is rather likely that one would need to use
generalization for [Product] -- assuming Seats and Rooms are
intrinsically Products (i.e., an is-a relation exists in the problem
space for that problem space's notion of 'product').

Quote:

why i use interface:
- because I not sure the future customer will introduce more products
into the system, which I should be ready to extend the system?

The whole point of the OO paradigm is to make software maintainable.
That is, one depends on the OO paradigm to facilitate change. Corollary:
solve the problem in hand, not one that *might* appear in the future. If
the future brings a new problem, it should be easy to modify the
existing solution to resolve it at that time.

IOW, don't use polymorphic interfaces just because they are there. Only
use them if they are directly relevant to the problem in hand. [In this
case a polymorphic interface for [Product] is likely to be useful, but
that has nothing to do with [Order]. Thus a client of a Product would
navigate the association path *through* an Order to get to that interface.]



--
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer

H. S. Lahman
H.lahman at (no spam) verizon.net
software blog: http://pathfinderpeople.blogs.com/hslahman/index.html
 
...
Posted: Mon May 11, 2009 7:50 am
Guest
Thanks for all the informative reply.

Guess my concept of OO isn't strong enough. No doubt I still trap in
the era of structural/procedural programming + RDBMS (vb, php, mysql
etc) and treats class design like rdbms table design.

I've learned java (plus some OO with PHP) before and know the benefits
of OO. And that's why I want to get rid of the old programming style
and head towards OO (with C# now).

And for now, I think I'll leave the subject first and build my
fundamental instead.

It would be great appreciation if someone would recommend me some good
books or url of OO? Thanks!
 
H. S. Lahman...
Posted: Mon May 11, 2009 6:48 pm
Guest
Responding to s.i.g...

Quote:
Guess my concept of OO isn't strong enough. No doubt I still trap in
the era of structural/procedural programming + RDBMS (vb, php, mysql
etc) and treats class design like rdbms table design.

Yes. To do OO development properly you need to forget everything you
ever learned about P/R.

Quote:

I've learned java (plus some OO with PHP) before and know the benefits
of OO. And that's why I want to get rid of the old programming style
and head towards OO (with C# now).

Alas, learning the OO paradigm by coding in an OOPL is a very poor way
to learn the paradigm. The OOPLs are still 3GLS and they make a lot of
compromises with the hardware computational models. Worse, they are
still inherently procedural in nature because they are 3GLs. So for
converts to OO development they make it very easy to map procedural
techniques onto the OOPL syntax.

[You don't need to create designs with bubble & arrows for every
application; you can go directly to writing OOPL code. But you need to
understand the design principles behind the bubble & arrows before doing
that.]

My advice would be to take a break and read a couple of books on OOA/D.
The "Books" category of by blog provides some advice on finding a good
OOA/d book.


--
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer

H. S. Lahman
H.lahman at (no spam) verizon.net
software blog: http://pathfinderpeople.blogs.com/hslahman/index.html
 
John \"Z-Bo\" Zabroski...
Posted: Tue May 12, 2009 2:38 am
Guest
On May 11, 7:54 pm, "Daniel T." <danie... at (no spam) earthlink.net> wrote:
Quote:
"H. S. Lahman" <h.lah... at (no spam) verizon.net> wrote:

Responding to s.i.g...

Guess my concept of OO isn't strong enough. No doubt I still trap in
the era of structural/procedural programming + RDBMS (vb, php, mysql
etc) and treats class design like rdbms table design.

Yes. To do OO development properly you need to forget everything you
ever learned about P/R.

It's not all that bad. OO is not revolutionary, it's evolutionary.
Anybody who has a solid grasp of the modular programming paradigm will
feel quite at home in an OO context. They won't have very much to learn
at all.

I think that good class models have a structure similar to that seen
in well-structured relational databases, owing to the normal forms.
Schlaer and Mellor were the ones who really advocated this view point.

So a lot of what you know about relational model, i.e. how to design
tables, can apply to OO. However, OO is a huge break from procedural
programming.
 
Daniel T....
Posted: Tue May 12, 2009 3:54 am
Guest
"H. S. Lahman" <h.lahman at (no spam) verizon.net> wrote:
Quote:
Responding to s.i.g...

Guess my concept of OO isn't strong enough. No doubt I still trap in
the era of structural/procedural programming + RDBMS (vb, php, mysql
etc) and treats class design like rdbms table design.

Yes. To do OO development properly you need to forget everything you
ever learned about P/R.

It's not all that bad. OO is not revolutionary, it's evolutionary.
Anybody who has a solid grasp of the modular programming paradigm will
feel quite at home in an OO context. They won't have very much to learn
at all.

Quote:
I've learned java (plus some OO with PHP) before and know the benefits
of OO. And that's why I want to get rid of the old programming style
and head towards OO (with C# now).

Alas, learning the OO paradigm by coding in an OOPL is a very poor way
to learn the paradigm.

I would qualify that somewhat. Learning the OO paradigm using a single
3GL language is harder than learning it if you understand multiple
languages.


Quote:
The OOPLs are still 3GLS and they make a lot of
compromises with the hardware computational models.

Not completely true. Some languages refuse to make those compromises,
they have a harder time in the marketplace because of it though (I'm
thinking primarily of Smalltalk here.)

Quote:
My advice would be to take a break and read a couple of books on OOA/D.
The "Books" category of by blog provides some advice on finding a good
OOA/d book.

I suggest "Object-Oriented Design Heuristics" as a good starting point.
 
Daniel T....
Posted: Tue May 12, 2009 4:55 pm
Guest
"John \"Z-Bo\" Zabroski" <johnzabroski at (no spam) gmail.com> wrote:
Quote:
On May 11, 7:54 pm, "Daniel T." <danie... at (no spam) earthlink.net> wrote:
"H. S. Lahman" <h.lah... at (no spam) verizon.net> wrote:

Responding to s.i.g...

Guess my concept of OO isn't strong enough. No doubt I still trap in
the era of structural/procedural programming + RDBMS (vb, php, mysql
etc) and treats class design like rdbms table design.

Yes. To do OO development properly you need to forget everything you
ever learned about P/R.

It's not all that bad. OO is not revolutionary, it's evolutionary.
Anybody who has a solid grasp of the modular programming paradigm will
feel quite at home in an OO context. They won't have very much to learn
at all.

I think that good class models have a structure similar to that seen
in well-structured relational databases, owing to the normal forms.
Schlaer and Mellor were the ones who really advocated this view point.

Pushing common data up into common base classes in the name of
"normalization" is one of the biggest problems I see in beginner's OO
practice. You can get away with it in a dynamic typed language, because
the inheritance relationship doesn't create as tight a coupling. but...

When dealing with a static typed language, things are a little more
involved, because inheritance serves double duty. Whenever you have one
construct that represents more than one abstract concept things get
problematic. (That problem started this thread.)

Quote:
So a lot of what you know about relational model, i.e. how to design
tables, can apply to OO. However, OO is a huge break from procedural
programming.

I don't think so. A class is full of procedural code, all OO does is
wrap that procedural code in a higher level of abstraction so it is
easier to deal with. The higher level of abstraction that is most often
used is modularization, and that has been around long before OO. The
other abstraction is the interface, which any operating system
programmer can tell you about, they routinely use them for driver
pug-ins for example.

All the OO paradigm does (imho) is make modularization easier and
interfaces pervasive.
 
H. S. Lahman...
Posted: Tue May 12, 2009 7:13 pm
Guest
Responding to Daniel T....

Quote:
Guess my concept of OO isn't strong enough. No doubt I still trap in
the era of structural/procedural programming + RDBMS (vb, php, mysql
etc) and treats class design like rdbms table design.
Yes. To do OO development properly you need to forget everything you
ever learned about P/R.

It's not all that bad. OO is not revolutionary, it's evolutionary.
Anybody who has a solid grasp of the modular programming paradigm will
feel quite at home in an OO context. They won't have very much to learn
at all.

Start with collaboration based on Do This rather than I'm Done and it
goes downhill from there.

Quote:

I've learned java (plus some OO with PHP) before and know the benefits
of OO. And that's why I want to get rid of the old programming style
and head towards OO (with C# now).
Alas, learning the OO paradigm by coding in an OOPL is a very poor way
to learn the paradigm.

I would qualify that somewhat. Learning the OO paradigm using a single
3GL language is harder than learning it if you understand multiple
languages.

They are all bad because...

Quote:
The OOPLs are still 3GLS and they make a lot of
compromises with the hardware computational models.

Not completely true. Some languages refuse to make those compromises,
they have a harder time in the marketplace because of it though (I'm
thinking primarily of Smalltalk here.)

The Big Three characteristics of 3GLs are: procedural block structuring,
stack-based scope, and procedural message passing. All the OOPLs,
including Smalltalk, still depend on those things. (Though some, like
Smalltalk, do a better job of hiding it by employing less obvious syntax.)

But the real problem with the 3GLs is physical coupling due to the use
of type systems to deal with the Big Three. That introduces the need for
refactoring _just to make the 3GL code more maintainable_ (as opposed to
solving the customer's problem). That sort of refactoring after the
logic is working correctly is totally unnecessary at the 4GL level of
OOA/D. Worse, at the OOP level it can lead to architectural drift in the
long term.

Every OOPL employs a sophisticated type system. So in that sense the
OOPLs are even worse than the procedural languages; the type system
itself is a major compromise with the hardware computational models.



--
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer

H. S. Lahman
H.lahman at (no spam) verizon.net
software blog: http://pathfinderpeople.blogs.com/hslahman/index.html
 
H. S. Lahman...
Posted: Tue May 12, 2009 9:40 pm
Guest
Responding to Daniel T....

Quote:
Pushing common data up into common base classes in the name of
"normalization" is one of the biggest problems I see in beginner's OO
practice. You can get away with it in a dynamic typed language, because
the inheritance relationship doesn't create as tight a coupling. but...

When dealing with a static typed language, things are a little more
involved, because inheritance serves double duty. Whenever you have one
construct that represents more than one abstract concept things get
problematic. (That problem started this thread.)

I see the problem somewhat differently and from that perspective I don't
think it has much to do with statically vs. dynamically bound OOPLs. For
example, we've both seen a lot of LSP debates online that were based on
models like:

[Rectangle]
+ majorSideLength
+ minorSideLength
+ behaviorX
A
|
+-------------...
|
[Square]
+ sideLength

The debaters will go on an on about arcane implementations of behaviorX
that break and how to specify that behavior to avoid LSP issues. Yet
they never seem notice that the real problem is a basic generalization
error in defining the side length knowledge attributes. IOW, they don't
seem to think that LSP applies to knowledge as well as behavior.

Because of the basic set focus of OO generalization, any member of the
[Rectangle] set *must* have a majorSideLength and a minorSideLength.
That instantly creates at least two 3NF violations for any member of the
[Square] subset. It also violates the basic is-a notion of OO
generalization because the knowledge semantics is fundamentally
different so that a Square is something quite different than a Rectangle
and can't be Rectangle.

[Note that the problem doesn't get any better if one leaves off
Square::sideLength. If both majorSideLength and minorSideLength are set
to the same value, one has a 3NF violation because one value is
dependent on the other rather then the Square identity. If one leaves
one value uninitialized, one has a 1NF violation because the data domain
is not simple.]

Of course if one did the generalization correctly, one would end up with
something like:

[RegularPolygon]
A
|
+-----------+-----------+
| |
[4Sided] [MultiSided]
A A
| |
+-----+----------+---... ...
| |
[Square] [Rectangle]
+ sideLength + majorSideLength
+ minorSideLength

Now the knowledge definitions have consistent subset scope. More to the
point, one can probably define behaviorX at some level so that LSP and
NF are not violated without a whole lot of difficulty.

Bottom line: I don't see a problem with superclasses having knowledge
attributes -- so long as one ensures that those attributes are valid and
semantically equivalent for every descendant subclass. But I see that
stricture is an OOA/D issue, not an OOPL issue.

Quote:

So a lot of what you know about relational model, i.e. how to design
tables, can apply to OO. However, OO is a huge break from procedural
programming.

I don't think so. A class is full of procedural code, all OO does is
wrap that procedural code in a higher level of abstraction so it is
easier to deal with.

Wow. I'm really surprised that you feel that way.

Quote:
All the OO paradigm does (imho) is make modularization easier and
interfaces pervasive.

There is no doubt that modularization is easier. But I think that is
just a convenient byproduct of decoupling via interfaces. In turn,
interfaces provide a mechanism for decoupling, so they are ubiquitous.

But I think the primary goal of the OO paradigm is to provide decoupling
among software elements. That's what encapsulation and implementation
hiding are all about. I also think that the separation of message and
method in OOA/D provides a fundamental shift in construction paradigms
from the imperatives (Do This) of procedural development and the
announcements (I'm Done) of OO development. That changes the whole
mindset of program construction from hierarchical, functional
decomposition flow of control to peer-to-peer, DbC-based flow of control.

Procedural development strongly encouraged implementation dependencies
among behaviors so that the legendary Spaghetti Code was commonplace.
(One could write modular, decoupled programs in procedural languages but
it was damned difficult and required a good deal of skill and
experience.) OTOH, the OO paradigm strongly discourages any sort of
dependencies among methods so that even entry level developers can
create fairly maintainable programs.

One demonstration of that is to look at the call graphs of typical
procedural and OO programs. The call graph for an OO program will be a
true rat's nest -- far worse than that of a procedural program, which
will tend to have a very regular hierarchical structure. But because of
the way the OO program is constructed, there will much better isolation
of elements and far fewer dependencies. That will make the typical OO
program much more maintainable despite the ugliness of the call graph.


--
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer

H. S. Lahman
H.lahman at (no spam) verizon.net
software blog: http://pathfinderpeople.blogs.com/hslahman/index.html
 
S Perryman...
Posted: Tue May 12, 2009 10:42 pm
Guest
Daniel T. wrote:

Quote:
"H. S. Lahman" <h.lahman at (no spam) verizon.net> wrote:

Yes. To do OO development properly you need to forget everything you
ever learned about P/R.

It's not all that bad. OO is not revolutionary, it's evolutionary.
Anybody who has a solid grasp of the modular programming paradigm will
feel quite at home in an OO context. They won't have very much to learn
at all.

Indeed.
Anyone who learnt to program with modules and ADTs (CLU, Ada, Modula-2 etc)
will find OO very easy indeed.

The Simula inheritance and type substitutability models, property re-
definition etc (virtual etc) are no big deal either.


Quote:
Learning the OO paradigm using a single
3GL language is harder than learning it if you understand multiple
languages.

Depends what single language you start from (see above) .


Regards,
Steven Perryman
 
Daniel T....
Posted: Wed May 13, 2009 4:56 pm
Guest
On May 12, 1:40 pm, "H. S. Lahman" <h.lah... at (no spam) verizon.net> wrote:
Quote:
Responding to Daniel T....

Pushing common data up into common base classes in the name of
"normalization" is one of the biggest problems I see in beginner's OO
practice. You can get away with it in a dynamic typed language, because
the inheritance relationship doesn't create as tight a coupling. but...

When dealing with a static typed language, things are a little more
involved, because inheritance serves double duty. Whenever you have one
construct that represents more than one abstract concept things get
problematic. (That problem started this thread.)

I see the problem somewhat differently and from that perspective I don't
think it has much to do with statically vs. dynamically bound OOPLs. For
example, we've both seen a lot of LSP debates online that were based on
models like:

[Rectangle]
+ majorSideLength
+ minorSideLength
+ behaviorX
A
|
+-------------...
|
[Square]
+ sideLength

The debaters will go on an on about arcane implementations of behaviorX
that break and how to specify that behavior to avoid LSP issues. Yet
they never seem notice that the real problem is a basic generalization
error in defining the side length knowledge attributes. IOW, they don't
seem to think that LSP applies to knowledge as well as behavior.

Because of the basic set focus of OO generalization, any member of the
[Rectangle] set *must* have a majorSideLength and a minorSideLength.
That instantly creates at least two 3NF violations for any member of the
[Square] subset. It also violates the basic is-a notion of OO
generalization because the knowledge semantics is fundamentally
different so that a Square is something quite different than a Rectangle
and can't be Rectangle.

[Note that the problem doesn't get any better if one leaves off
Square::sideLength. If both majorSideLength and minorSideLength are set
to the same value, one has a 3NF violation because one value is
dependent on the other rather then the Square identity. If one leaves
one value uninitialized, one has a 1NF violation because the data domain
is not simple.]

Of course if one did the generalization correctly, one would end up with
something like:

[RegularPolygon]
A
|
+-----------+-----------+
| |
[4Sided] [MultiSided]
A A
| |
+-----+----------+---... ...
| |
[Square] [Rectangle]
+ sideLength + majorSideLength
+ minorSideLength

Now the knowledge definitions have consistent subset scope. More to the
point, one can probably define behaviorX at some level so that LSP and
NF are not violated without a whole lot of difficulty.

Bottom line: I don't see a problem with superclasses having knowledge
attributes -- so long as one ensures that those attributes are valid and
semantically equivalent for every descendant subclass. But I see that
stricture is an OOA/D issue, not an OOPL issue.

Also note however that you are normalizing based on interface
contracts, not based on data. If the data happens to be normalized
too, great but that isn't the goal of the hierarchy.

Quote:
So a lot of what you know about relational model, i.e. how to design
tables, can apply to OO. However, OO is a huge break from procedural
programming.

I don't think so. A class is full of procedural code, all OO does is
wrap that procedural code in a higher level of abstraction so it is
easier to deal with.

Wow. I'm really surprised that you feel that way.

What? Even you use an action language to implement methods. That
action language must have loops and if statements. Private methods in
a class are simply a syntactical variant of procedures, especially if
they are not meant to be over-ridden.

Quote:
All the OO paradigm does (imho) is make modularization easier and
interfaces pervasive.

There is no doubt that modularization is easier. But I think that is
just a convenient byproduct of decoupling via interfaces. In turn,
interfaces provide a mechanism for decoupling, so they are ubiquitous.

But I think the primary goal of the OO paradigm is to provide decoupling
among software elements. That's what encapsulation and implementation
hiding are all about. I also think that the separation of message and
method in OOA/D provides a fundamental shift in construction paradigms
from the imperatives (Do This) of procedural development and the
announcements (I'm Done) of OO development. That changes the whole
mindset of program construction from hierarchical, functional
decomposition flow of control to peer-to-peer, DbC-based flow of control.

I agree with the above, except for that last sentence. Well written
modular code has the same mindset IMHO.

Quote:
Procedural development strongly encouraged implementation dependencies
among behaviors so that the legendary Spaghetti Code was commonplace.
(One could write modular, decoupled programs in procedural languages but
it was damned difficult and required a good deal of skill and
experience.) OTOH, the OO paradigm strongly discourages any sort of
dependencies among methods so that even entry level developers can
create fairly maintainable programs.

I fully agree with the above. To paraphrase Riel, OO added a syntax
that made it easy for even average programmers to conform to modular
programming's best practices. I wouldn't call making it easier for
average people to do the same thing that experienced people do any
sort of "revolution" though.
 
H. S. Lahman...
Posted: Fri May 15, 2009 11:02 pm
Guest
Responding to Daniel T....

Quote:
Of course if one did the generalization correctly, one would end up with
something like:

[RegularPolygon]
A
|
+-----------+-----------+
| |
[4Sided] [MultiSided]
A A
| |
+-----+----------+---... ...
| |
[Square] [Rectangle]
+ sideLength + majorSideLength
+ minorSideLength

Now the knowledge definitions have consistent subset scope. More to the
point, one can probably define behaviorX at some level so that LSP and
NF are not violated without a whole lot of difficulty.

Bottom line: I don't see a problem with superclasses having knowledge
attributes -- so long as one ensures that those attributes are valid and
semantically equivalent for every descendant subclass. But I see that
stricture is an OOA/D issue, not an OOPL issue.

Also note however that you are normalizing based on interface
contracts, not based on data. If the data happens to be normalized
too, great but that isn't the goal of the hierarchy.

Actually, the notion of interfaces never entered my mind. B-)) I did it
purely on the basis of the semantics of the knowledge responsibilities.

While normalization isn't the goal of the hierarchy, it is a very
valuable tool for determining the correctness of the hierarchy.

<Hot Button>
A lot of OO authors minimize normal form or don't even mention it.
Instead they provide a bunch of cookbook guidelines for defining
responsibilities that <most of the time> get to the same place. When
I've asked why they don't talk about normalization the answer I have
usually gotten is that it is too complex or too distracting.

Saying it is too complex seems very condescending to me. Basically they
are saying that most developers are too dumb to understand and IT DBAs
are some sort of anointed priesthood.

Saying it is distracting when the entire static structure of OOA/D
notations is based on set theory's relational model bothers me even
more. How can people understand how to use such complex semantics
properly if you don't explain the fundamental principles on which the
entire notation rests?!? It's like trying to explain the physics of
motion without talking about F = ma.
</Hot Button>

Quote:

So a lot of what you know about relational model, i.e. how to design
tables, can apply to OO. However, OO is a huge break from procedural
programming.
I don't think so. A class is full of procedural code, all OO does is
wrap that procedural code in a higher level of abstraction so it is
easier to deal with.
Wow. I'm really surprised that you feel that way.

What? Even you use an action language to implement methods. That
action language must have loops and if statements. Private methods in
a class are simply a syntactical variant of procedures, especially if
they are not meant to be over-ridden.

At the risk of being pedantic, the AALs are specification languages, not
implementation languages. They only specify What the behavior
responsibility is, not How it should be done. (FWIW, my speculation is
that today's AALs will be replaced by languages that are much closer to
formal methods languages and DbC expressions.)

But my problem wasn't with the idea that there is lots of procedural
code. A the OOP level there *must* be because of the marriage to
hardware computational models. And most computation is based on
algorithms at some level.

My issue was with the simplistic view that all OO does is provide
procedure wrappers at a higher level of abstraction. The fact that a
method *must* be mappable into a 3GL procedure is a necessity of Turing
computation. But how one defines what is in those methods and how they
collaborate is where the OOness lies.

You may recall that Bob Martin used to have a pet saying that OO was
just about jump tables. I think saying OO just provides wrappers is the
same sort of myopic oversimplification.

Quote:

All the OO paradigm does (imho) is make modularization easier and
interfaces pervasive.
There is no doubt that modularization is easier. But I think that is
just a convenient byproduct of decoupling via interfaces. In turn,
interfaces provide a mechanism for decoupling, so they are ubiquitous.

But I think the primary goal of the OO paradigm is to provide decoupling
among software elements. That's what encapsulation and implementation
hiding are all about. I also think that the separation of message and
method in OOA/D provides a fundamental shift in construction paradigms
from the imperatives (Do This) of procedural development and the
announcements (I'm Done) of OO development. That changes the whole
mindset of program construction from hierarchical, functional
decomposition flow of control to peer-to-peer, DbC-based flow of control.

I agree with the above, except for that last sentence. Well written
modular code has the same mindset IMHO.

Procedural development strongly encouraged implementation dependencies
among behaviors so that the legendary Spaghetti Code was commonplace.
(One could write modular, decoupled programs in procedural languages but
it was damned difficult and required a good deal of skill and
experience.) OTOH, the OO paradigm strongly discourages any sort of
dependencies among methods so that even entry level developers can
create fairly maintainable programs.

I fully agree with the above. To paraphrase Riel, OO added a syntax
that made it easy for even average programmers to conform to modular
programming's best practices. I wouldn't call making it easier for
average people to do the same thing that experienced people do any
sort of "revolution" though.

OK. If you agree with all this, how is OO merely about providing
wrappers for procedural code at a different level of abstraction? B-)

I think you need to have a pretty loose definition of 'syntax' to map
modern OOA/D Riel's way. Modern OOA/D is a complex construction
methodology, not some kind of predefined template for mapping the real
world. IOW, OOA/D is about semantics rather than syntax.

I just don't think it is that simple. My counter would be the OO code
written by procedural converts going directly to OOP without learning
OOA/D. They end up writing PL/I or C programs with strong typing. If
they didn't have the skill and experience to write modular PL/I and C
programs before converting, the OOPL syntax isn't going to help them do
so after converting.


--
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer

H. S. Lahman
H.lahman at (no spam) verizon.net
software blog: http://pathfinderpeople.blogs.com/hslahman/index.html
 
John \"Z-Bo\" Zabroski...
Posted: Mon May 18, 2009 1:20 am
Guest
On May 12, 11:13 am, "H. S. Lahman" <h.lah... at (no spam) verizon.net> wrote:
Quote:

The Big Three characteristics of 3GLs are: procedural block structuring,
stack-based scope, and procedural message passing. All the OOPLs,
including Smalltalk, still depend on those things. (Though some, like
Smalltalk, do a better job of hiding it by employing less obvious syntax.)

But the real problem with the 3GLs is physical coupling due to the use
of type systems to deal with the Big Three. That introduces the need for
refactoring _just to make the 3GL code more maintainable_ (as opposed to
solving the customer's problem). That sort of refactoring after the
logic is working correctly is totally unnecessary at the 4GL level of
OOA/D. Worse, at the OOP level it can lead to architectural drift in the
long term.

Every OOPL employs a sophisticated type system. So in that sense the
OOPLs are even worse than the procedural languages; the type system
itself is a major compromise with the hardware computational models.

I've always wanted to ask you this, so here goes:

Why don't you mention callbacks in your list of physical coupling?
Actually, callbacks are much worse than physical coupling, because
they create logical coupling messes that cannot be undone.
 
 
Page 1 of 2    Goto page 1, 2  Next
All times are GMT
The time now is Fri Nov 27, 2009 8:48 pm