Saturday, January 26, 2013

Code Review by Philip Arguelles


Ingenuity: So, what was it you were working on, Phil?

Philip: To give you an overview, the project I'm working on has cell scripts -- a script that will be triggered by an update or an add event of a specific key in the database.

Of course, I was using Python-Django in its development.


Ingenuity: So what issue did you discuss on your code review?

Philip: On the talk, I discussed about how to easily capture and keep track of changes in a specific database table without using Django signals. This was easily done by adding several codes in the built-in "__init__" function of the class.

Another issue discussed was how to efficiently compare the equality of the objects. Since the objects are not native datatypes, I used and overrode the built-in function "__eg__", "__le__", "__ne__", "__gt__", and "__ge__" so that we can use the operators "==", "<=", "!=", ">=", ">", and "<" on objects; no need to iterate on the object fields!


Ingenuity: Wow, that's ingenious! Where did you get that idea?

Philip: Thanks! I had help from http://docs.python.org/2/reference/datamodel.html


Ingenuity: There really are lots of wonderful things to discover on the worldwide web, if you know where to look! What other cool stuff did you share on your talk?

Philip: Yes, that's true. There are millions out there.

Another thing that I discussed was how to prevent the code execution from breaking while it is running and how to inform the admin of the errors in the individual cell scripts.

This was solved by sparingly using the "try-except" clause and skipping the cells which has errors in them while simultaneously recording the errors encountered on the database for the admin to see.


Ingenuity: Thanks for your time, Phil. That was a great code review!

Philip: No problem. Thank you too.


*Philip Arguelles has been with the team for more than a year and has been steadily improving on his Python and Django skills. He is also adept at PHP, JavaScript, HTML, MySQL, SQL, and Ajax. Silent and unassuming, he works best under pressure and has earned the trust and approval of both the team and its clients.

No comments:

Post a Comment