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

Related Questions

Let me begin by saying this; I know that similar questions exist, but they
How does Google find relevant content when it's parsing the web? Let's say, for
Good afternoon - I have a pretty general question today - I've been tasked
I want my JS to load certain information that needs to come from the
I can't imagine that there doesn't exist an efficient, lightweight, secure authentication and authorization
i'm thinking if i really need a service layer. I'm using spring + hibernate
Good Morning, As stupid as my question might sound, i have spent the last
I'm having a difficult time finding how to do true data binding for UITableViews.
I have recently started playing around with iOS development and have got most of
I'm in the process of converting a system from sql server to mongodb. I

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.