Skip to main content
added 274 characters in body
Source Link
cl-r
  • 127
  • 5

Here, briefly in Java :

if may be replaced by the Observable/Observer Pattern, more useful, stable and secure.

A type is defined in enum, each typeName of refer to an Observer, the ordinal() position in enum give the bit of the type [ordinalBitOfType].

A muscle have a set of one or more ordinalBitOfType

The Observable have a HashSet of ordinalBitOfType to request: enumType.ARMS.ordinal() and enumType.TORSO.ordinal()

Then it activates observers. All concerned Observers print "hello" and can update Map or something else in the Observable, others do nothing.

EDIT
In Observable/Observer Pattern only one if by Observer is needed to respond at : is myBit contained in the Observable.Set?

If you create New types, you have to create new Obervers, don't worry about already Observers jobs, they will work fine, just put the new bits in the right muscles.

You can had Observable Pattern in a Observer for nested if.
Take care, you cannot decide the order of the Observers called by the JVM.

EDIT 2 : some rewriting + O'Reilly book

The clearest book about Pattern design I've read : "Head First Design Patterns", encourage to master it.

EDIT 3

I open a second answer because I realize I was blinded by the if/then/else problem, and also because Observable instance passed to an Observer which can modify it, is a good pattern for limited and stable parameters to manage intricated ifs.

Here, briefly in Java :

if may be replaced by the Observable/Observer Pattern, more useful, stable and secure.

A type is defined in enum, each typeName of refer to an Observer, the ordinal() position in enum give the bit of the type [ordinalBitOfType].

A muscle have a set of one or more ordinalBitOfType

The Observable have a HashSet of ordinalBitOfType to request: enumType.ARMS.ordinal() and enumType.TORSO.ordinal()

Then it activates observers. All concerned Observers print "hello" and can update Map or something else in the Observable, others do nothing.

EDIT
In Observable/Observer Pattern only one if by Observer is needed to respond at : is myBit contained in the Observable.Set?

If you create New types, you have to create new Obervers, don't worry about already Observers jobs, they will work fine, just put the new bits in the right muscles.

You can had Observable Pattern in a Observer for nested if.
Take care, you cannot decide the order of the Observers called by the JVM.

EDIT 2 : some rewriting + O'Reilly book

The clearest book about Pattern design I've read : "Head First Design Patterns", encourage to master it.

Here, briefly in Java :

if may be replaced by the Observable/Observer Pattern, more useful, stable and secure.

A type is defined in enum, each typeName of refer to an Observer, the ordinal() position in enum give the bit of the type [ordinalBitOfType].

A muscle have a set of one or more ordinalBitOfType

The Observable have a HashSet of ordinalBitOfType to request: enumType.ARMS.ordinal() and enumType.TORSO.ordinal()

Then it activates observers. All concerned Observers print "hello" and can update Map or something else in the Observable, others do nothing.

EDIT
In Observable/Observer Pattern only one if by Observer is needed to respond at : is myBit contained in the Observable.Set?

If you create New types, you have to create new Obervers, don't worry about already Observers jobs, they will work fine, just put the new bits in the right muscles.

You can had Observable Pattern in a Observer for nested if.
Take care, you cannot decide the order of the Observers called by the JVM.

EDIT 2 : some rewriting + O'Reilly book

The clearest book about Pattern design I've read : "Head First Design Patterns", encourage to master it.

EDIT 3

I open a second answer because I realize I was blinded by the if/then/else problem, and also because Observable instance passed to an Observer which can modify it, is a good pattern for limited and stable parameters to manage intricated ifs.

added 383 characters in body
Source Link
cl-r
  • 127
  • 5

Here, briefly in Java :

Ifif may be replaced by the Observable/Observer Pattern, more useful, stable and secure.

A type is defined in enum, each typeName of refer to an Observer, the ordinal() position in enum give the bit of the type [ordinalBitOfType].

A muscle have a set of one or more ordinalBitOfType

The Observable have a HashSet of ordinalBitOfType to request: enumType.ARMS.ordinal() and enumType.TORSO.ordinal()

Then activateit activates observers. All concerned Observers print "hello" otherand can update Map or something else in the Observable, others do nothing.

EDIT
In Observable/Observer Pattern only one if by Observer is needed to respond at : is myBit contained in the Observable.Set?

If you create New types => new, you have to create new OberversObervers, don't worry about already Observers jobs, they will work fine, just put the rightnew bits in the right muscles.

You can had Observable functionPattern in a Observer for nested if.
Take care, you cannot decide the order of the !Observers called by the JVM.

EDIT 2 : some rewriting + O'Reilly book

The clearest book about Pattern design I've read : "Head First Design Patterns", encourage to master it.

Here, briefly in Java :

If may be replaced by the Observable/Observer Pattern, more useful, stable and secure.

A type is defined in enum, each typeName of refer to an Observer, the ordinal() position give the bit of the type.

A muscle have a set of one or more ordinalBitOfType

The Observable have a HashSet of ordinalBitOfType to request: enumType.ARMS.ordinal() and enumType.TORSO.ordinal()

Then activate observers. All concerned print "hello" other do nothing.

EDIT
In Observable/Observer Pattern only one if by Observer : is myBit contained in the Observable.Set?

New types => new Obervers, don't worry about already Observer they will work fine, just put the right bits in the muscles.

You can had Observable function in a Observer for nested if !

Here, briefly in Java :

if may be replaced by the Observable/Observer Pattern, more useful, stable and secure.

A type is defined in enum, each typeName of refer to an Observer, the ordinal() position in enum give the bit of the type [ordinalBitOfType].

A muscle have a set of one or more ordinalBitOfType

The Observable have a HashSet of ordinalBitOfType to request: enumType.ARMS.ordinal() and enumType.TORSO.ordinal()

Then it activates observers. All concerned Observers print "hello" and can update Map or something else in the Observable, others do nothing.

EDIT
In Observable/Observer Pattern only one if by Observer is needed to respond at : is myBit contained in the Observable.Set?

If you create New types, you have to create new Obervers, don't worry about already Observers jobs, they will work fine, just put the new bits in the right muscles.

You can had Observable Pattern in a Observer for nested if.
Take care, you cannot decide the order of the Observers called by the JVM.

EDIT 2 : some rewriting + O'Reilly book

The clearest book about Pattern design I've read : "Head First Design Patterns", encourage to master it.

added 286 characters in body
Source Link
cl-r
  • 127
  • 5

Here, briefly in Java :

If may be replaced by the Observable/Observer Pattern, more useful, stable and secure.

A type is defined in enum, each typeName of refer to an Observer, the ordinal() position give the bit of the type.

A muscle have a set of one or more ordinalBitOfType

The Observable have a HashSet of ordinalBitOfType to request: enumType.ARMS.ordinal() and enumType.TORSO.ordinal()

Then activate observers. All concerned print "hello" other do nothing.

EDIT
In Observable/Observer Pattern only one if by Observer : is myBit contained in the Observable.Set?

New types => new Obervers, don't worry about already Observer they will work fine, just put the right bits in the muscles.

You can had Observable function in a Observer for nested if !

Here, briefly in Java :

If may be replaced by the Observable/Observer Pattern, more useful, stable and secure.

A type is defined in enum, each typeName of refer to an Observer, the ordinal() position give the bit of the type.

A muscle have a set of one or more ordinalBitOfType

The Observable have a HashSet of ordinalBitOfType to request: enumType.ARMS.ordinal() and enumType.TORSO.ordinal()

Then activate observers. All concerned print "hello" other do nothing.

Here, briefly in Java :

If may be replaced by the Observable/Observer Pattern, more useful, stable and secure.

A type is defined in enum, each typeName of refer to an Observer, the ordinal() position give the bit of the type.

A muscle have a set of one or more ordinalBitOfType

The Observable have a HashSet of ordinalBitOfType to request: enumType.ARMS.ordinal() and enumType.TORSO.ordinal()

Then activate observers. All concerned print "hello" other do nothing.

EDIT
In Observable/Observer Pattern only one if by Observer : is myBit contained in the Observable.Set?

New types => new Obervers, don't worry about already Observer they will work fine, just put the right bits in the muscles.

You can had Observable function in a Observer for nested if !

Source Link
cl-r
  • 127
  • 5
Loading