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

  • Home
  • SEARCH
  • 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 417935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:37:46+00:00 2026-05-12T18:37:46+00:00

I need good examples and best practices on program architecture. I’m trying to build

  • 0

I need good examples and best practices on program architecture.

I’m trying to build a JS UI for an app that works with Google.Maps. In the 1st draft, user should be able to draw geometric shapes on the map in a way similar to G.M. Then the shapes are sent through AJAX and the response is displayed.

Problem is that the code got complicated just with polygons editing.

Inspired by Joel’s “Duct-tape Programmer”, I tried to sketch a straightforward code that makes actions and switches event handlers, to avoid big if-else trees. “New poly” button creates an observer for map.onclick, changes event handlers for other buttons or hides them, and hides itself, etc.

The downside of this approach is that data handling code is mixed with interface. A code that creates a div container to display the data on the new polygon stands next to the code that deals w/ G.M or w/ the shape data. If I want to revise the UI, I’ll need to process the WHOLE app.

I could review it later and move this UI-generating code elsewhere, but then came my lead programmer. He instead insisted on “messaging” approach: a simple event system where objects subscribe to events and fire them. Interface code can be perfectly isolated from data handling and talking to G.M, but now each listener has to double-check if this message is to it.

For example, clicking on a poly on a map must highlight it and start editing. But not if another poly is being drawn. So, some are-you-talking-to-ME?-code is necessary everywhere.

I’ll appreciate good examples of UI architecture approaches.

  • 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-12T18:37:46+00:00Added an answer on May 12, 2026 at 6:37 pm

    The event handling idea suggested to you is a good approach.

    Here’s some more ideas:

    • Make the shape drawing thing a component
    • The shape drawing component sends events to other code, to react to stuff like “editing” or “clicked”
    • This component could also handle the editing part – It sends “clicked” event to controller, controllers tells the component to go into edit mode
    • While in edit mode the component would not send normal “clicked” events until the editing was closed, avoiding your problem of having to check

    In general, it’s a good idea to have a “view” layer which simply deals with displaying the data and sending events about user actions on that data (ie. clicks, etc.) to a “controller” layer, which then decides what to do – for example it could decide to change the view into editing mode.

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

Sidebar

Ask A Question

Stats

  • Questions 307k
  • Answers 307k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer But then I found out that JavaScript cannot read data… May 13, 2026 at 9:25 pm
  • Editorial Team
    Editorial Team added an answer There is a call to native method t2cPingDatabase made and… May 13, 2026 at 9:25 pm
  • Editorial Team
    Editorial Team added an answer The data in the writeable documents folder (including user defaults… May 13, 2026 at 9:25 pm

Related Questions

I need good examples and best practices on program architecture. I'm trying to build
As my experience with .Net really began as working on existing in-house applications for
I'm writing a DSL in Ruby to control an Arduino project I'm working on;
I am designing the application in Flex that connects to some web services to
How can I detect (with regular expressions or heuristics) a web site link in

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.