Object-oriented programming is a programming paradigm using "objects": data structures consisting of data fields and methods together with their interactions.
1
vote
0answers
14 views
Displaying a scrolling stock exchange ticker in a window
I've written my first OOP program (194 lines including docstring and comments) in Python that uses Tkinter as GUI and Threads. The program shows a window and displays a scrolling stock exchange ...
9
votes
3answers
72 views
Tic Tac Toe game in Java OOP
I have written a simple GUI Tic Tac Toe Application and since this is my first shot, I think it can be improved a lot.
Please tell me what you think about it and what you see I made wrong so I can ...
1
vote
1answer
18 views
Implementing use of 'with CustomClass() as foo' in own class with DB-Connection
I'm building a GameClient-Class in Python which handles user input and has to read from a database (MongoDb). I want to know if that is the best practice to implement it, so that I can use it with ...
3
votes
1answer
60 views
Confusing control flow
Currently, the following code runs and produces the expected and desired output. However, I'm sure that there's much wrong with it.
This project queries the (flat) database, instantiates each row as ...
3
votes
0answers
43 views
Debug log wrapper
Please review code correctness, best practices, design and code formatting.
I will be adding functionality and most likely additional refactoring, however a stringent review would be welcome before I ...
3
votes
2answers
64 views
Controller: Sign up action clean up
I don't know if it's just me, but I feel like my sign up action method has gotten a bit messy.
I think that perhaps instead of setting error messages in a controller, I should set error codes which I ...
3
votes
2answers
45 views
Using `exec()` in an autoloader
After reviewing autoloader functions on the site, I didn't see anything like this, and I was wonder what may be wrong with this?
...
7
votes
5answers
290 views
Fraction class implemented in Objective-C
Inspired by this question: Fraction (rational number) structure with custom operators, I have written this class for doing some simple work with fractions.
...
3
votes
1answer
43 views
Refactoring this producer consumer class to minimize what is exposed
I don't like the service class below, specifically, the way it exposes the internals of the producer. While it would be possible to combine all three classes into one producer-consumer, I would ...
7
votes
2answers
447 views
Protect database from SQL Injection and similar attacks - PHP
I am doubtful about the security of my PHP code. I am new to programming, but want to learn how to secure things, protect my databases from SQL injection, and other best practices. I'd like to know if ...
13
votes
6answers
554 views
0
votes
0answers
9 views
What's a good simple way to combat the n+1 problem? [migrated]
I'm trying to better understand performance in PHP. One issue I'm thinking about is the n+1 problem. By n+1 I mean something like this:
...
5
votes
2answers
66 views
Revised Job Queue for Strategy Game
After posting my previous question about this Job Queue, I decided I wasn't actually very happy with it. I am embarrassed to admit that upon further testing it did not function properly in all ...
0
votes
3answers
41 views
Should I declare all of the outer functions inside the object literal?
I am working on an HTML5/jQuery todo list app and here is my code so far: http://jsfiddle.net/rdesai/csTS7/19/
As you might notice, there are some functions called at the beginning of the JS code. ...
9
votes
2answers
199 views
Sessions and Authentication
I've a feeling I'm overdoing my Auth class, and that it could be done in a simpler and more understandable way.
Could you give me advice on this, please?
This is ...
6
votes
5answers
166 views
Casting base to derived class according to a type flag
I have been writing an event class for my game engine and I came across to the following problem:
Is casting a base class object to a derived class object given a type flag a good programming design?
...
5
votes
2answers
155 views
DB abstraction, private methods in OOP PHP library
This library registers a new user.
Questions:
Where should the DB class instantiation happen for user class? I tried instantiation in the constructor but that property doesn't seem to be available ...
4
votes
1answer
40 views
Nodes and Boundary Conditions in Finite Element Method
The problem:
A Node is located in a specific coordinate (x, y, z).
A Node can be one of these types: ...
4
votes
1answer
87 views
First attempt at making a user class
I've just begun creating my first user class. First, I need some clarifications.
Am I using try and catch correctly?
To ...
9
votes
2answers
301 views
OO design for Tic Tac Toe program
I am practicing object oriented design and have taken Tic Tac Toe as an example. I have written first all the requirements and then started writing code. I would like to get it reviewed so that I can ...
6
votes
1answer
104 views
Simple chat console app
I wanted to practice using sockets and multithreading. This is simple code where I start a Server and connect to it via Client ...
1
vote
0answers
15 views
Application Class Security
Is my Application.php class secure for continuing development?
The Application.php acts as a registry for the whole application. I tried not to rewrite already working code that is being pulled from ...
12
votes
2answers
105 views
Nokogiri crawler
The following code works but is a mess. But being totally new to Ruby I have had big problems trying to refactor it into something resembling clean OOP code. Could you help with this and explain what ...
5
votes
3answers
99 views
Job Queue for Strategy Game
I've posted a revised version of this here.
I posted about this basic problem a while ago, and I got the recommendation to move the code for managing the Jobs of my game to another class. I have ...
1
vote
1answer
37 views
Cleaning up a class that contains the object it represents [closed]
I've recently started writing a tic-tac-toe game (following the Odin project) and am trying to write a class to hold the board game.
What I'm not sure about, is that the board class holds all the ...
1
vote
1answer
53 views
More efficient way to loop through an object
There's a part in my page where you can add, edit or delete school details, and it wasn't supposed to save entries to the database until the user hits Enter, so I save all data in an object first.
My ...
4
votes
2answers
65 views
Finite Element Method analysis
Please take a look at this class and point out its flaws. I am developing a simple Finite Element Method analysis with PHP.
What this class basically does:
Given an input set (coordinates, ...
7
votes
1answer
140 views
Less-repetitive code for document-analyzer
I've refactored my code such that every function has only one responsibility. Now I'd like like to work on making it DRY.
I'm noticing a lot of duplication in the ...
1
vote
1answer
48 views
Better PHP Autentication Class [closed]
Authentication and keeping information secure is my goal with writing my Authentication class while making sure it is extendable completely as possible over making it usable for anything over just ...
11
votes
2answers
410 views
Inventory - how to handle items?
I've been designing a game server, where a player has inventory, bank, and other features with items.
There are some definitions of what item can be in my game:
Item is either stackable or not ...
3
votes
2answers
147 views
Updating necessary data using just one function
My objective is to update necessary data using one function instead of having different functions to update different fields. So, I've created one and I think this is not really elegant, efficient or ...
0
votes
0answers
19 views
Re-factoring restrictions validation functions for proper OOP design in MVC framework
I am aware that code review is for refactoring code from an existing code. Let me first to say that the following code works but inefficiently and its very convoluted, so I would like to apologize if ...
4
votes
2answers
110 views
Skill Upgrades for Strategy Game
I built a simple class to handle skill increases for the workers in a strategy game for iOS. The basic idea is that whenever a worker finishes a job, their skill (which starts at 0) will increase by ...
2
votes
2answers
78 views
Validator extended to handle domain objects / entities
I started improving my validator library even more, and I think I'm at the last final element (domain object / entity validations) before I can gladly say that my Validator library is completely done ...
3
votes
1answer
79 views
My first login class in PHP with PDO and bcrypt
This is the first time using a class. Please review this and tell me if it's secure and if it's the right way to do it. The code itself is working, but I have doubts in the way I used all this.
...
3
votes
1answer
48 views
Dynamically create a table with values from an object
I want to create a table that looks like this:
...
5
votes
1answer
73 views
Controller for handling user registration
I spent a lot of time doing Go Horse Extreme programming, but now I want to be a better person.
How can I make this method smaller, better, more OOP?
...
5
votes
2answers
85 views
Update of Classes for user registration and authentication
Old Post: Classes for user registration and authentication
This post is an update of the old post of mine. This is the code after suggestions were implemented in the review. Do you think I could make ...
0
votes
2answers
38 views
5
votes
2answers
139 views
2
votes
1answer
27 views
Python Vector implementation that acts as a class and also a collection of staticmethods
Recently I've been wondering about ways of implementing objects in code that can be represented by other primitives. An example of this is a Vector, which can be represented by a Vector\$N\$D where ...
4
votes
2answers
90 views
Validator refactored to be OO
Based on my previous post I completely re-factored my code to make it object oriented.
Anything I could improve when it comes to:
Object oriented code;
Efficiency;
Readability.
Any other ...
3
votes
1answer
53 views
Base class for subclasses that can track their own instances
I'm new to Python, with some background in Java and C# from a while ago, and more recently in scripting worlds like Bash and AppleScript.
I wanted to be able to create classes that could
report ...
5
votes
2answers
91 views
Adding features to a strategy game
I'm working on a basic strategy game for iOS and I have a question about the overall layout of the code in the program. I added some features to the game today and I had to add code to several ...
5
votes
1answer
41 views
Secure Functions in a Database Class
I am trying to solve as many issues as possible with my Database Class and bind statements as far as possible without actually doing it in the front-end. The goal is to do all of the heaving lifting ...
3
votes
2answers
77 views
Getting cars and bicycles from a database and writing them into two different arrays
I've written a simple class which should:
get 10 top cars and 10 top bicycles from database
write them into 2 different arrays
It works, but I'm trying to find a simpler or clearer solution.
...
4
votes
1answer
71 views
Object Oriented vs Not jQuery & JS
I have taken a widget/ plugin that I wrote yesterday and just now it has been re-written in an object oriented format. It is certainly more code to write it the OO way, so please let me know also how ...
1
vote
1answer
56 views
PHP ImageMagick Image Processing Class
I've written an image processing library for downscaling, sharpening, compressing and caching images using PHP and ImageMagick.
Having recently been a chef in the kitchen of procedural and vague ...
0
votes
1answer
43 views
Factory Pattern to Abstract Factory Pattern [closed]
My Product Factory
public interface IProdctFactory
{
void Drive(int miles);
}
My Vehicle Factory
...
5
votes
1answer
61 views
Social application with users and sessions
I work with a legacy application. This is my attempt to add some sanity in an new feature I want to add.
It's a social application with users, sessions etc. The entire application is run in a ...