A post over at c.l.py steered me towards this - Building user interfaces for object-oriented systems.
It has some interesting, if perhaps somewhat controversial, things to say on the nature of object orientation.
You may have read in a book somewhere that an object is a data structure of some sort combined with a set of functions, called methods, that manipulate that data structure. Balderdash! Poppycock! First and foremost, an object is a collection of capabilities. Very true, this. The important thing about an object is what is does, not what it has. The latter is an implementation matter.
Classes are irrelevant -- they're just a convenience provided for the compiler. Also true. This was pointed out to me while looking at JavaScript recently. Its rather, uh, idiosyncratic OO model does away with 'classes' as such. Instead, you just define a construction function, and add methods to its prototype. Look, Ma, no classes. (I don't really like this approach much - it makes subclassing rather clumsy if nothing else. But it does work after a fashion.)
All data is private. Period. (This rule applies to all implementation details, not just the data.) get and set functions are evil. (They're just elaborate ways to make the data public.) I like Python's approach here. No data is really private (see The principle of least privilege for why), but you can intercept any references to this data if you want. So, you just refer to object.attribute, and it's the object's business whether that just accesses the data attribute or calls a method. No need for get and set methods here.
All objects must provide their own UI. What? Is he serious? The presentation object should always be separate from the business object! Some business objects don't need any presentation layer, and some may need several. (The persistence layer should also be separate.)
Posted to Software development by Simon Brunning at May 30, 2003 10:43 AMTo clarify that last point, I think he means all objects must provide a means for displaying salient information about themselves.
In Python this is the repr method.
Still, a fascinating article, thanks for the pointer.
Posted by: Andy Todd on May 30, 2003 12:16 PM"The important thing about an object is what is does, not what it has."
I'd disagree. The important thing about an object is what it is.
What an object has and what it can do are both a function of what it is.
Posted by: Charles Miller on May 30, 2003 12:39 PMCharles,
Thus speaks a static typer. Think Python - free your mind. Only try to realise the truth - there is no spoon.
In Python, you do not, for example, care whether you have a *real* file object, or something which *acts* like a file object. So long as your object can behave like a file, (i.e. it has the appropriate methods) you don't care what it *really* is.
Posted by: Simon on May 30, 2003 01:29 PMObjects and OO and static typingn and all that stuff are things to help implement a system. The interface should be usuable. Your average user doesn't know/care/want to know what an object is or what is the deal with private data or any of that. Make a usable UI and build the app as best you can. OO is a great way to achieve that implementation.
Posted by: Dave on May 30, 2003 03:48 PMAlso, WRT "get/set methods are evil". That is just retarded. What if you have data that you need to display and then collect? You need to be able to get the individual pieces of the data, and set them when they change. I am so sick and tired of OO masterbaters complaining about things being not-OO as if that matters for one second. Software is meant to be used, not hung in a museum and admired for it's OO-ness. I feel sorry for any user that has to use software written by the quoted author.
Posted by: Dave on May 30, 2003 03:50 PMYeah, but they probably do care how much the systems cost to develop and maintain*. So this stuff *does* matter, though the end user doesn't care.
* Funny how often this last one gets forgotten - hence Perl. :-)
Posted by: Simon on May 30, 2003 03:51 PMI don't see the link between static typing, and the idea that an object has identity. Even in dynamic, prototype-based OO like Javascript, the objects you pass around are still "something": a row of a table, a mouse-click event, or the second heading of the page.
What's happening is an equivocation over the meaning of "you". Are "you" the creator of the object, or are you making use of the object? Certainly, when creating an object (either out of whole cloth, like in Javascript, or in the form of a class), you take into account that object's users, but that is not your sole concern.
When writing code that wants to _make_ _use_ of an object, the capabilities approach is the way to go. In a statically-typed language like Java, you would have to isolate each individual capablity (or set of capabilities) in an Interface. In a dynamically-typed language, you just call the methods you expect to be there.
The client of an object doesn't have to know what the object is. That's basic OO, whether statically or dynamically typed. It's about as controversial as calling the Pope a Catholic. To extend that to the definition of the object itself, however, is equivocation that seems to be done solely for the purpose of making this rather pedestrian claim sound bold and new.
Back to the objects themselves, though.
Regardless of how they are used externally, the objects themselves are still things. Objects glue capabilities together with identity. Identity, that understanding of the implementor of what an object _is_, gives the capabilities meaning. Without identity, unrelated capabilities give us the Manager class, the Big Ball of Mud: objects that do lots of things, but have no coherent sense of purpose.
Posted by: Charles Miller on May 31, 2003 02:30 AMInteresting post, Charles. Thanks!
You point out a very important distinction - the *builder* of a class (or whatever is is you do to create a type), and the *clients* (users) of that class. The builder of a class, naturally, has to take note of things that the client doesn't. All the implementation details that the client need not and should not be aware of are the builders responsibility. To me, the class is just one of those things.
What the client cares about is, as you say, the *interface*. In Java, this is explicit. In Python, it’s implicit, but it still exists – the notion of a file-like object, for example, is a common one.
naked ebony female mens penis amd balls bible quotes about sex nostalgia merchanvhs movies
Posted by: Dimka on October 27, 2008 08:57 AMfree gay jerk offf sex gags dad gay sex distinguish between sexual and asexual reproduction in the hydra.
Posted by: Alina_m on October 29, 2008 07:07 AMPosted by: Alina_m on October 30, 2008 04:55 AM