Refers to structural definition of class unit in object-oriented languages.
Questions tagged [class-design]
1125 questions
6
votes
3 answers
Class Structure for a list Class?
I am looking for some class structure help. Lets say I have a class called Dog holds information about the dog (name, weight, type) but because there could be multiple dogs, I would also like a class to hold all of these dogs, for use throughout…

Spooks
- 6,937
- 11
- 49
- 66
6
votes
2 answers
Java - Return correct type from Generic method
I have the following class structure:
public class Team {
...
}
public class Event {
}
public abstract class Fixture implements Event {
...
}
public abstract class Forecast {
}
public class MyPrediction
user130076
6
votes
5 answers
CSS - common classes
In my web app I use several CSS classes to write less code. I use them quite often in the markup to add single property or two in some cases.
These are the following
.clear { float: none; clear: both; }
.fl_l{ float: left; }
.fl_r{ float: right;…

Denis Bobrovnikov
- 634
- 3
- 10
- 19
6
votes
1 answer
Best practice for avoiding code duplication while implementing iterator and const_iterator classes
What are the best practices to avoid code duplication when implementing class pairs such as iterator and const_iterator or similar?
Does one usually implement iterator in terms of const_iterator using lots of const_casts?
Does one employ some sort…

Armen Tsirunyan
- 130,161
- 59
- 324
- 434
6
votes
2 answers
SSIS: Curious: why is the last parameter in FireInformation method a ref bool?
I'm currently working on a SSIS package and after the 80th time using FireInformation inside a Script Task, I have to wonder: why would the method require you to pass in a ref boolean as its last parameter? The documentation doesn't state anything…

enriquein
- 1,048
- 1
- 12
- 28
6
votes
4 answers
C++ Class design - easily init / build objects
Using C++ I built a Class that has many setter functions, as well as various functions that may be called in a row during runtime.
So I end up with code that looks like:
A* a = new…

Kenny Cason
- 12,109
- 11
- 47
- 72
6
votes
4 answers
How do I design this procedural code as class based (object oriented)?
I'm a beginner-intermediate self taught Python developer,
In most of the projects I completed, I can see the following procedure repeats. I don't have any outside home code experiences, I think the below code is not so professional as it is not…

All Іѕ Vаиітy
- 24,861
- 16
- 87
- 111
6
votes
2 answers
Objective-C partial implementation of classes in separate files
I am using core data and am generating classes from my data model.
I implement custom methods in these classes, however when i regenerate i generate over the top so i end up copying and pasting a bit. What i would like to do is split my…

Aran Mulholland
- 23,555
- 29
- 141
- 228
6
votes
6 answers
Modern C and C++: it is possible to use one defined structure for other declared structure?
Let's say I want to make some sort of engine which should support loading graphical Images, so I have
struct Image;
Image* load_image_from_file(...);
I don't want external world to know what Image really is, they'll deal only with pointers to it.…

user2998754
- 89
- 5
6
votes
7 answers
Best practice: instance variables filling over time
I'm new to the concept of object oriented programming (in java) and I often encounter the following design problem:
I often create classes with instance variables which are not known at the moment of initialization. These variables are filled over…

Fabian Gehring
- 1,133
- 9
- 24
6
votes
5 answers
C# properties issue
The other day I bumped into a little problem regarding C#'s properties.
Let's say I have this setup:
public class Point
{
public float X;
public float Y;
}
public class Control
{
protected Point m_Position = new Point();
public Point Position
…

impmja
- 191
- 1
- 9
6
votes
5 answers
What does a compiler add to an empty class declaration?
Suppose, I write
class A { };
The compiler should provide (as and when needed)
a constructor
a destructor
a copy constructor
= operator
Is this all the compiler provides? Are there any additions or deletions to this list?

Moeb
- 10,527
- 31
- 84
- 110
6
votes
1 answer
RPG Game loop and class structure (cocos2D for iPhone)
I'm looking to make an RPG with Cocos2D on the iPhone. I've done a fair bit of research, and I really like the model Cocos2D uses for scenes. I can instantiate a scene, set up my characters etc. and it all works really nicely... what I have problems…

mac_55
- 4,130
- 7
- 31
- 40
6
votes
7 answers
C++ equivalent for java final member data
First, my latest coding is Java, and I do not want to "write Java in C++".
Here's the deal, I have to create an immutable class. It's fairly simple. The only issue is that getting the initial values is some work. So I cannot simply call…

Ayman
- 11,265
- 16
- 66
- 92
6
votes
4 answers
Class design suggestions: extending a class and code reuse
The gist of this question is about extending a class, minimizing jam-packing everything into a single class, and maximizing code re-use. After reading this question, please feel free to edit the title or description to make it more succinct. Though…

sivabudh
- 31,807
- 63
- 162
- 228