Click here to Skip to main content
15,902,189 members
Home / Discussions / Java
   

Java

 
GeneralRe: How do I decide for class responsibilities? Pin
Richard MacCutchan9-Jul-12 9:03
mveRichard MacCutchan9-Jul-12 9:03 
GeneralRe: How do I decide for class responsibilities? Pin
Nagy Vilmos9-Jul-12 9:12
professionalNagy Vilmos9-Jul-12 9:12 
GeneralRe: How do I decide for class responsibilities? Pin
jschell9-Jul-12 12:13
jschell9-Jul-12 12:13 
GeneralRe: How do I decide for class responsibilities? Pin
pasztorpisti14-Jul-12 0:03
pasztorpisti14-Jul-12 0:03 
GeneralRe: How do I decide for class responsibilities? Pin
jschell9-Jul-12 12:01
jschell9-Jul-12 12:01 
GeneralRe: How do I decide for class responsibilities? Pin
Andrei Straut16-Jul-12 0:22
Andrei Straut16-Jul-12 0:22 
GeneralRe: How do I decide for class responsibilities? Pin
pasztorpisti13-Jul-12 23:40
pasztorpisti13-Jul-12 23:40 
AnswerRe: How do I decide for class responsibilities? Pin
Pete O'Hanlon9-Jul-12 7:55
mvePete O'Hanlon9-Jul-12 7:55 
It is confusing if you concentrate on one item to the exclusion of all else. Take your example; you have a statement that "a blog entry has to have a title and a body". Okay, I can see where you are going with that, but you're now wondering whether or not you violate SOLID to have a body element AND a title element. This is designing in isolation. You need to consider the other requirements to see what effect they have.

For instance, suppose you have a requirement that states that a title must have more than 20 characters and less than 150 characters. Does this mean that you need to create a separate Title class which encapsulates the rules, or do you make it part of the BlogEntry class? Well, that depends - you might want to create a separate validation engine which is responsible for enforcing the rules, in which case you would probably just use attributes on your BlogEntry properties, so the mechanism for defining HOW to validate the properties is external, but the rules for each element are attached (this is a common technique).

Then you need to consider where your rules are applied. Do you do everything in your UI, or do you abstract to a business rules class? Is your BlogEntry class actually a model instead? Should you use MVC?

The thing I'm trying to get at here is that there is no "one size fits all" solution. As others have said, it's experience, but it is also a case that your start and end point has to be "what do I need to put in to satisfy the requirements?" By all means, consider the use cases - a well architected use case should be a vital part of developing your application because it should tell you how the user will actually use your application. Beyond that, adhering to SOLID is a mix of experience and common sense, and you shouldn't slavishly adhere to something just because someone else has written about how good it is.

*pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

"Mind bleach! Send me mind bleach!" - Nagy Vilmos


CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

GeneralRe: How do I decide for class responsibilities? Pin
Nagy Vilmos9-Jul-12 8:23
professionalNagy Vilmos9-Jul-12 8:23 
GeneralRe: How do I decide for class responsibilities? Pin
Pete O'Hanlon9-Jul-12 8:31
mvePete O'Hanlon9-Jul-12 8:31 
GeneralRe: How do I decide for class responsibilities? Pin
Nagy Vilmos9-Jul-12 8:33
professionalNagy Vilmos9-Jul-12 8:33 
GeneralRe: How do I decide for class responsibilities? Pin
Pete O'Hanlon9-Jul-12 8:41
mvePete O'Hanlon9-Jul-12 8:41 
GeneralRe: How do I decide for class responsibilities? Pin
Nagy Vilmos9-Jul-12 8:45
professionalNagy Vilmos9-Jul-12 8:45 
GeneralRe: How do I decide for class responsibilities? Pin
Pete O'Hanlon9-Jul-12 8:53
mvePete O'Hanlon9-Jul-12 8:53 
GeneralRe: How do I decide for class responsibilities? Pin
Nagy Vilmos9-Jul-12 9:00
professionalNagy Vilmos9-Jul-12 9:00 
AnswerRe: How do I decide for class responsibilities? Pin
Stingrae7899-Jul-12 10:00
Stingrae7899-Jul-12 10:00 
QuestionInstrument Automation Pin
CMA215-Jul-12 10:45
CMA215-Jul-12 10:45 
AnswerRe: Instrument Automation Pin
TorstenH.5-Jul-12 19:22
TorstenH.5-Jul-12 19:22 
AnswerRe: Instrument Automation Pin
jschell6-Jul-12 11:20
jschell6-Jul-12 11:20 
Questionjava with text file Pin
RORY175-Jul-12 9:35
RORY175-Jul-12 9:35 
AnswerRe: java with text file Pin
TorstenH.5-Jul-12 19:13
TorstenH.5-Jul-12 19:13 
GeneralRe: java with text file Pin
RORY175-Jul-12 23:15
RORY175-Jul-12 23:15 
GeneralRe: java with text file Pin
RORY175-Jul-12 23:37
RORY175-Jul-12 23:37 
GeneralRe: java with text file Pin
TorstenH.5-Jul-12 23:40
TorstenH.5-Jul-12 23:40 
GeneralRe: java with text file Pin
RORY176-Jul-12 0:51
RORY176-Jul-12 0:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.