Skip to main content

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.

Filter by
Sorted by
Tagged with
5 votes
1 answer
317 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. ...
feldentm's user avatar
  • 1,779
4 votes
4 answers
335 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. ...
user23013's user avatar
  • 2,510
6 votes
1 answer
346 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 ...
Kilian Kilmister's user avatar
1 vote
1 answer
213 views

How might we convert type declarations into constructor calls? [closed]

Suppose that we have two languages, A and B. In language A, there are a lot of data-type declarations. In language B there are no data-type declarations to the left of the assignment operator, but ...
Samuel Muldoon's user avatar
2 votes
1 answer
493 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 ...
Ooker's user avatar
  • 175
4 votes
2 answers
455 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 ...
user23013's user avatar
  • 2,510
3 votes
2 answers
413 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 ...
user23013's user avatar
  • 2,510
11 votes
3 answers
321 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 ...
FireTheLost's user avatar
  • 1,613
10 votes
1 answer
384 views

What are the different class-like constructs that languages use today?

Taking this question to its logical extreme. Some languages like C++ and Python use class for everything. Python classes are classes, interfaces (both nominal and ...
Silvio Mayolo's user avatar
5 votes
2 answers
218 views

Why do languages differ about when `super` must be called in a constructor?

Many languages require you to call super before setting your own properties, like in TypeScript: ...
Bbrk24's user avatar
  • 9,057
2 votes
1 answer
156 views

Virtual functions from two classes

Years ago, I have implemented something in C++ that involves two kinds of list of the same value type: a sparse list and a dense list. Each operation between two lists has 4 versions (two of them are ...
user23013's user avatar
  • 2,510
5 votes
1 answer
157 views

How should unapplied method references be handled?

Several OO languages allow you to grab unapplied method references. Some, such as Kotlin or Python, have them accessible from the class itself and just append self ...
Bbrk24's user avatar
  • 9,057
6 votes
2 answers
1k views

Why does C++ require private methods to be declared with public ones?

C++ and Objective-C both require forward declaration of the methods and fields on a class. Objective-C lets you hide the existence of internal/private methods & fields altogether: ...
Bbrk24's user avatar
  • 9,057
12 votes
2 answers
293 views

How can an object-oriented language support hot reloading of classes?

Consider an object-oriented language like Java. Typically, when a class is modified and recompiled, the software which uses that class must be closed and restarted, and the program state may need to ...
kaya3's user avatar
  • 19.7k
8 votes
2 answers
148 views

How can runtime type checks be implemented?

Most if not all OO languages have some way to determine whether an object belongs to a given class at runtime. In some languages -- both interpreted (like JS) and compiled (like Objective-C) -- ...
Bbrk24's user avatar
  • 9,057
10 votes
2 answers
125 views

How should I represent objects under prototype-based inheritance?

If I use a class-based system, I know what shape an object will be at the time I construct it, and I know exactly which fields and methods it has. They can be put in fixed locations that remain stable,...
Michael Homer's user avatar
  • 13k
13 votes
2 answers
373 views

Why is Smalltalk’s cascade operator not more common?

According to the Wikipedia article on Smalltalk, in the Expressions section, | window | window := Window new. window label: 'Hello'. window open If a series of ...
Bbrk24's user avatar
  • 9,057
2 votes
1 answer
105 views

How do I Implement User-Defined Classes? [closed]

Say I have a programming language that can support user-defined classes (all debates over whether OOP is actually good aside) - how do I store instances of these user-defined classes when executing a ...
lyxal's user avatar
  • 1,785