Debugging trick – Conditional break point

One of the most important developer activities is debugging.
Imagine there are 1000 employees in a record and application is giving error for a particular employee lets say with name “prem”. Console error says its some time inside the loop where all the records are iterated. Generally people put a break point  before the error prone line number and watches the value to find out the state. If its linear flow its good but if it is the loop then one has to wait for ( worst case 1000, best case within 10 ) repetition to get to know the root cause.

Here comes the experience of developer and facility of tool IDE which is called as conditional break point. By doing the right click on break point one can the property of conditional break point. you just need to simple give the condition ,as in if clause ->  emp.getName().equals(“prem”). By virtue of this condition the code will break only when the employee name is “prem”. This will save a lot of time to watch and analyze all the names of employees manually to find out the buggy/error prone employee object “prem”.

In such cases previously i use to do System.out.println(), recompile and run app time and again. then before check in the code need to remove systemouts. Now I realize it was such a pain and when better tricks are available 😉

For more details to set conditional break point using Eclipse visit the below link:

One thought on “Debugging trick – Conditional break point

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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.