Lessons Learned – Recipe for Entangling Classes

To share a piece of weird code I saw today – design pattern name should be “I just wanted everybody to have everybody sweetheart”

class A(var b : B, var c : C) {
 b.a = this
 b.c = c
 c.a = this
 c.b = b
}

class B {
 var a : A = null
 var c : C = null
}

class C {
 var a : A = null
 var b : B = null
}

val b = new B
val c = new C
val a = new A(b, c)

Leave a Reply

Your email address will not be published. Required fields are marked *