Refers to structural definition of class unit in object-oriented languages.
Questions tagged [class-design]
1125 questions
14
votes
4 answers
When should you use friend classes?
Possible Duplicate:
When should you use 'friend' in C++?
I have come to a stumbling block because of lack of documentation on friend classes. Most books just explain it briefly, e.g an excerpt from C++: the Complete Reference:
Friend Classes are…

ApprenticeHacker
- 21,351
- 27
- 103
- 153
14
votes
4 answers
Class prototyping
I have put several instances of class b in class a but this causes an error as class a does not know what class b is.
Now I know I can solve this problem by writing my file b a c but this messes up the reachability as well as annoys me. I know I…

Skeith
- 2,512
- 5
- 35
- 57
14
votes
5 answers
Improve this PHP bitfield class for settings/permissions?
I have been trying to figure out the best way to use bitmask or bitfields in PHP for a long time now for different areas of my application for different user settings and permissions. The farthest I have come so far is from a class contributed by…

JasonDavis
- 48,204
- 100
- 318
- 537
14
votes
5 answers
.NET ORMs need virtual, and can't deal with sealed?
I am just getting started with .NET ORMs, to the point where I haven't even decided between Entity Framework and NHibernate. But in both cases, I'm running into a problem in that they seem to want me to compromise the integrity of my domain model in…

Domenic
- 110,262
- 41
- 219
- 271
14
votes
4 answers
How to share data between separate classes in Java
What is the best way to share data between separate classes in Java? I have a bunch of variables that are used by different classes in separate files in different ways.
Let me try to illustrate a simplified version of my problem:
This was my code…

f20k
- 3,106
- 3
- 23
- 32
14
votes
6 answers
What's wrong with Copy Constructors? Why use Cloneable interface?
When programming C++ we used to create copy constructors when needed (or so we were taught). When switching to Java a few years ago, I noticed that the Cloneable interface is now being used instead. C# followed the same route defining the ICloneable…

Hosam Aly
- 41,555
- 36
- 141
- 182
14
votes
4 answers
What are the pros/cons of choosing between static and instance data access classes in a web app?
I've read several other questions on this topic (here, here, and here), but have yet to see a great answer. I've developed my fair share of data access layers before and personally prefer to use instance classes instead of static classes. However,…

Kevin Babcock
- 10,187
- 19
- 69
- 89
13
votes
2 answers
Execute Set of ValidationRule-C# Class Design - Better Approach
I have a case there I need to execute set of validation rules for different companies. There will be multiple validation rules against one Company.
So I have following table Structure
Company
ID CompanyName
1 ABC
2 DEF …

vmb
- 2,878
- 15
- 60
- 90
13
votes
7 answers
Which is the better C# class design for dealing with read+write versus readonly
I'm contemplating two different class designs for handling a situation where some repositories are read-only while others are read-write. (I don't foresee any need for a write-only repository.)
Class Design 1 -- provide all functionality in a base…

devuxer
- 41,681
- 47
- 180
- 292
13
votes
2 answers
How do I manipulate a tree of immutable objects?
I'm building an entire application out of immutable objects so that multi-threading and undo become easier to implement. I'm using the Google Collections Library which provides immutable versions of Map, List, and Set.
My application model looks…

Frederik
- 14,156
- 10
- 45
- 53
13
votes
12 answers
Should a c# class generate instances of itself?
I have a class that defines a CallRate type. I need to add the ability to create multiple instances of my class by reading the data from a file.
I added a static method to my class CallRate that returns a List. Is it ok for a class to…

user10178
- 532
- 1
- 4
- 13
13
votes
3 answers
C#. Where struct methods code kept in memory?
It is somewhat known where .NET keeps value types in memory (mostly in stack but could be in heap in certain circumstances etc)...
My question is - where is the code of the struct?
If I have say 16 byte of data fields in the struct and a massive…
please delete me
13
votes
5 answers
Is it reasonable to have a fair amount of public properties in a class?
Or in more specific words, is it "ok" to not be relying on setters and getters?
I'm dealing with a class that checks the availability of rooms and sets public properties of which there are more than a dozen. Things such as:
unitNumber
roomTypes (…

meder omuraliev
- 183,342
- 71
- 393
- 434
13
votes
8 answers
Help on implementing how creatures and items interact in a computer role playing game
I am programming a simple role playing game (to learn and for fun) and I'm at the point where I'm trying to come up with a way for game objects to interact with each other. There are two things I am trying to avoid.
Creating a gigantic game object…

mikedev
- 733
- 9
- 16
13
votes
2 answers
How to force only smart pointers instance for a class?
I've been working on a way to prevent user of using a class without smart pointers. Thus, forcing them to have the object being heap allocated and managed by smart pointers.
In order to get such a result, I've tried the following :
#include…

Nemikolh
- 700
- 4
- 19