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)

19
votes
2answers
686 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 ...
13
votes
5answers
2k 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 ...
12
votes
1answer
328 views

Is splitting to small classes good?

I have materials: class Material {...}; class ConcreteMaterialA : public Material {...}; class ConcreteMaterialB : public Material {...}; I want it to have a ...
11
votes
3answers
3k 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 ...
11
votes
2answers
741 views

Is it wrong to write an entire program under one class/method in Java?

I'm new to programming and have created a simple Rock, Paper, Scissors game. The entire program is under a single class and the main method. I hear that's probably not the best way to code. How ...
11
votes
2answers
601 views

Too many objects, too “deep” class structure?

I have a pretty large model library I'm working on and it's turning out quite complex, or so I believe at least and I could use a second opinion. The basic idea is that the user should only have to ...
10
votes
6answers
793 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? ...
10
votes
4answers
2k 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 ...
10
votes
2answers
2k views

Card Deck class for a Poker game

I have recently finished creating my own Deck class for my Poker game. It works the way I want it to, but I would like to know if I can make it better and/or more ...
10
votes
1answer
810 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: ...
10
votes
1answer
326 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 ...
10
votes
1answer
631 views

How can I manage different problems in Math Quiz?

Ok, this will be the first question for this project. This is a Math quiz system. Always must generate different problems for each problem, but at the same time, I have to generate the same exam for ...
9
votes
5answers
2k views

Simple ASP.NET C# class design

Here's a class I'm designing: ...
9
votes
1answer
106 views

Key Press Handler

I have made a class to import into my projects to more easily handle the state of the keyboard so I can use stuff like: if(Keys.returnKey(37)){ As opposed to ...
9
votes
1answer
85 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 ...
8
votes
5answers
401 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 ...
8
votes
3answers
397 views

Class with a sometimes unused property

From times to times I stumble over the following situation: I have got a class with a property that's only used if another property has a particular value, for instance: ...
8
votes
3answers
304 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 ...
8
votes
3answers
914 views

C++ Student Class

Is this a good approach of designing a class or is there some other way that I am not aware of? Student.h specification file ...
8
votes
2answers
125 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 ...
8
votes
4answers
707 views

Poker game classes

I've built this two classes for a Poker game on Android and I would appreciate some feedback on my code. Have no mercy. The harsher you are, the better. Feel free to add your number of WTFs/minute. ...
8
votes
2answers
294 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. ...
8
votes
2answers
468 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, ...
7
votes
4answers
221 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 ...
7
votes
4answers
3k views

Text-based RPG game using classes

I am studying for a degree in "Bachelor of Engineering in Information and Communication Technologies." I am currently on vacation, just after we started learning C++ at the end of the semester. I ...
7
votes
2answers
82 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 ...
7
votes
1answer
543 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. ...
7
votes
2answers
206 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 ...
7
votes
2answers
267 views

How can I make this method less verbose?

I point to my problem in the comments of my code. I have a class RomanNumeral: ...
7
votes
2answers
422 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 ...
7
votes
2answers
150 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 ...
7
votes
1answer
810 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): ...
7
votes
2answers
237 views

Playing cards in C++

I am currently learning C++ (note: I am using C++11) and have begun working on a small project to practice what I've been learning. This project is a deck of cards that I hope to use later to create ...
7
votes
2answers
96 views

Specific PHP Data Access Class

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 ...
7
votes
3answers
163 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. ...
7
votes
2answers
409 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 ...
7
votes
1answer
123 views

ClassHierarchy Design in java for a small project

I have written a java code which does following:- Main goal is to fetch emails from (inbox, spam) folders and store them in database. It fetches emails from gmail,gmx,web.de,yahoo and Hotmail. ...
6
votes
7answers
967 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 ...
6
votes
4answers
762 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. ...
6
votes
3answers
660 views

Is this Date class well-written?

I'm a C++ beginner and have made a simple class. But I'm not sure if this is well-written. It's basically just a Date class. ...
6
votes
2answers
1k 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 ...
6
votes
2answers
217 views

Blackjack game with classes instead of functions

To try out the concepts and tools I've been learning, I decided to write a Blackjack game. I wrote it entirely with functions, so it hasn't helped me at all with the concept I really lack ...
6
votes
1answer
320 views

Playing Card Class - is this right?

The Art and Science of Java, a course book that uses the ACM library, has an exercise that reads like this: Implement a new class called Card that includes the following entries: • Named ...
6
votes
1answer
508 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 ...
6
votes
2answers
268 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: ...
6
votes
2answers
71 views

Planning a rather large refactoring of physics code in a good way?

I have a large file that I want to refactor. My idea is to make helper classes with helper methods so that I can modularize methods. Is that a good idea? For instance before refactoring: ...
6
votes
1answer
168 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? ...
6
votes
1answer
113 views

Creating C++ classes and objects

I'm brand new to programming (in general) and C++ (in particular). I'm learning the basics of classes and objects. I'm trying to do the following: Create a class called ...
6
votes
1answer
48 views

Sorted unidirectional list with add, delete and find

I am aware of the fact that a sorted unidirectional list has only very few use cases, but nevertheless, this python code feels fairly long for Python code. How can I improve it? ...
6
votes
2answers
117 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: ...