Friday, December 24, 2010

Design Patterns Explained

History

(3000 B.C.) When people first started wearing clothes, they realised that it was not really comfortable. So they tried various designers until one of them (Armani or Versace. I forgot) came up with the idea of using softer fabrics. He decided to call the stuff soft-wear. But due to copyright issues, he had to change the name to software. (Another theory is that people could not figure out which part of the fabric was soft. So they normally said, "Soft? Where?". But question mark was an illegal character, and DOS accepted only 8-letters. So the name 'software' stuck on).

There was fierce competition in the market as more and more 'designs' came out with every fashion week. Soon people realised that they could take whatever was common from other designers' creations, and 'patterns' began to emerge. It was easy to see that this development was seminal for all future work in the field of Software Design Patterns, as we use it till today.

In an effort to create much needed awareness in this field, I have created a condensed list of common patterns in the software world, complete with how to avoid common mistakes, a look at the class diagram, the type of pattern, and a brief description of each pattern. Expert tips and relevant links for further reading have also been included.

Adapter

Not to be confused with - Adopter

Class diagram -

Type - AC-to-DC

Description - In those days, the concept of electricity was not taught very well in school. So there were a lot of voltage fluctuations. In a spark of genius, one of the interns came up with the idea of using an adapter to partially stabilize the current. The designer resisted a lot, but finally gave in. This led to electrifying results. And it shocked nearly everyone in the audience. A great pattern for any occasion.

(See also - Angelina Jolie)

Bridge

Not to be confused with - Fridge

Class diagram -
Type - Suspension

Description - It was one of those times when looming deadlines decided what came into vogue. The designer was already knee-deep in trouble. Having only 4 days to come up with something big, he decided to bridge the gap between modern and contemporary. (At that time, the two were different, duh). As fate would have it, it turned out swimmingly. In fact, he achieved mouth-watering results. A great pattern to have in any designer's toolkit.

(See also - River)

Command

Not to be confused with - Commode

Class diagram -
Type - Hygienic

Description - There was a change in management, and the new boss was unfamiliar with GUI. (In fact, he was quite noob with the command line as well, but still..) In any case, he wanted to obtain a commanding position in the market. So he called his employees and told them to be extra-efficient and also ensured that no one was slacking off. The result -- inch-prefect cuts and immaculate stitches. But as everyone was over-efficient, they displayed the creations 3 days before the actual fashion event. And nobody showed up. So they had to change management again. (Note- this pattern is actually a misnomer. Just telling)

(See also - Control, Alt, Delete)

(Abstract) Factory

Not to be confused with - An actual factory

Class diagram -
Type - Expensive

Description - 'Twas the age of getting artistic with everything. A mini-renaissance was in place, as people began to diversify into those who truly appreciated art, and those who were not fatheads. Obviously, though, the former group took over managerial posts. And tried to explain in vague terms to the designers how the designs should be 'abstractly ephemeral' but not 'amorphously evanescent'. (Whatever that meant). In the mean time, a smart programmer wrote a piece of code that used random numbers to mass-produce weird shapes and print them. The managers were impressed, for apparently, that was exactly what they had in mind. This method has ever since been known as the abstract factory. A must-have if you find yourself being managed by people with an IQ of zero (or less).

(See also - M. F. Hussain)

Flyweight

Not to be confused with - Mosquito-weight

Class diagram -
Type - Insectoid

Description - It was one of those bad days for the fashion industry. A model was walking on the ramp when a fly happened to land on her shoulder. Now mathematically, weight_of_fly >> weight_of_model. (Hope you understand the gravity of the situation) The result? Wardrobe malfunction. Since then, it has been made mandatory to make clothes that can withstand a minimum amount of weight, also known as flyweight. This had the masses protest, but it was a necessary thing to do. A great pattern for the whole family.

(See also - Fly wait)

Observer

Not to be confused with - Webserver

Class diagram -

Type - Class II Evil

Description - When you have competitors in the market, it is imperative to keep a watch on every aspect of the industry. Even a small thing unnoticed can cost the company. Especially spies. The famous spy, Chloro-fluoro-carbon Bond, was hired by a fashion label to spy on the market leader. In 3 days' time, he came back with full details on the next batch of designs. Having spent very little on R&D, the company rolled out the same designs with exquisitely crafted fabric. Thus, managing to wipe out all competition. Since then nearly all companies have started planting 'observers' in their rivals' company. A crucial pattern. Don't stay home without it.

(See also - Observant, Obmaid)

Proxy

Not to be confused with - Frock-C

Class diagram -
Type - Representative

Description - Since most of his time was spent in the studio, it was very difficult for him to maintain attendance in class. So this designer did what any student in his place would do. He asked his friends to 'give proxy'. The perfect blend of smart students and dumb professors ensured that he never had to go to college again. What's more, he could focus solely on fashion design. And produced the best of his work in that period. At present, this is one of those patterns that you just cannot afford to miss out on.

(See also - Prox A, Prox B)

State

Not to be confused with - Union Territory

Class diagram -
Type - Geographic

Description - When faced with the equivalent of a writers' block, one of the designers decided to travel the country in search of inspiration. He travelled many places, trying to imbibe the characteristic qualities of each region. When he got back, he was in a woozy state of mind. In a press statement, he said that he would do something that was never done before. So he categorized all the places he had visited into various states. And made a design on each one of them. Lucky for him, it clicked. Moral of the story? None at all. Still, you just have to have this pattern.

(See also - City, Country)

Template

Not to be confused with - Temspoon

Class diagram -
Type - Culinary

Description - No matter how hard you try, you just always end up arriving a few minutes late. This was the story of an intern who's only problem was just that. But he tried to make up for it by putting in extra effort in everything he did. On the verge of losing his job, he decided to create something that would be so unbelievably good, that he would get instant promotion. Hard-work and diligence paid off. And he got just what he expected -- the Lead Designer's post. Since then, this has been a timeless classic. A pattern that could come in handy in the most untimely moments.

(See also - Temp-ontime, Regular-late)

(Note - If you didn't get the last line for each pattern's description, try to get hold of a copy of Café Coffee Day's gift brochure)

No comments:

Post a Comment