Hints and tips

Here are a couple of brief tips to keep in mind about some of the patterns we've seen in this chapter:

  • When implementing the interpreter pattern you may be tempted to use JavaScript proper as your DSL and then use the eval function to execute the code. This is actually a very dangerous idea as eval opens up an entire world of security issues. It is generally considered to be very bad form to use eval in JavaScript.
  • If you find yourself in the position to audit the changes to data in your project, then the memento pattern can easily be modified to suit. Instead of keeping track of just the state changes, you can also track when the change was made and who changed it. Saving these mementos to disk somewhere allows you to go back and rapidly build an audit log pointing to precisely what happened to change the object.
  • The observer pattern is notorious for causing memory leaks when listeners aren't properly unregistered. This can happen even in a memory managed environment such as JavaScript. Be wary of failing to unhook observers.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset