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
0
votes
1answer
13 views

optimize integer validation

I have some classes with properties, wich could only have numeric values in a given range (e.g. 0 to 8). This should be validated and wrong values prevented with an exception. The given behavior may ...
0
votes
0answers
29 views
5
votes
2answers
142 views
+100

Class showing a format similar to var_dump RC5 Version

Some methods of this library require some improvements (see this description): In the constructor I am trying to create the possibility that the user modifies the ...
0
votes
1answer
68 views

C# code for Dhond't voting method UK Parliament

Please can you check if the code I have written follows 4 rules of OOP well enough, if there is anything that could be improved or is just wrong I am happy to change (very new to C# sorry if it's ...
1
vote
0answers
20 views

Parsing a large XML file and storing in Postgres efficiently using Pythonic code

I have a bunch of large XML files that I have to parse and store in Postgres. I have done a lot of procedural code but I want to think in terms of objects and reap the benefits. Any help in that ...
-1
votes
0answers
52 views

How to use Dependency Injection properly in asp.net core?

I have a legacy Asp.net Core 3.1 application which uses Kestrel server and all our GET and <...
0
votes
0answers
28 views

Find number of times a property has a truthy value in a nested object

I have a nested object and I would like to calculate the number of times the property 'error'. I am able to go n levels deep and find the count. Is there a better solution than mine? ...
2
votes
1answer
59 views

Python - Inheritance: sharing objects across instances

Use case - motivation & challenge Hi all! I have been working with Python for the last two years, but never learned proper object-oriented programming and design patterns. I've decided for this ...
2
votes
1answer
41 views

Replace words from a file with words from a dictionary based file

I'm working on a coding challenge that tasks me with taking a file with a dictionary, reading from it, and then replacing the matching words from the input file with what is found in the dictionary. I ...
6
votes
2answers
553 views

Simple Banking System with Python

Relevant Background: Greetings. This is my first attempt at using the OOP paradigm (only really used R prior to this). The project prompt came from ...
1
vote
2answers
57 views

Router and solid principle

I would like to know if my Routing system respects the solid principle ? The system is simple, Router class contains the routes and returns the correct route and Route class represents a route, ...
-1
votes
0answers
51 views

Router with solid principle

I want to know if my Routing system respects the solid principle ? And how i can unit test this code ? The system is simple, Router class contains the routes and returns the correct route and Route ...
2
votes
1answer
46 views

Guess Number Game - Console based game using Java

This game is pretty common for beginner projects. I wrote a version of this before all in Main - so here I challenge myself to recreate it in a more OO style. I wanted to take a more OO approach, so ...
1
vote
0answers
99 views

A Generic Two Dimensional Data Plane with Common Math Calculation Build-in Methods in C#

This is a follow-up question for A Generic Two Dimensional Data Plane with SubPlane Method in C#. Thanks to aepot's answer. I am trying to implement a series methods to enhance the ability and ...
2
votes
3answers
95 views

LRU Cache Implementation in C++

I am learning C++ by implementing small design problems. I have tried to implement LRU cache and the implementation that I have attached here works fine. However, I am not sure whether my code is in ...
1
vote
1answer
84 views

How should I refactor my code to increase its modularity or reduce complexity?

I believe this set of code is very repetitive in a way where every method does almost the same task but it is repeated multiple times. This is what the code looks like and its main purpose is to ...
2
votes
0answers
61 views
0
votes
1answer
58 views

BFS implementation in JAVA

...
2
votes
1answer
41 views

Hardware driven data processing and ploting in need of better control flow

This is code for a measurement setup that receives a steady stream of UDP data, finds the trigger in one channel and operates on the data in the other channel to enhance the signal and remove noise, ...
4
votes
2answers
335 views

C++: eccentricity function on metric spaces

An eccentricity function with parameter \$r\$ on a metric space \$X\$ with \$N\$ points is \begin{gather} f(y) = \left( \sum_{x \in X} \frac {d^r(x, y)} N \right)^{1/r};~~~x,y \in X \end{gather} (...
3
votes
1answer
62 views

Board game design in C++

I'm trying to build a board game and solve it using algorithms such as Monte Carlo Tree Search in C++. My current design follows this python project, in which I have a class hierarchy for ...
3
votes
0answers
72 views

Was this an idiomatic and prudent way to extend R's matrix multiplication syntax? Should I have used R's object system?

After reading one too many Lisp books, I decided to try extending R's syntax. My goal was to implement repeated matrix multiplication in a way such that I could write ...
3
votes
1answer
58 views

Game in Python3 using OOP

So iam making a game using OOP in python however is this the best practise when defining your objects? are you meant to define them all at the end of the script like I've done, or are you meant to ...
1
vote
1answer
61 views

A Paragraph Merger with Removing Overlapped Duplicated Lines in C#

I am trying to make a paragraph merger that takes multiple paragraphs and output a concatenated result with removing the duplicated overlapped lines due to redundancy. Each input paragraph is with the ...
1
vote
1answer
62 views

C++ matrix class follow up

This is a matrix class with addition and multiplication. I tried incorporating all the helpful advice I got on my previous attempt C++ matrix class , specifically using std::vector for memory ...
0
votes
2answers
59 views

Javascript + Filter object of values

I have the object with values. I trying to filter based on values. ...
6
votes
2answers
146 views

C++ matrix class

I wrote a matrix class in C++ with an addition and multiplication method. It works fine, but I don't think a C++ programmer would enjoy reading this. I would love some help with that. ...
6
votes
0answers
67 views

Java service to convert xls files to HTML

I have a service that converts an Excel spreadsheet file into HTML. It is working just fine, but it is quite a big method that doesn't follow any SOLID principles. Therefore I would like to improve it ...
7
votes
1answer
128 views

Blackjack game in Java

So this is a blackjack game, any feedback or tips on what I should remove from the code that is not needed is very appreciated. Note: some of the names of classes or variables are in Swedish but it ...
3
votes
1answer
74 views

Is this usage of the dynamic keyword an indicator of a design fault?

I feel like I'm likely violating a design principal or two here so I'd appreciate any mistakes or antipatterns being named and pointed out. I'm attempting to map a system in code which represents a ...
1
vote
0answers
13 views

How to code a minimization problem with constraints and indices into PSO within MATLAB? [closed]

I have a GAMS code that represent a mathematical model which depends delay (i,p) for each job i and the period of day p. So, I have indices for represent delay and objective is minimizing of summing ...
1
vote
1answer
106 views

A Generic Two Dimensional Data Plane with SubPlane Method in C#

This is a follow-up question for Generic Two Dimensional Data Plane with Manipulation Methods For C# and A SubPlane Method for Generic Two Dimensional Data Plane in C#. Based on iSR5's suggestion, in <...
2
votes
1answer
70 views

Software driver for analog to digital converter

I have been developing a software driver for the internal a/d converter on this platform. The a/d converter peripheral is described in following document. The driver is written in C++ and is build ...
4
votes
2answers
126 views

JavaScript: Parking lot simplified OOD

I was trying to designing a simplified parking lot management system. It has three types of slots (s,m,l). The goal here is that we want to make the placement/release of cars as efficient as possible, ...
2
votes
1answer
112 views

Implementation of a ticket queue system in JavaScript

I got this question during an interview. The question itself was very open-ended - it asked me to implement a ticket queue system, where by default it would have 3 different queues to hold tickets ...
2
votes
2answers
53 views

How to convert traditional code to reusable function

I have different function for different task below this function. To reduce the code, I have written following function. Is this the best way to apply OOPs? or any better way to do? Function ...
3
votes
1answer
70 views

Simple Hangman game in Python3

I made a simple Hangman game in Python: ...
4
votes
2answers
62 views

Modifying __getattr__ to return a nested attribute instead of the named object

I'm writing an application with two basic class types: DocumentObject Property (of document object). Property instances are attributes of the ...
1
vote
1answer
36 views

Transform Data from JSON and CSV to another JSON format

I have 2 files wholesaler_a.csv ...
1
vote
2answers
79 views

Create a Card game called match

For an interview, I had to create a card game called match. The rules were the following: Players can choose a number of packs of playing cards and combine them ...
3
votes
4answers
54 views

Generates barcodes using iterator objects and an iterable objects

first allow me to explain the what the purpose of this program is: a "barcode" as I'm calling it consists of three parts: plant_id=['ATX','HOU','CHS'] Serial Number: a string of 9-digits ...
1
vote
1answer
64 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
2answers
128 views

Object Attribute Stored in New List from Existing List of Objects

For my CS class I the task given was to take a given Person Class with a name and age attributes. Then, with an existing list of Person Objects, create a function that returns a tuple of (mean, median,...
2
votes
2answers
84 views

C++ switch-like code structure

I'm developing a class for connection to LCD (Liquid Crystal Display). It can connect in two modes: 4-bit and 8-bit. And the number of modes may be increased. The mode can be configured in the ...
0
votes
1answer
70 views
1
vote
2answers
65 views

Create a simple hangman game using OOP and Javascript

I had a task to create a simple hangman game using O.O.P. with Javascript. It had to render the puzzle and remaining guesses to the DOM but didn't require any C.S.S. This is what I created. This is my ...
2
votes
1answer
68 views

Text-based console game

I'm currently learning C# in hopes of making games on my own using Unity. I'm using the Udemy class by Denis Panjuta and followed 8 sections before making my first app by myself. The 8 sections ...
2
votes
1answer
56 views

Python code for simple Vending Machine simulation implementing OOP principles

I am recently learning OOP concepts and thought that implementing a simple workflow simulating a vending machine would help me put what I've learnt into practice. I am open to criticisms and feedback, ...
2
votes
4answers
101 views

statistics classes with number and object inputs

I want to create two classes that accept values and perform operations on them. However, one of them is accepting numerical values - RollingStatisticsNumbers; and the other objects - ...
2
votes
0answers
38 views

How do I create an “Environment Variable Setter”?

I have a NodeJS/Typescript project. In server.js, I want to set my environment variables from a .env file. To achieve this, I am ...

1
2 3 4 5
71