Click here to Skip to main content
15,914,162 members
Home / Discussions / C#
   

C#

 
GeneralRe: Form disappearing Pin
Member 238990017-Apr-16 1:16
Member 238990017-Apr-16 1:16 
GeneralRe: Form disappearing Pin
OriginalGriff17-Apr-16 1:30
mveOriginalGriff17-Apr-16 1:30 
GeneralRe: Form disappearing Pin
Member 238990017-Apr-16 1:42
Member 238990017-Apr-16 1:42 
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 
The short version: "How do you use Enums in C# as: structural element ? design strategy ? Do you see any special "danger" in using elaborate Enum structures ?"

In the last few years, somehow I have moved to more, and more, frequent use of Enums in C# ... without having, at any point in time, made a conscious decision to do so (though reading code examples by people I consider .NET gurus here on CP, and on StkO, is probably an influence). Of course, I like the idea that Enums are memory-parsimonious, simple, relatively light-weight, and I like what using the [Flags] attribute lets you do. I really like the fact Enum values are compile-time constants that can be used in a 'Switch statement block.

I've come to believe that use of Enums + Interfaces (and generic Interfaces) are, as well, very powerful tools for application design (this may be so obvious to many of you reading this that you may wonder: "where has he been ?").

I've also come to think of Enums as a form of "self-documentation" in Code, as a design-organizing principle ... I am very curious how you react to that idea.

I have, lately, been reading the historical record of various advices on best practices with Enums given my MS over time.

And, I am aware of the argument/concept that creating an app with a large dependency on Enums may result in "future fragility:" an update changes one of the Enums ... adds a new value, makes some Enum value == 0 ... and code-breaks all over the place. I wonder if there's any qualitative difference ... vis a vis an app's future modifications ... between dependency-with-Enums and dependency because of reliance on Interfaces, or Class/Struct OOP design ?

I've recently been experimenting with Enums, doing things using "nested Enums:
C#
[Description("The Play")]          // standard attribue: DescriptionAttribute
[Status("Tests Valid 03/23/2016")] // custom attribute: StatusAttribute
public enum ThePlay
{
   Act1 = 1, Act2 = 2, Act3 = 3
}

[Description("The Murder")]
[Status("Act1 changed 12/02/2015")]
public enum Act1
{
   Scene1Suspects = 1, Scene2TheDetectives = 2
}

[Description("The Suspects")]
[Status("Scene1Suspects added 12/02/2015")]
[Flags]
public enum Scene1Suspects
{
   None = 0x0,
   Butler = 0x2,
   LadyX = 0x4,
   LordX = 0x8,
   Gardener = 0x10  
}
And, I find it easy to parse these (using Reflection) and construct a UI (like a TreeView) at run-time.using the Enums' names, values, and the content of any Attributes; it's easy to detect if the Enum uses 'Flags, relatively easy to make (using a TreeView) a node structure that enforces multiple child node checkboxes to be checked ... and, by the same token, easy enough to create a node structure that allows only one child node CheckBox to be checked

Possible drawbacks to using Enums as more than "simple" design-elements ?

1. no generic constraints of Type 'Enum allowed in generic objects: Jon Skeet has a "work-around" for this (which I haven't tried): [^]

2. more work required to serialize an Enum so it retains "Label" content.

3. Enums are not as "Type safe;" they're just "dumb wrappers" over some block of allocated integral Types.

4. an example of arguments against using Enums is presented in this article which provides code for a Class based alternative: [^].

appreciate your response.

thanks, Bill
«The truth is a snare: you cannot have it, without being caught. You cannot have the truth in such a way that you catch it, but only in such a way that it catches you.» Soren Kierkegaard

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 
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 

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.