573 questions
1
vote
1
answer
92
views
Address of 'this' pointer in Inheritance hierarchy
I was debugging some legacy code and while doing that found some inconsistency in the address of this pointer in the class hierarchy like this:
#include <cstdio>
#include <vector>
class ...
2
votes
1
answer
181
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 ...
2
votes
3
answers
1k
views
On which side shall I put the diamond sign in an UML diagram
I am trying to figure out where should the diamond be placed in this example, I understand its a has-a relationship and diamond should be placed to indicate the whole and part relationship.
I have ...
0
votes
2
answers
561
views
Why is my constructor telling me that a field must contain a non-null value when I am assigning it in the constructor but through a property? [duplicate]
In my class, I set the value of _owner indirectly in the constructor through the Owner property. However, the compiler still thinks that a value will not be assigned by the end of the constructor. The ...
-2
votes
1
answer
42
views
Is there a way to access a variable from a acctual CHILD class?
ps: I dont want to acess a parent class var but rather an actual child class
How do I access the $table var from User class? I know it sounds silly but is there a way to access this child class var ...
-2
votes
1
answer
74
views
Need Advice: C# OOP Class (or Data) Relationship
I am working on my research project. Let say I have a steel bar with predefined length of 6 m. I installed 3 sensor at location 0m, 3m, and 6m. The steel bar will be subjected to several test ...
0
votes
1
answer
71
views
What is the optimal way to manage the creation of objects of the same type that only differ in the values of their fields? [closed]
I have encountered this scenario several times but I couldn't find a definitive answer on the optimal way to manage it.
Here's the issue. I have a Java 21 backend application that provides a React app ...
-3
votes
1
answer
781
views
Hotel Reservation Use Case Diagram
I am designing a use case diagram for a HRMS (Hotel Reservation Management System). I tried to capture properly all the requirements. But I am confused, as I did some research and I read in this ...
-1
votes
1
answer
65
views
Abstraction vs Encapsulation , not the bookish definition , real world examples
I have searched about this topic everywhere that what's the difference between abstraction and encapsulation
, even one of the most voted stack overflow question , but at the end it seems confusing
...
2
votes
2
answers
131
views
Is Dependency Inversion Necessary to Ensure Decoupling between Caller and Callee?
I am trying to understand the dependency inversion principle (DIP) via some simple, but concrete codes and classes (implemented in python) from this tutorial. I am summarising it (with my own comments ...
1
vote
1
answer
79
views
Python: trace all previous call stack of a library for debug purpose
Is there any elegant and easy way to trace all the call stacks in Python of a library for debugging or code understanding purposes?
Suppose there is a very big huge library that I'm importing and need ...
0
votes
0
answers
84
views
Is it possible to provide default implementations of other traits through custom traits?
I have some questions from object oriented design. If I want to define a base class Path, which has two subclasses File and Dir, Path provides the validate method and the from_str method. For some ...
1
vote
1
answer
144
views
Where should I locate an Event Listener? Basics of OOP
After a few years I'm trying to get back to programming and therefore i am trying to programm a relatively simple app in android studio.
Im still at the part of thinking how the programm should be ...
1
vote
2
answers
62
views
does this form a circular dependency?
I am developing a chess program, currently refactoring some classes, and was wondering if the followings are creating a circular dependency.
Class A, depends on class B and C, and class C depends on ...
0
votes
1
answer
329
views
object-oriented programming architecture with database access design
With object-oriented programming in mind, how does the database come into play with objects? Like for example, let's say there is a Student class, with attributes like name, number, courses, etc
The ...
-1
votes
2
answers
67
views
How to make aninterface not too specific
I am creating a class that is supposed to upload files to many a S3 Bucket with a presignedUrl.
For now, I just have to upload files to a S3 Bucket.
But in the future, i will have to upload files in ...
0
votes
1
answer
48
views
Declaring and initializing object of type child class in its base class
What's the name of the code smell committed by the following code. I try to google around to find the de-facto name of the following code smell to no avail.
The reason why I'm searching for it is ...
2
votes
1
answer
349
views
design a set to classes to report battery/power status of different alexa devices
I was asked below quesion in Amazon sde2 low level design interview recently and I have shown below my solution during the interview. I was rejected in this round. Can you help me with a solution of ...
0
votes
1
answer
38
views
Resolve code duplication using Generics VS Inheritance
I have a common reader for three different classes, but there is some code duplication because the reader has different methods for each of the classes A, B, and C. Is there anyway I can make the code ...
0
votes
1
answer
896
views
Service Class with Multiple Repositories
class AccountClosureService(
private val accountClosureRepository: AccountClosureRepository,
private val userApplicationRepository: UserApplicationRepository,
){
// CRUD METHODS
}
interface ...
0
votes
2
answers
913
views
Why is the 'Public' keyword not being recognized"?
I am new to Salesforce Development/Apex and am running practice exercises.
When I run this code thru the 'Anonymous Apex' window, it throws an error reading:
"Unexpected token 'Public'. "
...
0
votes
1
answer
122
views
Object oriented constructor for Toplevel class (no side-effects)
I'm having trouble writing the constructor for a class that inherits from tkinter's Toplevel dialog. I'm calling it from another class that itself inherits from Frame. The problem I'm getting is a ...
1
vote
1
answer
81
views
Selenium Pagination
I am trying to get all links with pagination. I am using selenium. Since there is more than ten thousand data, it will take time to get all links and some informations in it. I want to use pagination. ...
-1
votes
1
answer
62
views
Can you advise on how to structure the problem proposed?
I'm re-working an old procedural algorithm in object oriented programming, and I'm trying to design the different classes/objects.
The algorithm is executing a couple of functions/methods.
The output ...
2
votes
1
answer
102
views
Declaring object classes in C?
I declared a few geometric figures types such as:
typedef struct s_sphere{
t_tuple origin;
double radius;
} t_sphere;
typedef struct s_cylinder{
t_tuple origin;
double height;
...
0
votes
0
answers
278
views
Two classes with exact same methods and field. Only 1 field has different value
Client needs me to provide two different classes Service1Transformer and Service2Transformer. Both classes need to implement the interface Transformer which only contains a transform() method. Now ...
1
vote
1
answer
422
views
Features and Use Case Diagrams Vs Requirements and Use Cases
According to "Head First Object-Oriented Analysis and Design", Complex projects involves first finding a feature list -> drawing use case diagrams -> breaking into smaller modules ...
0
votes
0
answers
52
views
Improving python code - Object Oriented (writing a deposit and charging code for bank)
I wrote 2 codes for a task that asked for a code to be used for the deposit and charging functions, and I want to see if there is a way to improve my code; make it more generic, or use __init__ ...
0
votes
0
answers
34
views
Speed type tester - how to reference variables out of scope?
I am relatively new to python and I am struggling with building this speed type tester, I am not sure as to why I can seem to change the value of ''time_over'' from false to true in the first function,...
0
votes
1
answer
203
views
Basic python - calculating %change between close and open price
I've got the following question and the challenging part of for me is to calculate the wanted value without using panda.
Question :
Please download a CSV file containing the stock history of some ...
0
votes
1
answer
180
views
TypeError: 'str' object is not callable when I was changing instance attribute
class Airport:
def __init__(self, code, city, country):
self._code=code
self._city=city
self._country=country
def __repr__(self):
return "%s(%s,%s)"%(...
2
votes
1
answer
2k
views
Can I use Final Activity node several times in an activity diagram?
I am currently drawing an activity diagram. There are several activities and end states, For example There is an end state 'display details' .After that activity is ended. Like this there are many ...
0
votes
0
answers
90
views
Matlab-Error-Variable might be used before it is defined
enter image description hereI have defined some classes and two of them Called "Global" &"GlobalFlag".
All the classes are in one folder and same path.
But in another related ...
1
vote
1
answer
5k
views
Python multiprocessing of class method
I want to perform parallel processing of a class method. This method writes to a dict to save the data. Within threads it works, but once the method exits, the dict appears to be untouched. Here is a ...
0
votes
0
answers
27
views
Access class parents attributes from a class child
so i have a class phone where we find the attributes : brand --> str, model--> datetime, price--> float, quantity: int
this is my code so far
the class parent
from datetime import datetime
...
0
votes
2
answers
112
views
How to delete elements from to do list?
I apologize if this is a bit confusing to read, this is my first post.
Please consider the following code:
HTML:
...
<form>
<input type="text" id="to-do-...
0
votes
1
answer
284
views
Labels(tkinter) in python, how can I update the value of a Label and then display it, without showing the previous values of that label?
So, I have this code, and it calculates an OTP(value) each time I click on Button(OTP), and that value is showed on myLabel. However, when it is displayed the values are getting accumulated, E.g. if I ...
-1
votes
1
answer
64
views
In Python can class.main() calls init method automatically?
I have a code snippet. Can anyone tell me whether class.main calls the initi method automatically? I cannot find a main method defined here, but calling to main. What is TwitterStreamWarcIter.main ...
0
votes
0
answers
84
views
Calling a function of the derived class from a variable type of parent class [duplicate]
I am learning Object Oriented Programming. I wrote the following simple program, but I don't follow why the call b->derived_function(); doesn't work. I understand the base class Base does not ...
1
vote
1
answer
207
views
Open-Closed Principle in Python OOD
I am designing a parking lot. Now I have three kinds of parking spots. I want to initialize my parking lot like this:
Building({Size.SMALL: 5, Size.MEDIUM: 6, Size.LARGE: 7})
This means this parking ...
4
votes
2
answers
207
views
Best Practice for OOP function with multiple possible control flows
In my project, I have this special function that does needs to evaluate the following:
State -- represented by an enum -- and there are about 6 different states
Left Argument
Right Argument
Left and ...
0
votes
1
answer
174
views
Creating Groups Based on Object Property Values then Assigning their Children to these Groups based on Parent Values
Context
I'm building a 3 tier nested hierarchy dropdown to display the location of certain IoT devices within a building. The Floors are at the top of the hierarchy and grandparents of the Level ...
0
votes
0
answers
53
views
JAVA-Assertion fails even expected output seems to be matching with the actual output. Please help me out with the possible solutions
This is the result of Integration testing!
Message:
N/A
Stack trace:
org.opentest4j.AssertionFailedError: expected: <Songs Loaded successfully
1 Kiran
Playlist ID - 1
Playlist ID - 2
Delete ...
-1
votes
1
answer
165
views
Creating class for missing variables in python
I would like to create class to find the missing values but below is my mistakes and how can I fix that please help?
import pandas as pd
data={'product':['A','B','C','D'],'sales':[100,None,...
0
votes
0
answers
55
views
Is there a way of avoding diamond kind problems this OO Design
I have an event processing use case where I am using templates for various kinds of logic involved during event processing e.g transaction handling, processing template based on events e.g update, ...
2
votes
1
answer
69
views
explanation to this recursion problem in python
check this sample code for backtracking, there are two ways I can append the variable i to curr before backtracking, the one here (not commented) updates the global ans array, whereas the other way ...
0
votes
0
answers
70
views
Questions about Java OOP(Inheritence)
I am trying to make a videogame that is similar to "Turing Complete". In this game you are supposed to connect circuit pieces to create a computer by the end. So I have a question on ...
0
votes
2
answers
218
views
How to use polymorphism in anemic domain model design?
Now i am working on a mmorpg server,Let's talk one scene that player drop something from inventory to world
If I design the Drop with rich domain model,i will create code like this
class Player {
...
-1
votes
1
answer
56
views
I am getting null as outcome ? Could anyone catch and rectify for the same Thanks
This method I created
public class Use {
private
String firstname;
String lastname;
public String output() {
return "Hii my name is " + firstname + ...
0
votes
1
answer
235
views
Access attribute of container from member Python
I have a class (PlayerList) that contains Player objects (or subclasses) by inheriting from list builtin. I want each of the Player objects to use the container's attribute true_dice. The problem is ...