Skip to content

Optimize Your Code

This blog is about optimizing software and application performance tuning

Cost vs risk of leaking code

Source code leaking or hogging resources is a nightmare for any organization and developers alike. Be it an application which crashes randomly due to unusually high memory consumption or any software which hogs CPU and starves other applications to death, these are perfect recipes for disaster for any organization.

Poorly written working code can often be far worse than non-functional code as it can lead to catastrophic side effects.  It is a double-edged sword as it not only eats up system resources and hampers its performance, at the same time it adds up an entry in terms of cost for problem determination, defect resolution, research, operational and support costs.

How costly is leaking code?

continue reading…

  • Share/Bookmark

Proof of concept will lead to a quality solution

Many projects will require a Proof of Concept as a tool that in some cases, will determine the ultimate fate of the project as a whole. While the POC can be useful and sometimes indispensable, it seldom should be seen as a sole judgment of the final proposed product. In other words, it has limitations and can only provide information that must be considered in combination with other factors.

The chief purpose of a POC should be to gain insight into the basic performance aspects and characteristics of a specific software concept. This should be looked at as one of several bits of information that can serve as a gauge for the overall feasibility of the proposed product. It is important to keep expectations of a Proof of Concept in line with what its true function is.

In the most general sense, it is a prototype that represents the capabilities or possibilities of a final product. In a manner of speaking, it is a scale model that attempts to prove that a theory can be transformed into a reality, but it should not be expected to have the same complete functionality. It does not have to perform the task, but should be only required to prove that the performance objectives are practical.

continue reading…

  • Share/Bookmark

Many developers do not realize the importance of understanding how Garbage Collection works in Java. Many books state that Java performs “Automatic Garbage Collection” which is unfortunately misunderstood and taken by granted for developers.

While it’s true that Java offers a very effective garbage collection technique, it is the duty of a programmer to ensure that their code does not hog memory and is free of memory leaks.

Why is Garbage Collection needed?

In real life, when a thing outlives its utility, we treat it as garbage/ trash. JVM follows a similar principle for source code. When an object is no longer referenced, its heap space can be freed and reused by new objects.

continue reading…

  • Share/Bookmark

Keep Important Software Simple

Designing software and solving design problems can often be a complicated process. However, in most cases, the habit of over-complicating can get out of hand.

Utilizing small, distinctively singular components simply results in a more manageable and sustainable product. Using the KISS (Keep Important Software Simple or also Keep It Simple, Stupid) principle in your design as a basic methodology will ultimately result in a better piece of software.

Ideally, well designed coding will be composed of a series of small and manageable parts that address the purpose of the software. Every decision should be geared toward providing value to the end user in the most efficient manner possible. Breaking down individual problems into distinct elements makes it easier to reach this goal.

continue reading…

  • Share/Bookmark

Fifa World Cup 2010

If you are a big soccer fan like me, you would be eagerly awaiting the start of the 2010 FIFA World Cup in South Africa. As this sporting extravaganza is due to start in less than two weeks from now, I hopped on to the 2010 FIFA World Cup website to check out the match schedule.

Much to my dismay, the website is very slow and certain pages take forever to load. Just to make sure that the culprit was not my internet connection, I decided to do a YSlow test on http://www.fifa.com/worldcup/.

The YSlow analysis is inline with my original observations on the website. FIFA World Cup is amongst the most widely viewed sporting events in the world. It surely deserves a better-performance website than the current one. So, why is the current site so slow? Or why are some websites slower than others in general? This detailed report walks through the relevant aspects of website performance optimization with the 2010 FIFA World Cup website as a case study.

continue reading…

  • Share/Bookmark
The DRY, or Don’t Repeat Yourself, principle is a software design concept that stresses the importance of not duplicating code. Besides the fact that

DRY - Don't repeat yourself.

duplication is waste, there are other maintainability and performance benefits to be gained by avoiding unnecessary redundancies.

Code repetition can be tempting, mainly because it sometimes appears to be the easiest way out. However, a copy and paste programming approach is a sure-fire way to create a tangled mess that can bring recurring nightmares. Every repetition brings with it the possibility of reducing ability for efficient adaptation and change. Additionally, changes in one part of the architecture can necessitate multiple changes in others as well.

Whether we like it or not, maintenance is central to all programming activities to some degree. It begins as soon as the first few lines of code are written and will likely be a factor for the lifetime of the product. Keeping a design clean and understandable can mean the difference between a system that excels and performs, or one that is mediocre and problematic.

continue reading…

  • Share/Bookmark

It’s a frustrating situation and all the aspirin in the world won’t make the headache go away. You have an existing, unique software product that can’t be

Confused? Rewrite today?!

easily replaced. However, you’ve found that you have reached the ceiling on extensibility and maintainability. Maybe the project platform is inflexible, resulting in severe portability or scalability issues. Performance and maintainability are something you only dream about and life is just no fun anymore.

It may be time to seriously consider a rewrite. Nobody likes the concept of throwing the baby out with the bath water and that really isn’t what rewriting is all about. It often just means having software that meets the functional requirements. Too many people equate rewrites with burning down City Hall in favour of some wild construction project that may or may not be completed in our lifetimes. In reality, sane people do it everyday, quickly and with excellent results.

There comes a time when everything becomes outdated or obsolete. Demands on a piece of software can also change rapidly and today’s configurations won’t always meet tomorrow’s requirements. Re-factoring of software has its limits. Sometimes, it simply can’t be repaired and must be rebuilt. All the same, this is not necessarily a bad thing.

continue reading…

  • Share/Bookmark

Do you see the dreaded ‘OutOfMemoryError’ while running your Java application? Does it crash every now and then? Does it have memory leaks? Is your

Memory leaks

application slowing down the operating system significantly? Is your application taking forever to execute? Developers are often left pondering over these questions while writing Java applications. So, what are memory leaks? What causes them? How can you fix them in your Java applications?

In the first post of this series, we walk you through the relevant details to understand memory leaks in Java. The later posts of this series will focus on how to detect and fix memory leaks in Java applications.

What are memory leaks?

continue reading…

  • Share/Bookmark
Excessive hardware for your software problem!?

Excessive hardware for your software problem!?

The first thought that crosses the minds of many when they experience performance problems, is that their machine lacks enough power for the job at hand. While this may be true in a handful of cases, the true culprit is likely to be in the application, rather than the hardware. A common initial reaction is to blame hardware for being too weak to perform its tasks. In reality, the cause of the difficulty might easily lie in problematic software that is eating more than its fair share of the pie.

Sadly, more than a few people are sucked into the idea of piling on more muscle in the form of memory, CPU upgrades and other new hardware solutions. This can be an expensive way to treat a symptom rather than cure the disease. Some IT managers are often too quick to jump to the conclusion that the system is not working hard enough, when in reality, the applications are simply asking it to do too much.

In most instances, optimization should be considered as a first line of defense against lagging performance issues. Very often, optimizing will clean up inefficiencies such as software interfaces and codes at much lower costs than equipment replacements. A single factor like an improper pre-compiled code or a loop unrolling issue might be the root cause of the troubles. The best and usually cheapest solution is to repair the real problem rather than covering it up with a stack of new devices.

continue reading…

  • Share/Bookmark
Breaking the performance barriers.

Breaking the performance barriers.

Are you looking to optimize your software? Have you conducted a performance tuning exercise on your source code before its deployed live? These are common questions in the software development industry and it’s unfortunate that many developers and organizations treat Software Optimization and Performance Tuning as synonyms.

I’ve seen these terms being used in place of each other on several websites be it tutorials or job descriptions. The truth is that software optimization and performance tuning are not the same.

Software Optimization is a much broader term than what most people believe it to be.  Optimization encompasses a wide variety of techniques, one of which is Performance Tuning. Let’s delve deeper into these concepts to understand how they differ from each other. continue reading…

  • Share/Bookmark

Optimize Your Code is Digg proof thanks to caching by WP Super Cache