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

learn more… | top users | synonyms (3)

-1
votes
0answers
13 views

Re factoring Duplicated For Loop in PHP Method [on hold]

Disclaimer: I understand the code may not work 100%, as I see issues already, but the core thing I am looking for help with is moving the duplicated for loop out of the function and into its own, ...
0
votes
0answers
14 views

PHP session_set_saver_handler with session timeout

I have developed a class that utilises the session_set_saver_handler function so I can store sessions within my DB. The class works just as I would like. However, ...
-1
votes
0answers
41 views

Please check the code quality of the OOP beginner

I started with OOP around 1 week ago and I would like to ask you to check my code and give me some tips and advice but also tell me what I'm doing completely wrong. I'm giving you code of my ...
2
votes
1answer
65 views

A color class and a CRUD class for it

Is it better to have only one class color and include the functions from the second class in the 1st one? Or leave them apart? Why is one better than the other or ...
-2
votes
0answers
11 views

Tables with same columns in Relational Database [on hold]

I need to know if its a good practice to make tables with the same columns on the database. I have a situation where i have 4 kinds of documents wich each one of them have a correct format (something ...
7
votes
1answer
47 views

Media lending library

My assignment was to make a "Lending Library" that keeps track of items. We were advised to create two classes and a main method. What I am unsure of is if any of my code would be considered bad ...
4
votes
0answers
44 views

Blocking reads when writes are happening on two flows

I am trying to implement lock by which I want to avoid reads from happening whenever I am doing a write. My requirements are: Reads block until all three maps have been set for the first time. Now ...
5
votes
0answers
49 views
+100

Generic Networking Class for PHP

I am in the process of writing networking code for PHP that is meant to be used in long-running PHP processes. I realize that PHP is supposedly not well suited for long-running processes, however ...
3
votes
1answer
40 views

Converting Procedural JS Code to Object

I'm new to JS and trying to improve my code with the use of more organised objects. I have the following procedural code which I have converted to an object. It does an ajax load within main. Aside ...
3
votes
1answer
34 views

OO coding style in short Ruby scripts

I've been using Ruby for about a year now, mostly for small scripts with uses ranging from data munging to DevOps tasks. However, I am not intimately familiar with OOP (I appreciate the functional ...
4
votes
3answers
121 views

Case Study - Basic sales tax

The solution was to be assessed, not just on completing the task but also on code quality and design, presence of testing, robustness, maintainability etc. Problem Statement Scenario Basic ...
2
votes
1answer
39 views

Program simulating dictionary using file handling - part 2

This is the new version of the dictionary program which I uploaded for reviewing here. I would be grateful if the program could be reviewed for all the points mentioned in the above link. ...
3
votes
2answers
60 views

Ball Entity for a Entity/Component/System Soccer Game

Here is a code snippet of a class that I be interested to refactor. I was in doubt on how to proceed with the process of instantiation. The original ask was here. After think about it and heard some ...
5
votes
1answer
126 views

Code Golf challenge that plays Mafia

I am working on writing a Code Golf King of the Hill challenge, the details of which can be read here. You can read the full code here. Briefly, the game proceeds in cycles of night then day. There ...
7
votes
3answers
245 views

Go (board game) in Java — version 2

First version: Go (board game) in Java What's new: I now use (as advised) HashMap<GoPoint, StoneColor> where GoPoint ...
-1
votes
1answer
24 views

Globally accessible helper class [closed]

I would like to get opinion if I am doing this right. I am creating a helper class that is globally accessible to my whole project. I want it to be easily called like ...
1
vote
0answers
38 views

Soccer game using libgdx and an Entity System Framework

I'm working in a game as a hobbie. I'm using an Entity/Component/System architecture using Libgdx as Engine and Ashley as Entity Framework. I have a GamePlayScreen in which I initialize my system, ...
2
votes
1answer
47 views

Parking lot and vehicle classes

The expected functionality is that a user/vehicle interacts with a ParkingLot and it allots the space in Park method based on ...
2
votes
0answers
132 views

Procedural to OOP MVC: Understanding Controllers, Models, and Service Layer

I designed a framework to make the switch from procedural to OOP design. This question will contain multiple parts I will bold each question to make reading/dissecting easier. I attempted to look into ...
5
votes
2answers
116 views

Slim API with 3 layer architecture

I'm new to Slim and the three layered approach I'm using below. So far I have the API, a Presentation layer (leaving out for now), a Business Logic Layer, and a Data Access Layer. The code's working, ...
13
votes
4answers
1k views

Go (board game) in Java

Go is a board game (it looks like 5-in-a-row and plays like chess) and I tried to program it in Java. Rules: Two players take turn placing stones on a board. The goal is to capture teritory. ...
1
vote
2answers
36 views

Separate Ajax code in separate modules

This is the first time I am working on OOJS code and I am a beginner in JS. I think I have pretty much messed it up. I am planning to modularize my code, but with the inclusion of ...
0
votes
1answer
34 views

Minesweeper in JavaScript

I have written Minesweeper in JavaScript. Using OO-Approach. Cell class describes a cell in the grid. Cell.t property tells ...
2
votes
2answers
43 views

PHP Autoload Class From Namespace

I wrote this function to be passed as a param in spl_autoload_register(). It autoloads PHP classes from their respective directories using their namespace, named ...
0
votes
1answer
26 views

Implementing quicksort with pivot of first, median or random

I am attempting to implement the quick sort algorithm whereby the pivot will be chosen by the user, and can either be median, first, or random. I am supposed to return a ...
0
votes
1answer
50 views

Define constants in Util class or not

Which is best? I have a bunch of components in my projects. It's related to Ashley (a java entity system) to libgdx (a game engine). this components are like that: ...
-1
votes
0answers
30 views

Avoiding action class proliferation in my dialogue system [closed]

I'm running into an issue of class proliferation in my dialogue system. The system works fine as it is, but I just finished writing out a list of possible actions that could happen based on the ...
-1
votes
2answers
40 views

Varying the parent class dynamically in Python

I am trying to dynamically pick a parent class in Python 2.7: ...
3
votes
1answer
52 views

Interval scheduling problem in C++

The problem I attempted to solve is described as: What is the largest subset of mutually non-overlapping intervals which can be selected from I? Where I is a set of N intervals where each ...
0
votes
1answer
25 views
4
votes
1answer
70 views

Second attempt at a Blackjack game

I posted yesterday about my first attempt at a Blackjack game. After I received much helpful advice I tried my best to fix up my code. I was wondering what you would think about round two! Edit: I ...
8
votes
3answers
673 views

First attempt at a Java Blackjack game

I just completed my first multi class program, Blackjack, and it works! It allows the user to play Blackjack against a single dealer, with no other players at the table. I was wondering, seeing as it ...
6
votes
2answers
97 views

Bank ATM program in Ruby

After reading a bunch of Ruby tutorials, I decide to write fake ATM bank software. I've tried to use OOP design and just want to know if I'm on the right road. ...
6
votes
1answer
60 views

Particle Swarm Optimization

I wrote my first python code to conduct PSO. I am wondering about the best practices for Python. While my code works, I want to make sure it's orthodox as well. For example, here is my class I use ...
2
votes
0answers
23 views

Simulate object.__getattribute__ in Python

I want a Python example that illustrates how object.__getattribute__ resolves instance attribute lookups. I'm looking for feedback about the following code. Is it ...
2
votes
1answer
48 views

Read and output CSV content OO PHP

Okay, I am wanting to expand my armoury within PHP, so I've been researching OO PHP. With my researched knowledge I went on to create a quick script that reads a CSV file and outputs the results. CSV ...
4
votes
4answers
121 views

Find Kth largest element in an array

I am preparing for interviews where my code would be judged based on optimizations, OOP concepts, code readability as well as my knowledge of JAVA and design patterns. What comments will you give in ...
4
votes
1answer
30 views

Ensuring data consistency in a PointsAlongCircle object

I'd like to write classes which are Pythonic, readable and easy-usable. A main issue for me is to keep data consistency. Here is an example (version 1): ...
4
votes
2answers
64 views

Object-oriented approach to sieve of Eratosthenes

I was trying to implement the sieve of Eratosthenes entirely by myself, using only what I have learned so far. Now I'm wondering what I can do to improve my code's readability. Optimizing the ...
2
votes
1answer
86 views

DirectX Window Class

After figuring out DXGI, I wrote a class that combines the act of creating a window and its associated swap chain (as well as an OOP approach to messages). The class supports different window modes ...
8
votes
4answers
407 views

U.S. Postal Service zip code and bar code class

This program accepts either a 27 digit binary bar code of type string, or a 5 digit integer zip code of type int. The program ...
5
votes
1answer
34 views

TicTacToe game in Ruby

I would appreciate any feedback you could offer. I'm self-learning, so I don't really know a "standard" that my code should be up to. I'm also not sure how to get rid of that bit of logic at the ...
4
votes
2answers
83 views

CSV import-export in Python

I have finished a really short and small import / export script using Python 2.7, and now I would like to structure it using classes and methods where possible. Could anybody give me some advice on ...
1
vote
1answer
89 views

Web application for consuming a REST service

The application is a web application that consumes a REST service. Web config has the REST URL along with the parameters. REST URL and the values are passed as ...
4
votes
1answer
51 views

Handling users connection to the application

This is a simple User class that I'm using throughout the application for anything related to the users. To tell if a user is logged in or not, I check the presence ...
4
votes
1answer
75 views

HND Java module (vending machine simulator)

As part of the distinction requirement, I am required to ask for testing/review of my code. There was no time allotted for this in class, and as such I am turning to the folks of StackExchange for ...
8
votes
3answers
173 views

Implementing OOP in this Java word count program

I wrote a program that reads a text file and then outputs the unique words, their frequency, and the line numbers that word appears on. It also counts the number of sentences in the text file. All ...
2
votes
1answer
33 views

Easily registering WordPress custom post types and taxonomies

I am developing a library to easily register WordPress custom post types and taxonomies. But the problem is I can't use one instance of object because of adding the object in WordPress hooks. So ...
5
votes
0answers
46 views

ECMAScript text component

At the moment, I'm learing ES6 and how to write classes. And I'd like to know if I'm doing things right and I have some points that are not clear to me. Please find my code here at bitbucket and ...
6
votes
1answer
61 views

Temporary file utility class in Python

I decided to write a tiny class to automatically write and delete a file given filename and content. It is intended to make testing IO less verbose. I include a small example usage. ...