Skip to main content
Share Your Experience: Take the 2024 Developer Survey

New answers tagged

2 votes

OneOf with multiple steps and early returns

This reads like a better use case of a tryXXXXX() pattern, it would let you break out early on any failures to handle errors better. bool tryBuildSteeringWheel(input, out OneOf<SteeringWheel, Error&...
Ian Jacobs's user avatar
4 votes
Accepted

OneOf with multiple steps and early returns

Anytime I see something like this that goes against long established conventions, I look for these things: Does the new thing make it easier to test the creation of a new Car? Does the new thing ...
Greg Burghardt's user avatar
3 votes
Accepted

Invariant rule in Liskov Substitution Principle

Why this invariant rule? A class invariant is a condition that is guaranteed to be true for the lifetime of an object, i.e. once the object construction is finished, up to the start to its destruction,...
Christophe's user avatar
  • 77.9k
2 votes

Invariant rule in Liskov Substitution Principle

An Invariant is a statement about "property" of a type, in the plain english sense. A precondition refers to the state before a method or function So, ShippingStrategy.FlatRate being greater ...
Ewan's user avatar
  • 76.3k
0 votes

Multiple API calls potentially spawning multiple Websockets - Threading vs Async

Independent of anything else, you should try to find out how to cancel a network call, once it looks like you dont need or cant use the result anymore. Usually the situation is: Your computer takes ...
gnasher729's user avatar
  • 45.7k
0 votes

Is there a better way of using getters and setters on private members of a class?

In some instances, I use "spelled out" getters as I want something special done for the return. I came to this page looking for the syntax and did not see this use case listed so I will ...
Spencer Sullivan's user avatar

Top 50 recent answers are included