{"id":722,"date":"2013-04-24T11:04:39","date_gmt":"2013-04-24T09:04:39","guid":{"rendered":"http:\/\/www.pellissier.co.za\/hermien\/?p=722"},"modified":"2013-04-24T11:06:51","modified_gmt":"2013-04-24T09:06:51","slug":"getting-more-out-of-the-debugger","status":"publish","type":"post","link":"https:\/\/www.pellissier.co.za\/hermien\/?p=722","title":{"rendered":"Getting More out of the Debugger"},"content":{"rendered":"<p>The NetBeans IDE&#8217;s debugging tools is one of maybe the top 5 features that I simply cannot live without! And as you can imagine, debugging is something I do quite regularly. So I was rather surprised when I only recently discovered an AWESOME feature that has been around for a long, long time. \ud83d\ude42 This feature is Variable Formatters.<\/p>\n<p>To explain what a Variable Formatter is, some context is required. So lets have a look at the Variables window while debugging a very simple little Java application.<\/p>\n<figure id=\"attachment_724\" aria-describedby=\"caption-attachment-724\" style=\"width: 672px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger01.png\"><img loading=\"lazy\" class=\"size-full wp-image-724\" alt=\"Variables Window\" src=\"http:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger01.png\" width=\"682\" height=\"593\" srcset=\"https:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger01.png 682w, https:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger01-300x260.png 300w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><\/a><figcaption id=\"caption-attachment-724\" class=\"wp-caption-text\">Variables Window<\/figcaption><\/figure>\n<p>That is a pretty useful view. I can see all the variables that I could possibly need at a glance. (Of course, that is easy with an application this simple.) Of interest to this particular discussion, however, is the Value column. Notice how the various types have different string representations that are displayed. Now lets create a simple class called SomeObject:<\/p>\n<p>[java]public class SomeObject {<\/p>\n<p>    private String var1;<br \/>\n    private String var2;<\/p>\n<p>    public SomeObject(String var1, String var2) {<br \/>\n        this.var1 = var1;<br \/>\n        this.var2 = var2;<br \/>\n    }<\/p>\n<p>    public String getVar2() {<br \/>\n        return var2;<br \/>\n    }<br \/>\n}[\/java]<\/p>\n<p>and create an ArrayList filled with SomeObjects, to inspect in the debugger:<\/p>\n<figure id=\"attachment_727\" aria-describedby=\"caption-attachment-727\" style=\"width: 672px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger02.png\"><img loading=\"lazy\" class=\"size-full wp-image-727\" alt=\"ArrayList in the Variables Window\" src=\"http:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger02.png\" width=\"682\" height=\"279\" srcset=\"https:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger02.png 682w, https:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger02-300x122.png 300w\" sizes=\"(max-width: 682px) 100vw, 682px\" \/><\/a><figcaption id=\"caption-attachment-727\" class=\"wp-caption-text\">ArrayList in the Variables Window<\/figcaption><\/figure>\n<p>Each of the elements in the list can of course be expanded to see the details. But what if you were looking for a specific element in a very long list? The great news is, that Variable Formatters allows us to customise how these items are displayed! From the main menu, select Tools &gt; Options. Choose the Java page, and then the Java Debugger tab, Variable Formatters category.<\/p>\n<figure id=\"attachment_729\" aria-describedby=\"caption-attachment-729\" style=\"width: 756px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger03.png\"><img loading=\"lazy\" class=\"size-full wp-image-729\" alt=\"Variable Formatters options\" src=\"http:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger03.png\" width=\"766\" height=\"652\" srcset=\"https:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger03.png 766w, https:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger03-300x255.png 300w\" sizes=\"(max-width: 766px) 100vw, 766px\" \/><\/a><figcaption id=\"caption-attachment-729\" class=\"wp-caption-text\">Variable Formatters options<\/figcaption><\/figure>\n<p>A number of formatters are already specified, but we can add a custom one:<\/p>\n<figure id=\"attachment_730\" aria-describedby=\"caption-attachment-730\" style=\"width: 584px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger04.png\"><img loading=\"lazy\" class=\"size-full wp-image-730\" alt=\"Custom Formatter\" src=\"http:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger04.png\" width=\"594\" height=\"568\" srcset=\"https:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger04.png 594w, https:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger04-300x286.png 300w, https:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger04-24x24.png 24w\" sizes=\"(max-width: 594px) 100vw, 594px\" \/><\/a><figcaption id=\"caption-attachment-730\" class=\"wp-caption-text\">Custom Formatter<\/figcaption><\/figure>\n<p>And very impressively, it gets applied immediately when you click OK on the options dialog! Even while the debugger is running! Now the display looks like this:<\/p>\n<figure id=\"attachment_731\" aria-describedby=\"caption-attachment-731\" style=\"width: 673px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger05.png\"><img loading=\"lazy\" class=\"size-full wp-image-731\" alt=\"Customised Display\" src=\"http:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger05.png\" width=\"683\" height=\"279\" srcset=\"https:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger05.png 683w, https:\/\/www.pellissier.co.za\/hermien\/wp-content\/uploads\/sites\/2\/2013\/04\/debugger05-300x122.png 300w\" sizes=\"(max-width: 683px) 100vw, 683px\" \/><\/a><figcaption id=\"caption-attachment-731\" class=\"wp-caption-text\">Customised Display<\/figcaption><\/figure>\n<p>Suddenly ANY type of variable can have a user friendly, and customised, presentation in the variables window!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The NetBeans IDE&#8217;s debugging tools is one of maybe the top 5 features that I simply cannot live without! And as you can imagine, debugging is something I do quite regularly. So I was rather surprised when I only recently discovered an AWESOME feature that has been around for a long, long time. \ud83d\ude42 This &#8230; <a title=\"Getting More out of the Debugger\" class=\"read-more\" href=\"https:\/\/www.pellissier.co.za\/hermien\/?p=722\" aria-label=\"More on Getting More out of the Debugger\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[3,4],"tags":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1v8WL-bE","_links":{"self":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/722"}],"collection":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=722"}],"version-history":[{"count":7,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/722\/revisions"}],"predecessor-version":[{"id":733,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=\/wp\/v2\/posts\/722\/revisions\/733"}],"wp:attachment":[{"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pellissier.co.za\/hermien\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}