{ C# }

  • Not Pattern - an Algebraic Data Types alternative invented by me

    | /

    Chinese Version

    TL;DR: Summary

    Algebraic Data Type (abbreviated ADT, sometimes called Discriminated Union, Tagged Union, enum in Rust) is a language feature which can be used to express that a data has multiple cases and each case has different content. Compared with inheritance or interface implementation, sometimes the cases and structure of a data are stable, but the operation of this data (especially the operation of different processing according to the case) is uncertain and extensible. Algebraic data types are suitable for this situation. Currently, many languages do not support this language feature. This article will introduce a pattern of my own design to express this kind of data, finding a balance between ease of use and less error-prone.