www.webdeveloper.com
Results 1 to 3 of 3

Thread: java script design pattern mediator

Hybrid View

  1. #1
    Join Date
    Feb 2011
    Posts
    90

    java script design pattern mediator

    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."

    what is the meaning of this sentence?

    I

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    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.
    Last edited by rnd me; 11-25-2012 at 03:14 PM.

  3. #3
    Join Date
    Nov 2012
    Posts
    1
    Quote Originally Posted by rnd me View Post
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles