You've gone to lengths to model your domain with the correct behaviours, the common language and the business constraints.
For example, for a music venue, here'd be a simple model.
class Show {| // Stolen from awesome dev cboakes | |
| @mixin breakpoint($min-width: null, $min-height: null, $medium: screen) { | |
| @if ($min-width != null and $min-height != null) { | |
| @media #{$medium} and (min-width: $min-width) and (min-height: $min-height) { | |
| @content; | |
| } | |
| } @else if ($min-width != null and $min-height == null) { | |
| @media #{$medium} and (min-width: $min-width){ | |
| @content; |
| /* Sometimes it's pretty easy to run ito troubles with React ES6 components. | |
| Consider the following code: */ | |
| class EventStub extends Component { | |
| componentDidMount() { | |
| window.addEventListener('resize', this.onResize.bind(this)); //notice .bind | |
| } | |
| componentWillUnmount() { | |
| window.removeEventListener('resize', this.onResize.bind(this)); |
| /** | |
| * JavaScript Get URL Parameter | |
| * | |
| * @param String prop The specific URL parameter you want to retreive the value for | |
| * @return String|Object If prop is provided a string value is returned, otherwise an object of all properties is returned | |
| */ | |
| function getParam(str, prop) { | |
| let params = {}; | |
| let search = decodeURIComponent(str); | |
| let definitions = search.split( '&' ); |
| // Replace letters | |
| @function str-replace($string, $search, $replace: '') { | |
| $index: str-index($string, $search); | |
| @if $index { | |
| @return str-slice($string, 1, $index - 1) + $replace + str-replace(str-slice($string, $index + str-length($search)), $search, $replace); | |
| } | |
| @return $string; | |
| } |
| class PreFlightService { | |
| goToGate(flight) { | |
| if (flight instanceof Flight !== true) throw new Error('Must be a flight') | |
| if (flight.atGate) throw new Error('Flight is already at the gate'); | |
| return new Flight(Object.assign({}, flight, { | |
| atGate: true | |
| })); | |
| } | |
| refuel(flight) { | |
| if (flight instanceof Flight !== true) throw new Error('Must be a flight') |
| <?php | |
| class CollectionMonad extends Monad { | |
| public function __construct(array $value) { | |
| $this->value = $value; | |
| } | |
| public function bind($callback) { | |
| $newValues = array(); | |
| foreach ($this->value as $value) { | |
| $newValues[] = $this->callCallback($callback, $value); |
| <?php | |
| namespace Voting\Infrastructure; | |
| use Firebase\JWT\JWT; | |
| use DomainException; | |
| use SignatureInvalidException; | |
| use UnexpectedValueException; | |
| use Exception; | |
| use Date; |
| console.clear() | |
| let state = { | |
| todos: [] | |
| } | |
| let box = data => ({ | |
| map: fun => box(fun(data)), | |
| fold: fun => fun(data), | |
| val: data |
| console.clear(); | |
| type model = { | |
| input: { | |
| type: 'text', | |
| class: 'someclass' | |
| }, | |
| output: '' | |
| } |