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

C#

 
GeneralRe: Form disappearing Pin
OriginalGriff17-Apr-16 1:44
mveOriginalGriff17-Apr-16 1:44 
GeneralRe: Form disappearing Pin
OriginalGriff17-Apr-16 1:40
mveOriginalGriff17-Apr-16 1:40 
GeneralRe: Form disappearing Pin
Philippe Mori18-Apr-16 12:34
Philippe Mori18-Apr-16 12:34 
AnswerRe: Form disappearing Pin
ChizI19-Apr-16 7:25
ChizI19-Apr-16 7:25 
Questionusing Enums as a design-strategy ? Pin
BillWoodruff16-Apr-16 21:59
professionalBillWoodruff16-Apr-16 21:59 
AnswerRe: using Enums as a design-strategy ? Pin
Garth J Lancaster16-Apr-16 23:01
professionalGarth J Lancaster16-Apr-16 23:01 
GeneralRe: using Enums as a design-strategy ? Pin
BillWoodruff16-Apr-16 23:29
professionalBillWoodruff16-Apr-16 23:29 
AnswerRe: using Enums as a design-strategy ? Pin
John Torjo18-Apr-16 1:37
professionalJohn Torjo18-Apr-16 1:37 
A few notes on my opinions/usages on enums:

1. I quite love enums. Especially when you use them to specify an argument to a function

Like enforcing a constraint,

enum month { jan, feb, ... , dec };

2. I know there are pitfalls, but if you know them, enums are really powerful. They are self-documenting. Code looks much better at the point of call.

Just imagine:

var lines = x.Split( new[] {"\r\n"}, SplitOptions.RemoveEmptyEntries);

The latter argument could have been a boolean, but then the code would have been much harder to understand:

<br />
// what does "true" really mean?<br />
var lines = x.Split( new[] {"\r\n"}, true);


3. One of the possible problems when using enums is when you add a new value. In this case, you'll pretty much need to update all the code that used switch-es based on this enum. That's why I strive to have as few functions that require a switch based on all possible values.

4. About "future fragility": If other code depends on exact enum values, I usually put a comment on top of the enum

// Do not change the values. Other assemblies depend on this exact matching<br />
enum month { jan = 1, feb = 2, ... , dec = 12 };


5. "Nested" enums. I have used something more or less similar in my code, but never more than 2 levels deep. So far, I haven't encountered any pitfalls.

6. Took a look at the Class based alternative - clearly, there are some scenarios for it, but I think most of the time, it's overkill (my personal opinion, of course Wink | ;) )

Best,
John
-- Log Wizard - a Log Viewer that is easy and fun to use!

GeneralRe: using Enums as a design-strategy ? Pin
BillWoodruff18-Apr-16 4:45
professionalBillWoodruff18-Apr-16 4:45 
GeneralRe: using Enums as a design-strategy ? Pin
John Torjo18-Apr-16 9:12
professionalJohn Torjo18-Apr-16 9:12 
QuestionHow do i establish a ADO.NET application without installing SqlServer in client side. Pin
Member 1246281515-Apr-16 20:44
Member 1246281515-Apr-16 20:44 
AnswerRe: How do i establish a ADO.NET application without installing SqlServer in client side. Pin
OriginalGriff15-Apr-16 21:07
mveOriginalGriff15-Apr-16 21:07 
GeneralRe: How do i establish a ADO.NET application without installing SqlServer in client side. Pin
Member 1246281515-Apr-16 22:34
Member 1246281515-Apr-16 22:34 
GeneralRe: How do i establish a ADO.NET application without installing SqlServer in client side. Pin
Richard MacCutchan15-Apr-16 22:42
mveRichard MacCutchan15-Apr-16 22:42 
GeneralRe: How do i establish a ADO.NET application without installing SqlServer in client side. Pin
Dave Kreskowiak16-Apr-16 3:07
mveDave Kreskowiak16-Apr-16 3:07 
AnswerRe: How do i establish a ADO.NET application without installing SqlServer in client side. Pin
Pete O'Hanlon16-Apr-16 2:08
mvePete O'Hanlon16-Apr-16 2:08 
QuestionHow to covert longitude and latitude to x and y values for state plane coordinate systems Pin
Member 1234906415-Apr-16 10:55
Member 1234906415-Apr-16 10:55 
AnswerRe: How to covert longitude and latitude to x and y values for state plane coordinate systems Pin
Sascha Lefèvre15-Apr-16 11:40
professionalSascha Lefèvre15-Apr-16 11:40 
AnswerRe: How to covert longitude and latitude to x and y values for state plane coordinate systems Pin
M Sukhdeep15-Apr-16 13:35
M Sukhdeep15-Apr-16 13:35 
AnswerRe: How to covert longitude and latitude to x and y values for state plane coordinate systems Pin
Patrice T15-Apr-16 19:34
mvePatrice T15-Apr-16 19:34 
AnswerRe: How to covert longitude and latitude to x and y values for state plane coordinate systems Pin
V.16-Apr-16 5:06
professionalV.16-Apr-16 5:06 
QuestionRead specific bytes continually from a file Pin
Tirumaleswara Reddy.K15-Apr-16 1:33
Tirumaleswara Reddy.K15-Apr-16 1:33 
AnswerRe: Read specific bytes continually from a file Pin
Richard MacCutchan15-Apr-16 1:53
mveRichard MacCutchan15-Apr-16 1:53 
AnswerRe: Read specific bytes continually from a file Pin
Pete O'Hanlon15-Apr-16 2:18
mvePete O'Hanlon15-Apr-16 2:18 
GeneralRe: Read specific bytes continually from a file Pin
Mycroft Holmes15-Apr-16 15:02
professionalMycroft Holmes15-Apr-16 15:02 

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.