Hi I am reading a book (Learning JavaScript Design Patterns Addy Osmani)about design pattern and their implantation in Java script, in the chapter of the mediator pattern, there is the following sentence:
" It places the responsibility for maintaining a constraint squarely in the mediator."
it means that you can more-or-less hijack an existing API, add your own validation to the values accepted by some/all of the API calls, and seamlessly return acceptable values from the original API via the new facade.
this would be in contrast to re-coding the orig API to check constraints inline. if somethings already there are working but not ideal, this is one way to modify it without having to "re-invent the wheel".
that said, i've flipped through that book and i personally think, broadly speaking, that a lot of the patterns are more suited to c# or java than javascript. the specific code used to implement some of these patterns is terrible javascript, causing needles closures that waste ram and prevent garbage collection, while others are just much slower than using shared prototype methods would have been.
im not saying "don't learn the patterns", but don't worry as much about coloring inside the lines as writing a fast and maintainable application.
it means that you can more-or-less hijack an existing API, add your own validation to the values accepted by some/all of the API calls, and seamlessly return acceptable values from the original API via the new facade.
this would be in contrast to re-coding the orig API to check constraints inline. if somethings already there are working but not ideal, this is one way to modify it without having to "re-invent the wheel".
that said, i've flipped through that book and i personally think, broadly speaking, that a lot of the patterns are more suited to c# or java than javascript. the specific code used to implement some of these patterns is terrible javascript, causing needles closures that waste ram and prevent garbage collection, while others are just much slower than using shared prototype methods would have been.
im not saying "don't learn the patterns", but don't worry as much about coloring inside the lines as writing a fast and maintainable application.
Agree!!!You can find a Java book which describes this part in detail to read.
Bookmarks