Thursday, June 05, 2008

"#region is evil" Part II - my bad

Ok, it is not always evil. If you have class with 50 properties, there is little can be done. Refactoring by grouping properties into the types is gross overengineering. So pack this stuff in the #region, I'll look the over way.


Nick Markovic said...

No! Regions are evil. If you have a class with 50 properties you have a problem. if you have 50 properties on your class it is a good sign that you are not following the "Tell don't ask" principle

Michael Goldobin said...

Hmm... That's a tough call.
What if it is, say, entity on which extensive reporting will be based? I need them and their sets and gets.
Creating composite properties seems to be overengineering.

Chris Barrow said...

I tend to disagree that a class with 50 properties means you have a problem. Admittedly, if you have a class with 50 properties, there is probably something to be done, but in many cases a programmer is faced with having to implement a class which may not be of his design (i.e. - bad architecture).

Overall, I still agree with your original post. Regions are bad. They make it difficult to review code at a later date, and by default, VS2003-2008 doesn't search for code in collapsed regions.

© 2008-2013 Michael Goldobin. All rights reserved