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
1
vote
1answer
47 views

Factory Method Design Pattern Implementation as a Coffee maker program

File: InfoFactory.h contains four classes. CaffienatedBeverage is an Abstract class with one pure virtual function Name. It ...
-1
votes
0answers
30 views

PHP class about acts for municipal property with many properties, getters and setters

Can someone tell me is this good practice or somekind of design pattern. I want to avoid big class with many properties, setters and getters, and other methods. Object properties match database table ...
2
votes
3answers
107 views

Java OOP Calculator (no GUI)

i have created an object orientated Calculator without GUI. i have provided only the most important parts of the code. I want to add another review question for those parts (especially: ...
5
votes
1answer
480 views

Designing an URL Shortener

Recently I was assigned a URL shortener design problem while interviewing with a well known organization. Here is the exact problem statement: Build a simple URL shortener service that will accept a ...
3
votes
2answers
137 views

Implement IDisposable correctly using object composition principle

Is it possible to implement IDisposable pattern correctly while using object composition principle to promote code-reuse, reduce code duplication and hide verbose &...
-1
votes
2answers
71 views

Simple Vehicle speed representation

This code models two vehicle types, with a method to accept a string representing a boost to change speed. How can I optimize performance in inheritance child class? How can I reduce the code inside ...
1
vote
1answer
110 views

Perfect Rectangle checker

While submitting this question i found that someone already made up this question in python, here is my java implementation of the Perfect-Rectangle-Challange challenge: Given an array rectangles ...
1
vote
2answers
106 views

DDD: interaction between 2 objects in a RPG-game

Context PlayerHouse is a place where the Player (the game character) can refill its health, store its inventory, etc. like in a RPG-game. The user can upgrade it for example to refill player's health ...
2
votes
2answers
77 views

OOP - Contact Form PHP Backend - Procedural to OOP - Dynamic MySQL Prepared Statement PHP

I just converted procedural code to OOP code. Is there any performance or security issue with this code or what should I consider further? interface ...
2
votes
1answer
61 views

Terminal python tic-tac-toe game

As someone that started to learn basic python programming, I decided to make a Python tic-tac-toe game for the terminal, to develop my OOP skills. I would like to know if my code has a lot of ...
2
votes
1answer
42 views

Pagination helper class

The most nauseous problem with pagination is the fact that you have to write two almost identical queries. For the various reasons I am not inclined to use the SQL-only way (such as ...
5
votes
1answer
490 views

Using a generic call to access different variations of a method

In the code below, the primary purpose of class MyRNG is to create a single method getMyRandom() that will return a random ...
2
votes
0answers
42 views

editing the array I've included instead of editing the file of included array php

In order to reduce time complexity, instead of loading (and then dumping to use it for later) the whole file into an array (It would be O(n) with n=number of lines), I have saved it as array into a ...
2
votes
1answer
66 views

Create a Time class - OOP in Python

Create a Time class. Time is on my side Specification Basic attributes: hour, minute, second and day (default is 0), + getters, + setters (using a decorator) If ...
-1
votes
1answer
52 views

Proper way to Implement a Birthday Class in Object Oriented Python [closed]

I have the following class ...
1
vote
0answers
89 views

C# User class using SqlServer Database

I am creating my first business application. Unfortunately, I do not have anyone experienced in .NET or c# to review my code, and this is my first time not only using SQL, but also creating code in a ...
4
votes
1answer
93 views

Using OOP/Class Module called “FastMode” to toggle Application object properties in Excel

I'm programming a tool in Excel which reads two exported .csv files, performs some calculations based on Dates and Strings and ...
3
votes
2answers
131 views

Temperature Converter: °C to K

What it does Converts melting point and boiling point from degrees celsius to kelvin These are in a dict which is in a tuple as no changes should be made to it No user input Purpose Learning ...
-1
votes
1answer
38 views

c++ program with 2 classes [closed]

Im making this project from few days , and now i need little help because i am struggling. The task says II. Define a student booklet class CStudBook that inherits CStudent with a member data ...
4
votes
1answer
68 views

Object-oriented calculator class

I started learning OOP programming style in PHP. After end of the course, I wrote a simple calculator in OOP style. Can some one check my code and give me feedback? ...
0
votes
0answers
24 views

Best practice to denote circular references in typescript classes and objects

Setup I am writing a class based, object oriented algorithm in typescript. In many cases, a class will create another child class, passing itself as an argument to the child class. For example: <...
2
votes
2answers
69 views

Registering listeners according to SOLID pricipals

I'm practicing oop concepts these days. To figure it out I tried the below problem. There is a sensor monitoring system. It is a simple system that prints a value, ...
0
votes
2answers
55 views

Optimizing methods with multiple if checks on getter values

I have a method where I fetch user input, check if certain values exist, and based on that build my own custom input object that I would use to search in a database. The code for the search method is ...
7
votes
1answer
168 views

Stop cheating on home exams using python

Background I am teaching a course at university level, and have lately been working on creating a home exam for my students. However, the institute has given clear instructions that collaboration is ...
0
votes
0answers
17 views

Create Many Subtypes which are all exactly the same VS use just one type

Is it good practice to create many subtypes which are all exactly the same just for more descriptive class names? I did this but then I realised all my subtypes were redundant, and it seemed kind of ...
6
votes
4answers
577 views

Monty Hall simulation - OOP

I mainly write code for data analysis so don't think about or use OOP at all on the day job. I thought I'd have a go at a simple Monty Hall simulation in an object-oriented style to figure out how it ...
2
votes
1answer
44 views

Singleton in Ruby without using Singleton module or class variable

When I need a singleton class in my Ruby code (for example, single logger for multiple classes) I usually use code like this: ...
3
votes
1answer
77 views

SkylineProblem in Java

taken from leetcode.com: A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Given the locations and heights of all the ...
1
vote
1answer
31 views

Managing duplicate class instances in a javascript Set

I have a class called Thing. For simplicity, let's say it initializes with a unique id, and that's all that's unique about it: ...
4
votes
1answer
78 views

class that handles the rpg game map

I created a class to handle maps in my RPG game, before it became a class this was a collection of functions I created, but I thought it could be used as a class. although this code is working but i ...
1
vote
1answer
37 views

Android APP user registration page implementation

This is a follow-up question for Android APP User class implementation. I am attempting to build a user registering system and this post shows the user registration page implementation. The ...
2
votes
0answers
26 views
2
votes
0answers
18 views

Capturing email extracted data in dataframe to store in database of a django web frame work [duplicate]

This code was written to capture extracted text from emails and store those details in a database. Now the challenge is to reduce the amount of code, improve simplicity and reduce the duplication of ...
2
votes
1answer
79 views

Quadratic equation class in Python OOP

Hello everyone In today's assignment I had to write a function to determine if (and how many) the quadratic function defined by the formula f(x) = ax^2 + bx +c has roots. I had decorators to write. ...
0
votes
0answers
57 views

Extract fields from email and store into a Django database

This code was written to capture extracted text from emails and store those details in a database. I would like to reduce the amount of code, improve simplicity and reduce the duplication of my code. ...
2
votes
2answers
91 views

PhoneBook in Java - follow-up

This is a follow-up to this phonebook code. This Phone Book allows the user to Enter a value between 1-3. Entering 1 lets the user Add a number to the phone book, when the process is finished, the ...
1
vote
1answer
41 views

Android APP Password Strength Assessment class implementation

This is a follow-up question for Android APP User class implementation. I am attempting to create a password strength assessment class which is named ...
0
votes
0answers
24 views

Microsoft Academic API wrapper

Description This is my attempt at writing a wrapper around Microsoft's research API (evaluate endoint). My goals were: learn how to write classes does it look ok overall? should all methods except ...
1
vote
1answer
62 views

Snake game MVC (Vanilla JS) - Help separating concerns

I'm making a snake game for practicing the MVC pattern and also going out of my comfort zone (I'm in data processing / data science, mostly procedural coding) The game is available in https://nabla-f....
-1
votes
3answers
101 views

C# oop eco system simulation

This is my attempt at simulating an eco system. Basically this thing is suppost to simulate how an eco system works. Its not the most accurate thing but it's something. Let me know what you think ...
0
votes
1answer
110 views

A C# hangman game

I made this c# hangman game... I would like to know what you all think about it. This is a pretty basic but still gets the job done let me know what you think. ...
0
votes
1answer
61 views

Android APP User class implementation

This is a follow-up question for Android app class serialization. The implementation of User class has been updated and the functionality of null string checking, ...
0
votes
0answers
58 views

Android app class serialization with static Load / Save method

This is a follow-up question for Android app class serialization. As forsvarir's updated answer mentioned "A static load that returns a new instance of a ...
3
votes
1answer
173 views

Robot OOP Class in Python part 2

Good morning guys! I've just got done fixing my previous version of this code, and here we are with the "final" version. How would I improve it further? I wanted to create the board, and the ...
0
votes
1answer
97 views

Unit tests for User class with JUnit 5

This is a follow-up question for Android app class serialization. Some problems have been mentioned in forsvarir's answer. Then, I am following JUnit 5 User Guide to redesign the test cases for ...
3
votes
1answer
95 views

New in PHP OOP and need opinion am I doing it the right way

I am new to using PHP OOP and decided to start learning by converting something I wrote in procedural PHP. So now I need your opinion and recommendations for my first work. One of the main reasons I ...
1
vote
1answer
64 views

checking is ellipse is filled or not

following code below works fine but feels kind of a mess. any one has a better way to do this I am creating a basic "Enter Pin" to unclick screen on a app. So if user enter 1st digit, than ...
2
votes
1answer
58 views

Android app class serialization

I am attempting to build an Android APP with the custom serializable class User. The public method Save is to save class ...
1
vote
1answer
117 views

C# Coffee Machine

I saw this post and tried to do my attempt. This is the requirement of task: Design a coffee machine which makes different beverages based on set ingredients. The initialization of the recipes for ...

1
2 3 4 5
73