in reply to Role::Tiny: When to use apply_roles_to_object?
> The problem with object-oriented languages is they've got all this implicit environment that they carry around with them. You wanted a banana but what you got was a gorilla holding the banana and the entire jungle
or
> Furthermore, he cites an instance of a Java professor whose "idiomatic" solution to a problem was to create six new classes, rather than to simply use a lookup table.
Classes are templates defining behavior (methods) for object instances belonging to that "type". The "constructed" objects are usually restricted to hold data (attributes).
Sometimes you just need flexible objects having a variety of behaviors which can't be easily typed.
For instance (let's objectify a $woman ;-) ...
metaphor
I always say: My father is German and my mother is complicated.The truth is she has three passports, a college degree from a 4th country and speaks 3+ languages. I.e. I can't "type" her anymore.
So I'd rather avoid this discussion, before my food gets cold. And it's annoying to finally point out that people don't have the necessary background to understand. (that is their (stereo)type system sucks)
So creating a singleton "class" for every combination of attributes and functions an object could have is expensive, especially in Perl where you have to represent classes in a global hierarchy::of::packages .°
It's easier to add methods to an object without the need of typing.
Self or JS are classless, a JS object inherits from another JS object.
But that's also bit one dimensional. *
There are good reasons for OOP like encapsulation or polymorphism, but you could easily be trapped in design hell if you have to maintain an overly complicated class hierarchy, especially because people often can't even agree on the terminology.
another quote:
> Paul Graham has suggested that OOP's popularity within large companies is due to "large (and frequently changing) groups of mediocre programmers". According to Graham, the discipline imposed by OOP prevents any one programmer from "doing too much damage"
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
FootballPerl is like chess, only without the dice
*) you can also add methods on the fly to an object in JS. object.my_sub = function (...) { ... this.bla ...};
°) Well, she may be a class of her own but she's not my type.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Role::Tiny: When to use apply_roles_to_object?
by karlgoethebier (Abbot) on May 02, 2019 at 17:08 UTC |