Design Patterns

Sunday, September 13, 2009

Hello friends, Next, I'm planning to write a series of posts on Software Engineering Design Patterns. I'll try to keep them as simple as possible with more real world examples. Checkout this space for Software Engineering Design Patterns.

Taegukgi - The Brotherhood of war

Movie: Taegukgi - The Brotherhood of war
Year: 2004
Director: Je-Kyu Kong
Cast: Dong-Kun Gang, Bin Won, Eun-Ju Lee
IMDB rating: 8.1/10.0

Plot:

"You know that I want both of us to go home alive at the end of the war. But if it is going to be only one of us, I want it to be you."

This dialogue from the movie explains the plot very well than I can do in any way. Taegukgi - The Brotherhood of war, is yet another visualization of the war between the South and North Korea, but this time Je-Kyu Kong manages to paint an extravagant emotional drama of two brothers drafted into the war.

Story:
We see many Korean movies still focus on the Korean war because there was never adequate time for the people to process what transpired. A war, in every sense is deadly and Taegukgi, makes this point very well established with its viewers. A strong well knitted story line, sound technicalities, near to perfect portrayal of characters, most of all, the cast and crew who brought out the story alive before our eyes makes this movie a must watch.

Well, Taegukgi is the story of two brothers - an aspiring shoemaker[Jin-Tae] and his younger brother[Jin-Seok], a studios intellectual youth, etched on the backdrop of the deadly war fought by South and North Korea. Jin-Tae lives with his mother, younger brother and his fiance [Young-Shin]. Jin-Tae works hard in a shoe shine stand to help his younger brother with his studies and both of them were aspiring for a good future. They have a struggling life, yet they were a strong happy family. The first few scenes of the movie well establishes the kind of love that's flowing through the family, especially the strong bond between the brothers.

As you would expect, all hell broke loose in the name of the war between South and North Korea making the life of the common people endangered. Everybody flees to the refugee camps in the dreams of safety, whereas the government had other plans for young men. All the young men where drafted into the war, so as Jin-Tae and Jin-Seok.

The war is brutal, Jin-Seok escapes a near to death heart attack after seeing the brutality of the war. Jin-Tae makes it a point to protect his brother and send him back home even if it costs his own life. The army officer of the battalion assures to release Jin-Seok if Jin-Tae gets the medal of honor for his services in the battle field and this sets off the fire in Jin-Tae.

Jin-Tae volunteers himself for every risky mission and manages to pull them off efficiently. I think, on the course of the war he really gets fully involved and likes everything he does. But, still his motive was clear, he has to get the medal of honor and send his younger brother to home. The brutality of Jin-Tae was very new for Jin-Seok and he could not digest it even though deep down he realizes that his elder brother does all these things for him. He can't accept Jin-Tae risking his life for him, and moreover he is very much afraid of totally losing the innocent, lovable Jin-Tae he had known all these years. The brutality of the war takes its toll on Jin-Seok and his relationship with his brother was estranged.

Jin-Tae, finally manages to get the coveted medal of honor and along with that, Jin-Seok's release. But, all in vain. Their battalion reaches the bothers home town, Jin-Seok visits his family and the unexpected slew of events makes you realize that our life is a very thin thread which is very easy to cut off. Jin-Tae and Jin-Seok couldn't save the life of Young-Shin, she gets killed by her own people. Jin-Seok was arrested and sent for interrogation. Jin-Tae was taken to the new battalion officer in-charge. Chinese forces attack the city massively, and the officer orders the soldiers to set fire to the prison. Jin-Tae tries his best to save his brother, but he couldn't and later finds the reminds of his brother's stuffs in the prison. He believes that his brother was dead and kills the battalion officer with a stone. Brutal.

The next scene opens up with Jin-Seok in a medical rehabilitation center, ready to go home in a week. Mean while, the death of Young-Shin and the believed death of Jin-Seok had triggered Jin-Tae against his own nationals and he joins the North Korean army. Jin-Seok gets a letter written by his brother to his mother, he realizes how much his brother meant to him and his family. The next day he was given the news of his brother taking sides with the opposites and at that moment Jin-Seok realizes that Jin-Tae did that thinking his younger brother was dead. Jin-Seok goes back to the battle field to find out his brother and get him back.

After a lot of struggle he manages to see Jin-Tae only to see him totally out of his mind. Jin-Tae couldn't realize Jin-Seok, he fights him off thinking he's a south Korean and when he realizes Jin-Seok, he was already stabbed. He convinces his younger brother to leave him, promises him that he will be back and covers his back when Jin-Seok runs for his life and finally, Jin-Tae was thrown off into pieces by the staggering bullets of the Chinese army.

Jin-Tae: "You know that I want both of us to go home alive at the end of the war. But if it is going to be only one of us, I want it to be you."

Review:
The movie is technically really sound. The director has pulled off the war scenes very well, a near to perfect reality. The blood, bullets, bombs, dead bodies, mutated limbs, heads and what not. He has covered the brutality of both the South and North Koreans, the blood thirsty people and the plight of the commons. Easily one of the best war and combat films I've seen all these while.

Next best thing is the story and the screen play. You start with the movie as a spectator and you never know when you became a part of the story. There are several heart-aching, furious, agitated moments which you really feel inside you on the course of the movie.

Best part is the climax, though, right from the beginning you know that Jin-Tae is going to die, you just wish that he would walk out alive, the victory of the character.

The only nagging thing is the cinematography, the camera is all shaky. May be that's for the best, you don't get to see those gory scenes very clearly.

Verdict:
A must watch, but seriously not for the human beings with a week heart [you might weep during and after the movie].

Being innovative, the secrets.... Continued...

Saturday, September 12, 2009

Rule # 7
Be a doer, not only a thinker.

The last and the best rule. I'll tell you something, just sit back, relax and go down your memory lane for a couple of minutes to see the path you've crossed. Think about everything you wanted to do, and see what you've done actually. We all want to do many a things in our life, but we end up not doing most of them due to various valid unavoidable reasons and there is also a fair share of our own disabilities too. As we move on, we change our priorities, our interests gets changed and we always drift a lot on our way. And that's the beauty of our life, we think as far as we could in the future before making every important decision but still, there's a pinch of uncertainty in all our decisions and it might turn the tables in the real future.

If you want to be successful, you should start doing whatever you want to do rather than just thinking it virtually. There might be a lot many reasons why you can't do something, you might be overloaded in your work, have lot of personal issues to sort out, list will go on and on. I'm telling you, just thinking about something in your imagination will not be useful for yourself or any other for that sake. If you think you have an wonderful idea and you don't spend enough time on realizing it, then your idea will always be an idea. And sooner or later someone else with a better will power from some other part of the earth would realize the same idea, whereas you would be whining about it. Don't let yourself to be a victim.

It all boils down to only one thing, time management and personal discipline to adhere to whatever you plan. Where there is a will, there is a way. If you really wish, you can easily do all the stuffs you want to do and still find a lot of time for your family and friends. Improve your concentration, try to compartmentalize your thoughts, do one thing at a time and do it perfectly. Collect proper information, spend time to analyze and plan correctly, because you can't afford to go wrong. You've got to do it and do it right the first time.

At times it may happen that you might face a wall in your journey, try to break the wall but if you know that you can't break it, don't hesitate to retreat to take some other route altogether. And never be afraid of failure. Even if you fail, try to embrace it with a satisfaction and keep your head high. If somebody tells me that they never failed, I would pity them because they have never tried anything in their life. Success and failure are the end results of the journey. They doesn't matter much, what real ly matters is the journey itself, the experience is worth millions.

Motivate yourself; learn to forgive, not only others; at times, yourself too. Yes, you've to learn to forgive yourself and give credit for what you've done. No body makes miracles. All one can do is to give their best shot at everything they do. Most of the time, hard work really yields its result in one or the other way. Every time you try something, you a feather to your crown which actually you cannot see but the rest of the world can.

I really love Leonardo-da-vinci a lot, the greatest and most efficient brain of the era. But, I respect Michelangelo a lot for the same reason we're discussing now. Leonardo-da-vinci had an excellent brain and he indeed has a whole lot of "I did it first" stuffs in his portfolio now, nearly four centuries later. What's the use? Whereas Michelangelo did manage to do things in his lifetime, rather than just playing them around in his imagination.

So, ladies and gentlemen, take inspiration from Michelangelo but think like Leonardo.

I'm done guys. Hope this will help somebody and please, pass on your comments.

Being innovative, the secrets.... Continued...

Friday, September 11, 2009

Rule # 4
Be imaginative.

The toughest part, being imaginative. I've got a small kids play area in our apartment complex. It is the best place to just sit and watch the forth coming generation of our country. I love kids. Of course, who isn't? I love them like I love a meticulously made tattoo in some one's hand. Both look good as long as they are in others hand. If you happen to be a parent for three kids, no offense mate. Believe me.

Jokes apart. There is this interesting thing about kids. A three years old will be 100 times more imaginative than you at any given time [I'm assuming that three year kids doesn't read a blog]. I can bet you my entire life's earning on that. Just give them a car and a super man toy, in no time they will show you a full length feature film. Oh boy, they are really imaginative. The kind of questions they ask, the stories they tell, excellent.

Oh, I remember, I were a kid once upon a time and I'm no more a kid. Not only that, I'm no more imaginative. Hmmm, well, now-a-days I do imagine, but most of the times its about my girl and a luxurious life. If you're not like me, then this is not for you. Skip this and jump to the next rule.

If you're reading this, I really understand the emotional turmoil you're going through now. Yes, we all were a kid, once upon time. But, we lost our purity and innocence during our journey to become a man or woman.We understand the limitations very well now, we're clear about the boundaries, we think that we know what we can do, and we're all well accustomed to the phrase - "that's not my cup of coffee, dear". OMG, give it a break. Don't curb your imagination straight away by analyzing the feasibility or its application.

If its not feasible to achieve your ideas today, there might be a new way tomorrow. If you cannot apply your idea in any of the known streams today, there is a possibility that you might create a new stream. Be passionate and do not let the child inside to face a slow, painful death.

Rule # 5
Ready to face criticism.

Critics are as important as innovators and criticism is as important as idea generation. Without these critics, it will be really difficult to find the limitations and disadvantages of our own idea. I'm telling you, world needs them, a lot of them. But, only those who do constructive criticism. Constructive criticism will help someone to fine tune his idea and criticism, just for the sake of it is a venom. The world is full of people who think themselves as the savior of the world and will try their best to devastate you by their questions. Be informed and ready to tackle them. Never allow these rodents to destroy your brain child. After all, they try to protect themselves by destroying you.

Don't let them get you, at the same time be open minded to accept constructive criticism and improve your idea.

Rule # 6
Open up yourself for suggestions.

Don't let your knowledge to shut down your access doors with the outside world. Your link with others is a very thin thread and it is very easy to break it. The worst part is, it happens without your knowledge. If somebody gives you some information, analyze it, take the essence of it. Be polite and helpful to the needy. Always try to be accessible for others. Spend time with people, socialize, make friends and get a life for yourself. After all, we get to live only once.

There is only one more rule left and we're gonna see that tomorrow. Thanks.

What should I do to be more Innovative?

Thursday, September 10, 2009

aah... Here we go! Is it so easy to innovate? What if I say, hmmm, well, YES!!! I can hear you say, "I'm gonna kick your a**". Patience buddy, we can talk it out. Let me tell you a secret to be innovative, only those who look for it, shall find it.

As I said in my last post, Innovation needs a mind set - a disciplined and yet chaotic mind. Confused, don't worry. You can be really happy about being confused, because you are at least thinking about something. Thinking gives you your own identity and it helps to improve your personality as a whole.

I think am going off my tangent, let us get back to today's question. What it takes to be innovative? Innovation, as any other brain child doesn't happen overnight. You just cannot force your mind to innovate. All you can do is help your brain by providing more space for it to work and more information.

Did I say information? Better be it. Yes, Information - the first and foremost ingredient to be innovative. Be informed about what's going on around you in your workplace, latest buzz in your work domain, and more than anything, read a lot about technology.

Rule # 1
Feed your brain with lot of good information [good amount of carbohydrates, protein, fiber and low fat]

Read, try to read a lot. Be aggressive in getting information. Because, once when you start feeding your brain with lot of valuable information it has lot more challenging work to do. Think about the fastest of the fastest super computer in the world, multifold its performance by a very high number and now enough of gaping, the performance you imagined is the performance of our brain. Human brain is the fastest in logical thinking, deductions and learning. Your brain will do magic if it has the information when you least expect it.

Rule # 2
Be a smart worker and think about the different means to achieve the result.

As I said earlier, only those who look for it, actually see it. To be innovative, you should develop an eye of an eagle for specifics. Be rigorous in analysis and asking questions. Don't be a labor, be a smart worker. Okay, I hear that too. What's the difference? Occording to me, a labor is someone who works more physically and less mentally. The kind of work doesn't demand more thinking and analysis. If you just work like a labor in an information industry, there are high chances for you getting chucked out. So, buddy start moving around in the given space for you. And especially learn to ask this question, "Why not?".

Rule # 3
Be happy, always.

Be happy about what you do. Happy soul is the haven for a healthy mind. If you are not happy about your work, baby, its time you land somewhere else. Try to develop an identity for yourself, and more than that fight hard to protect it.

It doesn't end here. Let's continue this topic tomorrow as well.

Innovation - How important is it?

Wednesday, September 9, 2009

Innovation, let us first see what my Word Web has to say about this word:

1. A creation (a new device or process) resulting from study and experimentation
2. The creation of something in the mind
3. The act of starting something for the first time; introducing something new

isn't it very straight forward? Innovation literally means creating something new , but beware ladies and gentlemen, it does not stop with an idea in practice.

According to me innovation is more than what it literally means. Innovation is having "a mind set or state of the mind, where we really look out for a positive change, try to look at the problem in a whole new light and conceptualize our imagination to take it to the next level".

The importance of innovation was never appreciated like this before. In this information era, with a global market to capture and slew of competitors to tackle, all the companies understand the importance to innovate to be the market leader. At any point of time, only innovative people succeed in a competitive market by gaining an edge over others. This was like never before, before the invention of World Wide Web, it wasn't easy for companies to get a market share of their own in a foreign place. It was mainly because of the lack of a medium to get access to customers globally and market their products. With World Wide Web, there came a new facet to every business and every business now compete for their market share in the virtual space provided by the World Wide Web.

You need not worry about innovation if you do not care about your market share or your competitors or if you're doing business for charity [You need not innovate, if you think you are a monopoly in your business which I suppose is very rare now-a-days]. If you want to be successful in your business [whatever it may be], gain the market edge over your competitors and gain satisfied customer, you have to understand the importance of innovation and should do your best to get the message clear to all levels of employees in your organization.

Innovation was always considered as a separate stream of work altogether and companies had separate group of people who were designated to innovate. Research and development wing of the companies acted as though they own the copy right for the word innovation. Employees were expected to do their work, importantly, do it as they were taught to do it. Majority of the companies considered most of their employees as labors and they never utilized their employees potential fully.

The information era has bought a lot many transformation across various industries. It has introduced a whole lot of new ways to do things and provided a powerful medium to reach majority of the world population to market their products. Also, it has taken the competition in every sector to a new level and customers are valued the most now than ever. With increased competition and with variety of customers from different geographical locations to satisfy, every global and local company is trying its best to keep its market edge.

Now, the management has realized that good idea can come from any walk of the life. They understand the importance of involving their employees more closely in the growth of the company by giving them more space, freedom of speech, more importantly they are allowed to use their brain whereas the middle management and upper management are trained to take valuable opinions from anyone.

What it means? Those who were considered as labors are now given more responsibility by giving more freedom and ownership. This obviously helps the company to create a all new kind of bond with their employees - the employees feel they belong to the organization rather than just being an employee, or to be more rude, a labor.

The climate of innovation creates a healthy competition among the employees and it actually challenges them in every way. But innovation is like a religion, anybody can speak about it but it takes a lot to follow it and execute it properly.

In my next post we'll talk about what does innovation mean for an individual.

STL - What is an istream_iterator?

Tuesday, September 1, 2009

Class: istream_iterator

Iterators constructed by istream_iterator are input iterators, but they are not output iterators. Means that istream_iterator objects can read data only in a single direction, and data cannot be written through an istream iterator object.

Constructors:
The class istream_iterator provides two public constructors.

1) istream_iterator(istream &) This constructor provided by the istream_iterator type produces an input iterator for values of type T from a given input stream.

2) istream_iterator() This constructor provided by the istream_iterator produces an input iterator that works as an end marker for istream iterators. This is simply a value to which istream iterators become equal when the istream they are scanning reports an end of stream condition.

Lets see an example where we use the istream_iterator to read strings from an input file and load the strings in a vector.

Note: The following code is just a code snippet, not the full program.

...
cout << "Enter the dictionary file name:";
string dictionaryName;
cin >> dictionaryName;

ifstream dfs(dictionaryName.c_str());
if(!dfs.is_open())
{
cout << "Unable to open the given dictionary file name.";
return 1;
}
cout << "Reading the dictionary file...\n";
typedef istream_iterator<string> string_stream;

vector<string> words;

copy(string_stream(dfs),string_stream(), back_inserter(words));
...

The above program takes the name of an input file which contains list of words. If the file is available and opens properly, it reads the words from the input file and creates a vector of strings.

We create an istream iterator for type string and then create an instance of the istream iterator to read the data from the input file stream.

Please try this out. Of course, we have not explained about the copy(...) STL function available in the header file algorithm and also the back_inserter(...). We'll see about them in tomorrow's post.