{"id":46,"date":"2016-03-04T06:45:18","date_gmt":"2016-03-04T06:45:18","guid":{"rendered":"http:\/\/lennycheng.com\/blog\/?p=46"},"modified":"2017-01-04T06:48:37","modified_gmt":"2017-01-04T06:48:37","slug":"decoupling-in-programming-and-in-life","status":"publish","type":"post","link":"http:\/\/lennycheng.com\/blog\/2016\/03\/04\/decoupling-in-programming-and-in-life\/","title":{"rendered":"Decoupling in Programming and in Life"},"content":{"rendered":"<p><span class=\"transparent\"><strong>Disclaimer:<\/strong> Although I\u2019ve studied basic design patterns and will soon be studying refactoring techniques, I am not an expert on software engineering (yet). This article represents some of my current thoughts about decoupling architectures and they may not be fully accurate. If you disagree with me, I would be more than happy to hear your thoughts and make improvements to this article.<\/span><\/p>\n<p><span class=\"transparent\">To decouple is to separate something from something else *. We can decouple a car\u2019s steering wheel from the car by removing its steering wheel; we can decouple one segment of a railway track from another by forcing a space between the two tracks; we can decouple the lenses on glasses from their frames by taking the lenses off. In the previous examples, decoupling seemed to be counterproductive because it broke the car, the railway track, and the glasses.<\/span><\/p>\n<p class=\"font_8\"><span class=\"transparent\">In programming, to decouple is to do good\u2026is to make components independent of each other\u2026is to design scalable architecture. But wait, if a program\u2019s components are independent of each other<\/span><\/p>\n<ol>\n<li class=\"font_8\"><span class=\"transparent\">How can the program even work correctly?<\/span><\/li>\n<li><span class=\"transparent\">Why does it make the architecture scalable?<\/span><\/li>\n<\/ol>\n<p class=\"font_8\"><span class=\"transparent\">There is word play on the meaning of \u201cindependent\u201d. Here, independent components can still have relationships with other components but compared to dependent components, we can more easily modify them to achieve a new goal without needing to modify nearby components. A decoupled or loosely coupled program\u2019s architecture often contains many independent components that work together and when we modify the program (I use \u201cwhen\u201d instead of \u201cif\u201d because software continuously changes) to fulfill new requirements, we change as few selective components as possible instead of many components. The modified program\u2019s general architecture and the relationships between its components would remain similar to the original program\u2019s.<\/span><\/p>\n<p class=\"font_8\"><span class=\"transparent\">The opposite of a decoupled or loosely coupled program is a coupled program. A coupled program&#8217;s components are heavily reliant upon one another and therefore, modifying the program to achieve a new goal involves modifying many intermingled components.<\/span><\/p>\n<p class=\"font_8\"><span class=\"transparent\">There are several advantages to building decoupled or loosely coupled programs instead of coupled programs. We can:<\/span><\/p>\n<ul>\n<li class=\"font_8\"><span class=\"transparent\">quickly add enhancements to the program, including new features for sudden requirement changes <\/span><\/li>\n<li class=\"font_8\"><span class=\"transparent\">m<\/span><span class=\"transparent\">ore easily debug the program<\/span><\/li>\n<li class=\"font_8\"><span class=\"transparent\">more readily envision the big picture\/abstractions in addition to the implementations<\/span><\/li>\n<li class=\"font_8\"><span class=\"transparent\">gain greater insights into how the program works<\/span><\/li>\n<li class=\"font_8\"><span class=\"transparent\">continuously make the program scalable<\/span><\/li>\n<li class=\"font_8\"><span class=\"transparent\">greatly enjoy developing and testing the program!<\/span><\/li>\n<\/ul>\n<p><span class=\"transparent\">Sometimes, we can apply programming principles to our daily lives by approaching situations with decoupled mindsets. The keyword is \u201csometimes\u201d. I\u2019m certainly not advocating decoupling our relationships; it\u2019s healthy to be interdependent with each other! However, we can decouple our confidence levels from our accomplishments: what we have done is different from our personalities and one doesn\u2019t need to depend upon another. We can also decouple our physical possessions from our self-image: where there is sufficient risk, never risk your life just to save a bank account. In addition, we can decouple what we want to do, our personal goals, from what other people want us to do: pursuing a goal because we believe it is intrinsically meaningful is way more fun than pursuing it because someone says we should pursue it.<\/span><\/p>\n<p><span class=\"transparent\">Building programs with decoupled or loosely coupled components is advantageous for our code! At times, thinking with decoupled or loosely coupled mindsets is advantageous for ourselves!<\/span><\/p>\n<p>_______________________________________<br \/>\n* <span class=\"transparent\">Oppositely, to couple is to be together, such as a couple!<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Disclaimer: Although I\u2019ve studied basic design patterns and will soon be studying refactoring techniques, I am not an expert on software engineering (yet). This article represents some of my current&#8230;<\/p>\n","protected":false},"author":1,"featured_media":47,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/posts\/46"}],"collection":[{"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/comments?post=46"}],"version-history":[{"count":2,"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/posts\/46\/revisions"}],"predecessor-version":[{"id":548,"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/posts\/46\/revisions\/548"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/media\/47"}],"wp:attachment":[{"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/media?parent=46"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/categories?post=46"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/tags?post=46"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}