Core to Object-Oriented Programming (OOP), a class is a template for creating new objects that describes the common state(s) and behavior(s).

learn more… | top users | synonyms (1)

3
votes
1answer
20 views

Character Sprint Spaghetti Code

I finally managed to get the code to work properly. It makes the player object move faster if the user double taps the arrow key with a few 'ticks' (new frames) after the 1st stroke. - User presses ...
1
vote
2answers
97 views

Creating a Party Game to learn OOP

I've been developing sites using Dreamweaver for the last 15 years, I do a lot of code editing manually so I have quite a good knowledge of the PHP language. I'm diving into object orientated ...
7
votes
2answers
72 views

Tree Template Class Implementation for C++

I have not done any parameter checking, however I think the meat of the class is there. Let me know what you think. ...
1
vote
1answer
45 views

Optimized Form fields generating class

I am building an application full of forms and so I thought it is good idea to create a class to populate form fields. Here is my class and I am sure it can be optimized more than now and could be ...
0
votes
1answer
33 views

Managing several payment means in my Rails 3.2 app

I'm trying to manage several means of payment in my Rails 3.2 application. Let's say I have 2 means : Credit Cards & Bank Transfers (BIC), working with 2 different payment providers. Those means ...
2
votes
3answers
55 views

Raising error if method not overridden by sub-class

Background I have a base (only 2 classes inherit from it, and only from it) abstract (meaning I don't want it to be used directly) class that implements some common functionality. Some of it depends ...
7
votes
2answers
73 views

Python script to test music sight reading

I decided to write a program to test music theory, and, while it would've been much easier for me to make it elegant and perfect in Java, I thought I'd take the opportunity to get more familiar with ...
3
votes
1answer
53 views

Flat-file DB with CRUD

I just finished writing a flat-file DB class for PHP which supports selecting, updating, inserting and deleting. I was wondering if there are any ways to make it faster or if I'm doing anything the ...
7
votes
2answers
194 views

Cleaning up and commenting on my code for Pong game

This post is a follow-up to When should I consider the number of my method arguments too big? I took the some advice from previous post and I'm almost done with cleaning up the code. I didn't make ...
4
votes
3answers
65 views

New Game - Am I going down the right path for DOM manipulation?

I find myself using a lot of .find functions within what I'm developing. The reason being that I need to run this same function on a TON of different characters ...
10
votes
1answer
309 views

When should I consider the number of my method arguments too big?

I'm writing a simple Pong game, I have a method bounce() that makes everything run: the ball, the paddles, score etc. and it uses 12 arguments: 3 counters, 2 ...
6
votes
2answers
158 views

Class for printing class hierarchy as text

I'm coding a little class hierarchy printing tool for easy show hierarchies of java classes. This is my current code: ...
5
votes
3answers
498 views

Is there a better way to pass variables into a class?

Is there a better way to pass variables into a class? ...
4
votes
3answers
301 views

Nested class or two separate classes?

I am making this program that is going to calculate distance from randomly generated dots (with x and y coordinates) to 5 bigger ones and then its going to put each smaller dot into the group with ...
4
votes
2answers
136 views

Using threads to find max in array

I really do not have access to anyone, outside of professors, that is highly knowledgeable about Java so I figured I would post my stuff here to further my knowledge and improve my coding. This is ...
3
votes
1answer
77 views

Is this a complete PDO prepared class?

Is this class perfect for databases? All I want to know is what I should change to make it perfect. ...
7
votes
4answers
198 views

User search implementation

In my Java code I have these three classes. Basically I have a User class, and also a GUI class that holds TextViews and other things (GUI related) for the ...
6
votes
2answers
108 views

Proper use of class constants

This question specifically relates to the use of the class constants ABOVE and BELOW in the sample code below. I have a few different classes that look like this: ...
2
votes
1answer
71 views

“Property Container” design-pattern

I've tried to write my Property Container design-pattern implementation. Could anybody, please, tell me, if this code is really what I intended to write (follows ...
8
votes
2answers
91 views

Javascript/ECMAscript 6 classes organization

So I have been trying to wrap my head around all the new options in ECMAscript 6 and to do this I tried to develop a simple setup which would allow me to place absolutely positioned ...
6
votes
2answers
656 views

Empty Interface usage - is this a code smell?

I've recently made a set of interfaces/classes to work with converting a spreadsheet into an object but I utilise an empty interface in my design: So first off I have my interface which defines what ...
3
votes
1answer
56 views

Using classes vs. using functions

I am trying to learn how to tell if my code will be better off creating a class as opposed to using many functions. I am a new Python programmer trying to get the hang of when classes should be ...
0
votes
0answers
29 views

Classes to iterate over millions of records, performing calculations and comparisons on each

I'm converting a PHP written with a lot of procedural loops to classes. There is a hierarchy of nested information represented in nested associative arrays. The actual records are from currency ...
1
vote
1answer
47 views

Is this a model? What is controlling it (controller?) and how does the data get to the view?

My goal is to instantiate a class based on the request and call a method on it based on the request verb. The classes I'm referring to will have methods such as ...
2
votes
1answer
60 views

Best structure for a Person in PHP classes (and databse)

I am (in the process of) creating a system to store People and their details - names, date of birth (dob), addresses, phone numbers, etc. - and I'm curious how it is best achieved. Below is an an ...
4
votes
3answers
77 views

What are my options for read-only access with many member variables?

I have a MouseInputHandler class that registers itself to an InputManager. When the InputManager class receives events they are ...
6
votes
2answers
132 views

How can I layout this class to make it easier to use for API developers?

I have an application that allows the user to place a string of text into a PDF document. I have three different ways that they can do this: Use a Form Field. Then they have four properties to ...
3
votes
1answer
59 views

Best practice to create XML messages with DOMDocument class in PHP

I want to create XML messages for webservice communication. These messages should be created from a pool of reusable elements. Therefore I have created different classes. A "factory" class, that only ...
5
votes
1answer
157 views

Does this tkinter-based web browser widget use a well implemented class?

I have fully functional code in class format, and as far as I am aware from my previous question, it conforms to PEP 8 and the code logic and implementation is suitably pythonic. My main concerns here ...
0
votes
1answer
40 views

Class-based signal generator [closed]

I'm creating a class-based signal generator that, given a buy threshold, sell threshold and a list of list of indicators, creates a 'buy' of 'sell' signal on a given day if the indicator from that day ...
5
votes
4answers
1k views

Sharing data between Forms

I want to create a class that has properties that can be set from one form, and accessed by any other form in the program. I created the form below and this works perfectly but I'm not sure if this ...
1
vote
1answer
51 views

Class Design for Unidirectional one to many relationship [closed]

I joined a new project in support/enhancement role. I had a walk-through of code and found the classes (and relationships) are designed as follows: Suppose class Department has many Employees and in ...
-1
votes
1answer
59 views

Error caused by c++ iterator in 2D Point structure [closed]

I've written a structure of 2D Point. But it doesn't compile due to some errors caused by iterator. I can't figure it out. Here is my code: ...
9
votes
4answers
984 views

Card and Deck classes

I would like to know whether I'm going in a correct way or not in building my Poker game. So far, I've implemented card and deck classes and I would like to see your feedback about my work. Feel free ...
7
votes
1answer
333 views

Drawing a triangle and some concentric circles

For class, I had to use Java to draw a triangle and some concentric circles. Here's my code (questions follow): ...
9
votes
1answer
67 views

Shortcuts and imports for large RPG basic code

I decided to work on putting together an Arena-style (very basic) text-based RPG as a way to help myself learn Python. Unfortunately, after about 1,000 lines of pieced-together code, I realize that ...
7
votes
3answers
122 views

Directly accessing class attributes in Rock Paper Scissors

I am reading a beginning Python programming book and in it the author says that you want to avoid accessing a class' attributes directly, but instead to create methods that return attribute values. ...
13
votes
5answers
1k views

Rational number arithmetic

I was assigned to make a Rational class to perform functions on fractions. After awhile I got it to work, but now I'm wondering how to simplify and clean up my code. Basically how to improve and use ...
1
vote
1answer
96 views

Interface using SQL DataRow instead of a user-defined class [closed]

Normally, I create a user-defined class (object library) and then propagate its properties across solutions, e.g. from a website to a WCF web service, referencing class dll in both solutions. But I ...
5
votes
1answer
62 views

Did I convert this C++ class to Common Lisp correctly?

Here is the original C++ class I converted to Lisp at the very bottom of this post. ...
8
votes
3answers
207 views

Model cars as classes

I am learning about object oriented programming in Python using classes. I have attached an image of what I had in mind when structuring my classes. This is supposed script model cars. I want to know ...
5
votes
2answers
62 views

Specific PHP Data Access Class review

As part of a fun project to help build my knowledge of PHP. I've written a Data Access Class here to bridge the site to the database. I know there are a lot of ...
4
votes
2answers
107 views

Handling access to database connection both inside and outside of classes

Is this an OK way to handle access to database connection both inside and outside of classes? I used to include a PHP file -- database.detl.php -- at the very top of my index.php file containing the ...
0
votes
0answers
100 views

Logic inside class properties setters & getters [closed]

I'm trying to build a case against this as we have a developer that likes to use class properties in place of methods. I think it's a bad idea. In some cases he is accessing the data layer inside the ...
2
votes
1answer
93 views

new to libs/classes , accordion js plugin,css3 webkit

Accordion plugin As I don't use jQuery (because I just have fun with chrome and ios/android) and I prefer to write my own functions, I decided to write a simple Accordion function some time ago: ...
1
vote
1answer
64 views

Class initialisation of fields

I have a the beginnings of a class (in this case for a NeuralNet). I'm not very happy with how I am initializing self.ws, seems a bit off. What is the pythonic way to do this? ...
2
votes
1answer
90 views

Custom session class

...
0
votes
1answer
104 views

Review of my PHP Wrapper around Third Party Soap API

I have written a wrapper for Soap based 3rd party web service. https://gist.github.com/veganista/bd940750d9e240e63b89 I'm pretty happy with it so far (I think, anyway). It's only a small sub-set of ...
2
votes
2answers
269 views

Calculating Julian dates

Refactor this code so that I don't have to insert the parameters any time I need to use one of the functions. I have a class, say julian, for calculating Julian ...
1
vote
2answers
103 views

Passing private variable in JavaScript nested class?

I am thinking about passing a private variable of one class into another class, for some belonging case like 'company --> department --> employee'. As an employee can tell some information of his ...