Construct that is used as template for creating new objects. Class describes the state and behavior that the objects of the class all share.

learn more… | top users | synonyms (1)

3
votes
1answer
20 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
0answers
12 views

Program stops working, pointer error i'm sure [migrated]

I have this program, and I'm still getting used to C++ pointers, so It's probably an issue with that. But I am having the program crash when the getStructData() function is called. I've probably ...
0
votes
1answer
38 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 ...
7
votes
5answers
189 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 ...
2
votes
1answer
58 views

Review my PHP 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 ...
4
votes
7answers
251 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 ...
10
votes
3answers
272 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
86 views

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

So, 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 ...
5
votes
1answer
70 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
41 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
95 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 ...
0
votes
2answers
111 views

Critique Requested on PHP Pagination Class

I did most of my PHP coding back with PHP 4, and among the projects I did was a popular pagination class. I've been meaning to bring it up to date with PHP 5 and OOP practices. I've also been working ...
0
votes
1answer
46 views

Creating a singleton container class for intrer-class messaging

My question is for validation of my code (any loop holes / bugs) and guidance the best methodology to implement for my requirement. I am developing a Python application that will have many classes. ...
4
votes
1answer
102 views

Generalized is() type-checking function for JavaScript

In a complex library I've been working on, I got pretty tired of all of the individual type functions and operators to determine whether I was working with an object or piece of data of a given type. ...
4
votes
2answers
143 views

Implementation of OOP for retrieving list of objects from database

If I have a Person class that outlines the properties of a person and one of People that just contains a List<Person> like so: public class Person { public Person(){} public int ...
4
votes
2answers
246 views

Issues with this pattern to restrict access to private members?

Since the original post, I have explored further regarding this pattern. In an effort to fix one self-percieved flaw (the lack of ability of prototype methods to access private object members), I have ...
3
votes
1answer
30 views

Get Ancestor Class Name that Defines CONST in PHP?

I have a class hierarchy in PHP and in some of the parent classes I have defined a constant, let's assume that constant is called TYPE for my example. I want to be able to pass in a valid value for ...
2
votes
2answers
193 views

Building a Red Black tree using a structure as a node

I have the following structure: struct Keys { //value of word in the vector<string> words. string word; //index of word in the vector<string> words. int index; //I want to ...
3
votes
1answer
78 views

Marking class with no abstract methods as an abstract

Consider an interface: public interface IWindowOperations { // Some operation methods. } Class definitions: public abstract class BaseWindow<T> : IWindowOperations { // partially ...
1
vote
1answer
26 views

A better way for class management with jQuery

so I've made a carousel, which uses a function that is passed a target element, and from this element it adds next, prev, next next, and prev prev classes to its siblings (causing the rotation) - what ...
2
votes
1answer
77 views

User system using PDO

I'm making a very basic user system, and this is what I have so far: <?php /* The class for constructing any user's information */ class User { protected $userId, $email, ...
3
votes
1answer
66 views

Review/rate my new graph class

I have written a PHP class called "graph". It is a class that performs RESTful-like commands to a MySQL database. I have posted the GitHub repo. Here is the code as well: config.php <?php ...
4
votes
1answer
121 views

Critique of Pascal's Triangle Class

I'm working my way through The Java Programming Language, Fourth Edition - The Java Series. This is Exercise 7.3: Write a program that calculates Pascal's triangle to a depth of 12, storing each ...
1
vote
0answers
108 views

Do I need inheritance or no?

I'm using Pygame to create a small game with few rectangle shapes. However, I want to learn more about classes, and I'm trying to use them. I'm very new to classes and inheritance, but I want to ...
1
vote
0answers
101 views

Basic structure of a simple php REST api

I've read plenty about php OOP design principles and patterns. I can work with classes and inheritance. My issue is with actually using classes for some purpose. In this case, I want to create a ...
4
votes
2answers
242 views

Random password generator

I just wrote my first Java class, and I wanted to share it with you and maybe get some quick check from more experiences coders than I am. I want to learn OOP, Java is just the tool I thought was the ...
3
votes
1answer
163 views

Review/optimization of craps game rules and code: version 2

Thanks to all who've answered my previous question. I've taken all the advice and created a Craps class and gameplay. I just wanted to ask for more advice on how to optimize my code. #include ...
1
vote
2answers
60 views

What is a better way to organize this Python code in a class?

I wrote a script that will eventually go onto a Raspberry Pi. It takes a picture then uploads it to Twitter every 15 minutes from 5:30-9:00pm. It works fine as is, but I feel I need to organize ...
1
vote
1answer
28 views

Throwing error if settings / arguments are undefined is this a good breakout function?

var _ = require("underscore"); var checkSettingsUndefined = function(settings){ if(_.isEmpty(settings)){ throw new Error("settings are empty"); } } var Class = function(settings){ ...
1
vote
2answers
199 views

Review of Dice class

I don't intend on implementing this into an application yet as I'm going to test it first. As such, it doesn't do much beyond rolling. It also overloads some "typical" operators such as == and !=. ...
0
votes
1answer
663 views

Java Fraction Class - Adding Together Two Objects [closed]

I'm currently working on a fraction class. I've successfully figured out how to create a fraction object as well as check for errors but I've blanked and cannot figure out how to add together the two ...
1
vote
2answers
80 views

In this script what can I turn into funtions and how can I go about doing it?

I have just made a simple script which spawns an alien that chases the player, but I want to move as much of the script into funtions so as to minimize the amount of code, to make it run better when ...
2
votes
3answers
327 views

Simple class exercise - min, max, and average of vector items

This program calculates the min and the max value and the average of the items of a vector. It's an exercise from a book so I can't change the header file. Is this code proper? sales.h #include ...
2
votes
3answers
145 views

Simple class exercise using the “this” pointer

This is my solution for an exercise from a book. It's a simple Golf class with member variables fullname and handicap. The constructor sets the variables to the provided name and handicap using ...
1
vote
1answer
180 views

Critique my PHP Cookie class?

I wrote this class to make cookie management easier. I know it makes use of serialize(), but I have no intention of storing very much data in the cookie, and it seemed a cleaner solution than, say, ...
4
votes
1answer
129 views

Shader class implementation

I'm trying to design a Shader class. For now, I'm just trying to get basic outline for handling uniforms. Some design goals I aimed for is to avoid passing a string to a function as this is error ...
3
votes
2answers
134 views

Is the use of Struct or Class personal preference?

I have a solution in which I instantiate a class with various types inside of it. I feel it is becoming to cumbersome to instantiate and then create variables for each of the types I want to access ...
5
votes
4answers
682 views

Testing parity of number of items

This is my first C++ program with classes, and I don't want to develop bad skills. It's very simple and consists of 3 files. This is an exercise from a book, hence the name of the driver file. ...
-1
votes
1answer
55 views

Why isn't it giving me a color for my apple? [closed]

This is not homework; just an exercise I'm doing on my own. In my main: apple j = new apple(); j.Flavor = "sweet"; j.Color = "green"; Console.ReadKey(true); In a class: using System; using ...
1
vote
1answer
159 views

File Downloading, Unzipping and extracting Content - PHP script and tests

EDIT. Here is the new version after bumperbox's very helpful suggestions. I was thinking or renaming into Downloader or something but the problem is, I see downloading is performed at lower level of ...
2
votes
0answers
86 views

Loading 'Plugins' in Ruby

I have written a plugin loader in Ruby, and I would like to know if it uses the best technique to handle classes, or if anyone has any recommendations on how to improve my code. I have written a ...
5
votes
2answers
277 views

Improving remake of factoring/prime factorization calculator

Background info on factoring and prime factorization. I've remade this program from my first attempt, and I'm sure it can still be improved. My questions: These calculations should only be done ...
2
votes
1answer
72 views

Streamlining repetitive class definitions in python with a class_factory() function

I forked this repo to be more concise. The code is here. I'll paste it below since that seems to be the style. I removed the class definitions at the bottom that I didn't change -- the edit I'm ...
4
votes
2answers
94 views

I know I'm not doing these methods right

I'm having difficulty understanding the implementation of methods in classes. I'm pretty sure I'm not doing this the correct way. Can anyone show me the way it should be done. This code works by ...
6
votes
1answer
344 views

Critique Request: PHP Request-Method Class

I'm working on a general Requestmethod class which sanitizes and recasts the input of users in an automatic fashion. I've also tried to do array-access in cookies. My biggest question are: Is this ...
2
votes
1answer
149 views

Please criticize some Tic-Tac-Toe classes

Please criticize the classes GameJudgeImpl and GameInfo so that I could make them clearer. public interface GameJudge { public GameInfo gameInfo(); } public enum GameResult { UNKNOWN, DRAW, ...
1
vote
2answers
105 views

How can I improve the logic of my code?

I was trying to solve this problem on leetcode: http://leetcode.com/onlinejudge#question_2 and my solution can be found here: public class Solution { public ListNode addTwoNumbers(ListNode l1, ...
3
votes
2answers
156 views

Trying to use classes in my python code. Not sure if being done correctly

The point of my code is to: Read in the observed data from the a catalog of stars (whitespace separated table). Do some unit conversions on the observed data (math stuff). Apply an interstellar ...
1
vote
1answer
118 views

Representing database row as a class

For my current project, I have elected to represent database rows as objects. So an individual comment can be retrieved as a class like so: $comment = new Comment(1); Here is the Comment class ...
9
votes
1answer
460 views

Should I put default values of attributes on the prototype to save space?

Suppose I've got a JavaScript function that I'm treating like a class - that is, I want to make many instances of it: function Blerg() { this._a = 5; } Blerg.prototype.getA = function() { return ...