Thursday, May 06, 2010

the next try will be the right one

“No matter how big and tough a problem may be, get rid of confusion by taking one little step towards solution. Do something. Then try again. At the worst, so long as you don’t do it the same way twice, you will eventually use up all the wrong ways of doing it and thus the next try will be the right one.”

- George F. Nordenhold through Julie911

Tuesday, May 04, 2010

Migrating JSF 1 composition components to JSF 2

In JSF 1, composition components are defined using <ui:composition>. The “template” attribute of ui:composition is optional. Meaning the composition component can opt to confirm to a template or not. So these components could be classified into those that confirmed to a template and those that did not.

 

Type 1: Composition components that confirm to a template:

A composition component confirms to a template by specifying the template name in the template attribute (e.g: ui:composition template=”section.xtml”).  Then it overrides certain aspects of the template. In the example 1 below, section.xhtml, which is the template, defines “contents” (at 1). The composition component defined in Student.xhtml specifies section.xhtml as its template at 2. Section.xhtml further defines-its-own or overrides “contents” at 3. Had there been no 3, 4 would get rendered.

 

Example 1

 

Section.xhtml

<ui:composition>

  <div…> …

  <ui:insert name=”contents”> 1

    This is the default text for “contents”. This text will be rendered when a component does not override this ui:insert with a ui:define name=”contents” 4

  </ui:insert>

</ui:composition>

 

Student.xhtml

<ui:composition template=”section.xhtml”> 2

  <ui:define name=”contents”> 3

    <h:outputText…..> <!—contents of the student section à

  </ui:define>

</ui:composition>

 

Type 2: Composition components that *do not* confirm to a template:

A composition component can be stand alone too. In this case the ui:composition tag will reference no template.

outputField.xhtml

<ui:composition >

  <h:outputText

    Value=”#{fieldLabel}”/>

  <h:inputText

    Value=”#{field.property}”/>

</ui:composition >

 

Company.xhtml

<ui:composition …>

  <a:outputField

    fieldLabel=”Company Name”

    field=”#{company}”

    property=”name”/>

</ui:”composition>

 

Migrating to JSF 2:

Type 2 components above are good candidates to become composite components in JSF 2 (as composite components, like type 2 composition components, are stand-alone and confirm to no templates).

JSF Composition Components vs. Composite components

 

Composition Components

Composite components

1

Composition components can use a template

e.g.

view.xhtml

<a:location …/>

location.xhtml

<ui:composition template=”section.xhtml”>

  <ui:define name=”contents”>

    <h:outputText …/>

  </ui:define>

</ui:composition>

Composite components cannot. The need to be decorated to confirm to a template.

e.g.

view.xhtml

<ui:decorate template=”section.xhtml”>

  <ui:define name=”contents”>

    <a:location…>

  </ui:define>

</ui:decorate>

Location.xhtml

<composite:interface>

  <composite:attribute …/>

</composite:interface>

<composite:implementation>

   …

</composite:implementation>

2

Composition components have no constructs to define action listeners and such

Composite components are more closer to a full blown custom component and can hence define action listeners

3

JSF 1 only

JSF 2 only

 

Monday, May 03, 2010

Separating what keeps changing from what does not

In an application, the UI keeps changing a lot more frequently than the underlying APIs. Designing bearing this in mind would help achieve a better design.

Effective seperation of concerns

To achieve a effective separation of concerns, the coupling among the separated concerns must be minimal. This way, the implementation of each of the separated concerns have a opportunity to have minimal coupling.

Saturday, May 01, 2010

Be thankful that the road is long and challenging, because that is where you’ll find the best that life has to offer.

Just because the road ahead is long, is no reason to slow down. Just because there is much work to be done, is no reason to get discouraged. It is a reason to get started, to grow, to find new ways, to reach within yourself and discover strength, commitment, determination, discipline.

The road ahead is long and difficult, and filled with opportunity at every turn. Start what needs starting. Finish what needs finishing. Get on the road. Stay on the road. Get on with the work.

Right now you’re at the beginning of the journey. What a great place to be! Just imagine all the things you’ll learn, all the people you’ll meet, all the experiences you’ll have. Be thankful that the road is long and challenging, because that is where you’ll find the best that life has to offer.



- Ralph Marston through Julie911

Dare

“Dare to look foolish; the real fools are those who never attempt anything. Dare to make mistakes; they are the best teachers you will ever know. Dare to take action; there’s a risk you may fail, yet if you take no action failure is a certainty. Dare to be fully alive. Dare to speak your mind. Dare to enjoy the beauty of the world. Dare to make a difference. Dare to love. Dare to be the person you know you can be. Dare to expect the best; you’ll usually get it. Dare to do what is right rather than what is convenient or expedient. It will truly make a difference in the way you see yourself, and the way others see you. You’re here, with this magnificent day available to you. Dare to make it the best you can.”

- Author Unknown through Julie911

Monday, April 19, 2010

Evil is a little man afraid for his job.

“Evil is a little man afraid for his job.”

 

-          Roy Scheider

Tuesday, April 13, 2010

difficult to concentrate.. overwhelmed with feelings of remorse, regret

Data: "I am finding it difficult to concentrate. I believe I am overwhelmed with feelings of remorse, regret regarding my actions on the observatory (after being installed with the emotion chip Data failed to help his friend who was therefore kidnapped)." Data says he cannot continue to work and opts to be de-activated until his emotion chip is removed.
Captain: "Part of having feelings is learning to integrate them into your life data. Learning to live with them no matter what the circumstances....Sometimes it takes courage to try Data, courage can be a emotion too."
- Star Trek VII: Generations

Like this: http://e.ggtimer.com

http://e.ggtimer.com/1%20minute

Saturday, April 10, 2010

One day at a time

“One day at a time — this is enough. Do not look back and grieve over the past for it is gone; and do not be troubled about the future, for it has not yet come. Live in the present and make it so beautiful it will be worth remembering.”

- Ida Scott Taylor through Julie911

Thursday, March 25, 2010

Café Gratitude - a different, nice way to introduce oneself

Café Gratitude is our expression of a world of plenty. Our food and people are a celebration of our aliveness. We select the finest organic ingredients to honor the earth and ourselves, as we are one and the same. We support local farmers, sustainable agriculture and environmentally friendly products. Our food is prepared with love. We invite you to step inside and enjoy being someone that chooses: loving your life, adoring yourself, accepting the world, being generous and grateful every day, and experiencing being provided for. Have fun and enjoy being nourished. Welcome to Café Gratitude!

Saturday, March 20, 2010

Uncomplicated happiness

"Before the claustrophobia (fear of having no escape and being closed in) of winter closed in, Korphe's people lived as much possible outdoors. Most families took their two daily meals on their roof. And washing down a bowl of dal and rice with strong tamburok tea, after a satisfying day's work, Mortenson loved basking in the last of the sunlight with Haji Ali's family and chatting across the rooftops to the dozens of families doing the same.
Norberg-Hodge admiringly quotes the kind of another Himalayan country, Bhutan, who says the true measure of a nation's success is not gross national product, but "gross national happiness". On their warm, dry roofs, among the fruits of their successful harvest, eating, smoking and gossiping with the same sense of leisure as Parisians on the terrace of a sidewalk cafe, Mortenson felt sure that , despite all that they lacked, the Balti still held the key to a kind of uncomplicated happiness that was disappearing in the developing world as fast as old-growth forests. "

- Three Cups of tea by Greg Mortenson & David Oliver Relin in chapter titled "Building Bridges"

Tuesday, March 16, 2010

Fear, Excitement and determination

When you look at a players eye, you see Fear, Excitement or determination. One should have determination.

- An IPL couch

10 things science says will make you happy

From YES! Magazine through Julie911

1. Savor Everyday Moments

Pause now and then to smell a rose or watch children at play. Study participants who took time to “savor” ordinary events that they normally hurried through, or to think back on pleasant moments from their day, “showed significant increases in happiness and reductions in depression,” says psychologist Sonja Lyubomirsky.

2. Avoid Comparisons

While keeping up with the Joneses is part of American culture, comparing ourselves with others can be damaging to happiness and self-esteem. Instead of comparing ourselves to others, focusing on our own personal achievement leads to greater satisfaction, according to Lyubomirsky.

3. Put Money Low on the List

People who put money high on their priority list are more at risk for depression, anxiety, and low self-esteem, according to researchers Tim Kasser and Richard Ryan. Their findings hold true across nations and cultures. “The more we seek satisfactions in material goods, the less we find them there,” Ryan says. “The satisfaction has a short half-life—it’s very fleeting.” Money-seekers also score lower on tests of vitality and self-actualization.

4. Have Meaningful Goals

“People who strive for something significant, whether it’s learning a new craft or raising moral children, are far happier than those who don’t have strong dreams or aspirations,” say Ed Diener and Robert Biswas-Diener. “As humans, we actually require a sense of meaning to thrive.” Harvard’s resident happiness professor, Tal Ben-Shahar, agrees, “Happiness lies at the intersection between pleasure and meaning. Whether at work or at home, the goal is to engage in activities that are both personally significant and enjoyable.”

5. Take Initiative at Work

How happy you are at work depends in part on how much initiative you take. Researcher Amy Wrzesniewski says that when we express creativity, help others, suggest improvements, or do additional tasks on the job, we make our work more rewarding and feel more in control.

6. Make Friends, Treasure Family

Happier people tend to have good families, friends, and supportive relationships, say Diener and Biswas-Diener. But it’s not enough to be the life of the party if you’re surrounded by shallow acquaintances. “We don’t just need relationships, we need close ones” that involve understanding and caring.

7. Smile Even When You Don’t Feel Like It

It sounds simple, but it works. “Happy people…see possibilities, opportunities, and success. When they think of the future, they are optimistic, and when they review the past, they tend to savor the high points,” say Diener and Biswas-Diener. Even if you weren’t born looking at the glass as half-full, with practice, a positive outlook can become a habit.

8. Say Thank You Like You Mean It

People who keep gratitude journals on a weekly basis are healthier, more optimistic, and more likely to make progress toward achieving personal goals, according to author Robert Emmons. Research by Martin Seligman, founder of positive psychology, revealed that people who write “gratitude letters” to someone who made a difference in their lives score higher on happiness, and lower on depression—and the effect lasts for weeks.

9. Get Out and Exercise

A Duke University study shows that exercise may be just as effective as drugs in treating depression, without all the side effects and expense. Other research shows that in addition to health benefits, regular exercise offers a sense of accomplishment and opportunity for social interaction, releases feel-good endorphins, and boosts self-esteem.

10. Give It Away, Give It Away Now!

Make altruism and giving part of your life, and be purposeful about it. Researcher Stephen Post says helping a neighbor, volunteering, or donating goods and services results in a “helper’s high,” and you get more health benefits than you would from exercise or quitting smoking. Listening to a friend, passing on your skills, celebrating others’ successes, and forgiveness also contribute to happiness, he says. Researcher Elizabeth Dunn found that those who spend money on others reported much greater happiness than those who spend it on themselves.

 

Saturday, March 13, 2010

Effect of exposure time on photos

An exposure time of 1/8 sec (0.125)

An exposure time of 1/30 sec (0.033)

An exposure time of 1/2 sec (0.5)


On my Sony W-290 this is set by switching to P (programming) mode and setting the EV (Exposure Value) (0 - image 1 above, -2 - image 2 & 2 - image 3) accordingly.

Thursday, March 11, 2010

I am grateful that somehow we are made, in the most trying of times, to just block out everything and keep going, even when you have no idea what to do or how it will all work out.

“I am grateful that somehow we are made, in the most trying of times, to just block out everything and keep going, even when you have no idea what to do or how it will all work out.”

- Sarah Dessen through Julie911

Wednesday, March 10, 2010

Mastering complexity

‘…Geniuses…people with extraordinary skill…devise innovative idioms, mechanisms and frameworks that others can use as architectural foundations of other applications or systems…However as Peters observes “The world is only sparsely populated with geniuses…”… Although there is touch of genius is all of us, in the realm of industrial-strength software we cannot always rely upon divine inspiration to carry us through. Therefore we must consider more disciplined ways to master complexity.” – Grady Booch in “Object-Oriented Analysis and Design with Applications”

What we create becomes meaningful to us only once we stop creating it and start to think about why we did so.

“What we create becomes meaningful to us only once we stop creating it and start to think about why we did so.” - Rabbi Elijah of Vilna

Monday, March 08, 2010

Contentment is natural wealth

“Contentment is natural wealth, luxury is artificial poverty.” 

 

– Socrates through Becoming Minimalist

Friday, March 05, 2010

Data Object and Service Object Design

Data Objects hold data. They do *not* operate on the data (like save, delete etc…).

Service Objects operate on the data held by Data Objects.

 

Data Object design is more real life driven. If there is a “Is a” relationship between two entities in real world, the model objects have a “Is a” relationship. For example a Dog “Is a” Animal.

 

Service Objects design is more application architecture driven. For example if a reusable functional logic should be achieved through aggregation or composition or a utility class (read post titled “Don’t extend to extend functionality. Extend to only override functionality”).

Fragile Base Class problem

Don't extend to extend functionality. Extend to only override functionality

Don’t extend to extend functionality

Extend to only override functionality

 

When an API is extended, the author of the API must factor in the fact that it would be extended. If not extension had exposed a means to invoke an API in a way that it was not designed to handle.

On the other hand when aggregation is used, only public APIs are used and hence the class is used as it was intended to be used. When authoring classes care must be exercised in deciding what must be private, protected, default, public and final (a way of saying this API does not support extension).

Wednesday, March 03, 2010

Wanting what one gets is happiness

Getting what one wants is success
Wanting what one gets is happiness

- In an NPR program

Interesting Article

Choice

Freedom of choice is good. But when one has a whole lot of options to choose from, restricting oneself becomes necessary to achieve direction.

 

When Buddhist monks are trained, options available to them are considerably restrained. In real life, we have a whole lot of options to choose from though. But if those choices are not made consistently, then a sense of direction seems missing.

 

-          My understanding of Sheena Iyengar’s thoughts on NPR today

Tuesday, March 02, 2010

it is not how much we have, but how much we enjoy, that makes happiness

“it is not how much we have, but how much we enjoy, that makes happiness.”

from Plain Advice for Plain Peoplehttp://www.assoc-amazon.com/e/ir?t=becomingminim-20&l=as2&o=1&a=0553348973 by Charles Spurgeon through “Becoming Minimalist”

 

our souls are...hungry for...the sense that we have figured out how to live so that our lives matter

“our souls are not hungry for fame, comfort, wealth, or power. our souls are hungry for meaning, for the sense that we have figured out how to live so that our lives matter.”

- harold Kushner through Becoming Minimalist

 

Our best decisions, the ones that we never regret, come from listening to ourselves.

“Our best decisions, the ones that we never regret, come from listening to ourselves.”

- Felicity through Julie911

Monday, March 01, 2010

you try a little harder when you're scared.

“You know, I think you try a little harder when you’re scared.”

- Rocky Balboa through Julie911

I know you're scared. Don't be. The world really is beautiful.

“I know you’re scared. Don’t be. The world really is beautiful.”

- Alicia Millstone through Julie911

Friday, February 26, 2010

Floating point numbers in String.format()

String.format(

"SQL completed in %.2f seconds.",

((float)(endTime - startTime)/1000)

)

Output:

SQL completed in 0.02 seconds.

Display the parameter as a floating point decimal (%f) with 2 decimal places (%.2f).

 

Thursday, February 25, 2010

Judge before and after doing a scene but not during

Judge before and after doing a scene but not during (when the scene is being made)

 

-          An actor on NPR

The more precise you are about your decisions the better are the chances of winning

The more precise you are about your decisions the better are the chances of winning

 

-          Almost close to the wordings of a winter Olympic athlete

Tuesday, February 23, 2010

"Not being able to do everything is no excuse for not doing everything you can."

“Not being able to do everything is no excuse for not doing everything you can.”

- Ashleigh Brilliant through Julie911

"Young lovers seek perfection. Old lovers learn the art of sewing shreds together and of seeing beauty in a multiplicity of patches."

“Young lovers seek perfection. Old lovers learn the art of sewing shreds together and of seeing beauty in a multiplicity of patches.”

- How To Make An American Quilt through Juli911

Saturday, February 20, 2010

Karakoram Highway

"In 1968, the Chinese, anxious to create an easy route to a new market for their manufactured goods, to limit Soviet influence in central Asia and to cement a strategic alliance against India, offered to supervise and fund the completion of the thirteen-hundred-kilometer route from Kashgar, in southwestern China, to Islamabad."

- Three Cups of Tea by greg Mortenson & David Oliver Relin


The pleasure to be found in submission to prayer

"...kneeling among one hundred strangers, watching them wash away not only impurities, but also, obviously, the aches and cares of their daily lives, he glimpsed the pleasure to be found in submission to a ritualized fellowship of prayer."

- chapter 6 titled "Rawalpindi's Rooftops At dusk" in "Three Cups of Tea" by Greg Mortenson & David Oliver Relin

Thursday, February 18, 2010

Why read only operations should also be in a transaction?

1.       The transaction can be marked as read-only and any accidental/un-intentional writes can be discovered and fixed

2.       The read operations can be wrapped with a “propagation required” (if a transaction already exists while performing the operation, use it. Else create a new transaction) there by the read operation can participate in write transactions.

Tuesday, February 16, 2010

Find unique, non-empty lines in a file

cat test.txt | sed '/^ *$/d' | sort | uniq # uniq requires its input to to be sorted

Monday, February 15, 2010

Visit to Zion National Park

Was on family road trip to Zion National Park over the long week end. Here are few of the snaps:




Wednesday, February 10, 2010

Detachment

“…in order to acquire anything in the physical universe, you have to relinquish your attachment to it… You don’t give up the intention, and you don’t give up the desire. You give up your attachment to the result… The moment you relinquish your attachment to the result, combining one-pointed intention with detachment at the same time, you will have that which you desire… because detachment is based on the unquestioning belief in the power of your true Self… Attachment… is based on fear and insecurity and the need for security is based on not knowing the true Self. The source of wealth, of abundance or of anything in the physical work is the Self; it is the consciousness that knows how to fulfill every need. Everything else is a symbol: cars, houses,… Symbols are transitory; they come and go. Chasing symbols is like settling for the map instead of the territory. It creates anxiety; it ends up making you feel hollow and empty inside, because you exchange yourself for the symbol of your Self…Only from detached involvement can one have joy and laughter. Then the symbols of wealth are created spontaneously and effortlessly… To be grounded in this experience (of spontaneous wealth creation) you have to be grounded in the wisdom of uncertainty. In this uncertainty you will find the freedom to create any-thing you want.” Seeking security does not work. No amount of security is enough. “ In ancient wisdom traditions, the solution to this whole dilemma lies in the wisdom of insecurity, or the wisdom of uncertainty. This means that the search for security and certainty is actually as attachment to the know. And what’s the know? The known is our past. The known is nothing other than the prison of past conditioning. There’s no evolution in that – absolutely none at all. And when there is no evolution, there is stagnation, entropy, disorder and decay. ..Relinquish your attachment to the known, step into the unknown, and you will step into the field of all possibilities…This means that in every moment of your life, you will have excitement, adventure, mystery. You will experience the fun of life – the magic, the celebration, the exhilaration and the exultation of your own spirit…When you are attached, your intention gets locked into a rigid mindset and you lose the fluidity, the creativity, and the spontaneity inherent in the field (of all possibilities) (that can orchestrate an infinity of space-time events to bring about the outcome that is intended).  The Law of detachment accelerates the whole process of evolution. When you understand this law, you don’t feel compelled to force solutions. When you force solutions to problems, you create new problems. But when you put your attention on the uncertainty, and you witness the uncertainty while you expectantly wait for the solution to emerge out of the chaos and the confusion then what emerges is something very fabulous and exciting. This …alertness – your preparedness in the present, in the field of uncertainty – meets with your goal and your intension and allows you to seize the opportunity. ” The opportunity contained within every problem that you have in your life. “Good luck is nothing but preparedness and opportunity coming together.”

Relinquish your attachment to the outcome

“Relinquish your attachment to the outcome. This means giving up your rigid attachment to a specific result and living in the wisdom of uncertainty. It means enjoying every moment in the journey of your life, even if you don’t know the outcome”.

 

1.       “I will make a list of all my desires. I will carry this list with me whenever I go. I will look at this list before I go into my silence and meditation. I will look at it before I go to sleep at night. I will look at it when I wake up in the morning.

2.       I will realize this list of my desires and surrender it to the womb of creation, trusting that when things don’t seem to go my way, there is a reason, and that the cosmic plan has designs for me much grander than even those that I have conceived.

3.       I will remind myself to practice present-moment awareness in all my actions. I will refuse to allow obstacles to consume and dissipate the quality of my attention in the present moment. I will accept the present as it is, and manifest the future through my deepest, most cherished intentions and desires.”

 

-          The Seven Spiritual Laws of Success by Deepak Chopra

Do more with less

“ … most of our energy goes into upholding our importance …  If we are capable of losing some of that importance, two extraordinary things would happen to us. One, we would free our energy from trying to maintain the illusory idea of our grandeur; and two, we would provide ourselves with enough energy to….catch a glimpse of the actual grandeur of the universe. [ from The Art of Dreaming ]”

 

3 aspects to achive do more with less

1.       Accept that this moment (people, situations, circumstances and events) is as it should be, because the entire universe is as it is. “When you struggle against this moment, you struggle against the entire universe.” So you should “accepts things as they are, not as you wish they were in this moment”. “When you feel frustrated or upset by a person or a situation, remember that you are not reacting to the person or the situation, buy to your feelings about the person or situation. These are your feelings and your feeling are not someone else’s fault. And if you can accept things as they are, you are ready to take responsibility for your situation...”

2.       “Responsibility means not blaming anyone or anything for your situation including yourself. Having accepted this circumstances, this event, this problem, responsibility then means the ability to have a creative response to the situation as it in now. All problems contain the seeds of opportunity, and this awareness allows you to take the moment and transform it to a better situation or thing” “Reality is an interpretation. And if you choose to interpret reality in this way, you will have many teachers around you…” Your situation is “precisely the one you need in your life at this moment. This is the hidden meaning behind all events and this hidden meaning is serving your own evolution”.

3.       Remain defenseless – relinquish “the need to convince … others of your point of view.” In doing so, you will “gain access to enormous amounts of energy that have been previously wasted. When you become defensive, blame others, and do not accept and surrender to the moment, your life meets resistance… You don’t want to stand rigid like a tall oak that cracks and collapses in the storm. Instead, you want to be flexible, like a reed that bends with the storm and survives. ”

Spontaneous right action

“In every moment of our existence, we are in that field of all possibilities where we have access to an infinity of choices. Some of these choices are made consciously, while others are made unconsciously.” ”…most of us – even though we are infinite choice-makers – have becomes bundles of conditioned reflexes that are constantly being triggered by people and circumstances into predictable outcomes of behavior.” “If you step back for a moment and witness the choices you are making as you make those choices, then in just this act of witnessing, you take the whole process from the unconscious realm into the conscious realm. This procedure of conscious choice-making and witnessing is very empowering.”

 

2 questions to ask before making a choice

1.       “What are the consequences of this choice that I’m making?”

2.       “Will this choice that I’m making now being happiness to me and to those around me?”

 

“There is only one choice, out of the infinity of choices available in every second, that will create happiness for you as well as for those around you. And when you make that one choice, it will result in a form of behavior that is called spontaneous right action.”

 

-          The Seven Laws of Spiritual Success by Deepak Chopra

That which doen't multiply through giving is neither worth giving nor worth receiving

That which doen't multiply through giving is neither worth giving nor worth receiving

-          The Seven Spiritual Laws of Success by Deepak Chopra

"Law of giving"

Also called “the Law of Giving and Receiving, because the universe operates through dynamic exchange”

 

-          The Seven Laws of Spiritual Success by Deepak Chopra

Non-judgment

“Judgment is the constant evaluation of right or wrong, good or bad. When you constantly evaluating, classifying, labeling, analyzing, you create a lot of turbulence in your internal dialogue. This turbulence constricts the flow of energy between you and the field of pure potentiality. You literally squeeze the “gap” between thoughts.”

“The gap is your connection to the field of pure potentiality. It is that state of pure awareness, that silent space between thoughts, that inner stillness that connects you to true power. And when you squeeze the gap, you squeeze your connection to the field of pure potentiality and infinite creativity.”

“Non-judgment creates silence in your mind.” Start your day with “Today I shall judge nothing that occurs” [ a prayer from A Course in Miracles ] “and throughout the day, remind yourself of that statement each time you catch yourself judging.” If it is difficult for a day say something like “For the next hour I shall judge nothing that occurs”

 

-          The Seven Spiritual Laws of Success by Deepak Chopra with my words (not in quotes)

Stillness

“One way to access” pure consciousness “is through daily practice of silence, meditation and non-judgment. Spending time in nature will also give you access to the qualities inherent in the field: infinite creativity, freedom and bliss.”

 

“Practicing silence means making a commitment to take a certain amount of time to simply be.” “If you never give yourself the opportunity to experience silence, this creates turbulence in your internal dialogue.

 

“Set aside a little time every once in a while to experience silence.”…”And every once in a while experience silence for an extended period of time, such as a full day…”. “Initially your internal dialog becomes even more turbulent. You feel an intense need to say something.” But as you “stay with the experience,” the “internal dialog begins t quieten. And soon the silence becomes profound.” “Then as the internal dialogue quietens, you begin to experience the stillness of the field of pure potentiality.”

 

Power of self

When our thinking is based on our objects in our experience, “we are constantly seeking the approval of others. Our thinking and behavior are always in anticipation of a response. It is therefore fear-based.” There is also a “need control things. The need for approval, the need to control things, and the need for external power are needs that are based on fear. This kind of power is not the power of pure potentiality or power of the self, or real power.” …”Power based on object referral …lasts only as long as the object of reference is there. If you have a certain (job) title or if you have a lot of money the power you enjoy goes with “ the title or money. “Ego based power will last only last as long as those things last. As soon as the title, the job, the money go away, so does the power”.

 

The true self, “which is your spirit, your soul, is completely free from those things. It is immune to criticism, it is unfearful of any challenge, and it feels beneath no one. And yet, it is also humble and feels superior to no one, because it recognizes that everyone else is the same self, the same spirit in different disguise.” .. “It draws people to you and it also draws things that you want to you.”…”It is the support of divinity; it is the support that comes from being in the state of grace. Your power is such that you enjoy a bond with people and people enjoy a bond with you”..”A bonding that comes from true love”.

 

-          “The Seven Spiritual Laws of Success” by Deepak Chopra with my words (not quoted)

Monday, February 08, 2010

There is my queen and what a privilege it has been to love her.

“True love. You know … when you’re old and you’re wrinkly and you’re sitting there gumming your food and your husband looks at you and even though he doesn’t see you very well anymore, he can see in your eyes the whole world: the future, the past, everything that was good and even things that were bad, and he can still say, ‘There is my queen and what a privilege it has been to love her.’”

- Prince Charming through Julie911

Don't be careless, but don't be too careful either.

“It’s easy to be confident when you have control of the puck. It’s very difficult to keep that confidence when you have to take whatever strange bounces life throws your way. Don’t be careless, but don’t be too careful either. You cannot be afraid to lose.”

- Jeffrey Nordling through
Julie911

School vs. Life

“The difference between school and life? In school, you’re taught a lesson and then given a test. In life, you’re given a test that teaches you a lesson.”

- Tom Bodett through Julie911

Time is tricky

“Time is tricky. You have whole months, even years, when nothing changes a speck, when you don’t go anywhere or do anything or think one new thought. And then you can get hit with a day or an hour, or half a second, when so much happens its almost like you are born all over again into some brand-new person you for damn sure never expected to meet.”

- Life is Funny through Julie911

You know we just don't recognize the most significant moments of our lives while they're happening. Back then I thought, well, there'll be other days. I didn't realize that that was the only day.

“You know we just don’t recognize the most significant moments of our lives while they’re happening. Back then I thought, well, there’ll be other days. I didn’t realize that that was the only day.”

- Field of Dreams through Julie911

Sunday, February 07, 2010

The right collaboration

Classes collaborate with each other to deliver their responsibility. In doing so, classes must make the least assumptions about the other classes. Too few assumptions, the collaboration will not be useful. Too many assumptions, the collaboration becomes a pack of cards (changes on one class will break the other class). More collaboration assumptions made is more coupling.

Interfaces help a given class to explicitly specify the assumptions that the clients can safely make when collaborating with that class. This set of assumptions must be balanced to be useful enough but not too detailed.

For example consider a StudentController class (a application UI class) that collaborates with JDBCStudentDAO class.

Class StudentController
{
JDBCStudentDAO dao = new JDBCStudentDAO();
public Student saveStudentUIAction(Student student)
{
return dao.jdbcSave(student);
}
}

In this case, StudentController makes assumptions about the implementation details of JDBCStudentDAO and public methods exposed by the implementation. This has the following disadvantages:
1. Any change in JDBCStundetDAO that violates any assumption made by StudentController will break StudentController.
2. Consider a HibernateStudentDAO which does *not* have the same public methods as JDBCStudentDAO (say HibernateStudentDAO only has a hibernateSave(Student) method and not a jdbcSave(Student)). Then replacing JDBCStudentDAO with HibernateStudentDAO will
a. Take more time to change StundentController
b. Cause more regression (every implementation assumption made by StudentController on JDBCStudentController that is violated by HibernateStundentController will lead to regression)

The solution: let StudentController reference a StudentDAO (an interface that explicitly states the assumptions that clients like StudentController can make). So we have

class StudentController
{
StudentDAO dao = new JDBCStudentDAO();
public Student saveStudentUIAction(Student student)
{
return dao.save(student); // Implemented by JDBCStudentDAO & HibernateStudentDAO
}
}

This solution solves ton of issues but not all of them. StudentController is still statically bound to JDBCStudentDAO.

To unit test StudentController let us suppose we write the following StudentControllerTest

class StudentControllerTest
{
public testSaveStudentUIAction()
{
Student student = new Student("Johnson");
Student savedStudent = studentController.saveStudentUIAction(student);
assertNotNull(savedStudent.getKey());
}
}

Let us assume that saveStudentUIAction can return null & throw a DuplicateStudentException. To simulate this scenario, JDBCStudentDAO must be exercised. But that is a test appropriate to JDBCStudentDAOTest, *not* StudentControllerTest. In short, StudentControllerTest must exercise and test only StudentController and not the classes that StudentController is dependent on. To achieve this, StudentController should be made to interface with a stub implementation of StudentDAO in the test cases and an actual implementation (like JDBCStudentDAO or HibernateStudentDAO) in the application. So StudentController should must not instantiate JDBCStudentController. But a implementation of StudentDAO must be handed over to it. This handing over of StudentDAO implementation can be achieved through Spring IOC (Inversion of control) or dependency injection.

So we now have

class StudentController
{
StudentDAO dao;
public Student saveStudentUIAction(Student student)
{
return dao.save(student); // Implemented by JDBCStudentDAO & HibernateStudentDAO
}
// This setter is invoked by spring IOC with stub implementation (that
// does what the test case wants to exercise) in test cases and
// actual implementation in the application
public void setDao(StudentDAO studentDAO)
{
dao = studentDAO;
}
public void getDao()
{
return dao;
}
}

Sunday, January 31, 2010

Basic Spring application

Here is a very basic spring application. This can be used to play around with various spring features.

This moment in the future

In the future you should be able to look at this moment and say to yourself that you couldn't have spent it better.

- Nithya (my wife)

Saturday, January 30, 2010

Fear is not what’s important, it’s how you deal with it.

“Fear is not what’s important, it’s how you deal with it. It would be like asking a marathon runner if they feel pain. It’s not a matter of whether you feel it, it’s how you manage it.”

- James Nachtwey - War Photographer (2001) through Julie911

...You’re not the first person who was ever confused and frightened and even sickened by human behavior

“Among other things, you’ll find that you’re not the first person who was ever confused and frightened and even sickened by human behavior. You’re by no means alone on that score, you’ll be excited and stimulated to know. Many, many men have been just as troubled morally and spiritually as you are right now. Happily, some of them kept records of their troubles. You’ll learn from them”

- J.D. Salinger, The Catcher in the Rye, Chapter 24 through Julie911

Thursday, January 28, 2010

Indexing tip

Searching by more than one column (i.e. more than one predicate in the where clause) is a very common scenario. To fasten such queries, creating indices is a common practice. The question: How to reuse the same index for both single column and multi column searches? For example, consider a student table with id, first_name and last_name columns. If the DB receives numerous queries with first_name and last_name in there where clause, then what should the indexing strategy be?

 

To elaborate on the question, the indexing strategy needs to support the following queries

 

Select * from student where first_name like ‘blah%’; -- Scenario 1

Select * from student where last_name like ‘blah%’; -- Scenario 2

Select * from student where first_name like ‘blah%’ and last_name like ‘blah%’; -- Scenario 3

 

One possible solution is to create 3 indices for the 3 scenarios (one for first_name, one for last_name and one for first_name and last_name). This is not so interesting.

 

The other alternative leverages on the fact that a query based on first_name only will also use an multi-column index (index on more than one column) provided first_name is the first column in the multi-column index.

 

So in the above scenario, the following indices need to be created:

 

CREATE INDEX idx_student_firstName_last_name ON student (first_name, last_name); -- takes care of first_name only (scenario 1) and first_name and last_name queries (scenario 3)

CREATE INDEX idx_student_last_name ON student(last_name); -- takes care of last_name queries (scenario 2)

Attributes of pure consciousness

Attributes of pure consciousness are pure knowledge, infinite silence, perfect balance, invincibility, simplicity and bliss.

 

-          Deepak Chopra in “The Seven Spiritual Laws Of Success

Wednesday, January 27, 2010

Never let negative feelings block the path to your goal

“One of the first principles of applied mindism is to never let negative feelings block the path to your goal. Otherwise you are always sinking back into discouragement.”

- Jack Nicholson through Julie911

The world will freely offer itself to you to be unmasked....it will roll in ecstasy at your feet

“You need not even leave your room. Remain sitting at your table and listen. You need not even listen simply wait. You need not even wait, just learn to become quiet and still, and solitary. The world will freely offer itself to you to be unmasked. It has not choice; it will roll in ecstasy at your feet”

 

-          Franz Kafka from “The Seven Spiritual Laws Of Success” by Deepak Chopra

Friday, January 22, 2010

The best portion of a good man’s life is....

"The best portion of a good man's life is the little, nameless, unremembered acts of kindness and love."

- William Wordsworth through Julie911

Failure Atomic

When a method invocation on an object fails, the object should revert back to the state that it was in prior to the invocation. If it does this, then the method is failure atomic.

Coining user messages in a failure scenario

When an operation (such as save) is triggered from an UI application, the call trickles down to underling APIs. If something wrong happens with the operation, then the user needs to be notified of the failure on the UI. The question: how and where should this UI message be coined?

 

Consider the following (over simplified) code to achieve a save operation

 

// 1. UI code calls setNewStudent(Student) with the student data entered in UI form (xhtml, JSP, etc…)

 

// 2. An action on the UI (button click for example) invoked the following method

StudentUIController.saveNewStudent()

{

    StudentDAO.SaveOfUpdate(getNewStudent()); // 3. UI Code makes DAO layer call to persist object

}

 

StudentDAO.saveOrUpdate( Student )  // 3.

{

    // Persist the student

}

 

One of the best practices to handle the failure scenario is to have the DAO layer (StudentDAO in this example) throw a custom exception. The UI layer (StudentUIController) must catch this exception and coin a message for the user. The custom exception should have enough information in it for the UI layer to coin a meaningful message for the user from the exception. In some cases, the DAO layer may also give a brief message of what went wrong in the exception.

 

Will update this post soon with the code after I have a working example of how this is to work.

 

Wednesday, January 20, 2010

"Don't be afraid to give your best to what seemingly are small jobs. Every time you conquer one it makes you that much stronger. If you do the little jobs well, the big ones will tend to take care of themselves."

“Don’t be afraid to give your best to what seemingly are small jobs. Every time you conquer one it makes you that much stronger. If you do the little jobs well, the big ones will tend to take care of themselves.”

- Dale Carnegie through Julie911

Tuesday, January 19, 2010

Remember no man is a failure who has friends.

"
Dear George,

Remember no man is a failure who has friends.

Thanks for the wings!

Love,
Clarence"

- Its a wonderful life

Ideals without common sense can ruin this town

Ideals without common sense can ruin this town - it's a wonderful life

Monday, January 18, 2010

Creating an index on a column using hibernate mapping

Mapping:

 

<property

  name="name"

  column="student_name"

  type="string"

  index="xyz__student_name"/>

 

Table Structure (in PostgreSQL)

 

CREATE TABLE xyz

(

  id bigint NOT NULL,

  student_name character varying(255),

  CONSTRAINT xyz_pkey PRIMARY KEY (id)

)

 

CREATE INDEX xyz__student_name

  ON xyz

  USING btree

  (student_name);

Creating a unique contraint on a column through hibernate mapping

Mapping:

 

<class …>

  <natural-id>

    <property

      name="name"

      column="name"

      type="string" />

  </natural-id>

</class>

 

Table Structure (in PostgreSQL):

 

CREATE TABLE xyz

(

  id bigint NOT NULL,

  "name" character varying(255) NOT NULL,

  CONSTRAINT xyz_pkey PRIMARY KEY (id),

  CONSTRAINT xyz_name_ukey UNIQUE (name)

)

 

Friday, January 15, 2010

may God turn their ...ankles, so that we may know them by their limping :-)

“May those who love us, love us. And those who don’t love us, may God turn their hearts. And if He cannot turn their hearts, may He turn their ankles, so that we may know them by their limping.”

- Keeping The Faith / Irish Prayer through Julie911

Wednesday, January 06, 2010

Don't be afraid

“Don’t be afraid. Don’t be daunted. Just do your job. Continue to show up for your piece of it, whatever that might be. If your job is to dance, do your dance. If the divine cock-eyed genius assigned to your case decides to let some sort of wonderment be glimpsed for just one moment, through your efforts, then olé! And if not, do your dance anyhow, and olé to you nonetheless.”

- 
Elizabeth Gilbert through Julie911

Monday, December 28, 2009

Finish each day and be done with it.

“Finish each day and be done with it. You have done what you could; some blunders and absurdities have crept in; forget them as soon as you can. Tomorrow is a new day; you shall begin it serenely and with too high a spirit to be encumbered with your old nonsense.”

- Ralph Waldo Emerson through Julie911

When we are ... just not brave enough ...

"There are times when it is hard to believe in the future, when we are temporarily just not brave enough. When this happens, concentrate on the present. Cultivate le petit bonheur (the little happiness) until courage returns. Look forward to the beauty of the next moment, the next hour, the promise of a good meal, sleep, a book, a movie, the likelihood that tonight the stars will shine and tomorrow the sun will shine. Sink roots into the present until the strength grows to think about tomorrow."
— Ardis Whitman through Julie911

I see who I wanna be in my daughter’s eyes

“In my daughter’s eyes I am a hero. I am strong and wise and I know no fear, but the truth is plain to see: she was sent to rescue me. I see who I wanna be in my daughter’s eyes.”

- Martina McBride through Julie911