Board index » delphi » Re: Evangelizing

Re: Evangelizing


2005-09-21 07:13:06 AM
delphi248
"Jarle stabell" <XXXX@XXXXX.COM>wrote in
message news:XXXX@XXXXX.COM...
Quote
>Aren't interface methods public?

For interfaces, private, public etc doesn't apply. You can say that all
methods are public in a given interface.
Sure, that is what I meant. :)
Quote
However, the class implementing an interface don't need to expose those
methods as public. (I use protected)
Gotcha.
Quote
>How do you "hide" certain interfaces from certain clients?

Clients don't know which class is "behind" the objects they see (via an
interface), so they don't need to know the full set of interfaces
implemented by the objects they have access to.
Right, so you're talking about passing objects around via interface
references. I with ya.
However, haven't you just moved the coupling from the "public class methods"
to the "interface methods"? So the client is coupled to the interface, and
any time you want to change the interface you've (potentially) got to change
all clients that use it. Right? And it gets worse - you have to change all
classes that implement the interface too!
Don't get me wrong, I see the value of interfaces they are very nice in some
situations. But I don't see how they "solve" anything by using them
exclusively in place of public methods & properties.
 
 

Re: Evangelizing

Quote
If you had been using goto as a fundamental construct for many years, and
suddenly someone convinces you that you should stop using it, meaning you
have to change your way of thinking, is it really that odd
It's odd to "cherish" it, yes. "I miss goto" is quite different to "I cherish goto".
Quote
You can let different clients access different interfaces to the same
object
Only if you rely on coding convention. There is nothing to stop every client
from using every interface. Are you after something like the Eiffel approach
others have been talking about?
And one of the two biggest problems I see with interface-based code is having
too many interfaces on one object.
Quote
some clients may see some "secret" features that other clients do
not know the existence of.
Seems to me that you should not be using just the one object, then.
Quote
(You don't need to have public methods in order to implement an interface.)
All methods defined in an interface are by definition public.
Quote
When using interfaces, classes are implementation details.
Code in methods in classes is always implementation detail whether or not an
interface is involved. You've used this expression several times now, but I
don't see what you're getting at - you seem to have used it in at least 2
different contexts.
Cheers,
Jim Cooper
__________________________________________
Jim Cooper XXXX@XXXXX.COM
Tabdee Ltd www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
__________________________________________
 

Re: Evangelizing

Quote
I think you guys are going to need to take this "dance" to non-tech! ;-))
Jarle has fixated on the wrong thing, probably because I dissed his bloke. I
wanted to talk about one of the papers, and why he thinks this chap's ideas are
important, but we still aren't having that discussion.
FWIW, I no longer read non-tech. Between the "Borland is dying" and "Why aren't
Borland doing a 64-bit Delphi? They're gonna die without it" threads, and a
certain tone that is creeping into all the others, it has driven me away :-)
Cheers,
Jim Cooper
__________________________________________
Jim Cooper XXXX@XXXXX.COM
Tabdee Ltd www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
__________________________________________
 

Re: Evangelizing

"Jim Cooper" <XXXX@XXXXX.COM>writes
Quote
FWIW, I no longer read non-tech. Between the "Borland is dying" and "Why
aren't
Borland doing a 64-bit Delphi? They're gonna die without it" threads, and
a
certain tone that is creeping into all the others, it has driven me away
:-)
I agree. I am a much more easy going individual when I avoid that group. :-)
 

Re: Evangelizing

Bob Dawson writes:
Quote
Like friendship, it is not a technique to be used
without compelling reason, and would only be employed if the objects
involved are already inherently bound by the nature of the domain.
In that situation I'd have no objection since there is no increase in
coupling.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: www.logicfundamentals.com/RADBooks.html
"The purpose of morality is to teach you, not to suffer and die, but to
enjoy yourself and live." - Ayn Rand
 

Re: Evangelizing

"Scott Roberts" <XXXX@XXXXX.COM>a écrit dans le
message de news: 4330972d$XXXX@XXXXX.COM...
Quote
Don't get me wrong, I see the value of interfaces they are very nice in
some
situations. But I don't see how they "solve" anything by using them
exclusively in place of public methods & properties.
As I start to move code into the .NET world where interface refcounting and
querying is no longer tied to the COM implementation, I find that my designs
are radically changing.
Where I'd normally use exclusively interfaces due to refcounting
problems, I find that I am able to design classes with a primary public
"interface" of its own which represents the primary purpose or behaviour of
the class, whilst supporting "secondary" behaviours with interfaces.
So you would have something like CustomerList as a class with public methods
like Add, Remove, etc and support for interfaces like IEnumerable,
IStreamable, etc.
One of the major influences in this decision is the ability that .NET
interfaces give you to get back to the implementing class from an interface;
something that was not possible or very messy in Delphi for Win32.
Joanna
Consultant Software Engineer
TeamBUG support for UK-BUG
TeamMM support for ModelMaker
 

Re: Evangelizing

"Wayne Niddery [TeamB]" wrote
Quote

In that situation I'd have no objection since there is no increase in
coupling.
Meyer discusses it as a way to keep a domain's business internal without
needing modules (or any visibility/scope context other than class). It's
clearly the Eiffel version of friend declarations.
Actually with the new 'strict' visibility term Delphi gives us almost the
same functionality--put two classes in a unit and you can have them be
friends for some private/protected methods, but not others. Eiffel's
selective export concept does exactly that, but specifies the relationship
in the class itself, rather than needing the unit/module construct to scope
the friendship rights.
bobD
 

Re: Evangelizing

"Jim Cooper" <XXXX@XXXXX.COM>writes
Quote
It's odd to "cherish" it, yes. "I miss goto" is quite different to "I
cherish goto".

I think he was simply using more poetic language; maybe expressing a
self-effacing nostalgia for an old way of writing programs. Clearly he
recognizes the problems inherent in goto. It didn't seem to me that he was
implying that he wished he could go back to using goto, like secretly in the
middle of the night, he writes code that uses goto :-)
-Corinna
 

Re: Evangelizing

Jim Cooper writes:
Quote
>You can let different clients access different interfaces to the same
>object

Only if you rely on coding convention. There is nothing to stop every
client from using every interface.
How do you use an interface on a given object implementing that interface if
you don't have the source code for the class of the object, nor the
declaration of the interface itself?
Unless your name is Danny Thorpe or Hallvard Vassbotn, I doubt you are able
to do it. No offense! ;-)
Quote
Are you after something like the Eiffel
approach others have been talking about?
Something in that direction, but probably at a more abstract level.
Quote
And one of the two biggest problems I see with interface-based code
is having too many interfaces on one object.
If the object has multiple responsibilites (able to play different roles),
that isn't a problem IMO. that is a situation when interfaces shine.
With interfaces, you can get away with being less "strict" in
implementing/constructing your classes, you can use quite a lot of tricks in
the implementation, without that complexity "leaking out".
Quote
>some clients may see some "secret" features that other clients do
>not know the existence of.

Seems to me that you should not be using just the one object, then.
If the responsibilities naturally belongs to the same object, or it simply
is convenient to implement it that way, interfaces let you get away with
having a bit more "dirty" classes.
Quote

>(You don't need to have public methods in order to implement an
>interface.)

All methods defined in an interface are by definition public.

>When using interfaces, classes are implementation details.

Code in methods in classes is always implementation detail whether or
not an interface is involved.
I'm not only considering the implementation of methods here, I am considering
the whole class (methods, fields, the class' place in the class hierarchy)
as being only "locally" interesting when using interfaces.
Quote
You've used this expression several
times now, but I don't see what you're getting at - you seem to have used
it in at
least 2 different contexts.
It is the features/responsibilites/roles which are important, how you
combine those into classes is "implementation".
The MFC pattern doesn't dictate you to implement it with three classes, it
is the three roles which are the essence of the pattern.
Cheers,
Jarle
 

Re: Evangelizing

Jarle stabell writes:
Quote
The MFC pattern doesn't dictate you to implement it with three
classes, it is the three roles which are the essence of the pattern.
Need to correct myself here:
It is the three roles and how they *collaborate* which are the essence of
the MFC pattern.
Cheers,
Jarle
 

Re: Evangelizing

Quote
How do you use an interface on a given object implementing that interface if
you don't have the source code for the class of the object, nor the
declaration of the interface itself?
I'm missing the point you're trying to make here. And Code Completion, is the
answer, BTW :-)
Quote
If the object has multiple responsibilites (able to play different roles),
that isn't a problem IMO. that is a situation when interfaces shine.
Here;s where we part company. that is exactly the problem I was describing. The
only time there is any need for that is when the responsibilities are very
tightly coupled (eg enumerating and sorting a collection). Otherwise it is a
(very) bad smell, and you should be splitting the responsibilities out into
separate classes. This is exactly the same problem faced by many objects that
have lots and lots of methods and properties.
Quote
With interfaces, you can get away with being less "strict" in
implementing/constructing your classes,
I don't follow that either, sorry
Quote
you can use quite a lot of tricks in the implementation
Again, that sounds very bad.
Quote
without that complexity "leaking out".
I'm not sure why you think interfaces are better at that.
Quote
If the responsibilities naturally belongs to the same object, or it simply
is convenient to implement it that way, interfaces let you get away with
having a bit more "dirty" classes.
So they're a bad thing then?
Quote
It is the features/responsibilites/roles which are important, how you
combine those into classes is "implementation".
OK. In that case, interfaces are implementation details too.
Cheers,
Jim Cooper
__________________________________________
Jim Cooper XXXX@XXXXX.COM
Tabdee Ltd www.tabdee.ltd.uk
TurboSync - Connecting Delphi to your Palm
__________________________________________
 

Re: Evangelizing

Jim Cooper writes:
Quote
>How do you use an interface on a given object implementing that
>interface if you don't have the source code for the class of the
>object, nor the declaration of the interface itself?

I'm missing the point you're trying to make here. And Code
Completion, is the answer, BTW :-)
Code Completion is of no help if you don't have the definition of the
interface.
Quote
>If the object has multiple responsibilites (able to play different
>roles), that isn't a problem IMO. that is a situation when interfaces
>shine.

Here;s where we part company. that is exactly the problem I was
describing. The only time there is any need for that is when the
responsibilities are very tightly coupled (eg enumerating and sorting
a collection). Otherwise it is a (very) bad smell, and you should be
splitting the responsibilities out into separate classes. This is
exactly the same problem faced by many objects that have lots and
lots of methods and properties.
In a way we basically agree here. But with interfaces, the smell isn't as
dangerous because it can be made very local. If I find it convenient to
merge together things which "academically" belongs in separate classes, I do
the merge because the consequences of doing it isn't as severe, because the
smell isn't noticable outside of the implementation of the given class. (The
class generally isn't visible to other units.)
Quote
>With interfaces, you can get away with being less "strict" in
>implementing/constructing your classes,

I don't follow that either, sorry
Reformulated in my previous paragraph.
Quote

>you can use quite a lot of tricks in the implementation

Again, that sounds very bad.
Not very bad because (as above), the consequences of the (sometimes "dirty")
tricks are kept very local.
Quote
>It is the features/responsibilites/roles which are important, how you
>combine those into classes is "implementation".

OK. In that case, interfaces are implementation details too.
Interfaces better match features/responsibilites/roles than classes. Don't
you regard them as being on a higher abstraction level than concrete
classes?
Cheers,
Jarle
 

Re: Evangelizing

"Jarle stabell" <XXXX@XXXXX.COM>wrote in
message news:433201d0$XXXX@XXXXX.COM...
Quote
In a way we basically agree here. But with interfaces, the smell isn't as
dangerous because it can be made very local. If I find it convenient to
merge together things which "academically" belongs in separate classes, I
do
the merge because the consequences of doing it isn't as severe, because
the
smell isn't noticable outside of the implementation of the given class.
(The
class generally isn't visible to other units.)
It sounds like this is analogous to database design. "Proper", "academic"
design requires full normalization (at least 3NF, if not further). But in
practice, most database designers find it more "convenient" to denormalize
their data a bit, or at the very least, use views and triggers, etc to
improve performance, or simplify common queries. The database design is
dirtier, but for a good reason.
Like an artist or architect, you *purposely* violate "proper" design because
your judgement tells you it is a good idea. And so then the trick is to not
go too far... (like artists tend to do :) )
-Corinna
 

Re: Evangelizing

"Jarle stabell" <XXXX@XXXXX.COM>wrote in
message news:433201d0$XXXX@XXXXX.COM...
Quote
Interfaces better match features/responsibilites/roles than classes. Don't
you regard them as being on a higher abstraction level than concrete
classes?
I think answer is going to be "no", hence you're discussion. :-)
Here's what I am hearing, and let me know if I have completely missed the boat.
You're saying:
This class implements 3 interfaces (A,B,C). Interface A is visible to client
X, interface B is visible to client Y, and maybe interfaces B & C are
visible to client Z.
What this implies is that your single class fulfills 3 different
roles/responsibilities. What *I* would do is create 3 different classes
(perhaps all derived from a common ancestor) to fulfill the 3 roles instead
of implementing 3 interfaces on a single class.
To me, an interface is a "client" design feature - not a class design
feature. I'd write a client that could process any object that
implements a specific interface, but I'd never create a class and try to
show/hide functionality in that class using interfaces.
Or maybe I have grossly misunderstood. :-)
 

Re: Evangelizing

Scott Roberts writes:
Quote

This class implements 3 interfaces (A,B,C). Interface A is visible to
client X, interface B is visible to client Y, and maybe interfaces B
& C are visible to client Z.

What this implies is that your single class fulfills 3 different
roles/responsibilities. What *I* would do is create 3 different
classes (perhaps all derived from a common ancestor) to fulfill the 3
roles instead of implementing 3 interfaces on a single class.
If the interfaces are completely different then I agree with you (because it
implies the implementing class is doing too much). But it is entirely
possible the interfaces are simply being used to limit access to a subset of
the class. That could be for the purpose of roles and/or security, or other
things. It also maybe that the interfaces also derive from each other so
that each one is a superset of the prior one.
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: www.logicfundamentals.com/RADBooks.html
"The moment the idea is admitted into society that property is not as
sacred as the laws of God and there is not a force of law and public
justice to protect it, anarchy and tyranny commence." - John Adams