{"id":63,"date":"2016-08-30T20:24:47","date_gmt":"2016-08-31T00:24:47","guid":{"rendered":"http:\/\/langstonsoftware.com\/?p=63"},"modified":"2016-09-21T10:44:54","modified_gmt":"2016-09-21T14:44:54","slug":"why-resharper-code-formatting","status":"publish","type":"post","link":"https:\/\/langstonsoftware.com\/2016\/08\/30\/why-resharper-code-formatting\/","title":{"rendered":"Why Resharper? Code Formatting"},"content":{"rendered":"
While Visual Studio is often made fun of for being bloated, and has more functionality than a single developer could hope to create in a career, it still has a few missing features. This is where Resharper from JetBrains steps in.<\/p>\n
In particular today I want to talk about just one feature Resharper has, and many developers don’t use, to both their own and their team’s detriment. Consider this post both overview and entreaty to those who don’t use this feature.<\/p>\n
That feature is automatic code formatting.<\/p>\n
Visual Studio by default tries to give you a lot of automatic code completion and indention. One of the simplest things it won’t do however, it break your lines as you write large statements. LINQ practically becomes unreadable as variable names become larger and conditionals become more complicated. Methods and constructors that take a large number of arguments become unwieldy. While you can and should tackle these problems with factoring out new methods and variables to contain their incidental complexity, sometimes you just need to see how the brick is made inline.<\/p>\n
You can apply automatic code formatting across a whole solution, a file, or as I often do in existing projects, just the hairiest parts of the code you are working on that day. In order to really get the most of your code formatting, you should configure the options to match your team’s coding guidelines, and then save those options in the repository so that they can be picked up automatically both other developer’s Resharper installations. You have these formatting changes be applied silently after you’ve set them up, removing the need to go thru the wizard on each run.<\/p>\n
Some settings I particularly suggest you look at are those that handle those automatic breaks after opening a new block or method argument list. Having these being treated more consistently make reviewing changes much more palatable in a diff tool. I’m also a fan of creating automatic breaks in long chained method calls, ternary operators, or string concatenations, keeping operators at the beginning of lines, letting the human reader front load the meaning of any given line. These are just calls made from personal experience. One of my favorite programming books, Code Complete 2, backs many of these positions. While many development coding guidelines might be based on terminal interfaces, it turns out there are plenty of reasons based in science on why humans can’t read lines over 80 characters very well, especially when those lines are full of difficult mathematical logic.<\/p>\n
I hope this has whet your appetite for nicely presented code in your projects. Luckily Resharper is the utensil you need to cut into this problem. If you’ve already installed Resharper, or this post has convinced you to try it out, please let me know how your experience with code formatting goes in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"
While Visual Studio is often made fun of for being bloated, and has more functionality than a single developer could hope to create in a career, it still has a few missing features. This is where Resharper from JetBrains steps in. In particular today I want to talk about just one feature Resharper has, and …<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false},"version":2}},"categories":[10],"tags":[],"class_list":["post-63","post","type-post","status-publish","format-standard","hentry","category-tools"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6Os38-11","_links":{"self":[{"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/posts\/63"}],"collection":[{"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/comments?post=63"}],"version-history":[{"count":1,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/posts\/63\/revisions"}],"predecessor-version":[{"id":64,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/posts\/63\/revisions\/64"}],"wp:attachment":[{"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/media?parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/categories?post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/langstonsoftware.com\/wp-json\/wp\/v2\/tags?post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}