Search Results
Search type | Search syntax |
---|---|
Tags | [tag] |
Exact | "words here" |
Author |
user:1234 user:me (yours) |
Score |
score:3 (3+) score:0 (none) |
Answers |
answers:3 (3+) answers:0 (none) isaccepted:yes hasaccepted:no inquestion:1234 |
Views | views:250 |
Code | code:"if (foo != bar)" |
Sections |
title:apples body:"apples oranges" |
URL | url:"*.example.com" |
Saves | in:saves |
Status |
closed:yes duplicate:no migrated:no wiki:no |
Types |
is:question is:answer |
Exclude |
-[tag] -apples |
For more details on advanced search visit our help page |
General guidelines on how to design classes with best known industry practices.
5
votes
Accepted
How to handle an aggregated list of the fields of multiple objects?
The simplest solution is to NOT have the aggregated list 'allVarOfAs'. Instead make it a method or property which returns the aggregated list on the fly, but doing a SelectMany over aList. E.g.
IEnu …
3
votes
Accepted
To god (class) or not to god?
Option 3: Create individual objects corresponding to specific responsibilities, and then have each user hold a collection of these.
The collection of responsibilities for a user will contain only the …
1
vote
How wrong it is to have multiple associations between classes?
First: What is the program supposed to do? You cannot make decision about architecture without knowing the purpose of the program. Also, ignore advice from people whom you haven't told the purpose of …
35
votes
Accepted
Singleton or instantiate everytime I use?
If the class has no state, you could consider turning it into a function or static method depending on your language.
3
votes
When using the Single Responsibility Principle, what constitutes a "responsibility?"
"Single responsibility principle" is perhaps a confusing name. "Only one reason to change" is a better description of the principle, but is still easy to misunderstand. We are not talking about say wh …
9
votes
Constructing an object: should I expose or hide parameters passed to the constructor?
You coworker is right. Internal state should be encapsulated by default and only exposed where there is a good reason to. So when in doubt, hide.
Should I really think for each parameter if it mak …
80
votes
How to warn other programmers of class implementation
The most effective and helpful way to prevent clients from "misusing" an object is by making it impossible.
The simplest solution is to merge Initialize with the constructor. That way, the object wil …
2
votes
When NOT to use a class / member variable?
A variable should always have the smallest scope and the shortest lifetime possible. Therefore a class member is preferable to a global variable, and a local variable or parameter is preferable to a c …
0
votes
Is it best practice for each call to a SQL Server to be in its own class, even when using de...
Having a class for each query method is not best practice.
A core OO design principle is: Classes should have low coupling and high cohesion. Unfortunately, the high cohesion side is often forgotten, …