OOP techniques are employed@bluebrain.
Oo is how we think we think.
etc...

trash(object) from the verb, to trash, bin etc.

Moderators: kiore, Blip, The_Metatron
So the core idea of OOP is its take on how to write modular programs. In most programming languages, it is a good idea to separate how something is used from how it works, and this idea has been cashed out in several ways (APIs, protocols, interfaces, signatures). It is sometimes a good idea to make these modules "hot-pluggable", so that they can be replaced and updated live in a system without ever having to do a rebuild.newolder wrote:objects are instances of code data and code methods.
OOP techniques are employed@bluebrain.
Oo is how we think we think.
etc...
This isn't OOP syntax. It's just an ordinary function application, something which you can do in any high-level language (save Prolog). In (single-dispatch) OOP, you don't trash objects. You tell objects to trash themselves. How's that for mimicking the way humans think?trash(object) from the verb, to trash, bin etc.
I don't think the ambiguity is really an issue, because the semantics of the look-up are well-defined. The diamond inheritance problem is another matter, where a derived class inherits two copies of an ancestor class by multiply inheriting parents. The correct behaviour here is achieved by explicitly using virtual inheritance, which C++'s programmers generally don't want for performance reasons, so you end up having to plan for multiple inheritance way in advance. This is the whole problem with nominal subtyping: you can plug new classes into an interface scheme, but you can't plug in new class diagrams.Calilasseia wrote:Oh, and one idea that has led to a lot of trouble in C++ is allowing child objects to inherit from multiple parents. This has been a source of numerous insidious and troublesome bugs in some large projects. The people responsible for Java specifically forbade multiple inheritance within the Java language because of it.
Within C++, it's possible to define two objects, have them both share a name for a method, then define a third object that inherits from these two, at which point, you have the less than happy scenario of deciding which of the identically named methods from which of the parents is going to be overridden in the child object. Worse still, because of the flexibility of method overloading, I've been told it's possible to have the child object refer to overridden versions of both of the parent methods via the same method label ... which again, drives a sodding tank battalion through the OOP paradigm.
Needless to say, I wouldn't trust a mission critical application to this language platform unless there were very strict rules in place as to what programmers could and couldn't do.
ref wrote:More generally, isolated objects mean nothing, only structured sets of objects do; and these language don't allow to manipulate those sets, to describe their properties. Languages with multiple dispatch, such as CLOS or Cecil, do a better job of not associating environments to objects.
Does it, though? Objects can't destroy themselves directly. You need another object in there.
Yes.One final point, if someone tells you that they have used OOP, or that their product contains OOP concepts, always call bullshit. It really is a buzzword in those contexts.
The delete operator only exists in C++. Languages with garbage collection handle all memory management issues themselves. Setting an object's reference to a null value is only good for getting null-pointer dereferences, the behaviour of which as far as C++ is concerned could involve formatting your hard-drive. This isn't stability.Calilasseia wrote:I always understood the process of instantiating and de-instantiating objects to be performed by entities outside the objects in question. The new and delete operators achieve this. An object can contain within it a constructor method, which is used to tell the new operator how to initialise an object if the creation of an instance is accompanied by relevant initialisation data, and which the new operator calls after it has allocated memory for that object, set up the pointers to the methods, and provided a pointer to the object for the object reference variable to contain. In its simplest form, the delete operator simply returns the allocated memory to the operating system's free list, and sets the object reference variable to some suitable 'null' value to indicate that it's no longer pointing to an object.
Destructor issues don't occur in garbage-collected languages, because there generally aren't any destructors. Languages like Python, which uses a very simple reference-counting garbage-collector make destructors somewhat more useful, since the programmer can make strong guarantees about when destructors are called.One big problem that needs to be addressed concerns garbage collection. In an environment where garbage collection is provided as an automatic feature of the run-time environment, problems can arise with respect to ensuring that destructors are called, if the programmer simply dereferences the entire list in one fell swoop, using the above doubly linked list example. indeed, there's an entire body of literature on the subject of garbage collection, because ensuring the consistent release of allocated resources (memory, file handles etc) is time consuming, and conflicts with the need to minimise the impact of the run-time environment's ancillary services upon the executing program.
Finding such a Holy Grail was a goal a few decades ago. The only programmers still seriously worrying about garbage-collector efficiency are systems programmers and people working on embedded devices, who constitute a tiny fraction of all programmers. Garbage collected languages have been the norm for over a decade now. They make your code far safer (no more null-pointer dereferences) and massively boost programmer productivity. Requiring manual memory management everywhere is now just one big exercise in grossly premature optimisation --- most of your code doesn't doesn't need to be that fast, and the average programmer is as likely to do a worse job than the garbage collector would at freeing resources, certainly when it comes to safety. If you need better efficiency in that one tight function, you might just need a smart compiler that will do stack-allocations automatically, or a language which provides stack-allocation primitives (C#'s value types, Lisp's dynamic-extent declaration), or you just need to write your own memory pools.Balancing these requirements is one of those particularly difficult computer science problems, and finding a consistent, secure and fast garbage collection method is one of those Holy Grails of computer science that may never be achieved. All of which is compounded yet again when you consider programs that are multi-threaded, even if the threads are actually executed on one processor via the multitasking executive - it's possible, if you're not careful, for one thread to specify that it wants to delete an object at the same time as another thread wants to press that object into use, and synchronising usage versus deletion of objects across threads in a multitasking environment is another nice minefield for the unwary, made all the more hilarious when one implements multithreading on a genuine multiprocessor environment, where the threads are given their own processor to run on.
I'm not sure. What languages are you familiar with? As Calilasseia said, objects are trashed in OOP languages by entities on the outside. Garbage-collecting languages deal with trash automatically, so this "taking out the trash" metaphor is pretty confused.newolder wrote:In my mind, self.trash takes the object in focus to the nearest waste receptacle. For example, the object in focus is a 1mm ball of steel in the hand before me. Self.trash causes magnet-like attraction whilst self.destroy makes the ball vanish. Am I way off?
VazScep wrote:...I'm not sure. What languages are you familiar with? As Calilasseia said, objects are trashed in OOP languages by entities on the outside. Garbage-collecting languages deal with trash automatically, so this "taking out the trash" metaphor is pretty confused.newolder wrote:In my mind, self.trash takes the object in focus to the nearest waste receptacle. For example, the object in focus is a 1mm ball of steel in the hand before me. Self.trash causes magnet-like attraction whilst self.destroy makes the ball vanish. Am I way off?
self.trash doesn't help you anymore than object.trash. "self" can't generally be used. The main point here is that trashing in the example has become a property of the object. Is that a reasonable assumption to make? Is trashing not equally a property of the trash-can? What about the cupboard under the sink? What about the person who carries the bag? Why is only the trash-bag given sole responsibility here, aside from the fact that Java insists on all verbs being owned by nouns? Do we not have a procedure here, something like:
person.acquireFrom(trashBag, sinkCupboard);
person.goTo(garage);
person.placeIn(trashBag, trashCan);
Now where do we put this procedure? Procedures in Javaland belong to nouns, so we need something like:
trashDisposalPlan.doIt(person, sinkCupboard, garbageCan)
Incidentally, "doIt" methods are common in Java. This is called the "Command Pattern", and is a great example of how OOP has been horribly confused by Java and the "Patterns Community" [*]. The Command Pattern is normally just a crude hack to simulate "first-class functions", which are not available in Java (they are now in C#), and which were always supported by Smalltalk and exploited pervasively.
[*] Design patterns have also been horribly confused by the "Patterns Community".
Nitpick: SQL isn't a metalanguage anymore than the others are. Any language can be used as a metalanguage, so long as you're using it to define another language (many languages nowadays use themselves as their own metalanguage --- C compilers are written in C)newolder wrote:Z80-assembly, Basic, Fortran, Pascal (e.g. “Delphi”), VB6, VB and metalanguages like sql etc.
In this case, when you write self.trash(), you are writing code inside the class which defines trash. Suppose you are calling the trash method from a different class? Then you need to write object.trash().I'm pretty sure I've coded the likes of
With self do
Begin
{code}
End; {With}
before now.
VazScep wrote:Nitpick: SQL isn't a metalanguage anymore than the others are. Any language can be used as a metalanguage, so long as you're using it to define another language (many languages nowadays use themselves as their own metalanguage --- C compilers are written in C)newolder wrote:Z80-assembly, Basic, Fortran, Pascal (e.g. “Delphi”), VB6, VB and metalanguages like sql etc.
In this case, when you write self.trash(), you are writing code inside the class which defines trash. Suppose you are calling the trash method from a different class? Then you need to write object.trash().I'm pretty sure I've coded the likes of
With self do
Begin
{code}
End; {With}
before now.
Return to General Science & Technology
Users viewing this topic: No registered users and 1 guest