Category Archives: personal

My development tips

Another unsorted list of ideas this time about coding tips.

code = mass

The source code isn’t an abstract element. OK it’s not as touchable as apples or bricks but it’s somehow under physical laws too. You must write as less code as you can to meet your requirements. Big code means big mass and if you have a big mass you will need more energy to change whatever you need. I can stop a car toy with my hand but I need something more to stop a real train with the same speed. Less code means less failure points and it’s easier to manage. Some people claim proudly they have written a library with thousands of code lines. Nobody pay us for writing lines of code. They pay us for the solutions. The lines of code that we write is our problem. So be as minimalistic as you can. The problem is that writing less code is more complicated than write more. We need to think more to write less code.

DRY (Don’t repeat yourself)

Original, isn’t it?.  Copy & paste is evil. Never use it in your projects. Spread the same code among different files means that you will need to remember where are those pieces of code when a bug appear (they appear, believe me). There’re a lot of techniques to avoid copy & paste source code. Use them. There isn’t any excuse to it.

Coding standards

The source code is one of your deliverables as developer. You must care about it. Adopt a coding standard. Chose one and use it. If you work with a team take this decision with your team, but don’t try to create one standard by your own. It’s a big job. If you use one of the existing coding standards (let’s say Zend Framework’s one) you will find tools to validate your code against it and the most common IDEs and text editors will be able to use it too. In other way if you create a new one you will need to develop those plug-ins and tools and even you will need to document it if you want to show it to another developer. To many work that nobody will pay for it only because you dismiss an existing one.

Revision control.

Mandatory. Even for small and personal projects. I like Mercurial. it’s easy to use and easy to install. Anyway there are others similar like git or bazzar. Or if you are old school, CVS and Subversion. When I start a project, after create an empty folder with the name of the project I always execute “hg init” to create my repository. Commit you code often. Every time you make something important commit your work. Don’t wait until your project is finished. Revision control is a great backup system too. When something wrong happens like accidentally delete of a folder or something similar you can recover it easily without any problem. Also with a simple hg push (or similar command with another software different from mercurial) you will save your project into another place. If you don’t know to use any revision control system aside time for it. Believe me. You will not need too many time to learn how to use it. At least a basic usage.

Text editor

Is your main tool as a developer. It’s like the hammer for a carpenter. You must train yourself in the use of it. A good skill in the use of a text editor or IDE will give great benefits. If you think in term of ROI, the investment you use in your IDE will return sooner or later. Some of them are not trivial. For example Eclipse needs time to learn how to configure it. You must skill yourself into the IDE if you don’t want to lose your time developing (remember time = money). I’ve seen people programming PHP with notepad. You need at least syntax highlight, syntax error detection, auto-completion, auto-completion with code introspection and debugging. Don’t waste your time.

Digressing about working with old code, refactoring and scope creep.

Maybe there’re people who write code without bugs and never need to change one line of their source code. That’s not me. I try to improve my coding skill for the years. That means sometimes I need to face against my old code and if need to rewrite it probably I will do in a different way. I always feel the desire to refactor it. Refactor code is a good thing but is not always viable.Let’s show an example. Nowadays I’ve embraced Zend coding standard. For instance one not camelized variable creeps me out. But in my early days as a PHP developer (almost ten years ago) I didn’t take care about any coding standards. If code worked, it was OK. Now I realized that’s not enough. Code must work. Indeed!. But it must be ready to be changed, adapted to new needs and meet new requirements, and another developer must be able to understand it. Last days before holidays I’ve been working adapting a project to PHP5.3. It’s not a hard job. Some functions have disappeared, now we only have one kind of regular expressions and a couple of things more. I need to check a lot of lines of code. Sometimes I blush myself when I see the code I wrote five or even eight years ago. I want to change a lot of things. Refactor again and again but I must remember that’s not in the scope of the project. The objective of the project is clear: The application must work in a server with PHP5.3. If I start to refactor code the project deviates from project’s main scope. That’s a clear scope creep’s signal.

According with theory the main signals of scope creep are:

  • More work has been done than required
  • Product features don’t match the specifications.

Scope creep one of the most important problems in real projects. It’s very difficult to explain to someone that you will delay your project because you have decided to refactor some pieces of code (code that worked). That’s means your project will be delayed because you’ve decided to improve something that nobody ask for it. If you are on schedule maybe you can assume some refactor but think this kind of work is only viable if the triple constraint model (aka Scope + Budget + Schedule) keep unaltered. You must assess if those unsolicited changes have any impact in the project. Projects must end at some point. At some point you will need to submit the project’s deliverables, put your feet up and relax. But the temptation is big. I know.

Soy rico

Lunes 7:00. Suena el despertador. Normalmente cuando suena el despertador es el peor momento del día. Hoy encima me ha sentado especialmente mal (lunes, vacaciones recientes, …). Llego a la oficina, miro el correo y me encuentro con esto:


I am Kun Chun, a legal practitioner. A defunct client of mine, that bears the same last name as yours, passed away due a heart-related condition on January 12th 2005. His heart condition was as a result of the death of all the members of his kinsfolk in the tsunami disaster on the 26th December 2004 in Sumatra Indonesia.

I am contacting you to seek your consent to present you as a successor to my late client, who has a deposit of $19million. This will be executed under a legal arrangement that will protect you against any legal ramification. If this business proposition offends your moral values, do accept my apology.

I can be reached on: xxx@xxx.xx

Best regards,

Kun Chun

Pues eso: un pobre hombre se muere en el tsunami de Sumatra en el 2004. Ese pobre hombre (descanse en paz) se apellidaba igual que yo (mira tu que casualidad) por lo que paso a ser su sucesor heredando una fortuna de 19 millones de dólares (ole). Y yo sin saberlo. Menos mal que Kun Chun se ha percatado de ello y me lo hace saber mandandome un email.

Internet es genial. Hoy he ganado 19 millones de dólares sin hacer nada. Entiendo que al amigo Kun tendré que pagarle algo pero pida lo que pida se lo merecerá. Menos mal que este correo ha pasado el filtro antispam porque de otra manera no me habría enterado.


Acabo de recibir un correo con propaganda de un antivirus. Es una lástima que no use antivirus porque el producto tiene una pinta buenísima. Literal copiado del correo:

Máxima eficacia del mercado en detección de virus (99,65%).

Una eficacia ni mas ni menos del 99,65%. Nada del 99% ni de un mísero 99,5%. Me ofrece un 99,65%. No se como se calcula ese porcentaje pero tiene muy buena pinta. Hombre mejor seía un 99,73% o un 99,82% pero la verdad es que un 99,65% esta muy bien.

Ademas me dicen que el producto esta:

Basado en la tecnología del líder en detección de virus de [nombreDelAntivirus] Lab.

Es de agradecer. Parce que tienen un laboratorio dentro del cual tienen varias personas y me ofrecen la tecnología del lider de ellos. Nada del mas pardillo ni mas ni menos que del lider.

Y lo que mas me ha asombrado:

Escaneo continuo de e-mails y del tráfico de Internet.

Con un par. Escaneo continuo de todo el tráfico de internet.

En fín, es una pena que no use esos productos porque si no este antivirus seria mi primera opción. Estoy seguro casi al 99,65% de ello.

virus letal

He recibido un aviso muy importante:

Si recibes una llamada al móvil, y en la pantalla aparece INVIABLE con DOS signos de exclamación (‘!!’): NO DESCUELGUES EL TELÉFONO, NI INTENTES RENUNCIAR A LA LLAMADA. Déjalo sonar hasta que pare, y después borra directamente la llamada perdida. Se trata de un virus muy potente que destruye por completo el mecanismo del teléfono: cuando esto pasa es imposible arreglarlo o tratar de encontrar una solución al problema.

Esto me parece el no vas. No solo es el virus mas destructivo del mundo mundial, sino que además te impide tratar de buscar una solución al problema.

Que Dios nos pille confesados.

Cambio de Blog

Es oficial. Me paso de blogger a wordpress.
Empezé a usar bloggger no se muy bien porque. Es fácil de usar, un par de clicks y los tienes en marcha, pero cuando quise empezar a poner código fuente me encontré con problemillas:
Que si toca el template por aquí, que si cambia los css, … En fin que no me apetecía hacer hacking en una herramienta propietaria como blogger (que yo sepa no se publica el código fuente aunque las modificaciones de templates están documentadas). Así que me abrí una cuenta en wordpress. Había instalado y jugado un poco con wordpress hace tiempo y no me gustaba mucho, pero al descubrir que dan hosting gratis me lanzé a probarlo y no lo cambio por blogger ni en pintura. Ha mejorado mucho desde que lo por primera vez.

Después de hacer el arduo trabajo de migrar todos mis posts de blogger a mano (eran la desorbitante cifra de 4). Me doy cuenta que podía haberlo hecho semiautomático exportándolos en blogger e importándolos en wordpress. En fin que se le va a hacer.

Por cierto el código fuente queda monísimo sin tener que tocar nada.









Get every new post delivered to your Inbox.

Join 869 other followers