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
1 vote
1 answer
203 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
450 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
  • 147
4 votes
2 answers
441 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,010
3 votes
2 answers
347 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,010
10 votes
3 answers
292 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,553
10 votes
1 answer
339 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
3 votes
2 answers
154 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
  • 8,563
2 votes
1 answer
148 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,010
5 votes
1 answer
139 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
  • 8,563
6 votes
2 answers
480 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
  • 8,563
12 votes
1 answer
230 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
  • 16.3k
8 votes
1 answer
113 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
  • 8,563
10 votes
2 answers
107 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
  • 10.9k
12 votes
2 answers
259 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
  • 8,563
3 votes
1 answer
95 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,747