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)

4
votes
3answers
469 views

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

Is there a better way to pass variables into a class? public class Truck { private int _wheels; private string _color; private bool _loaded; public int wheels { get { return _wheels; ...
4
votes
3answers
245 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 ...
0
votes
0answers
39 views

Plane seat assignment code exercise [closed]

I have 3 classes: PlaneSeat This is where there's all the information regarding a plane seat, is it occupied, seat ID and everything else. Plane Here it notes how many seats there are, empty seats ...
4
votes
2answers
83 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
59 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. error_reporting(E_ALL); class RESPETO{ private $_server = 'mysql'; private $_host = ''; ...
7
votes
4answers
187 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 properties that show on the screen. The ...
6
votes
2answers
102 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: class MyClass(object): ABOVE = ...
2
votes
1answer
53 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 the Property Container design-pattern ...
8
votes
2answers
82 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 <div>'s on ...
6
votes
2answers
567 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
52 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
25 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 ...
0
votes
0answers
5 views

Suggest a best practice to create Constants class [migrated]

There is a debate in between my team members about declaration of Constants class. We are moving the constant variables into separate class as like below public class Contants { public const ...
1
vote
1answer
44 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 getAll, getOne, post, and so on. If a ...
2
votes
1answer
53 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
70 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 forwarded to MouseInputHandler which changes it's state to reflect the ...
6
votes
2answers
130 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
48 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
85 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
36 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
463 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
41 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
36 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: #include<cstdio> #include<cstring> ...
9
votes
4answers
424 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
122 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): import javax.swing.*; import java.awt.*; import java.awt.geom.*; public class ...
9
votes
1answer
59 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
109 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
777 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
78 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 ...
3
votes
0answers
48 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. class TrainingData { public: TrainingData(const string filename); bool isEof(void) { return ...
8
votes
3answers
196 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 ...
4
votes
2answers
57 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 posts and articles out there explaining ...
4
votes
2answers
83 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
79 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
0answers
71 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? import numpy as np ...
2
votes
1answer
71 views

Custom session class

<?php /** *session.php *danutz0501 *@copyright 2013 **/ //defined('BASE_PATH')||(header("HTTP/1.1 403 Forbidden")&die('403 - Acces direct interzis.')); class session{ private $db, ...
0
votes
1answer
71 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
185 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 dates of today, a date I insert and ...
1
vote
2answers
79 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 ...
6
votes
1answer
103 views

PriorityQueue<T> Implementation — Flaws, Thoughts, General Feedback

I have been looking desperately for some more experienced .NET (C#) software developers to take a look at my code, and provide me with some good ol' honest feedback and/or criticism about it. It only ...
0
votes
1answer
56 views

How to put a lot of information in the class?

I have such a problem: I'm parsing a lot of HTML files with Simple HTML DOM Parser, that's why I need to use three foreachs to parse the necessary information from it -> I am getting a lot of ...
8
votes
5answers
275 views

Abstract Pet class

As a student of C# right now, I am trying my best to get a grasp on many of the systems being taught. I just completed Week 1 of a C# 102 class and the class was assigned a bit of homework. I am ...
3
votes
1answer
97 views

Using POST data to call a function from a specified class

I've inherited a class in a project which is purposed to execute a function that exists in POST data from a specified class. I've tried to clean this up as much as possible as well as secure it ...
5
votes
7answers
335 views

One instance per method call or multiple method call per instance

I have the following class designs, and I'm looking for the best practices, aligned to the OOP design principles/patterns. The ParameterParser will be used inside a foreach block through 10 items ...
11
votes
3answers
474 views

Is this a properly implemented linked list class?

The code below is a class implementation of a linked list. I DO have concerns. For example, is it normal for the class to have at least one node? In other words, this implementation cannot have an ...
3
votes
2answers
144 views

Image loader/writer design (no API, pure C++ on Windows)

I have an image loader, now only for bitmaps. I'm a little confused because I want to split my code to different classes, one for writing a BMP data to a file (WRITER), one for loading BMP data from ...
5
votes
1answer
89 views

How to refactor many small but similar classes in Ruby?

I have classes like these: class DepartmentSerializer < Serializer self.root = false attributes :id, :name has_many :employees, serializer: EmployeeSerializer has_one :location, ...
-2
votes
1answer
46 views

Classes in Python [closed]

I am trying to create a class about birds with a few different methods. This is just theoretical code. Is there anything that is inherently wrong with the code from a syntactical or semantics point of ...
2
votes
3answers
193 views

Modeling a pair of dice using composition in C++. Am I doing it right?

I've written a program all by myself, but I just want to make sure I did it right and if anybody has any suggestions on improving it in any way. Define and implement the Die class depicted by the ...