JavaScript Design Patterns

Where can I learn about JavaScript design patterns?

Here is a really good book by Addy Osmani title, “Learning JavaScript Design Patterns”.

Here’s a snapshot of the table of contents . . . good stuff . . .

What is a Pattern?
“Pattern”-ity Testing, Proto-Patterns & The Rule Of Three
The Structure Of A Design Pattern
Writing Design Patterns
Categories Of Design Pattern
Summary Table Of Design Pattern Categorization
JavaScript Design Patterns
  Constructor Pattern
  Module Pattern
  Revealing Module Pattern
  Singleton Pattern
  Observer Pattern
  Mediator Pattern
  Prototype Pattern
  Command Pattern
  Facade Pattern
  Factory Pattern
  Mixin Pattern
  Decorator Pattern
  Flyweight Pattern
JavaScript MV* Patterns
  MVC Pattern
  MVP Pattern
  MVVM Pattern
Modern Modular JavaScript Design Patterns
  ES Harmony
Design Patterns In jQuery
  Composite Pattern
  Adapter Pattern
  Facade Pattern
  Observer Pattern
  Iterator Pattern
  Lazy Initialization Pattern
  Proxy Pattern
  Builder Pattern
jQuery Plugin Design Patterns
JavaScript Namespacing Patterns

Force IE8 to IE7 Compatibility Mode

Is there a way that I can force IE8 users to enter IE7 compatibility mode when they hit my website so that I don’t have to change my working IE7 site?

Yes. There is. Details are on this Microsoft blog.

Essentially, there are two ways to implement this:

  • On a per-site basis, add a custom HTTP header

X-UA-Compatible: IE=EmulateIE7

  • On a per-page basis, add a special HTML tag to each document, right after the <head> tag

<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

I hope that works for you.  I understand from some that even with this setting, you might have to tweak a few things.


Free CSS Based Web Site Templates

Where can I get some free web site templates for my new web site?

A friend of mine was putting together a new web site for an idea that he’s tossing around. He IMd me to take a look at it. I was very impressed. It looked very sharp.

Knowing that he’s not a graphics or GUI guru, I was going to ask him who helped him on the design. Before I could ask, I noticed at the bottom of the page a reference to I clicked on the link and found a Mecca of great web site designs–all for free.

Check them out the next time you want to throw up a nice looking web site in a hurry.

Rounded Corners on Web Pages

How do I create rounded corners on web page blocks?

I found a nice tutorial with images and everything for creating really nice looking rounded corners on web pages. I was able to quickly round off my tables with this tool.

One problem that you’ll really want to solve is the color. Using your favorite graphics tool, you can first find the hue and saturation of the color that you want. Then, pull up each of the corner images and change the hue and saturation. This will allow you to match the colors.

You’ll probably have to create several sets of the rounded corners for each of the colors.

Application Service Provider Architecture Models

How do you architect an ASP web site?

I was recently asked by a new acquaintance how I might create an application service provider (ASP) oriented architecture for a new product his company is creating. They must be able to customize the application per customer while still maintaining a core, code-base. The system they are trying to create is actually pretty complex even as a single site.

In my experience, the solution to a complex system is extremely difficult to arrive at on the very first try. This point is discussed a bit in the fantastic book, "Wicked Problems, Righteous Solutions" (more about wicked problems). I suggested to him that—instead of trying to create the perfect application on the first attempt—he should aim towards perfection and temper his feature choices to only those specifically requested and prioritized by his alpha customers and then iterate.

This allows you time to learn more about the problem. It allows you time to learn the industry, the customers and the patterns of the application. As you learn, you can innovate and move the application further along. You can work with your customer to learn what works and what doesn’t work. As we discussed solutions, I pointed out that Windows Vista could never have been imagined when Windows 1.0 came out—it had to evolve.

What Does the Customer Want?
It is import in product development—especially early on when resources are limited—to make sure that you are creating only what customers are asking for. This seems obvious but is often over misunderstood. Marketing and Business Development can easily muddy the line between what the customer wants and what they believe will make the product “strategic”. If you’re not careful, you’ll find yourself working on elaborate, whiz-bang features that no one has asked for and that may never be used. Also, watch out for the Business Analyst or Subject Matter Expert that “knows what’s best for the customer” and orders up features that only they find useful.

Make absolutely certain that if the customer hasn’t asked for a feature, you have a darn good reason for implementing it. Sometimes, on smaller projects, you can get away with this and hide the costs for your gold bricking. I wouldn’t recommend it though. The guessing is just not worth it when you can simply ask the customer.

Partitioning Databases
“Do we have one big database for everyone that is hosted or a database for each customer?” he asked. "The answer depends upon the nature of the application and the data," I told him.

Consider my application Diggermajig. This site allows you to upload Accelerated Reader Exams for schools, display lists of book information, and create personal user accounts for monitoring progress and wish lists. I have one database for all of this because of how the information is all related. I use relationship tables between users and organizations and books to keep things separate. I don’t need to have a separate database for each "customer".

However, Fog Creek’s FogBugz software is a little different. If you create one of their risk free offer sites, you’ll get your very own personal database for storing your bugs, code sets and other information. Nothing you do to your database will impact anyone else’s in any way. This is required because of the nature of what is being stored in the database.

There’s also the hybrid—a combination of the two. One database for the static, application-wide data and a separate database for each of the customer’s data. We took this approach with Loan Complete. We had a single hybrid database for pricing information and a database per customer for company specific information like loans, code sets, users and status information.

When choosing an approach, keep in mind upgrading and maintenance costs. I’ll leave it to you to explore the pros and cons of each approach.

Partitioning Web Sites
You have the same considerations as the databases when customizing the look-and-feel of the site. This web site——allows you to customize the look and feel of the site. The content is custom as well but you are still only hitting one site. Contrast this with–a hybrid approach.

If you are getting into the ASP world with a new product, try to learn from what you can gather about what other people are doing with similar structures. Don’t be afraid of making mistakes. Be prepared to move fast and don’t look back. Creating an ASP site can be a lot of fun and a fantastic learning experience.