{"id":181,"date":"2019-07-11T16:50:14","date_gmt":"2019-07-11T22:50:14","guid":{"rendered":"https:\/\/www.great-white-software.com\/blog\/?p=181"},"modified":"2019-07-05T17:28:40","modified_gmt":"2019-07-05T23:28:40","slug":"coding-style","status":"publish","type":"post","link":"https:\/\/www.great-white-software.com\/blog\/2019\/07\/11\/coding-style\/","title":{"rendered":"Coding style"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Thomas Templemann <a href=\"http:\/\/blog.tempel.org\/2019\/06\/tts-generic-programming-guidelines.html\">wrote a nice blog post <\/a>about his preferred coding style guidelines.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And most I absolutely agree with.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Except one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">His suggested style is to test booleans simply for the value they hold and not to test for TRUE or FALSE explicitly. He considers testing for TRUE or FALSE bad style. Examples of bad style are :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if hidden = true then ... \/\/ bad style\nend if\nif hidden = false then ... \/\/ bad style\nend if<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Instead he suggests using good names and the following style<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if isHidden then ... \/\/ good style\nend if\nif not isHidden then ... \/\/ good style\nend if\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Personally I find that sometimes picking a &#8220;good name&#8221; so things read like an English sentence can be challenging and that any code you get from someone else may not adhere to the &#8220;good name&#8221; principle. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">As of late I&#8217;ve been working in a lot of code written in German. All the variable names, controls, etc are German. And so nothing reads well to me since I don&#8217;t read German. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">So I prefer a style like <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>if einigeWirklichSchrecklicheVariablennamen = true then ... \nend if\nif a\u8fd9\u513f\u6ca1\u6709\u53d1\u5e03\u53c2\u6570\u548c\u8fd4\u56de\u503c = false then ... \nend if<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">All this said whatever style you use stick to it and use it consistently throughout your code. Use Thomas&#8217;s if you like them and they work for use. Or <a href=\"https:\/\/www.bkeeneybriefs.com\/2014\/08\/naming-conventions-2\/\">those from BKeeney<\/a>. Or write your own set, try them out and work with them and tweak them until they make code easier to write AND easier to read and comprehend when you&#8217;ve been away from it for months at a time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Thomas Templemann wrote a nice blog post about his preferred coding style guidelines. And most I absolutely agree with. Except one. His suggested style is to test booleans simply for the value they hold and not to test for TRUE or FALSE explicitly. He considers testing for TRUE or FALSE bad style. Examples of bad &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.great-white-software.com\/blog\/2019\/07\/11\/coding-style\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Coding style&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[1],"tags":[26,3],"class_list":["post-181","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-coding-style","tag-xojo"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/181","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/comments?post=181"}],"version-history":[{"count":2,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/181\/revisions"}],"predecessor-version":[{"id":183,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/posts\/181\/revisions\/183"}],"wp:attachment":[{"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/media?parent=181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/categories?post=181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.great-white-software.com\/blog\/wp-json\/wp\/v2\/tags?post=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}