# Help with Rules please

**URL:** <https://community.openhab.org/t/help-with-rules-please/33991>\
**Category:** Beginners\
**Tags:** rules, setup, scriptsrules\
**Created:** [September 6, 2017, 10:40pm UTC](https://community.openhab.org/t/help-with-rules-please/33991 "2017-09-06T22:40:08Z")\
**Posts on this page:** 1\
**Showing post:** 16

<div class="post-metadata">

**Author:** ![rlkoshak](https://community.openhab.org/user_avatar/community.openhab.org/rlkoshak/32/75251_2.png) [@rlkoshak](https://community.openhab.org/u/rlkoshak)\
**Post date:** [September 8, 2017, 12:32pm UTC](https://community.openhab.org/t/help-with-rules-please/33991/16 "2017-09-08T12:32:11Z")

</div>

Besides lambdas, there is the [Separation of Behaviors DP](https://community.openhab.org/t/design-pattern-separation-of-behaviors/15886).

But you really only want to use either option if you need to execute the same code from multiple rules.

Finally, you can have as many else if statements as you want. Switch is a good alternative but not as common in the examples.

A normal usage would be something like:

```php
switch(someString){
    case "Foo": {
        // Do stuff when someString == Foo
    }
    case "bar": {
        // Do bar stuff
    }
    default: {
        // Do stuff when no offer other case matches
    }
}

```

You can have as many cases as you want. The Rules DSL, unlike most other languages, let’s you put arbitrary conditionals in the case. So you can have a case like:

```php
case some value == ”Foo" && otherValue.length > 3: {
    // Do stuff
}

```

---

_[View the full topic](https://community.openhab.org/t/help-with-rules-please/33991)._
