Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

4
votes
1answer
924 views

Wrapping bound methods

I've written this small class in Python that wraps bound methods but does not prevent the deletion of self. Do you have any thoughts on my code? Do you think I handle errors appropriately? Is it ...
6
votes
3answers
5k views

New to OOP; is this a good class design?

I have a few different classes in my application, but this specific class is the one I'm interested about. Please review for good practices and potential problems. ...
8
votes
5answers
11k views

Empty method in abstract class

I have an abstract class which holds a hook method for a template method. Not all classes which extend this class will need to implement this method (in fact most will not, but a few will). As such ...
3
votes
3answers
2k views

Validating a form and alerting the server if passed

This is my first script in object-oriented JavaScript (jQuery 1.5.2). Its purpose is to simply validate a form (nothing fancy at the moment just checks if any value is present on required fields) and ...
4
votes
3answers
2k views

Static class member destruction in C++

I have a basic cache set up. Whenever a user requests a bitmap, it fetches or loads it from disk if it isn't already loaded, significantly reducing load times. Currently, the design explicitly tells ...
4
votes
3answers
383 views

Sprite and AnimatedSprite

I have a Sprite class and an AnimatedSprite subclass, and I'd like to decouple these them and maintain substitutability, ...
3
votes
1answer
199 views

How would you ruby-fy this non-AR model class for Ruby on Rails app?

This is a class from my rails application. It is used as non-database model in my RoR application and uses syntax similar to AR design pattern. I wonder is there a way to make this look more like Ruby ...
4
votes
5answers
800 views

Request for Comments: Singleton pattern implemented in Java

I have several utility classes who should only ever have one instance in memory, such as LogHelper, CacheHelper, etc. One instance to rule them all. I've never implemented Singleton in Java before, ...
7
votes
2answers
2k views

Simple JavaScript canvas game

Here is a link to the code on JSFiddle. This is my first attempt at playing with canvas. Before I move on doing anything else, it would be nice to have insight from somebody who knows canvas and ...
6
votes
4answers
3k views

C++ enums - which one is better?

I have a large namespace, but I don't want enum constants to be a part of it. In cases where an enum is related with a class, I coded enums inside the class so I can reach it using the class name. ...
5
votes
3answers
1k views

Simple PHP Auth Class feedback

this is a basic PHP auth class I've put together for use with simple sites I do from time to time which don't warrant using a framework. I'm wondering if i'm separating out responsibilities all that ...
6
votes
2answers
369 views

PHP Debugger Object needs review

I'm a pretty visual person and I like to see all the cool information about objects, arrays and different variables in PHP. In the beginning I would just ...
3
votes
2answers
2k views

My Memory Game “Engine”

Mostly for the experience (but also so I could waste hours playing it), I made a simple memory card game in JavaScript. I built it so it has a backbone framework that could be easily extended by ...
3
votes
1answer
462 views

Improve OOP code

I am learning OOP and have written a class for Likes. There is a load, add, delete method and I think this code can be improved since there is a lot of duplication. Please let me know how I can ...
8
votes
2answers
1k views

C-style array class

I often use C API's in C++ that force me to use C-style arrays. I got sick of constantly using a dynamic vector with &vec[0], so I wrote this C-style array ...
4
votes
3answers
26k views

Learning OOP PHP, simple MySQL connection class.

I have posted an earlier version of this and here is the improved version from the feedback I recieved. Some of the feedback I received was; Don't chain method (tried my best to limit this) Do not ...
2
votes
2answers
2k views

Event Registration

I am new to the world of coding, PHP as well as XHTML. As my first stab at object oriented coding, I put together a basic registration form that is meant to serve as a means to collect user details. ...
2
votes
1answer
1k views

Javascript filter class to hide and show content on data-attributes

I'm a hacker, not a trained engineer. I ask/answer specific questions on StackOverflow and am pretty confident in my ability to get the browser to do what I want, I thought I could benefit a great ...
3
votes
1answer
236 views

Refactor a subroutine that divides date range into quarters.

The subroutine below, GetDetailsQuarterly, accepts two dates. Then it writes out each quarter that falls within the date range. It also gives the first and last day of the quarter. I really don't like ...
4
votes
1answer
574 views

User php class. Should I connect to DB in this class?

I have small Class which handles user's information. (name, surname, login, hash of password). Also this class can activate, register and login the user. This means I should connect to DB. Is it ...
2
votes
2answers
1k views

PHP Output Block Defining and Best Practices

I've been rolling around several ideas or approaches in my head, and none seem any more useful or "right" than another. I'm sure this is extremely objective but I'm looking for a close-to-definitive ...
10
votes
7answers
4k views

Rock Papers Scissors in Python

I am a newbie to Python and have started object-oriented programming recently. I have implemented a "Rock Paper Scissors" application in OOP. I would like for you to evaluate my code, and tell me ...
5
votes
2answers
714 views

OpenGL VertexArrayObject class

It seems to play up sometimes and I'm not sure if this is due to the class itself or the way I'm using it. Can someone confirm that this is a 'good' implementation of a ...
3
votes
3answers
324 views

PHP, Is creating a class for templates to much?

I am new to using classes heavily, and was wondering if going so far as to create a class specifically for templates was going to far. Here is a simplified version of my class template. Yes, I know I ...
5
votes
1answer
1k views

Review for a PHP socket proxy

For my current project we are commnunicating with an old mainframish hospital information system. This system has a service called 'Facelink' which is a simple TCP connection with a fixed set of ...
8
votes
1answer
203 views

Simplifying a Resizing Method

I'm making a simple container class for fun and education, but my rebuilding/resizing method seems rather inefficient. Is there an easier way to do this? ...
2
votes
2answers
2k views

Subclassing UIButton

I need to subclass UIButton, however the design of UIButton makes this really painful. This is because to create a button you ...
5
votes
2answers
521 views

Splitting code, am I doing it right?

I would like to have my code reviewed, I'm trying to get a general model I'm using for my stuff going and I don't want to keep using wrong or inefficient code if I can. My file structure is like this:...
6
votes
2answers
6k views

Recursive database actions

I am been using a code pattern for recursive database actions in my applications. I create two class objects of a database table, singular one (e.g Agent) for holding single record with all fields ...
15
votes
2answers
2k views

Guessing game - am I using the concept of objects in Java properly?

I'm new to Java and find it hard to grasp the concept of objects. I wrote a simple guessing game to practice the concept of OO programming but I am not sure if I am doing it correctly. The objective ...
8
votes
2answers
675 views

Object Paradigm for PHP, Practice in Design

I've created and I manage a point of sale web application built in PHP which has thus far followed no clear guidelines or methodology for development; it's operation is completely procedural. In turn, ...
4
votes
1answer
201 views

Sorting Visitors

I started to write a code with top-down tests. My first version, grow to something like this: ...
12
votes
6answers
1k views

Class for holding person's information

I have written another program in C++. Excluding the point that the class definition should be in a separate header file, is there anything that needs to be improved? ...
6
votes
2answers
542 views

JSON API for some bank account

I have been developing this class, and was wondering if anyone had any thoughts on how I can improve the performance of it. ...
12
votes
6answers
2k views

“Do you owe the government?” classes

Should my class pass parameters internally or reference class level scoped variables? I'm not sure on the best approach or style for procedure calls that have parameters. Should I go with the class ...
7
votes
1answer
425 views

Database method to query

I have a database class that in __construct() initialize a PDO connection and insert the instance into a $db private var. Now i'm working on a method that can be ...
11
votes
5answers
2k views

Simple ASP.NET C# class design

Here's a class I'm designing: ...
19
votes
2answers
748 views

Cleaning up class creation / extension

I was wondering for quite some time how to clean up the below code without blowing it up any further. The extension of the classes is the main concern here, it looks a bit too much like magic. That's ...