{"id":1826,"date":"2009-04-07T07:23:02","date_gmt":"2009-04-07T07:23:02","guid":{"rendered":"http:\/\/justthesam.com\/2009\/04\/netbeans-autoformatting\/"},"modified":"2009-04-07T07:23:02","modified_gmt":"2009-04-07T07:23:02","slug":"netbeans-autoformatting","status":"publish","type":"post","link":"https:\/\/justthesam.com\/?p=1826","title":{"rendered":"NetBeans&#8217; Auto-formatting"},"content":{"rendered":"<div>I&#39;ve endeavoured to rely on NetBeans&#39; auto-formatting feature before now, but I&#39;ve never been able to configure it quite to my tastes. In particular I had struggled to get rules for braces and line wrapping setup how I wanted for Java, with them almost always on a new line. I&#39;m not sure whether I had simply failed to find the right options or if they&#39;re new in 6.5.1 or another recent release.<\/div>\n<p><\/p>\n<div>It&#39;s perfect for cleaning up code that you&#39;re copying and pasting from the web, taking the labour out of it. All I need now in NetBeans is a less&#0160;tedious way of generating getters and setters that requires less mouse clicks, remembers your last preferences (put at end of file, no comments) and can have m_ prefix on the vars but not the accessor method names.<\/div>\n<p><\/p>\n<div>That said, better still would be for Java to grow up a bit and gain a better way to do boiler plate accessors. Which is better:<\/div>\n<p><\/p>\n<div>Java:<\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\"><br \/><\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">public int getFoo()<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">{<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">&#0160;&#0160;return m_foo;<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">}<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\"><br \/><\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">public void setFoo(value)<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">{<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">&#0160;&#0160;m_foo = value;<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">}<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\"><br \/><\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">public String getBar()<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">{<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">&#0160;&#0160;return m_bar;<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">}<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\"><br \/><\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">public void setBar(value)<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">{<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">&#0160;&#0160;m_bar = value;<\/span><\/span><\/div>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">}<\/span><\/span><\/div>\n<p><\/p>\n<div>Ruby:<\/div>\n<p><\/p>\n<div><span style=\"font-size: 12px; \"><span style=\"font-family: Courier;\">attr_accessor :foo, :bar<\/span><\/span><\/div>\n","protected":false},"excerpt":{"rendered":"<p>I&#39;ve endeavoured to rely on NetBeans&#39; auto-formatting feature before now, but I&#39;ve never been able to configure it quite to my tastes. In particular I had struggled to get rules for braces and line wrapping setup how I wanted for Java, with them almost always on a new line. I&#39;m not sure whether I had [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,23,33],"tags":[],"class_list":["post-1826","post","type-post","status-publish","format-standard","hentry","category-programming","category-ruby","category-webtech"],"_links":{"self":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/posts\/1826","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1826"}],"version-history":[{"count":0,"href":"https:\/\/justthesam.com\/index.php?rest_route=\/wp\/v2\/posts\/1826\/revisions"}],"wp:attachment":[{"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1826"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1826"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/justthesam.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1826"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}