Questions tagged [oop]
Object-oriented programming is a programming paradigm using "objects": an encapsulation consisting of data fields and methods together with their interactions.
62,301
questions
0
votes
0
answers
18
views
How to create optional properties in C#?
I want to create somewhat of a notebook app, where I can store different notes in a Database, I'm using Entity Framework for the context.. I have 2 different note types, one with input field and one ...
-3
votes
0
answers
21
views
Is it bad practice to use inner objects in OOP? [closed]
I do not know how to correctly phrase the title, so I will give an example.
In Backbone JS, a common example looks like this:
aModel = Backbone.Model.extend()
In my research, it seems like it is bad ...
0
votes
0
answers
65
views
In C++, when is it better to use a class with a state and an "execute" method, vs just a function? [closed]
My question is about code design in general, but consider the specific context of a numerical integration tool.
Option 1: a class with a state, setters, accessors, and an execute method.
class ...
0
votes
1
answer
20
views
Overriding toga.Button using super()
I'm a newbie in Python and to learn more about OOP I want to create a new button class based on toga.Button. I used the example on the Toga website (https://toga.readthedocs.io/en/stable/tutorial/...
1
vote
1
answer
28
views
initializing inline and initializing inside constructor which does run first in Typescript?
I'm learning about class concept in typescript. I recognize that there are two ways to initialize fields (properties) in typescript: initializing inline the class body and initializing inside the ...
0
votes
0
answers
15
views
update imports across all files after mass replacing a method header in subclasses
I have a method defined in a superclass, that is also defined in 32 subclasses
async fetchDepositAddress (code: string, params = {}): {
I updated this method to add a return type
async ...
-1
votes
0
answers
78
views
What about association in c++ [duplicate]
I don't understand the concept of association in C++.
This is my code examples:
Association: Object A knows about object B. Class A depends from B but does NOT consist of it
Car
{
???
};
...
0
votes
0
answers
14
views
Vscode not importing System.Object or any other library
I am encountering an issue with Visual Studio Code where it is not recognizing inherited files correctly. Initially, I had a problem where, in multiple places, class A inherits from class B, but VS ...
-2
votes
0
answers
18
views
Why am I able to create a class attribute using nested for loop and not able to do so using list comprehensions? [duplicate]
Why does this work?
class CardDeck:
suits = ['s', 'd', 'c', 'h']
ranks = [2,3,4,5,6,7,8,9,10,'Ace','Jack','King','Queen']
deck = []
for r in ranks:
for s in suits:
...
-1
votes
1
answer
17
views
Choosing Design Pattern between DB and Web App
I want to choose a design pattern for the next scenario:
We have one database and one web app, for certain users I want to scramble one of the columns of the database.
Currently, we think Proxy is the ...
-1
votes
0
answers
23
views
matplotlib shrinking pygame window
Whenever I run the program, the pygame window shrinks as the matplotlib window and the text inside is being rendered. I think im missing some information or im just being silly, help.
import pygame
...
4
votes
1
answer
94
views
Assign base object without changing inherited ones?
How valid is it to assign a new object to a base one, without changing the inherited ones?
The example below works as expected, but is it by chance?
This example is simple, but is there any situation ...
-2
votes
1
answer
54
views
When calling an inherited method from a derived class it tries to use the uninitialised fields of the base class [closed]
I have two classes. One called Agent, and the other called Player. Agent is the base class and Player is the derived class.
When calling the function SetHand() from the derived Player class, I run ...
1
vote
2
answers
19
views
Does multiple data processing violate the principle of interface separation?
I have the code.
@startuml
interface DbReader{
{abstract} read()
}
interface DbWriter{
{abstract} write(obj)
}
class DbConcrete {
read()
write(obj)
}
DbConcrete .up.|> DbReader
DbConcrete .up.|...
-1
votes
0
answers
17
views
What design should I use for this requirement: Static vs Non Static: Functional or OOP [closed]
Which design would you recommend for the following requirements: Static Methods, or traditional classes (immutable or something like a builder pattern). Are there any alternative designs or ...