What I Have Learned About Clean and Easily Readable Coding

After being a part-time freelancing web developer, I have taken on a challenge of cleaning up some code for a project for a client.

secure-code

After being a part-time freelancing web developer, I have taken on a challenge of cleaning up some code for a project for a client. This web application which my client uses is huge, and the majority of it is spaghetti code thrown together in a few HTML pages to display information from the MySQL database.

I am currently making a few tough choices to start over, salvage as much of the code as possible, use a framework, to continue development with this current project.

Usually, I build a simple web application out of Zend Framework that allows the creation of a news articles, pages, and different tidbits of information. This case, sense the project was already completed and needs some more work done, I was called to do it.

I know I have just came into the problem of computer science education. We are taught the tools and techniques, but not the actual trade. Building a web application is a craft, one which is acquired through years of practice and experience.

Starting from scratch?

Do not do it, period. Whenever we start from scratch, we tend to make more mistakes or the same amount of them. Generally, we code our web applications to work, but we also overthink the majority of the process to extend the application further.

I will always recommend a framework to work off of . They have fixed the majority of security issues, performance-based code, and made our lives so much easier. There may be a few classes and files which you will have to rewrite for yourself, but that is minor work than building your own framework from scratch.

The first time when you code a web application, you know that you are beginner, so you are very conservative. The second time, you have experience. You actually know what you are doing, so you can go the full mile and make a masterpiece.

What have I learned?

First, I know the project is an already working code. I need to keep it working as I try some maintenance on it, add features, and fix issues.

Second, I have learned some valuable lessons and gained some more experience with:

  • Code without a plan is going to be a disaster.
  • There is way more to programming than just coding
  • Most issues are solved already with a known framework (Zend, Laravel, and CodeIgnitor)
  • Try not to rewrite code. There is no project if I spend time rewriting the whole code base.

The goals of my work, and what my skillsets include:

  • Clean up the code base little bit by bit during maintenance
  • No matter how bad the code is, it is working, so improve on it
  • Security first, performance second, design third
  • “If it isn’t broke, don’t fix it” motto
  • Fix security issues if there may be any

Method to my Madness

With this project, I am painfully debugging the code and making it more usable for the future. It is a huge mess, but one that can be worked on and fixed so it is not as bad for the next developer that comes along to work on it. I am trying deal with the ugliness of the code, but if I do have to touch the code, then it is to fix a bug or security issue.

Regardless of how pretty the code is, that isn’t everything that matters. All that really does matter that the code is working.

Advertisements


Categories: Programming

Tags: , , , , , ,

%d bloggers like this: