Making your application with dynamic debug options

Many times our client report that you had debug string into an application. This debug string could be printed array, values echo from database, database queries and many other things. Even in flex/javascript application client report that their are unnecessary alert that is coming in between. These are not actually a errors these are the development level debug messages which we mistaken unable to comment.

What is the solution to this common problem?

The day I realized that I can control this, I started using the concept. Thanks to my previous boss Kaushik Chatterjee who bring this forward for me. Concept is fairly very simple. Define a global level debug variable with default value 0. Following code will explain what I am trying to convince.

<script language=”javascript”>

var debug = 0;
function debugMessages(message)
function getUserName()
debugMessages(“I am in this function”);

Above code is pretty simple to understand the concept.

First line of code defines debug variable with value 0 i.e 0 disable/ 1 enable

function debugMessages is responsible for all debugging messages. All messages will route through this function. Inside this its checking whats the value of debug variable. If its true then show alert message or simply discard it. So you can kept the value of debug variable always true as and when working on the development version. At production level simply turn off this variable and there will be no extra debug alert/message in the application.

Applying smart use of this technique, we can achieve alot and stop client from complaining these silly points which we really dont mean too. Atleast it will remove one bug from your system as entered by client as a bug.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: