Category: "Dojo"

PHP 5.1 JSON

If you need the JSON support functions json_encode and json_decode, but your server is not running PHP 5.2+, consider using the Zend framework.

One of the nicest things about the JSON support is that it will use json_encode and json_decode if they are available, if not, it will handle it.

Zend framework can be used as a library, so if all you need is the JSON support, you won’t incur alot of overhead.

The new version of Zend Framework includes dojo!

Comments - Etiquette

Comments are added to code to assist the reader in understanding the code. The following guidelines should be observed:

  • Comments should not be written to editorialize or entertain. Sarcasm should not be in comments. Questions can be placed in comments, where necessary, to ensure issues are identified and resolved.
  • Proper grammar and spelling are required. It reduces the opportunties for misunderstanding.
  • Comments, especially in an interpretive environment such as PHP, should be brief. Utilities that strip comments for distribution can eliminate this requirement.
  • Careful coding, with meaningful function and variable names may reduce the need for comments. Overly complex statements should be avoided.
  • Comments should be considered a visible part of the deliverable product and should be of appropriate quality. If it is a professional product, comments should be professional.
  • Comments must be updated to remain current as the code changes.

RIA server filesystem architecture

The /opt directory can be used to store shared components, as follows:

  • /opt/os - All open source components

  • /opt/common - All common scripts, such as form validation for contact us forms, anti-spam code.

    • /antispam

      • /html - (html and javascript) - to assist the user
      • /php - to protect the server
    • /footer - Footer text, specifically the company name and copyright indicator. This ensures it can be changed in one place to update every page on the server.

New accounts could access these components like so:


ln -s /opt/os/dojo 
ln -s /opt/os/Smarty 
ln -s /opt/os/Zend
ln -s /opt/common/html 
ln -s /opt/common/php
ln -s /opt/common/footer

These links allow relative references to the common resources, while providing central sourcing.

No More Flat Pages

Building a complex application requires creative use of the page space. At a certain point the page is full, and additional content/options/functionality must be integrated with innovative approaches.

  • Dialog or popup boxes are extremely effective for displaying search results. Integrated carefully into the form functions, it allows a user to review the search results without closing the box
  • Tabbed navigation is good for hierarchical content displays
  • Accordian panes are good for compressing a stack of content into a small area, opening them on refresh is helpful for the user

Half JAX

AJAX can be implemented in many different ways.

Options:

  • Place all the interface logic on the client side, and have the server act only as backend functionality. For a complex application, this method may be prohibitively difficult. The overhead of placing all the logic on the client side, and managing its delivery and execution is probably not worth the performance gains.
  • Segmenting the pages and populating them with HTML and related logic from the server. This would be using something similar to dojo content panes, which are HTML content. Similar to iframes.
  • Half JAX. Run the pages as HTML templates, augmented with AJAX navigation/population. Thus, the HTML remains static for the page, but the AJAX is used to fill the fields and provide advance features. With an efficient template engine and a sophisticated architecture, this is an excellent approach.
  • Use straight HTML pages, with a template engine. There is no law that AJAX must be used. :)

Delivering the HTML, with AJAX for form population and rich interface features is a nice compromise. The pages remain fairly fast, the rich features are available, and the complexity is limited. This is best implemented with a good architecture of reusable/common components.