{"id":28291,"date":"2017-12-23T11:08:54","date_gmt":"2017-12-23T09:08:54","guid":{"rendered":"https:\/\/mamchenkov.net\/wordpress\/?p=28291"},"modified":"2017-12-23T11:08:54","modified_gmt":"2017-12-23T09:08:54","slug":"defensive-programming-object-calisthenics","status":"publish","type":"post","link":"https:\/\/mamchenkov.net\/wordpress\/2017\/12\/23\/defensive-programming-object-calisthenics\/","title":{"rendered":"Defensive Programming : Object Calisthenics"},"content":{"rendered":"<!-- google_ad_section_start -->\n<p>I came across this nice and somewhat strongly opinionated video on <a href=\"https:\/\/en.wikipedia.org\/wiki\/Defensive_programming\">Defensive Programming<\/a>:<\/p>\n<div class=\"jetpack-video-wrapper\"><span class=\"embed-youtube\" style=\"text-align:center; display: block;\"><iframe loading=\"lazy\" class=\"youtube-player\" width=\"660\" height=\"372\" src=\"https:\/\/www.youtube.com\/embed\/8d2AtAGJPno?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-US&#038;autohide=2&#038;wmode=transparent\" allowfullscreen=\"true\" style=\"border:0;\" sandbox=\"allow-scripts allow-same-origin allow-popups allow-presentation allow-popups-to-escape-sandbox\"><\/iframe><\/span><\/div>\n<p>Marco Pivetta makes quite a few good points with I agree (and a few with which I disagree).\u00a0 One thing that he mentioned though I haven&#8217;t heard about &#8211; <a href=\"http:\/\/williamdurand.fr\/2013\/06\/03\/object-calisthenics\/\">Object Calisthenics<\/a>.\u00a0 Which turns out to be yet another set of rules and best practices for the object-oriented design and programming.\u00a0 Here are the rules to get you started:<\/p>\n<ol>\n<li>Only One Level Of Indentation Per Method<\/li>\n<li>Don\u2019t Use The ELSE Keyword<\/li>\n<li>Wrap All Primitives And Strings<\/li>\n<li>First Class Collections<\/li>\n<li>One Dot Per Line<\/li>\n<li>Don\u2019t Abbreviate<\/li>\n<li>Keep All Entities Small<\/li>\n<li>No Classes With More Than Two Instance Variables<\/li>\n<li>No Getters\/Setters\/Properties<\/li>\n<\/ol>\n<p>Read <a href=\"http:\/\/williamdurand.fr\/2013\/06\/03\/object-calisthenics\/\">the whole article<\/a> for explanations and examples.<\/p>\n<!-- google_ad_section_end -->\n","protected":false},"excerpt":{"rendered":"<!-- google_ad_section_start -->\n<p>I came across this nice and somewhat strongly opinionated video on Defensive Programming: Marco Pivetta makes quite a few good points with I agree (and a few with which I disagree).\u00a0 One thing that he mentioned though I haven&#8217;t heard about &#8211; Object Calisthenics.\u00a0 Which turns out to be yet another set of rules and &hellip; <a href=\"https:\/\/mamchenkov.net\/wordpress\/2017\/12\/23\/defensive-programming-object-calisthenics\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Defensive Programming : Object Calisthenics<\/span><\/a><\/p>\n<!-- google_ad_section_end -->\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"Defensive Programming : Object Calisthenics #WebDev #PHP #OOP #BestPractices","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"_links_to":"","_links_to_target":""},"categories":[1,18,62],"tags":[3069,3083,38,1908],"keyring_services":[],"class_list":["post-28291","post","type-post","status-publish","format-standard","hentry","category-general","category-programming","category-technology","tag-best-practices","tag-oop","tag-php","tag-youtube-videos"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":27291,"url":"https:\/\/mamchenkov.net\/wordpress\/2017\/02\/05\/defensive-bash-programming\/","url_meta":{"origin":28291,"position":0},"title":"Defensive BASH Programming","author":"Leonid Mamchenkov","date":"February 5, 2017","format":false,"excerpt":"If you write any Bash code that lasts more than a day, you should definitely read \"Defensive BASH Programming\" and follow the advice, if you haven't already. \u00a0It covers the following: Immutable global variables Everything is local main() Everything is a function Debugging functions Code clarity Each line does just\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":28490,"url":"https:\/\/mamchenkov.net\/wordpress\/2018\/04\/18\/wordpress-plugin-boilerplate-a-standardized-organized-object-oriented-foundation-for-building-high-quality-wordpress-plugins\/","url_meta":{"origin":28291,"position":1},"title":"WordPress Plugin Boilerplate &#8211; a standardized, organized, object-oriented foundation for building high-quality WordPress Plugins","author":"Leonid Mamchenkov","date":"April 18, 2018","format":false,"excerpt":"WordPress is an excellent system for a whole lot of different projects and needs.\u00a0 It's widely used, fast, and flexible.\u00a0 However it does show its age in many ways.\u00a0 One of the areas where things could be a lot better and simpler is the WordPress plugin development. WordPress plugins are\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":17764,"url":"https:\/\/mamchenkov.net\/wordpress\/2013\/02\/18\/ten-things-i-hate-about-object-oriented-programming\/","url_meta":{"origin":28291,"position":2},"title":"Ten Things I Hate About Object-Oriented Programming","author":"Leonid Mamchenkov","date":"February 18, 2013","format":"link","excerpt":"Ten Things I Hate About Object-Oriented Programming Apparently I\u2019m not the only one. In the immortal words of Edsger Dijkstra: \"Object-oriented programming is an exceptionally bad idea which could only have originated in California.\"","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":7882,"url":"https:\/\/mamchenkov.net\/wordpress\/2004\/09\/09\/object-oriented-programming-concepts\/","url_meta":{"origin":28291,"position":3},"title":"Object-oriented programming concepts","author":"Leonid Mamchenkov","date":"September 9, 2004","format":false,"excerpt":"Here is a nice (as in short and simple) tutorial on object-oriented programming concepts. It touches only briefly and a few concepts: objects, class, message, inheritance, and interface. There is a practical part based on Java. And that's about it. Studying this tutorial will not make you an OOP expert\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":9617,"url":"https:\/\/mamchenkov.net\/wordpress\/2005\/10\/28\/daily-del-icio-us-bookmarks\/","url_meta":{"origin":28291,"position":4},"title":"Daily del.icio.us bookmarks","author":"Leonid Mamchenkov","date":"October 28, 2005","format":false,"excerpt":"Shared bookmarks for del.icio.us user tvset on 2005-10-27 The Object Oriented Programming Web -- Programming and Computer Science Tutorials, Lecture notes and online books Tagged as: algorithms books development programming tutorials Dictionary of Algorithms and Data Structures Tagged as: algorithm algorithms computers concepts data development dictionary documentation education engineering howto\u2026","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":16628,"url":"https:\/\/mamchenkov.net\/wordpress\/2012\/08\/16\/geek-and-poke-teaching-object-orientation\/","url_meta":{"origin":28291,"position":5},"title":"Geek And Poke : Teaching Object Orientation","author":"Leonid Mamchenkov","date":"August 16, 2012","format":"image","excerpt":"Via Geek and Poke. \u00a0","rel":"","context":"In &quot;All&quot;","block_context":{"text":"All","link":"https:\/\/mamchenkov.net\/wordpress\/category\/general\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2012\/08\/OOP.jpg?fit=800%2C1132&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2012\/08\/OOP.jpg?fit=800%2C1132&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2012\/08\/OOP.jpg?fit=800%2C1132&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/mamchenkov.net\/wordpress\/wp-content\/uploads\/2012\/08\/OOP.jpg?fit=800%2C1132&ssl=1&resize=700%2C400 2x"},"classes":[]}],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/28291","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/comments?post=28291"}],"version-history":[{"count":0,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/posts\/28291\/revisions"}],"wp:attachment":[{"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/media?parent=28291"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/categories?post=28291"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/tags?post=28291"},{"taxonomy":"keyring_services","embeddable":true,"href":"https:\/\/mamchenkov.net\/wordpress\/wp-json\/wp\/v2\/keyring_services?post=28291"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}