You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: specification/README.md
+14-5Lines changed: 14 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -44,11 +44,12 @@ Wikipedia says
44
44
45
45
**Programmatic Example**
46
46
47
-
If we look at our creature pool example from above, we have a set of creatures with certain properties.\
47
+
If we look at our creature pool example from above, we have a set of creatures with certain properties.
48
48
Those properties can be part of a pre-defined, limited set (represented here by the enums Size, Movement and Color); but they can also be continuous values (e.g. the mass of a Creature).
49
49
In this case, it is more appropriate to use what we call "parameterized specification", where the property value can be given as an argument when the Creature is instantiated, allowing for more flexibility.
50
-
A third option is to combine pre-defined and/or parameterized properties using boolean logic, allowing for near-endless selection possibilities (this is called Composite Specification, see below).
50
+
A third option is to combine pre-defined and/or parameterized properties using boolean logic, allowing for near-endless selection possibilities (this is called "composite specification", see below).
51
51
The pros and cons of each approach are detailed in the table at the end of this document.
52
+
52
53
```java
53
54
publicinterfaceCreature {
54
55
StringgetName();
@@ -60,6 +61,7 @@ public interface Creature {
60
61
```
61
62
62
63
And ``Dragon`` implementation looks like this.
64
+
63
65
```java
64
66
publicclassDragonextendsAbstractCreature {
65
67
@@ -70,6 +72,7 @@ public class Dragon extends AbstractCreature {
70
72
```
71
73
72
74
Now that we want to select some subset of them, we use selectors. To select creatures that fly, we should use ``MovementSelector``.
Our third option is to combine multiple selectors together. Performing a search for special creatures (defined as red, flying, and not small) could be done as follows :
124
+
Our third option is to combine multiple selectors together. Performing a search for special creatures (defined as red, flying, and not small) could be done as follows:
@@ -128,6 +135,7 @@ Our third option is to combine multiple selectors together. Performing a search
128
135
129
136
InCompositeSpecification, we will create custom instances of ``AbstractSelector`` by combining other selectors (called "leaves") using the three basic logical operators.
130
137
These are implemented in ``ConjunctionSelector``, ``DisjunctionSelector`` and ``NegationSelector``.
0 commit comments