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.
17
votes
Accepted
Can renaming a method preserve encapsulation?
I think you are missing the point. Its not saying you should rename the setter and getter, but to have methods which add and remove items from the fridge. ie
public class Fridge
{
private int num …
8
votes
Accepted
Is Abstracting your code too much a bad use of SOLID Principles?
I would side with your enemy on this one.
The 'create a database and table logic' is clearly technically a separate responsibility from the 'get data from database' logic.
You can imagine the creati …
7
votes
Why are classes named "class"?
Just did some googling and it seems the terms were invented by Ole-Johan Dahl and Kristen Nygaard for their Simula programming language
We chose the terms “class” and “objects” of classes for our …
7
votes
Accepted
Is a callback function with `this` as an argument a bad practice?
No I think it's fairly common for events to pass the object raising the event and the event arguments to a handler.
I've seen it said that this is so events can be bubbled up through several handlers …
5
votes
Accepted
How to store objects with inconsistant properties
Don't try to make objects that simulate real world equivalents
Make objects that hold data that goes with their methods
In your materials example, you don't actually say what the data is used for.
…
3
votes
Is a class with a high number of member variables bad and is there a design structure for da...
It's unusual for a single object to have 50 variables that wouldn't be better grouped into sub objects.
For example a UK address has 14 fields. You could imagine that an address class that covered ad …
2
votes
Accepted
c# class generation/architecture for json rest service
I think you have two options here.
Best practice. Create objects which match the json returned by/sent to the API and serialize/deserialze these objects when you make calls or receive responses. Hid …
2
votes
How should an `Employee` class be designed?
First create an employee struct containing the properties of the conceptual employee.
Then create a database with matching table structure, say for example mssql
Then create a employee repository Fo …
2
votes
Accepted
C# - Class creating instances of other classes requiring different services
I think you are just going in circles here.
You can either use an ADM approach with one or more services and objects with no logic ie
Service
{
StartEngine(Engine e)
PressPedal(Pedal p)
...
} …
2
votes
DAL class structure for storing and organizing SQL using Dapper?
Normally I would say your "Backing class" is a "Repository" and should follow that pattern. For which i would normally recommend one per database
UserDataRepository
{
GetUserById(id)
GetAllRol …
1
vote
Eliminating cyclic dependency
I would remove the Dependency of IUserPublishedInfoInitializer on IDbRepository. Instead inject this as a construction parameter into the concrete UserPublishedInfoInitializer.
your dependency graph …
1
vote
Accepted
Proper event driven design when a consumer subscribes to many producers
2 is the mediator pattern.
You can get around the tight coupling by:
Injecting a IMediator interface with just 'publish' and 'listen'
By using a factory method to create the buttons and wire up th …
1
vote
Pros and cons of representing routes as legs or stops?
OK so once you have the data in memory its trivial to convert stops to legs and vice-versa.
Your problem will come when you are searching you database for particular sets of routes.
For example, I am …
1
vote
Accepted
Is it best practice for each call to a SQL Server to be in its own class, even when using de...
This looks like the repository pattern, which is generally considered to be a good thing, separation of concerns between your business and data layer.
The reason to put all these methods together in a …
0
votes
Class design for writing multiple versions of multiple files
I think the answer will depend on what you are trying to achieve other than writing files.
Lets leave out the POJOs for the moment, you read data from a DB and write it out to a specific file format …