mardi 5 novembre 2019

Is there a name for an antipattern where only certain permutations of property values equal a valid object?

I don't know how to describe it in words alone.

It's like suppose we have a hierarchy like

  • IFoo
    • Foo1
    • Foo2
  • IBar
    • Bar1
    • Bar2
    • Bar3

and an object like

public class Baz
{
   public IFoo Foo { get; set; }
   public IBar Bar { get; set; }
}

and business rule like

=================================
Foo type | Bar type | Valid Baz?
=================================
| Foo 1  |  Bar 1   |  false   |
---------------------------------
| Foo 1  |  Bar 2   |  false   | 
---------------------------------
| Foo 1  |  Bar 3   |  true    |     
---------------------------------
| Foo 2  |  Bar 1   |  true    | 
---------------------------------
| Foo 2  |  Bar 2   |  true    | 
---------------------------------
| Foo 2  |  Bar 3   |  false   | 

(Or is this even an anti-pattern?)

Aucun commentaire:

Enregistrer un commentaire