Sunday, January 14, 2007

My Sister's Indian (Red) Wedding

Yesterday was Mia's second wedding. This one was a Hindu, Fiji-Indian, red wedding and quite different to the first, although it had some similarities in terms of having vows and speeches (and yes, the same husband!). The red wedding included a lot of reading by the Pundit (the Hindu minister) in Sanskrit, many prayers with rice and petals held in hands, and various things put in a mango-wood fire. There were also various prayers with coloured powders, stuff to put on the forehead, water, gee, milk and bananas in front of statuettes. Male members of the bride and groom families wore turbans. Food was all vegetarian, but nice, and alcohol was forbidden. We danced a little at the end of the night. All in all, it was a lot of fun :-)

As the brother of the bride, I had quite a lot to do in terms of prayers and ceremonies. On the Tuesday before, the Pundit visited my place to bless a bundle of clothes and other things for Neeraj (Mia's husband) with water and a banana leaf. We then went to the Neeraj residence where we did a ceremony for about an hour, with all the ingredients mentioned above. Before the wedding, I was also responsible for making some popped rice - similar to popcorn but made from rice in the husk. I needed to give this to Neeraj and Mia several times from a yellow cloth sling the Pundit wrapped around me during the wedding, as the couple walked around the fire 9 times. Also there were various points where I needed to pour water for foot washing and similar.

To give you more of an idea, here's some pictures!

Friday, January 12, 2007

AntiPattern: BusinessObjects in the driving seat

When you have a rich domain model with a business object centric design, and a Windows forms GUI, it can be very tempting to start putting significant process logic in the business objects. After continuing along this path a little further, you may realise that the process needs some sort of user input, and you use events or some sort of notifier pattern to gain user input required by the process, while still maintaining layering in terms of referencing. Then additionally you may need to access some sort of external service.

Here is an example:
class Order : BusinessObject
public void SendOrder(INotifier notifier)
if (ReadyForDelivery ||
Confirm("Are you sure you want to send order lines?"
+ " They are not ready for delivery."))
OrderLine[] orders = GetLinesToSend();
foreach(OrderLine line in Lines)
SendLine(line); // send line using a web service?

Notify("Lines sent successfully.");

interface INotifier
void Notify(string msg);
bool Confirm(string msg);
OrderLine[] GetLinesToSend();
I would like to suggest that this is an anti-pattern and a trap. Although there is no direct reference from the Business Layer to the GUI layer (INotifier is implemented in GUI and passed down), the Business Layer now requires the ability to stay instantiated, pause while waiting for responses from the notifier, and then continue execution. This will work for rich client applications, but not in a stateless web environment. The ideal of being able to swap in/out the GUI layers on top of the Business layer is now compromised.

Instead, it would be possible to drive form the GUI layer, and call a service to send the Order Lines. In pseudo code below:
void SendMenu_Click(...)
if (Order.ReadyForDelivery ||
MessageBox.Show(...) == DialogResult.Yes)
using (ChooseLineForm chooseLineForm =
new ChooseLineForm(Order))
If the logic in the GUI layer became much more complex, it may be a good idea to pull it out into its own class (eg, LineSender). This class would be a type of GUI level controller, responsible for orchestrating the send process.

Using this approach, there are a number of benefits:
  • BusinessObjects have no reliance on GUI implementation, so can be used for Rich Client and Web Client indiscriminately.
  • Web developers are free to implement the user input process in stateless way more appropriate to their platform.
  • Functionality for sending Order lines (some sort of integration with a web service?) is pulled out into a service class which can be reused elsewhere (potentially sending other types of objects?) and unclutters the Order business object and removes its dependency on an external service.
  • Code is simpler and easier to follow.

Thursday, January 11, 2007

In Defense of Simplicity AND Complexity

Simplicity and complexity seem to have become hot topics for some of my favourite technical bloggers of late. These fine people have taken the view that things should be either simple or complex. Right, seems logical, these are opposites. However, I would like to suggest that in a well designed appliance which addresses a complex process, it should have both a simple AND a complex interface.

A couple of years ago, I bought a LG "Fuzzy Logic" washing machine. It has lots of buttons and settings on the front and one big button that says something like "Start". 97% of the time, I throw in my washing, some detergent and press the big start button, and the washing machine works out all the settings, displays them and then starts. In the 3% of the time when I want to do something different (eg, just a rinse), I use the more complex part of the interface to change the 'cycle' settings.

Recently, I bought an IXUS 65. It's a lovely digital camera, and it provides both a complex and a simple interface. As soon as I put in the battery, I was able to take pretty nice pictures by just clicking the big button on the top. No problem, I was very happy. Over the next few days, I glanced through the manual and fiddled with more complex settings for ISO, colour etc. However, in 95% of shots, I simply want to click the one big button that takes a nice auto-everything picture. It's only occasionally that I want to change the settings to achieve a particular effect or to override a mistake in the auto settings.

To conclude, I think that my talented fellow bloggers are all right. People like complex interfaces and simple interfaces, just at different times, for different tasks. The best gadgets and appliances offer both.

Saturday, January 06, 2007

Pandora - Streaming music

I'd like to point my readers to Pandora, a streaming music service which lets you define multiple channels for the different types of music that you like. You start each channel with a seed, which is a song or artist that you like. The service chooses songs similar to this and you then mark them as thumbs up or thumbs down, thus refining the channel more towards your musical taste. It is Flash and browser based, no downloads necessary. Sign up is easy, and the service is free, though add supported. Highly recommended!

How to Win Friends and Influence People

"How to Win Friends and Influence People" by Dale Carnegie is a very interesting and practical book. Of the personal/professional development books that I have read, this one is probably the most valuable.

Carnegie summaries each chapter in one sentence as a "principle". Here they are:
  • Don't criticise, condemn or complain.
  • Give honest and sincere appreciation.
  • Arouse in the other person an eager want.
  • Become genuinely interested in other people.
  • Smile.
  • Remember that a person's name is to that person the sweetest and most important sound in any language.
  • Be a good listener. Encourage others to talk about themselves.
  • Talk in terms of the other person's interests.
  • Make the other person feel important - and do it sincerely.
  • The only way to get the best of an argument is to avoid it.
  • Show respect for the other person's opinions. Never say, "You're wrong.".
  • If you are wrong, admit it quickly and emphatically.
  • Begin in a friendly way.
  • Get the other person saying "yes, yes" immediately.
  • Let the other person do a great deal of the talking.
  • Let the other person feel that the idea is his or hers.
  • Try honestly to see things from the other person's point of view.
  • Be sympathetic with the other person's ideas and desires.
  • Appeal to the nobler motives.
  • Dramatise your ideas.
  • Throw down a challenge.
  • Begin with praise and honest appreciation.
  • Call attention to people's mistakes indirectly.
  • Talk about your own mistakes before criticising the other person.
  • Ask questions instead of giving direct orders.
  • Let the other person save face.
  • Praise the slightest improvement and praise every improvement. Be "hearty in your approbation and lavish in your praise."
  • Give the other person a fine reputation to live up to.
  • Use encouragement. Make the fault seem easy to correct.
  • Make the other person happy about doing the thing you suggest.
Although these points give a bit of an idea what Cargnegie is advocating, I'd highly recommend reading the book. Each chapter is filled with stories - they are the valuable part as they provide examples of speeches, letters and conversations.

People have criticised the book as coldly manipulative. From reading the table of contents and the title of the book, I would be inclined to agree. Personally, from the content of chapters themselves, I find that a different story emerges. My reading is that Carnegie suggests that most people are fundamentally nice, and if they enjoy your company and you make them feel good they will reciprocate by looking out for your interests. Similarly, people will feel guilty if they are in the wrong, and will resolve their mistakes, as long as they are not angry from hurt pride or similar. Carnegie paints people as highly emotional beings, driven by pride and ego, but with huge untapped potential and happy to help others.

If I had to choose the 3 most important points from the book, I'd say:
  • People desire a sense of importance. Anyone will be pleased to have their opinion sought, talk about something of interest to them or have their achievements recognised and praised.
  • Use a light and indirect touch when trying to change people. Rather than criticising directly, explain a how you made a similar mistake in the past and the consequences, or give the person a good reputation to live up to.
  • When you make a mistake, don't hide it or argue. Instead, admit it straight out and blame yourself in the strongest terms.
I borrowed the book from the library, but am planning to buy my very own copy. It is worth having on the bookshelf and re-reading.