Artwork

Content provided by Jeffrey Palermo. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Jeffrey Palermo or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://ro.player.fm/legal.
Player FM - Aplicație Podcast
Treceți offline cu aplicația Player FM !

# Enumerated classes in .NET 6 - Episode 3

21:13
 
Distribuie
 

Manage episode 407163539 series 3558420
Content provided by Jeffrey Palermo. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Jeffrey Palermo or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://ro.player.fm/legal.

In this episode of Programming with Palermo, Jeffrey discusses the options and limitations of working with enumerated lists in .NET.

You can find the sample code on his github at https://github.com/jeffreypalermo/sample-enumerated-classes

Populating drop-down lists and multi-select lists has always been a challenge in interactive software. Some lists can be hard-code because they do not change (male/female, yes/no, day/night). Other lists have to be more dynamic, such as States the company services. Further, some known options in lists are required for business logic while others can be loaded from a database. Here are the general options you have to choose from the characteristics of them.

# Design options Java enums are very different from C# enums. In some way, Java has more built-in support in the language for richer enums, whereas C# leaves more up to the programmer. Regardless, any need can be satisfied with the right design pattern. The programmer must understand the tensions of the software in order to know the appropriate architectural element to introduce.

## Option 1: C# enumerations C# enums (enumerations) are compiled in code and have a value of an Int32 but can be made smaller by using the smaller integer types (short, etc). They have the name available as well as the integer value. Any change requires the software to be redeployed.

## Option 2: Enumerations with attributes With some custom reflection, one can add any number of attributes onto a enum value. This can allow any number of additional pieces of information to be attached. But new values cannot be dynamically loaded from a database or changes without redeploying the software.

## Option 3: Enumerating C# classes Enumerated classes is a design pattern that uses regular C# classes while making the usage syntax appear like a C# enum. No enum is actually used, but the intellisense experience and the syntax is nearly identical. This approach allows for an arbitrary number of additional properties on an enumerated value while also allowing properties to be updated at runtime as well as additional values in the enumerated listing to be added from any type of database.

# Summary Several very feasible options exist for managing drop-down lists and multi-select lists in applications. Each option comes with different capabilities and limitations before a change would require a redeployment of the software.

![Enumeration options](https://github.com/jeffreypalermo/sample-enumerated-classes/raw/master/enumerationoptions.png)

Thanks to Clear Measure for sponsoring this episode of Programming with Palermo.

This program is syndicated on many channels. To send a question or comment to the show, email programming@palermo.network. We’d love to hear from you.

To use the private and confidential Chaplain service, use the following Gentleman: 512-619-6950 Lady: 512-923-8178

  continue reading

35 episoade

Artwork
iconDistribuie
 
Manage episode 407163539 series 3558420
Content provided by Jeffrey Palermo. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Jeffrey Palermo or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://ro.player.fm/legal.

In this episode of Programming with Palermo, Jeffrey discusses the options and limitations of working with enumerated lists in .NET.

You can find the sample code on his github at https://github.com/jeffreypalermo/sample-enumerated-classes

Populating drop-down lists and multi-select lists has always been a challenge in interactive software. Some lists can be hard-code because they do not change (male/female, yes/no, day/night). Other lists have to be more dynamic, such as States the company services. Further, some known options in lists are required for business logic while others can be loaded from a database. Here are the general options you have to choose from the characteristics of them.

# Design options Java enums are very different from C# enums. In some way, Java has more built-in support in the language for richer enums, whereas C# leaves more up to the programmer. Regardless, any need can be satisfied with the right design pattern. The programmer must understand the tensions of the software in order to know the appropriate architectural element to introduce.

## Option 1: C# enumerations C# enums (enumerations) are compiled in code and have a value of an Int32 but can be made smaller by using the smaller integer types (short, etc). They have the name available as well as the integer value. Any change requires the software to be redeployed.

## Option 2: Enumerations with attributes With some custom reflection, one can add any number of attributes onto a enum value. This can allow any number of additional pieces of information to be attached. But new values cannot be dynamically loaded from a database or changes without redeploying the software.

## Option 3: Enumerating C# classes Enumerated classes is a design pattern that uses regular C# classes while making the usage syntax appear like a C# enum. No enum is actually used, but the intellisense experience and the syntax is nearly identical. This approach allows for an arbitrary number of additional properties on an enumerated value while also allowing properties to be updated at runtime as well as additional values in the enumerated listing to be added from any type of database.

# Summary Several very feasible options exist for managing drop-down lists and multi-select lists in applications. Each option comes with different capabilities and limitations before a change would require a redeployment of the software.

![Enumeration options](https://github.com/jeffreypalermo/sample-enumerated-classes/raw/master/enumerationoptions.png)

Thanks to Clear Measure for sponsoring this episode of Programming with Palermo.

This program is syndicated on many channels. To send a question or comment to the show, email programming@palermo.network. We’d love to hear from you.

To use the private and confidential Chaplain service, use the following Gentleman: 512-619-6950 Lady: 512-923-8178

  continue reading

35 episoade

Toate episoadele

×
 
Loading …

Bun venit la Player FM!

Player FM scanează web-ul pentru podcast-uri de înaltă calitate pentru a vă putea bucura acum. Este cea mai bună aplicație pentru podcast și funcționează pe Android, iPhone și pe web. Înscrieți-vă pentru a sincroniza abonamentele pe toate dispozitivele.

 

Ghid rapid de referință