Refers to structural definition of class unit in object-oriented languages.
Questions tagged [class-design]
1125 questions
20
votes
4 answers
Non-public top-level class vs static nested class
It seems to me that non-public top-level classes and static nested classes essentially perform the same tasks when creating a helper class.
A.java
public class A
{
public static main (String[] args)
{
AHelper helper = new…

Stephen
- 522
- 5
- 12
18
votes
2 answers
How to initialize an NSObject's subclass on iPhone?
I want to write some methods in a class so that other classes can call these methods using [instance methodName:Parameter].
If the class is a subclass of UIViewController, I can use initWithNibName to initialize it. But I want to write the methods…

Chilly Zhong
- 16,763
- 23
- 77
- 103
18
votes
12 answers
How do I break my procedural coding habits?
I recently read an interesting comment on an OOP related question in which one user objected to creating a "Manager" class:
Please remove the word manager
from your vocabulary when talking
about class names. The name of the
class should be…

Rob Sobers
- 20,737
- 24
- 82
- 111
18
votes
2 answers
What is the nicest toString builder class you have used or seen ? What made it nice
Lets face it writing nice toString messages is a boring messy chore that needs to be done as it can really be helpful for insepection in a debugger or logging.
What features do you like or wish should be in such a helper...
dumping properties…

mP.
- 18,002
- 10
- 71
- 105
17
votes
4 answers
USE case to Class Diagram - How do I?
I would like your guidance on how to create classes and their relationships (generalization, association, aggregation and composition) accurately from my USE case diagram (please see below).
I am trying to create this class diagram so I can use it…

Anthony
- 3,990
- 23
- 68
- 94
16
votes
5 answers
To implement a property or to implement a subclass
I've got a class called List_Field that, as the name suggests, builds list input fields. These list input fields allow users to select a single item per list.
I want to be able to build list input fields that would allow users to select multiple…

Emanuil Rusev
- 34,563
- 55
- 137
- 201
16
votes
2 answers
How to change the access modifier of a user control
I have a user control created in xaml, lets name it "View". In the View.xaml.cs I changed the access modifier for the class View to internal:
internal partial class View : ViewBase { ... }
After changing the access modifier the compiler states the…

PVitt
- 11,500
- 5
- 51
- 85
16
votes
5 answers
Using Qt signals and slots vs calling a method directly
Lets say I have a main window with a slider and a widget inside that window with a method called setValue(int). I'd like to call this method every time the value of the slider has changed.
Is there any practical difference between the two following…

jaho
- 4,852
- 6
- 40
- 66
16
votes
9 answers
How many methods can a C# class have
Is there a limitation on number of properties, methods a C# class can have?
I do a quick skim at Standard ECMA-334 and did not find any information on it.
Before jumping into why a class with many methods are bad design, I want to be more clear on…

DHornpout
- 6,400
- 4
- 25
- 20
15
votes
14 answers
Should protected attributes always be banned?
I seldom use inheritance, but when I do, I never use protected attributes because I think it breaks the encapsulation of the inherited classes.
Do you use protected attributes ? what do you use them for ?

Stephane
- 868
- 6
- 10
15
votes
2 answers
Overriding class variables in python
I'm trying to understand a bit how Python (2.6) deals with class, instances and so on, and at a certain point, I tried this code:
#/usr/bin/python2.6
class Base(object):
default = "default value in base"
def __init__(self):
…

Savir
- 17,568
- 15
- 82
- 136
15
votes
9 answers
Is it expensive to create objects?
I have just refactored a colleague's code that, roughly, looked like this...
public class Utility
public void AddHistoryEntry(int userID, HistoryType Historytype, int companyID)
{
// Do something...
}
public void AddHistoryEntry(int…

Chris Arnold
- 5,753
- 5
- 35
- 55
15
votes
8 answers
Class Designer in Visual Studio - is it worth it?
Does anybody use the Class Designer much in Visual Studio?
I have downloaded the Modeling Power Toys for 2005 and have been impressed with what I've seen so far. The MSDN Class Designer Blog doesn't seem to have been updated for a while but it still…

David A Gibson
- 2,013
- 5
- 35
- 60
15
votes
8 answers
OO Design Question -- Parent/Child(ren) -- Circular?
I'm fairly new to the OO design process, so please bear with me....
I have two entities that I need to model as classes, call them Parent and Child (it's close enough to the actual problem domain). One Parent will have one or more Children -- I have…

RolandTumble
- 4,633
- 3
- 32
- 37
14
votes
11 answers
How to decide between C# static and non-static methods?
[Edit]
My original-question was "Why to decide between static and non-static? Both do the same..."
Unfortunately it was edited to a C#-specific question what I really wanted to avoid.
So, let me do some additions:
When I say interface, I don't mean…

Inno
- 2,567
- 5
- 32
- 44