Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7670133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:45:09+00:00 2026-05-31T15:45:09+00:00

Background We have a fairly complex Silverlight client which we are rewriting in HTML/Javascript/CSS,

  • 0

Background

We have a fairly complex Silverlight client which we are rewriting in HTML/Javascript/CSS, built on top of the same web services. Actually we have two Silverlight different clients which we are porting, which share some common functionality.

I read the article on http://addyosmani.com/largescalejavascript/ and am planning to use the proposed architecture, and in particular the mediator pattern.

A 10000 feet overview of the pattern described by Addy:

  • code is divided into small Modules
  • Modules are only aware of a mediator object; Modules cannot communicate directly with other modules
  • the mediator has a simple interface for publishing and subscribing to messages
  • Modules can subscribe to messages (through the mediator API), giving a callback function
  • Modules can publish messages to the mediator, with a parameter object, and the mediator calls the callback method of any modules subscribed to the message, passing the parameter object

One of the main goals here is to achieve loose coupling between modules. So we can reuse the modules in the two clients. And test the modules in isolation. And the mediator should be the only global object we need, which has got to be good.

But although I like the idea, I have the feeling it is overly complicated in some cases, and that some of my team members will not be convinced. Let me explain by example:

Assume we have a helper function which performs a calculation – lets say it formats a string – and assume this function should be available to any module. This function could belong in a ‘tools’ or ‘helper’ module which is then reusable and testable.

To call this function from an arbitrary module I have to post a message, something like formatString with my input string as parameter. And the helper function has subscribed to the formatString message. But before I post the formatString message I first have to subscribe to a message like formatStringResult, with a callback function which can receive the result. And then once I get the result back, I unsubscribe from the formatStringResult message.

Question(s)

  • Should the mediator rather offer this type of helper functionality directly in it’s own interface?
  • Or should I extend the publish interface to allow an optional result parameter, where helper methods can directly write a result?
  • Is the tradeoff of having an extra mediator layer really worth the
    benefit of achieving loose coupling?

I’d really appreciate advice from developers with experience of achieving loose-coupling in ‘complex’ JavaScript applications.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T15:45:10+00:00Added an answer on May 31, 2026 at 3:45 pm

    You actually perfectly described the BarFoos application Framework:

    https://github.com/jAndreas/BarFoos

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

BACKGROUND: I have a GridView based on a fairly complex Adapter class which extends
I have a fairly simple app (just one index.html file and a css file
I'm fairly new to PowerShell, but have a strong C# background. The task I'm
Background: We have two directories of Crystal Reports for both the web side of
Background: Our app is a fairly straight forward MVC web app that calls a
I'm new to WPF and come from a WinForms background and have a fairly
Real quick background : We have a PDFMaker (HTMLDoc) that converts html into a
I am fairly new to c++, I dont really have any background in it.
For my app, I have a fairly complex set of configuration options that user
I come from a fairly strong C background, and have a rather solid foundation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.