web developer & system programmer

coder . cl

ramblings and thoughts on programming...


integrating pycheckers and emacs

published: 09-08-2011 / updated: 09-08-2011
posted in: development, emacs, programming, python, tips
by Daniel Molina Wegener

There are many versions of the pycheckers.py script. It is wrapper between various static analysis tools for Python code. I have my own modified version of the pycheckers script and it is running pep8, pychecker, pyflakes and pylint. I have that script integrated with Emacs, so I run the compile command to verify the code quality. My code should meet all Python standards to pass all checks that are made by those tools.

cyclomatic complexity in python

published: 31-07-2011 / updated: 31-07-2011
posted in: development, programming, python, tips
by Daniel Molina Wegener

According to the Zen of Python, complex is better than complicated, but it requires the code to be flat, and flat code means less nodes to visit during parsing. It also means that the code should be plain, without too much nested statements, well structured and small. Cyclomatic Complexity is a metric that allows you to know how many execution paths, or nodes are visited during the program execution. I was searching a program or module that allows me to know the Cyclomatic Complexity of my Python programs, even if have pylint, pychecker, pep8 and pyflakes to check my code, a well organized project, that is strict on its governance, maintains a well structured Continuous Integration tools with this kind of analysis enabled.

λ day meet-up

published: 24-07-2011 / updated: 24-07-2011
posted in: development, haskell, programming, projects, python, tips
by Daniel Molina Wegener

The past July 19, I’ve made a talk on the Dynamic Languages meet-up explaining some basics of functional programming. The presentation has two parts, the theoretical one, with the proper presentation and the second one with code examples. For the code examples I’ve used Lisp, Haskell and Python, with homologous functions, each one implemented on each used language, to ensure that are concepts were handled.

considerations in code review

published: 06-07-2011 / updated: 06-07-2011
posted in: development, java, programming, python, tips
by Daniel Molina Wegener

Once we have created code, we can evaluate how it was done. We can use various tools to check our creation among other activities. To do standard checks, we can use style checkers, static checkers, unit testing suites and the most important one, the human code review.

concurrency in redis and memcache

published: 19-06-2011 / updated: 19-06-2011
posted in: development, programming, projects, python, tips
by Daniel Molina Wegener

I have compared redis and memcache with a lighweight test. Now I have compared both key/value stores with a harder test, using 100 threads, and observing the speed between the parallel writes and parallel reads in both engines. I’ve used the Python binding, since I need to apply one of those key/value storage to certain Python application that I am currently developing. Certainly both have advantages between each other, but still I am preferring Redis over Memcached, because seems that Redis can manage more constant times between both operations, and seems to have a lighweight routine to make concurrent writes.

minimal design patterns in django

published: 11-06-2011 / updated: 11-06-2011
posted in: development, programming, python, tips
by Daniel Molina Wegener

Using design patterns to encapsulate application logic is very cool, only when you do not over-architect your application. Any excessive usage of design patterns and architectural patterns can lead you to oversized applications. Applying design patterns correctly can allow you to get a well defined architecture and a well designed application. You must remember that Django do not uses the MVC pattern, instead — as they development team describes it — Django is MTV: “Model, Template and View”. So, I will try to explain an implementation of the PAC architectural pattern driven under Django to allow you to implement scalable Django applications.

comparing redis and memcached

published: 13-05-2011 / updated: 13-05-2011
posted in: development, programming, python, tips
by Daniel Molina Wegener

Key/Value and on-memory databases are widely used to store cached objects or documents. I am currently developing some Python/Django applications which are subject of strong data writing. For some tasks, I must choose between two Key/Value stores, and both are well known and widely used: redis and memcached. Instead of asking for benchmarks, I have prepared some simple tests to see which one will offer me the best performance in similar conditions.