私は方向(前方/後方)の概念が非常に重要なアプリケーションに取り組んでいます。
問題は、コードベース全体に広がるいくつかの異なる規則があることです。ある場所ではそれがtrue / falseであり、他の場所では+ 1/-1です。
これをまとめるために、私は次のものを作成しました。
public class DirectionClass
{
public bool Forwards { get; set; }
public double Sign { get; set; }
public EDirection { get; set; }
//plus associated constructor overloads, implementing IEquatable, etc.
}
私は今、暗黙の変換が良いアイデアなのか悪いアイデアなのか疑問に思っています。
public static implicit operator DirectionClass(double sign);
public static implicit operator DirectionClass(bool forwards); //etc..
そして、私が奨励する可能性が高い古典的な落とし穴があるかどうか。