wood burning stoves*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Qualitiy of OO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Qualitiy of OO" Watch "Qualitiy of OO" New topic
Author

Qualitiy of OO

Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
Hello Folks,
Could someone expand and clarify this statement
One of the great qualities of object-oriented development is that you can vary the interfaces of classes independent of the implementation. [ UML Distilled, Fowler]

I thought its the other way around coz you can vary the implemenation as per the requirements while keeping the interfaces intact. could someone please help me understand this statement? thanks.
-Tulsi
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Hi Tulsi,

I found the sentence you quoted in UML Distilled 2nd edition, chapter 6, section Interfaces and Abstract Classes. In UML Distilled 3rd edition, chapter 5, section Interfaces and Abstract Classes, the section has been entirely rewritten. That sentence no longer exists. There is a paragraph about programming to an interface so that the implementation can be changed.

Regards, Marlene
Brian Smith
Ranch Hand

Joined: Oct 26, 2002
Posts: 232
Thanks for the reply Marlene. but don't you think the statement is a bit odd? any comments?
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
�you can vary the interfaces of classes independent of the implementation�

Hi Tulsi, Yes, I think the statement is odd. The converse (one interface, vary the implementation) is the usual way to think about using interfaces.

What does vary x independent of y mean? z = f(x, y). Hold y fixed and change x. Given an implementation, vary the interface without changing the implementation.

interface X { void f(); }
interface Y { void g(); }

class C implements X, Y {
public void f() { /*code*/ }
public void g() { /*code*/ }
}

--------

�Programming languages uses a single construct, the class, which contains both interface and implementation.�

This sounds like C++. C++ does not have an �interface� construct. "interface" has several different casual meanings. Classes that have things regarded as �interface� might contain data and functions that are implemented.

�Using the interface as a separate construct is rarely used, which is a shame.�

/Maybe/ Martin Fowler is thinking about C++. /Maybe/ when he said vary the interfaces, he meant, in C++ separate into different classes the things regarded as interface from the things regarded as implementation.

-------

I once asked the C++ folks what interface means to them:
comp.lang.c++.moderated Somewhere in that discussion is a list of various things interface means.
[ December 28, 2004: Message edited by: Marlene Miller ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Qualitiy of OO