stevedunn/stringlytyped
The StringlyTyped.ValueObjects project aims to cure Primitive Obsession, also known as StringlyTyped software, by providing a simple implementation of a ValueObject. Primitive Obsession is a code smell where developers become overly reliant on primitive data types, such as ints and strings, to represent domain ideas. This can lead to issues with enforcing constraints and ensuring immutability.
The project offers a solution through the use of ValueObjects, which are strongly typed, immutable domain objects. Instead of using primitives like ints, developers can create ValueObjects that represent specific domain concepts, such as CustomerId or SupplierId. These ValueObjects can include validation logic to ensure that the constraints of the domain concept are met, making the code easier to read and more strongly typed.
By using ValueObjects, the signature of methods becomes more strongly typed, preventing callers from accidentally passing the wrong types of parameters. Additionally, the validation logic is in one place, ensuring that invalid objects cannot be introduced into the domain. The project includes a simple implementation of a ValueObject and an example of its use with validation.
Primitive Obsession can lead to issues with enforcing constraints and ensuring immutability, as primitives do not provide built-in support for these features. By using ValueObjects, developers can address these issues and create more robust and maintainable code. For more information on Primitive Obsession, please refer to the blog post at dunnhq.com/posts/2021/primitive-obsession/.
Project Information
- Repository: SteveDunn/StringlyTyped
- Owner: SteveDunn
- Language: C#
- Created at: 2021-07-14
- Last Updated: 2022-02-08
Engagement Metrics
- Stars: 6
- Forks: 0
- Open Issues: 2
- Watchers: 6
- Subscribers: 4
Contribution Opportunities
- Issues are available for contributions.
- Project boards are active.
- Wiki is available for documentation and guides.
License
Apache License 2.0
Topics
Recent Contributors
SteveDunn
14 Contributions