Monday, June 3, 2013

Going back in time

Have you ever had a chance to go back in time. Well  I had a chance to do this just the other day.

I was  about to take my car out from my house and it was raining heavily (which is very common these days).  As I was was opening the gate I saw a taxi (tuk tuk) stuck on the road and the only people inside were a girl of about 12 years and the driver. Suddenly this little girl got out and started pushing the taxi in the pouring rain. It was difficult, but she trying her best.

I do not know what but something told me to help this girl out so I also went and checked what the situation was and we both started pushed the taxi. When we were pushing I saw that she was smiling all over and very happily pushing the taxi. For her being out in the rain was a very exiting thing, very soon I also started feeling the same because I started remembering how I used to run up and down my street in the pouring rain when I was young.

By the time we started to get the taxi running, we were both soaking wet but we were laughing our heads off and making fun at the rain and splashing on the water puddles. The taxi driver, who I later found was her father, got down and thanked me but I felt I should thank them for giving me this little moment in time to go back to my child hood and feel those same feelings and emotions again.

At the end of it I was soaking wet but I was emotionally juiced and that whole day I was feeling the same energy. I was thinking how beautiful life would be if once in a while we can become the kids that we were and literally go back in time as and when we need... I hope that when you read this you will also get the chance to go back in time as I did.


Thursday, October 25, 2012

Clean Code or Code Clean

I am pretty sure that most of the times, us developers have heard the following line from some senior personal "Why don't you code it clean the first time". Well in fact I have heard this many times as a developer and have told this to my juniors many times as well.

But when you dig deep, you begin to ask your self, Is there anything called coding clean these days. With the business demands, systems evolving, pressure to fix or develop faster etc... we as developers are tide down to quickly hash code and release! in fact all these new Agile methodologies and time boxed sprints are not making it any more easier.

So how do we make sure that we keep our code maintainable, clean and effective... We use a simple term called "Code Refactor".

So what really is refactoring...

Full Article - http://cleancoderefactoring.blogspot.com/

Sunday, May 6, 2012

Giving estimates on R&D software projects

Recently I was at a seminar were one of the participants asked a question regarding estimating properly when working on an R&D project from the expert panel.

The question was “How do we give proper deadlines when we are working on R&D projects, because when we start going into research we come up with so many stumbling blocks that we need to figure out so many things and our estimations goes out of the window”.
http://estimating-the-unknown.blogspot.com/


Friday, April 6, 2012

Aikido and My Life

Aikido, a traditional Japanese martial art which teaches the way of Budo, was introduced to me quite accidentally at a very turmoil junction in my life. I was at several cross roads of my life which was filling my life with much stress and it was impacting me on my health, my emotions and my life as whole.
I was immediately drawn to the flowing movements and charm of Aikido and from the day I saw Shihan Tadashi Komenoi, who later became my teacher and mentor, practicing with his pupils. However after experiencing Aikido first hand I knew I was truly beginning a journey that would not know any boundaries or limits.

Monday, June 20, 2011

Catching performance bottlenecks

Well I've been involved in several Performance issues and 90% of the time what I have seen is that asking the right questions would solve the problem and the other 10% is hope, pray, trial and error.

So I decided the I would share some of my experience in order help any IT personal who maybe praying, hoping and asking god to give some sort of solutions to a performance bottleneck.

Being a Java guy, I have been mostly involved in performance issues pertaining to JEE apps and surprise, surprise... 99% of the time the issue is with the application or the DB structures....
 
So here goes my two cents....

When I am called to check on performance issues I always go with a blank page... no pre-assumptions, no ideas why this is happening or what could be causing the issue.

The first set of questions I ask are

What does the user see as a performance issue?
When does he see it?
What is he doing when he see performance issues?
What has he done before getting the performance issues?

Well most of the time the performance issues comes in two folds,

1. The system is really slow in giving out a desired response
2. The system just crashes

I will cover the sluggish / slowness performance issues here and will have another dedicated article on system crashes and what I have done to handle them.

Well once I get to know that the issue is a slowness problem, I try to ask my second and third questions


When does he see it?
What is he doing when he see performance issues?

Most of the time the answers would be,

  1. When I try to go to certain screen or do some action in the screen
  2. When I run the application for a certain time
  3. At a specific time of day
  4. Or a real disgruntled customer would say ALL THE TIME 
From the above three questions and the answers that I get, I can start formulating some solutions.
 

Thursday, September 23, 2010

PL/TCL Trigger For Auditing with PostgreSQL

I was recently involved in identifying an issue with a PL/TCL audit trigger which was not working properly. The issue was whenever a modification was done to the table which was having the trigger, the triggers gets disabled and we would need to recreate the tables to be able t activate the triggers. Of course this was a major issue as each time something is done to the table we would need to rebuild the tables in order get the triggers working. Also just dropping and creating the triggers was also not a possibility and did not work.

Hence I started digging in to the issue and following is some insight into the way that we can create a PL / TCL trigger.

Why PL/TCL

Well in PsotgreSQL, there are many languages to create triggers from. PL/SQL, PL/TCL. PL/Python and PL/Perl. Of the four PL/SQL is the most famous for procedural program blocks in SQL DBMS. However there is a limitation in PL/SQL in that we can not have dynamic table names or columns names to be used within the trigger.

i.e. if we are to use the column that was changed and the table that was changed dynamically we would have an issue, because in PL/SQL we will not be able to pick the columns which are changed dynamically and they need to be statically coded in the PL/SQL function. This would cause us to have a separate PL/SQL function for each and every table we are going to add the trigger to or create separate trigger functions.
Hence PL/TCL to the rescue. With PL/TCL we can use C functions in PostgreSQL to get an array of changed columns and tables. Of course we would need to combine PL/TCL with PostgreSQL catalogue as well.

Set up

First we need to add PL/TCL capability to the database. In order to do this we need to compile PostgreSQL installation with adding PL/TCL. Once that is done we need to enable PL/TCL to the database.

i.e. using the CREATELANG function

createlang pltcl dbname or createlang pltclu dbname

Code

Following is an expert from a code that would create trigger function, and how that function can be attached to a table.

CREATE OR REPLACE FUNCTION xxx.log_to_audit_table()
RETURNS "trigger" AS
$BODY$


spi_exec "SELECT CURRENT_USER AS tguser"


spi_exec "SELECT c.relname AS tgname,n.nspname AS schema_name
FROM pg_class c , pg_namespace n
WHERE n.oid = c.relnamespace
AND c.oid = $TG_relid"



spi_exec "insert into xxx.testlogtable values ('inserted in log_to_audit_table $tgname')";

set pk_name ""

spi_exec "SELECT a.attname AS pk_name FROM pg_class c, pg_attribute a, pg_index i
WHERE c.relname = '$tgname'
AND c.oid=i.indrelid
AND a.attnum > 0
AND a.attrelid = i.indexrelid
AND i.indisprimary='t'"

spi_exec "SELECT audit_table_name AS m_aud_tbl_name
FROM $main_schema.audit_table_mapping
where schema_name = '$schema_name'
and tabel_name = '$tgname'"


.....

return OK
$BODY$
LANGUAGE 'pltcl' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;

And following is the trigger created to a table to audit


CREATE TRIGGER trig_audit_admin_user
AFTER INSERT OR UPDATE OR DELETE
ON xxx."user"
FOR EACH ROW
EXECUTE PROCEDURE "xxx"."log_to_audit_table"();

Well that's it. Whenever you need to add  audit feature to a table, add the trigger to the table.