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,297
questions
-1
votes
0
answers
26
views
How to handle different database objects in a single Java method
I'm writing a library that handles data storage in different tiers. Most objects are persisted to some hot tier database (DynamoDB) for fast access and eventually moved to a cold tier database (s3). ...
0
votes
2
answers
106
views
How do interfaces solve the circle-ellipse problem?
It is sometimes said that interfaces solve several problems of object-oriented programming, in particular the circle-ellipse problem. It would be this interface
class IEllipse {
public:
virtual ...
-3
votes
0
answers
34
views
Method Resolution Order in Golang [closed]
When method talk is called in C object it goes to A branch, and never goes to C branch of embeddings. My question is which MRO used in Golang and where in standart it desctibed
package main
import &...
0
votes
1
answer
22
views
What is the difference between Properties and VAR_IN_OUT in Structured Text Object-Oriented Programming?
I am new to Object-Oriented Programming (OOP) in Structured Text (ST), but both familiar with OOP in C/C++ and ST. I would like to understand what is the difference between Properties (with a ...
0
votes
0
answers
37
views
How to properly encapsulate data in this quadTree program? [closed]
I'm learning C++ and OOP by implementing some two-dimensional scientific computations on adaptive mesh with quadTree structure. The basic idea is that there is a rectangular forest of (Nx*Ny) trees, ...
0
votes
0
answers
26
views
Best Practice for updating class attribute based on values
I have to read set of csv files which have 5 columns like name, age, address, type and distance. As these column names are string and I want to iterate them in my pandas df. I have created a class ...
0
votes
1
answer
57
views
Handling diamond inheritance super class invocations in Python
I have a class setup that looks like below
from abc import abstractmethod
class Player:
def __init__(self, name, age):
self._player_name = name
self._age = age
@property
...
3
votes
1
answer
61
views
Why objects having instance of a class with private property in prototype throw when accessing private member?
Consider this code:
class Klass {
#priv = 42
get pub() {
return this.#priv
}
}
// these two correctly return 42
console.log(new Klass().pub);
console.log((new class extends Klass {})....
0
votes
0
answers
19
views
my paddle is not responding towards keys, Why? [duplicate]
i am building a pong game using python and my paddle is not responding towards keys. Why?
It's showing error
TypeError: unsupported operand type(s) for -: 'method' and 'int'
from turtle import Screen, ...
0
votes
0
answers
70
views
Pure virtual method called in derived class Player
I've been writing a simple 2D game in SFML. I've done a draft version of the game, but when I run the program, it reports an error:
Pure virtual method called
The debugger wrote the problem is in ...
1
vote
1
answer
64
views
How to override generic method in subclass java
I am trying to refactor some code in order to reduce code duplication.
Currently I have a service that takes its own custom Payload class and returns its own Response class. And currently it is not ...
-2
votes
1
answer
28
views
OOP Encapsulation - Does it provide full data protection?
Coursera: Encapsulation can used when dealing with secure data or methods because it can restrict which functions or users have access to certain information.
This means that encapsulation protects/...
2
votes
1
answer
57
views
Ruby setter-methods: Is the equal-character (=) a convention or functionality?
Taken this class as a example:
class House
def initialize(color, size)
@color = color
@size = size
end
def color
@color
end
# Is the = part of the syntax or a convention?
def ...
0
votes
2
answers
48
views
Errors when using abstract methods in Python when calculating
I am writing code for calculations, I started testing and ran into a problem, an error pops up when trying to get an answer:
Traceback (most recent call last):
File "G:\LARIS\tests\...
-1
votes
0
answers
25
views
When i try to update value of the code if i leave this field null it encounter an error and program exit [duplicate]
When i choose update product and leave warrantyPeriod blank this error occur
Enter new warranty period (leave blank to keep unchanged):
Exception in thread "main" java.lang....
-3
votes
0
answers
27
views
Passing all but 1 argument in Python init child class [closed]
I have a Child init function that takes in arguments and passes those to the parent function. However if the user passes in a 'token' param to the child class, I don't want that to be passed to the ...
1
vote
1
answer
30
views
Stopping a Python thread from class when an object gets deleted
I'm building a class which has a thread that does some work in the background. I want this thread to be deleted whenever the class is also deleted or goes out of scope. The code I'm using is ...
0
votes
2
answers
50
views
class keyword for UPROPERTY()
I'm new to UnrealEngine and studying C++ development in scope of games. For now I read a tutorial where I should create a AMyPawn and UPawnMovementComponent to attach it then.
Here is the definition ...
-2
votes
2
answers
90
views
Custom integer-like datatype with support for static casts without warnings
I'm writing my own little utility library, and I've opted to do something which I don't really see often (and there might be a reason) - I'm trying to implement a 'perfect' wrapper around C++ integer ...
0
votes
3
answers
118
views
How to update a form-related (data-)model with every form-data change?
I have the following function, in order to update values from four different input fields:
UPDATED
My Package Class is defined as followed:
class Package {
constructor(packageID, type, weight, ...
-1
votes
0
answers
42
views
How do I pass values to the constructor which requires an array type object? [closed]
class Students
{
private String rollno,name,dept;
private arrayObjects[] subjects;
public Students(String rollno,String name, String dept)
{
this.rollno=rollno;
this....
-3
votes
0
answers
38
views
Logic error when assigning the loaded data to object of an object array [closed]
When assigning details after loading the details , the values are changing to same values in object arrays.
This is the sample text file
Geethaka, w2024001, 55, 25, 100
Sankalpa, w2024002, 85, 95, 65
...
-2
votes
0
answers
59
views
Is there any way that I can write this class better than I did?
I'm developing an e-commerce website for my uncle using C#. I'm trying to think of a better way to write this class where I can perform the update operations faster, if I need to modify a user's data.
...
-7
votes
1
answer
93
views
can anyone tell me how can I create multiple objects using vector without specifying the length of vector
I tried to do it using the vector<string> and iterating through it to create the object but while assigning them value i am getting error
#include <iostream>
#include <string>
#...
2
votes
1
answer
35
views
Aggregation vs Composition : Thinking at object level or class level
I am confused about how to decide aggregation vs composition for Has-A relation. Let me explain my doubt with example of BookMyShow App(BMS) which is Show booking platform and assume a Show can be ...
-1
votes
1
answer
64
views
std::is_same_v weirdly return false when true is expected using CRT pattern
#include <iostream>
#include <type_traits>
template <template <typename,unsigned,typename...>typename interface,typename T,unsigned ChannelN, typename...Args>
struct base : ...
-3
votes
0
answers
31
views
i getting this error RangeError: Maximum call stack size exceeded [closed]
in the serviceA and serviceB both are depend on each other like i'm used the serviceA in ServiceB and serviceB in serviceA so its give me this error. i'm used the singleton class approach is any other ...
-1
votes
0
answers
35
views
Xcode Error on AppDelegate Class Declaration in Swift iOS Project [closed]
On line ten of this swift code I am getting a error I have asked ChatGpt and could not get a valid response that is why I reached out the the stack overflow community
//
// AppDelegate.swift
// I am ...
-2
votes
1
answer
55
views
How to share the A::a value to the other class B::b, if in A class i have class B object [duplicate]
So, I'm creating the c++ project and I've encountered a new problem.
And the question is: How i can get the A::a value in efficent way.
I will mention that class A is pretty big and i dont want to get ...
0
votes
2
answers
60
views
Accessing a method of the parent class, from a sub-class in c#
Im getting myself twisted up in a knot, trying to access a method in a parent class, from inside a child class. My aproach/understanding of how this works I think is off.
The entry of my application ...
0
votes
0
answers
21
views
Accessing a Python Object Instance by using a user-input [duplicate]
im trying to access a class method from a user input. An example would be that i want to get access the method "drive_to(destination)" from the instance "fast_bycicle" of the class ...
-4
votes
0
answers
22
views
Explain the concept of decorator in this example [duplicate]
How to access the decorator height and height.setter in this below code:
class Square:
def __init__(self, w, h):
self.__height = h
self.__width = w
def set_side(self, ...
0
votes
1
answer
57
views
Python Tkinter: Unable to make a calculator project
I am making a calculator project using Python Tkinter with an OOP concept, and I cannot figure out the problem with the function class. The function class is responsible for division, multiplication, ...
0
votes
0
answers
50
views
I was trying to create class mystack which would work like a stack datatype but i encountered unexpected output
This is the code where i tried to implement stack in c++ without pointer instead i used a interger variable called "top" to hold the current position of stack and also i created constuctor ...
0
votes
0
answers
40
views
Why go-staticcheck reports "unused method" when implementing interface
I have written a fairly simple code. It simply "implements" the factory interface in a stateless way. It works as expected, however I got a warning from Golang linter that both make() and ...
0
votes
1
answer
101
views
Java Generics Warnings
I've been studying generics in Java, and after learning from various sources, I attempted to build a generic class that accepts a Number or its subclass during instantiation. This class includes a ...
0
votes
0
answers
31
views
Returning "this" in Method with Generic Return Type [duplicate]
I'm writing generic methods and I am confused as to why the following code snippet throws a syntax error:
public abstract class Parent
{
public virtual T MyMethod<T>() where T : ...
-1
votes
0
answers
32
views
I wrote this code and I don't know why I get this error or how can I fix it [duplicate]
#based on McDonald's Menu
from abc import ABC, abstractmethod
from datetime import datetime
# all the amount are in grams
class SubIngredientABC(ABC):
def __init__(self, name : str, amount : ...
1
vote
3
answers
81
views
Inheriting Structs in C++
I am working with the LibAV library, converting it from C to C++ (and moving to an object oriented style).
This library has structs to hold data, which need to be created using specific allocation ...
-1
votes
1
answer
46
views
How to model subscriptions features when each feature has different threshold number for each subscription and different time interval limit
I am creating spring boot app that has 3 subscription plans.
basic
pro
unlimited
I have two actions(1.CREATE_POST, 2.GENERATE_POST) that should be limited for each plan.
For basic plan user should ...
0
votes
2
answers
36
views
How to parse API JSON response that contains 1 list of multiple (2 in my case) types of objects in Android, I'm using Retrofit for API call
'So I searched enough, there isn't any question like this im sure. And I'm wondering how can this be not a questions others have come across or am I soo noob?
So the API response is as follow
{
"...
-1
votes
1
answer
48
views
Accessing a live object from another microservice (Java)
I am trying to access an already created object in a microservice from another microservice.
The complete description of the problem is as follows -
framework - spring
Microservice A :
An object of ...
0
votes
1
answer
29
views
System Verilog: Biitwise coverage for multibit signal
I'm beginner in System Verilog. I want to implement a coverage such that a user will send a signal - lets call it input_signal[Width-1 :0] Where width is variable. I want to have bitwise toggle ...
-3
votes
1
answer
45
views
Instantiating large number of objects from different types
Assume there is interface:
type CustomMetrics interface {
Update() error
Init() error
}
This interface will have many different implementations (structs), each implementation will be shipped ...
-1
votes
0
answers
16
views
Bug in updating a system of differential equations
I am working right now with python to solve an ordinary differential equation involving some background function A_0. Very concisely, the problem I want to solve is something like this:
while not ...
0
votes
0
answers
53
views
Dlls & Memory Management
This is more of a general question and not specific. I am writing a dll in C++, there are C++ classes and some extern C-wrapper functions that handle the interaction between the client and the classes....
0
votes
0
answers
47
views
Correct approach for creating a modular application in C#
I am currently trying to develop an application (Windows Form), where the main objective is to establish a serial monitor, and an interface for board-specific controls (I have several similar modular ...
0
votes
1
answer
62
views
How to create a generic factory function that creates an instance of some type? [duplicate]
I need to create a factory function to create an instance that can accept any type with the different number of arguments.
I have two classes Employee and Contact and to create an instance for both ...
0
votes
0
answers
68
views
should really need to extract the member to another class
I have several classes for draw chart,
class ChartBase {
private:
int transparency; //chart attribute
};
class XYChart : public ChartBase{
private:
std::string xAxis;
std::string yAxis;
};
...
0
votes
1
answer
51
views
OOP command design pattern with polymorphism
I'm trying to make a command-like interface for a user system using OOP design structure and principles.
So I have an abstract User class and different types of users that derive from it.
Then I have ...