Questions tagged [object-oriented]

Object-oriented programming is a programming paradigm using "objects": data structures consisting of data fields and methods together with their interactions.

Filter by
Sorted by
Tagged with
5
votes
3answers
1k views

C++ basic bank money class

I am trying to create a basic money class that fits into a small console banking application I am making. Money.h ...
-1
votes
0answers
18 views

Vue JS - Error : Property 'xxxx' does not exist on type <component-name> [closed]

I'm new to vue, So, to describe my work: I implemented a form and bound it to the data() hooks to retrieve the data from the from, and then onSubmit() I create an object newClass{} and $emit it to ...
3
votes
1answer
92 views

Cyclic generator with access to current local state and executes callback after each cycle

I'm working on a Python class that is a cyclic generator, like itertools.cycle, but it offers access to its current state and executes a callback after the ...
6
votes
1answer
76 views

Model for a multi-channel programmable electrical power supply

I am modeling a programmable electrical power supply which has multiple independent channels (or "ports") in a class I'm calling Supply. One of its features is the ...
2
votes
1answer
63 views

PHP OOP: Configuring MySQL DB & query w/ Twig

I decided to up my PHP game and learn some OOP. I am re-building my website from procedural to OOP, but since I don't want to use a full framework I fiddle with some components. As a router I use ...
0
votes
1answer
54 views

Composition and lazy evaluation: is the composite class properly designed? [closed]

Let's consider the following assumptions: The Python programming language is used. One composite class is implemented. There are two or more component classes implemented. For instance, the composite ...
1
vote
2answers
96 views

Is my Tic-Tac-Toe design clean?

The following is an implementation of Tic-Tac-Toe game. I tried to incorporate S and O principles without violating ...
3
votes
2answers
8k views

What's wrong with static utility classes, versus beans?

My inclination is to make these methods static: ...
2
votes
2answers
281 views

Address class in PHP 7.4 with types

About this exercise I found out there is a form of strict types in PHP 7.4, so I freshened up my PHP coding with this simple Address class. I did not use PHP since ...
2
votes
2answers
308 views

Bool function in PHP to check if you run the script inside docker

I had to do a CLI script that does something, I also had to add a validation that checks if it runs inside the Docker. After some research I found a solution that people check some processes via ...
1
vote
1answer
2k views

Deque implementation with array in Java

I'm trying to implement a deque data structure with an iterator in Java using array. Please help to review and point out things that I can improve on. ...
0
votes
1answer
34 views

Advent of Code 2021 Day 4: Play Bingo against a Giant Squid

[This is my first post here - though I have been lurking in the back reading, plussing, and hopefully learning for over two years] Below is my solution for Advent of Code 2021 Day 4, where you are ...
4
votes
3answers
216 views

Implement IDisposable correctly using object composition principle

Update at the end Is it possible to implement IDisposable pattern correctly while using object composition principle to promote code-reuse, reduce code duplication ...
2
votes
1answer
99 views

red black tree implementation in cpp

I am learning algorithms and trying to implement them in c++, I have chosen to try to implement a red-black tree due to its self-balancing properties and its ability to stop the worst case of O(n) ...
0
votes
0answers
10 views

Good practice to structure a react code capable to connect to different devices

I am writing a "simulation" tool for my app where I can define a device (like IoT device/gateway device/server etc) and choose the type from which I want to receive data (Bluetooth/serial ...
4
votes
3answers
492 views

C++ money class for basic banking application

I wanted to get my code reviewed as I have tried to implement a basic Money class to represent money values in c++. Can anyone tell me if I am implementing my basic arithmetic operator overloads ...
0
votes
2answers
102 views

c++ Most clean way to implement duplicate Binary Search Tree for complex type

I have tried to make my own implementation for a BST task I was given for a complex type (Transaction), that should be able to store duplicate values as well. However, I am not sure if I have gone ...
3
votes
1answer
109 views

C++ bond mathematics calculator

I have written a program in C++ that processes financial bond mathematics, making extensive use of the valarray class, so that mathematical functions and operations ...
0
votes
1answer
24 views

interface different usages issue for two or more different implementations

I am writing a small micro-service in typescript with NestJS. This microservice is responsible of giving a user access to one of our company's systems trial access. At first I used hubspot integration ...
5
votes
1answer
467 views

CLI Menu library

I started writing a small CLI menu library in python. I'm uncertain of the structure and scalability of the current code. For example the Menu.choice method would ...
1
vote
0answers
25 views

AutoBind TypeScript decorator

Idea is to have an AutoBind decorator which you could append in front of any method to have it preserve its own this, instead of manually binding it when called. <...
2
votes
0answers
78 views

Android nested RecyclerView handling clicks, using OOP

Brief Background: I just started learning Android Development recently. I have some experience with programming and understand the basics of OOP but am not confident that I am using principles of OOP ...
0
votes
0answers
14 views

Object orientated hitbox overlap

An object named objStupid calls the script object_createHitbox to initialize some basic variables(x, y, width, height). Next, it ...
0
votes
0answers
51 views

Stock Exchange Low Level Design

I'm new to LLD. Just started practicing it. Please review my code below and give me suggestions to improve. Models ...
0
votes
3answers
78 views

Object-Oriented Hangman In Python [Follow-Up]

This is a follow up after revisions made from this question. I've separated the program into 2 classes. The HangManData class is used to store game data such as the ...
4
votes
2answers
80 views

UNO card game with AI players

I had lost a lot of cards of my UNO deck, and was frustrated, and that's when this idea struck my mind. I chose C++, knowing it would be hard, just to improve my understanding of the language. ...
7
votes
3answers
3k views

Chess game in Python - follow-up

Three weeks ago I wrote the first version of my chess game in Python and shared on Code Review. Thanks to your suggestions, I improved my code. I would like to know if I am going in good direction ...
4
votes
1answer
75 views

Objected-Oriented Hangman game In Python

I'm still a beginner in python and made this simple program to practice OOP, I've ended up using the self keyword a lot and I'm not sure if this is normal or if I ...
5
votes
1answer
82 views

Space Invaders clone for a college project

Edit: the project was submitted, and I got a good grade! :D I am finishing up a project for my computer science class. The project is a space invaders clone that uses the JavaFX library to provide ...
4
votes
2answers
274 views

Simple console application to practice OOP and file layout

I am not used to work with OOP so I decided to make a simple console "walk" game to focus on the OOP and the general game design process. I tried to make it as robust as possible but I feel ...
-2
votes
0answers
18 views

Why does sys.exit() subtract the total? [migrated]

I have a task at hand to write a program to calculate the sum of numbers. This is a beginner python program. I have found two solutions for this exercise in which one is working perfectly well and ...
4
votes
0answers
88 views

Sudoku sequence solver for non-standard constraints

This script is designed to help solve sequences in Sudoku puzzles with variant constraints (ex: Thermometer, Renban, etc.). Summary The user specifies the constraints they want applied as well as the ...
10
votes
6answers
2k views

Console Library System in C++

I'm a beginner and came up with this simple project in C++. Any feedback would be very much appreciated. GitHub Repo Note: I'm using a file called "db.txt" as a database. main.cpp ...
0
votes
3answers
108 views

A Class that creates a unit of Stock or a collection of Stocks

I have a dataclass of a single class object 'AStock' as such: ...
6
votes
1answer
213 views

Hot Dog Cookout Calculator

Hiii... Can you please check the code and see whether I might have done a mistake ? Beginner's eyes can be misleading quite easily. I feel like there's something wrong in this solution. I can't ...
2
votes
0answers
48 views

SQLite C/ADO VBA library with reflection

SQLite C/ADO VBA library with reflection The SQLiteCAdo library is a VBA middleware facilitating access to SQLite databases. Its two subpackages provide alternative connectivity options: via ADODB/...
0
votes
3answers
90 views

The bulls and cows game

I have implemented the bulls and cows game in C++. The code: ...
0
votes
0answers
54 views

Object Oriented Routing using Python's FastAPI

I created a BaseRoute class route handling. The BaseRoute class takes the following parameters: ...
3
votes
0answers
138 views

VBA class managing loading DLL libraries

I am playing with a custom-built SQLite library intending to access it from VBA via the C-language API. I keep the library within the project folder, so I load it via the LoadLibrary API. To make the ...
1
vote
1answer
51 views

Learning Javascript OOP with a Collapsing Item Class

I'm trying to get into object oriented javascript programming. I have written a class for collapsible elements as a test. These elements all have a certain class and no matter how many elements there ...
1
vote
1answer
68 views

Predeclared class instance tracks the number of regular instances

Predeclared class instance tracks the number of regular instances In VBA, predeclared class instances can act as object factories, and in general, it makes sense to keep this instance stateless. ...
1
vote
0answers
40 views

Resolving circular references in VBA via ObjectStore class and CleanUp cascade

Resolving circular references in VBA via ObjectStore class and CleanUp cascade I have been working on a VBA database library and realized I had a few circular reference loops in my class hierarchy, as ...
14
votes
4answers
1k views

Numerical integration in C++: Newton-Cotes formulas

I have tried my hand with implementing simple quadrature formulas in C++. Definite integral: $$\int_a^b f(x) dx$$ Domain of integration \$[a, b]\$ divided into \$n\$ intervals of equal length \$h = (b ...
3
votes
2answers
151 views

TicTacToe Objects calisthenics OOP

I'm learning Objects calisthenics and I was practicing with the typical Tic Tac Toe game, I was wondering if you could gimme feedback about my mistakes (Algorithmic problems, logic, and especially OOP ...
2
votes
2answers
86 views

Fractions in C++

I started learning classes and operator overloading in C++. To test my skills I decided to make a Fraction class with all necessary operations. I would appreciate improvements and suggesstions on my ...
2
votes
2answers
67 views

Setting instance variable for salary bonus based on academic position

I have a class Scholar which is basically a teacher in a university. I have to calculate the yearly salary of a scholar instance where the formula is ...
7
votes
2answers
102 views

Connect to MYSQL database in PHP with prepared statements

I have recently learned about using PDO. I created a db class which could handle common actions like create, update, delete and select. Is this method a correct way to connect to the database using ...
2
votes
1answer
95 views

Builiding a Model from Stored Procedures

After reading that Data Classes can be considered a code smell, I am shifting from a pattern with many data classes and a single manager class that handles all the instantiation of the classes, to a ...
7
votes
3answers
4k views

Enum usage to restrict class attribute values

I am using enums in python3 for the first time but unsure if I am using them correctly. I want to restrict the 'allowed values' for a class attribute ...
2
votes
1answer
88 views

Evaluating postfix expression on multidigit numbers

This is my solution for evaluating postfix expression using a stack. It does work on multidigit numbers, the problem I was struggling with last time. Now it works completely fine. This is the stack ...

1
2 3 4 5
74