私のデータベースには次のようなテーブルがあります:
conditionID, conditionType, conditionValue
ConditionType
is an enumeration with values like Integer, String, DateTime, etc.
ConditionValueは文字列として格納されます。
今度は、この行をクラスにカプセル化して、ConditionValueで比較を実行できるようにします。これはEqualTo、GreaterThan、LessThanなどです
現時点では、( otherValue
は私が比較している値です)のようなメソッドがあるので、私のデザインは正しくありません:
GreaterThan(string value, string otherValue);
GreaterThan(int value, int otherValue);
GreaterThan(DateTime value, DateTime otherValue);
私は何とかこの情報をカプセル化して、私ができるようなConditionValueクラスを作ることができます:
GreaterThan(IConditionValue condition, IConditionValue otherValue)