62,267 questions
Advice
1
vote
9
replies
109
views
Should I focus on coding exercises or building projects to learn C++?
I am a begineer and i want to learn c++ by doing projects please suggest me any project that i can do to increase my experience of c++
my old projects are:
hang man game
bank management system
has ...
0
votes
3
answers
95
views
How to refactor multiple if-elif statements into a Strategy pattern in Python?
The Problem: I am building a simple data processing tool. Depending on the file format (JSON, XML, or CSV), I need to apply different parsing logic. Currently, I’m using a long chain of if-elif ...
4
votes
2
answers
149
views
Get multiple indexes of an array at once, for comparison
I am working on a Tic_Tac_Toe project. I have an object (gameBoard) that contains an array, then I have another object that i want to create a player from to play on the board, then I have a function ...
Advice
2
votes
8
replies
143
views
C# Dependency Injection Without Objects?
When writing C# applications, it often feels like we’re encouraged to make methods instance-based even when they would naturally be static. Of course C# is an OOP-first language and patterns like ...
Advice
0
votes
10
replies
206
views
question regarding parent and child class
Given a class Child which is derived from class Parent. When creating an object from class Parent, select the correct type for the variable dan which will be assigned the reference to the Parent ...
Best practices
0
votes
3
replies
53
views
Class inheritence vs one class being element of the another
Suppose we have two classes A_class and B_class. We want to connect them in a way that allows to access methods and data of B_class from A_class .
We can do it through inheritance:
class A_class : ...
Best practices
0
votes
6
replies
113
views
How should toString methods be formatted
I lately learned about the toString method and its uses.
From what I've been taught, the toString method is used as a concise representation of an object as a string of characters, usually used as a ...
0
votes
1
answer
114
views
While implementing custom stack I got type 'int' must be a reference type in order to use it as parameter 'T' in the generic type or method 'Stack<T>' [closed]
I am getting this error while implementing a stack by myself.
Here is my code
interface IStack<T> where T : class
{
void Push(T item);
T Pop();
T Peek();
bool IsEmpty { get; }
...
Advice
2
votes
4
replies
141
views
How do I modify Enemy class to chase the player in an object-oriented programming JavaScript game?
I'm trying to create a game in HTML, CSS, and JavaScript. I started following the tutorial by FreeCodeCamp: https://www.youtube.com/watch?v=7BHs1BzA4fs. The tutorial was on a side-scrolling game(...
Best practices
0
votes
3
replies
131
views
Is using Singleton pattern in Python viable for global Configuration object?
I've read quite a bit on SO and elsewhere on Singleton being anti-pattern (hard to test, thread unsafe etc), e.g.: https://www.michaelsafyan.com/tech/design/patterns/singleton
However, there still ...
Advice
0
votes
10
replies
260
views
Are Claude's advices good practices that I should use?
I am still a beginner, and I am trying to understand what is a good practice and what is not. Saw a YouTube video on a little project about making a turn-based game in C# in the Console while also ...
Best practices
0
votes
5
replies
107
views
Is it good design to use dynamic cast?
I am trying to implement password manager on Java right now. I am implementing the vault. I have VaultEntry and VaultFolder classes. VaultEntry has fields id, parentId, name, username, email, password ...
2
votes
1
answer
182
views
Is this design of operator== correct?
I have a hierarchy of classes which should compare for equality by the following rules:
objects of different classes are not equal;
objects of the same class are compared using logic specific to ...
Advice
0
votes
2
replies
131
views
Getters and Setters in Python (Dataclasses)
I'm learning for my Introductory Programming Course in uni and I don't have an overview over the different cases when it comes to Setters and Getters and the slides are not quite helpful.
So for ...
Advice
0
votes
11
replies
206
views
When to use standalone functions in C++?
I am a beginner C++ programer and I am trying to make a very simple random number generator for my program.
I started doing this by creating a struct in a header file but I am wondering if this is a ...