Click here to Skip to main content
15,888,113 members
Home / Discussions / C#
   

C#

 
QuestionBreaking Up Classes Pin
Richard Andrew x6427-Jan-11 11:40
professionalRichard Andrew x6427-Jan-11 11:40 
AnswerRe: Breaking Up Classes Pin
TheGreatAndPowerfulOz27-Jan-11 11:49
TheGreatAndPowerfulOz27-Jan-11 11:49 
GeneralRe: Breaking Up Classes Pin
Richard Andrew x6427-Jan-11 11:53
professionalRichard Andrew x6427-Jan-11 11:53 
GeneralRe: Breaking Up Classes Pin
TheGreatAndPowerfulOz27-Jan-11 12:36
TheGreatAndPowerfulOz27-Jan-11 12:36 
AnswerRe: Breaking Up Classes Pin
RobCroll27-Jan-11 11:55
RobCroll27-Jan-11 11:55 
AnswerRe: Breaking Up Classes Pin
dan!sh 27-Jan-11 12:03
professional dan!sh 27-Jan-11 12:03 
GeneralRe: Breaking Up Classes Pin
TheGreatAndPowerfulOz27-Jan-11 12:37
TheGreatAndPowerfulOz27-Jan-11 12:37 
AnswerRe: Breaking Up Classes Pin
GlobX27-Jan-11 12:10
GlobX27-Jan-11 12:10 
Some classes are just going to be big, that's how it is sometimes. However, when we think about a 'rule' or a 'law' (in litigation or in engineering), we don't follow the rule blindly - we think "what is the law there to protect? What's its purpose?".

So, one of the golden rules "don't write mammoth classes" comes down to understandability, flexibility and separation of concerns (there are possibly more interpretations). That being the case, if your class is readable, fairly flexible and has a clear single purpose, then you've satisfied the underlying reasons for the rule - even if the class happens to have 2000 methods.

If you really think it's not achieving this, maybe only in terms of readability, then you could use partial classes[^]; you could restructure the class internally, maybe to use some encapsulated classes (you can't mention refactoring without mentioning Martin Fowler[^]); you could come to terms with the size Smile | :) Really, it's up to you if it's working or not.

Last but not least, I think the greatest invention in C#-land was the #region directive[^] - in a huge class, this is invaluable!!

EDIT: d@nish already beat me to partials and regions! damn... I thought I was so original Poke tongue | ;-P
GeneralRe: Breaking Up Classes Pin
TheGreatAndPowerfulOz27-Jan-11 12:39
TheGreatAndPowerfulOz27-Jan-11 12:39 
QuestionRe: Breaking Up Classes [modified] Pin
GlobX27-Jan-11 12:46
GlobX27-Jan-11 12:46 
GeneralRe: Breaking Up Classes Pin
Manfred Rudolf Bihy27-Jan-11 12:54
professionalManfred Rudolf Bihy27-Jan-11 12:54 
QuestionRe: Breaking Up Classes Pin
GlobX27-Jan-11 12:58
GlobX27-Jan-11 12:58 
AnswerRe: Breaking Up Classes Pin
Manfred Rudolf Bihy27-Jan-11 13:41
professionalManfred Rudolf Bihy27-Jan-11 13:41 
GeneralRe: Breaking Up Classes Pin
GlobX27-Jan-11 13:50
GlobX27-Jan-11 13:50 
GeneralRe: Breaking Up Classes Pin
Manfred Rudolf Bihy27-Jan-11 13:56
professionalManfred Rudolf Bihy27-Jan-11 13:56 
AnswerRe: Breaking Up Classes Pin
TheGreatAndPowerfulOz27-Jan-11 13:43
TheGreatAndPowerfulOz27-Jan-11 13:43 
GeneralRe: Breaking Up Classes Pin
GlobX27-Jan-11 14:03
GlobX27-Jan-11 14:03 
GeneralRe: Breaking Up Classes Pin
PIEBALDconsult27-Jan-11 14:13
mvePIEBALDconsult27-Jan-11 14:13 
AnswerRe: Breaking Up Classes PinPopular
Luc Pattyn27-Jan-11 13:07
sitebuilderLuc Pattyn27-Jan-11 13:07 
GeneralRe: Breaking Up Classes Pin
inayathussaintoori27-Jan-11 14:04
inayathussaintoori27-Jan-11 14:04 
GeneralRe: Breaking Up Classes Pin
musefan28-Jan-11 5:58
musefan28-Jan-11 5:58 
GeneralRe: Breaking Up Classes Pin
Luc Pattyn28-Jan-11 6:14
sitebuilderLuc Pattyn28-Jan-11 6:14 
AnswerRe: Breaking Up Classes Pin
PIEBALDconsult27-Jan-11 14:09
mvePIEBALDconsult27-Jan-11 14:09 
AnswerRead this ebook from los techies about the SOLID principles Pin
i.j.russell28-Jan-11 1:36
i.j.russell28-Jan-11 1:36 
AnswerRe: Breaking Up Classes Pin
Alan Balkany28-Jan-11 3:07
Alan Balkany28-Jan-11 3:07 

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.