## Further considerations for adding more complex modules
### properties
If the module uses **properties**, one should add a default value in the Nub's constructor for each property (see "Properties" above). The Nub should then register itself as **observer** of properties values changes. Example from `Trigo`:
Note that value should be set after registering the observer, so that the changes observation mechanism is properly triggered.
The changes observation mechanism should be added by implementing `Observer` interface, and creating an `update()` method as in the following example:
```TypeScript
public update(sender: any, data: any) {
if (data.action === "propertyChange" && data.name === "trigoOperation") {
// do something
}
}
```
If the acceptable values for a property are picked from an **enum**, then to properly serialize it one has to add a `case` in `invertEnumKeysAndValuesInProperties()` method of `session.ts`:
```TypeScript
case "trigoOperation":
res[k] = TrigoOperation[res[k]];
break;
```
Finally, for all the property values to be properly tested by fuzzy unit tests, one has to add a `case` in `CreateTestNub()` method, as well as a new method, in `spec/fuzzing.spec.ts`:
```TypeScript
function CreateTestNub(iCalType: number): Nub {
…
if (iCalType === CalculatorType.Trigo) {
setRandomTrigoOperation(n as Trigo);
}
…
}
function setRandomTrigoOperation(sn: Trigo) {
const op = Math.floor(Math.random() * 6); // enum has 6 values
sn.properties.setPropValue("trigoOperation", op);
}
```
### Nubs with children
If a module has children, the `childrenType` attribute should be set in the Nub's constructor. This attribute is used for translation in GUIs, notably ngHyd. Example from `MacroRugoCompound`:
When implementing parent's `Equation()` method, children should be calculated using `Calc()` and not `Equation()` or `Solve()`, so that their logs and results are properly attached to them.
```TypeScript
public Equation(sVarCalc: string): Result {
…
for (const child of this.children) {
child.Calc(sVarCalc);
…
}
```
## How to set up a new hydraulic structure equation