Something you can always do at database level

January 9, 2007

I found many developers even sometimes I do some code which could be possible at the database level. Why to format date at coding level when DATE_FORMAT function is available.

Developer should be careful enough to identify the cases where they can performes operation at database level. This will help to improve the overall performance and efficiency of your application.

I will be keep adding the tips about the same in this entry

First
=====
If you want to format date by fetching it from database, you can use DATE_FORMAT function.

eg. SELECT DATE_FORMAT(now(), ‘%y’) FROM tableName

Advertisements

Lessons learned

December 25, 2006

Last week I was not able to post any entry in my blog, lots of work was done last week. Code refactoring, javascript validators, Smarty templates formatting are some major areas I worked on.

There was too many good things I learned. Firstly I took javascript validation part for my project, I found there were so much redudant code I written when I started working on the project. After taking some deep grasp on it, I was able to implement new validation function which does most kind of validation for me. This was the great achievement from last week. I wrapped my 1000 lines of code within just 100 lines, I am feeling very good about this. I share the code with some other team members and they were happy about the approch I took.

Smarty was one more things which was looking very egly no proper identetion, formatting, comments. No uniformity within the codes. I clean up most of the smarty templates, there are still some more which I will clean up this week.

In PHP, I clean up most part of PHP script, I feel very sorry that I didnt concetrated initially on my code which leads to this.

Some notes I took from this incident
-Always write good code, think before writing the code.
-Analyse it in every aspect, how it can help you in future.
-Is your code is easy to modify in future.
-Can I use the same code in other projects too.

I already started implementing this earlier but not on this project, that was mistake from my side.

But finally I am happy that I clean up many things last week.

Cheers!!