Skip to main content

All Questions

3 votes
1 answer
454 views

Object-oriented programming design with relational database tables

I want to understand what is considered best-practice to better align with OOP when handling relational databases. I cannot find any online examples where classes and a more maintainable/re-usable ...
Yannis's user avatar
  • 147
-1 votes
3 answers
620 views

Is it better to override methods in classes or make methods general?

I am creating the backend of a microservice that will serve as a tool to see in real time how the company's employees are distributed by projects and what days they have assigned to each one. The ...
Diegol's user avatar
  • 1
21 votes
6 answers
6k views

Does subclassing int to forbid negative integers break Liskov Substitution Principle?

In Python 3, I subclassed int to forbid the creation of negative integers: class PositiveInteger(int): def __new__(cls, value): if value <= 0: raise ValueError("value ...
swoutch's user avatar
  • 321
5 votes
2 answers
1k views

Design classes to model 3D scanned faces of ancient Greek/Roman sculptures: is multiple inheritance a good design solution?

I would like to deepen the topic of multiple inheritance using Python and I usually find examples that are too simple. I love art and I imagined the following problem and I want to understand if ...
blunova's user avatar
  • 398
0 votes
1 answer
3k views

Using methods specific to a subclass

I came across this SESE page: What is a proper use of downcasting? (for C#) -- and it talks about when to downcast, and the possible downsides to it. In Python sub classes are slightly different ...
user avatar
3 votes
2 answers
2k views

One boilerplate class or many similar classes?

Lets say I'm trying to model a variety of objects that are virtually identical, the only difference being their class variables. Am I better off creating one boilerplate class and just calling the ...
Dan Oberlam's user avatar
  • 1,291
1 vote
1 answer
328 views

Adding new functionality to all of shelve.Shelf's subclasses in Python

In order to avoid the overhead associated with the shelve module's writeback option I'm interested in putting together a shelf class that only accepts hashable values, with hashability being a proxy ...
kuzzooroo's user avatar
  • 615