Core to Object-Oriented Programming (OOP), a class is a template for creating new objects that describes the common state(s) and behavior(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
313 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
2k 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
724 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 ...
10
votes
6answers
789 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
2answers
1k 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
5answers
2k views
10
votes
1answer
320 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
615 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
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 ...
9
votes
1answer
709 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:
...
9
votes
1answer
77 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
363 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
391 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
246 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
624 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
102 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
649 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
149 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
464 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
219 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
2answers
78 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
508 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
198 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
262 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
1answer
712 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
206 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
410 views
Please review this 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
3answers
148 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
388 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
122 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
651 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
749 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
655 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
862 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
1answer
317 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
3answers
2k 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.
...
6
votes
2answers
214 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
1answer
167 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
2answers
66 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
2answers
114 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:
...
6
votes
1answer
300 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 ...
6
votes
1answer
141 views
Attempt at an implementation of a TextFile class
How can I improve this class that should represent a text file?
Im trying to write a simple class to represent a text file - which one would think should be quite easy.. I don't intend to add all ...
6
votes
2answers
134 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 ...
6
votes
2answers
385 views
Any way to improve the performance of this PHP class?
I have been developing this class, and was wondering if anyone had any thoughts on how I can improve the performance of it.
...
5
votes
4answers
4k 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 ...
5
votes
3answers
510 views
Is there a better way to pass variables into a class?
Is there a better way to pass variables into a class?
...
5
votes
2answers
143 views
Improve/Correct PHP Class
I'm looking for code correctness and improvements for the following code. It's my first step into class based programing.
What the class does, is simply to read a directory (path is passed as ...
5
votes
1answer
347 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 ...
5
votes
2answers
461 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 ...