Questions tagged [object-oriented]
For questions about object-oriented concepts including encapsulation, polymorphism, and inheritance, or for questions about object-oriented languages that are built around these concepts.
25 questions
8
votes
1
answer
1k
views
Why does JavaScript use autoboxing?
JavaScript has a handful of primitive types such as strings and numbers. However, when doing something fancy, it often wraps these types inside temporary objects in order to use object methods, a ...
4
votes
1
answer
223
views
What options are there for code sharing/default implementations in a structurally-typed language?
In many OOP languages with explicit inheritance/interface implementation, code can be "shared" or reused through method inheritance from the parent type, or through default implementations ...
1
vote
0
answers
134
views
Are there languages, libraries, style guides, etc, to make destructors events?
In languages that has a distinction between virtual and non-virtual functions, it is suggested to make the destructors of polymorphic objects virtual, because otherwise if a pointer to the base class ...
2
votes
1
answer
335
views
Should comparison operators check whether their arguments are the same object?
I'll focus on the == operator in C++. Its usual declaration signature for overloading is:
...
6
votes
1
answer
484
views
Are there OO languages which implement objects as persistent data-structures?
I am an object-oriented developer professionally, but I have researched functional programming and (believe that) I understand the key principles which to varying degrees are applied in FP languages.
...
-1
votes
1
answer
347
views
Strongest criticisms of object-oriented languages? [closed]
Linus Torvalds has famously attacked the object-oriented language C++, but he didn't offer many specifics about why, besides saying C++ uses "inefficient abstracted programming models". What ...
0
votes
1
answer
331
views
Can WillThrow as a Bottom Type of a Full-Lattice Type Theory take the thrown Exception Type as Covariant Type Argument?
Context:
Let us assume a full-lattice type theory with at least types any, bool, Exception, <...
7
votes
0
answers
339
views
Are there languages having multiple level fine control over deep and shallow copy?
A reference or level-0 copy is the same object as the original, only accessed differently.
A level-1 shallow copy is a new object, with every member a reference to the member under the same name in ...
5
votes
1
answer
367
views
Can final and full lattice type theory be combined?
Let us assume a language that has final with Java semantics, i.e. a final type cannot have subtypes. Further, let that language have a full lattice type theory with at least one bottom type, e.g. ...
4
votes
4
answers
565
views
Is it meaningful to disallow member variables in interfaces?
In an object oriented language with single inheritance, there is often the concept "interface", separate from classes, as a replacement of what would otherwise require multiple inheritance. ...
7
votes
1
answer
463
views
How to design interfaces to mimic haskell-like type classes in an object oriented language?
A problem I sometimes run into when using a language like TypeScript or C# is
how they lack a perfect analogue to Haskell's typeclasses. Let's use
Haskell's Functor ...
2
votes
1
answer
602
views
Is it correct that Python does not encourage us to read objects's content? [closed]
After playing around Python a little bit, I feel like Python does not encourage us to read objects's content. Take JavaScript for example: just a simple act of calling an object will list all the ...
4
votes
2
answers
485
views
Were there attempts to support triggering accessors on modifying subelements of properties?
Some languages offer the feature of properties, different from normal member variables, that trigger some code when you read from or write to the property. The triggered code are called accessors. The ...
4
votes
2
answers
615
views
What are the possible variations of the type of "this" or "self"?
In the class definitions of an object oriented language, this refers to the object instance the code is about to work upon. Naturally, it should have the same type ...
11
votes
3
answers
406
views
What are the advantages/disadvantages of making every class an instance of an Object superclass?
In some languages, all classes have an implicit superclass. For example, Object in Java/Python and Any in Kotlin. All classes ...