{"id":49,"date":"2016-03-11T06:49:14","date_gmt":"2016-03-11T06:49:14","guid":{"rendered":"http:\/\/lennycheng.com\/blog\/?p=49"},"modified":"2017-01-04T06:52:11","modified_gmt":"2017-01-04T06:52:11","slug":"systems-interfaces-as-goals-implementations","status":"publish","type":"post","link":"http:\/\/lennycheng.com\/blog\/2016\/03\/11\/systems-interfaces-as-goals-implementations\/","title":{"rendered":"Systems -> Interfaces as Goals -> Implementations"},"content":{"rendered":"<p><span class=\"transparent\">In the book How to Fail at Almost Everything and Still Win Big: Kind of the Story of My Life, author Scott Adams recommends thinking in terms of systems instead of goals. Adams defines a system as \u201csomething you do on a regular basis that increases your odds of happiness in the long run \u2026 [or] \u2026with a reasonable expectation that doing so will get you to a better place in your life\u201d (33) and a goal as \u201ca specific objective that you either achieve or don\u2019t sometime in the future \u2026 [or] \u2026 a reach-it-and-be-done situation\u201d (33). Adams provides an example of applying systems vs goals in finance: \u201cBuying undervalued companies and holding them forever, or at least until something major changes\u201d (34) is a system whereas buying \u201ca stock because they expect it to go up 20 percent in the coming year [is] a goal\u201d (34).<\/span><\/p>\n<p class=\"font_8\"><span class=\"transparent\">I think that thinking in terms of systems or goals in life is similar to thinking in terms of interface vs implementation in programming. A system is a general idea of what to accomplish whereas a goal is a specific action related to the general idea. We can also imagine systems to be loosely defined goals without a timeline, and goals as a concrete tasks that bring us closer to achieving systems. In programming-speak, goals are ways to implement systems. For example:<\/span><\/p>\n<ul>\n<li class=\"font_8\"><span class=\"transparent\">To become rich is a system; selling a business within the next two years, investing with a well-known firm, working hard for promotions, and purchasing real estate are goals that propel us to become rich<\/span><\/li>\n<li class=\"font_8\"><span class=\"transparent\">To become healthier is a system; exercising three times a week, sleeping 8 hours daily, and eating healthy breakfasts are goals to help ourselves become healthier<\/span><\/li>\n<li class=\"font_8\"><span class=\"transparent\">To inspire others through writing is a system; practicing writing daily and taking writing workshops monthly are goals that help us develop our motivational writing skills<\/span><\/li>\n<li class=\"font_8\"><span class=\"transparent\">To act professionally in business settings is a system; punctually arriving for meetings is a goal that increases our professionalism<\/span><\/li>\n<\/ul>\n<p><span class=\"transparent\">There are many ways to write the concrete implementations of an interface; likewise, there are many ways to achieve a goal. Different implementations may contain similar code &#8230;<\/span><\/p>\n<h4 class=\"font_8\"><span class=\"transparent\">Eg, in the base class, we can have the members: \u00a0<\/span><\/h4>\n<p class=\"font_8\"><span class=\"transparent\">\u00a0<\/span><span class=\"transparent\">public void Accelerate() <\/span><\/p>\n<pre class=\"font_8\"><span class=\"transparent\">{ <\/span>\r\n<span class=\"transparent\">\u00a0\u00a0\u00a0 int maxSpeed = 100; <\/span>\r\n<span class=\"transparent\">\u00a0\u00a0\u00a0 CallAbstractMethodToHandleMaxSpeed(maxSpeed); <\/span>\r\n<span class=\"transparent\">}<\/span><\/pre>\n<p class=\"font_8\"><span class=\"transparent\">\u00a0&#8230;and different goals may contain similar features (eg, if our goals were publishing books and writing magazines, accomplishing each requires writing at least an hour daily). Each implementation may be independent of each other; each goal may also be unrelated to each other, such as setting a goal for next week and setting a goal for five years from now. We can also imagine a system to be like the Builder pattern:<\/span><\/p>\n<h4 class=\"font_8\"><span class=\"transparent\">\u00a0In the director class:<\/span><\/h4>\n<p class=\"font_8\"><span class=\"transparent\">\u00a0<\/span><span class=\"transparent\">public void BecomeHealthier(HealthBuilder healthBuilder)<\/span><\/p>\n<pre class=\"font_8\"><span class=\"transparent\">{ <\/span>\r\n<span class=\"transparent\">\u00a0\u00a0\u00a0 healthBuilder.ExerciseThreeTimesAWeek();<\/span>\r\n<span class=\"transparent\">\u00a0\u00a0\u00a0 healthBuilder.SleepEightHoursDaily(); <\/span>\r\n<span class=\"transparent\">\u00a0\u00a0\u00a0 healthBuilder.EatHealthyBreakfast(); <\/span>\r\n<span class=\"transparent\">}<\/span><\/pre>\n<p class=\"font_8\"><span class=\"transparent\">\u00a0<\/span><\/p>\n<p class=\"font_8\"><span class=\"transparent\">And if we were realizing these goals simultaneously instead of calling the methods sequentially, we can call them in parallel!<\/span><\/p>\n<p class=\"font_8\"><span class=\"transparent\"><strong>\u00a0 Summary:<\/strong> We specify the general idea with an interface\/system and we provide ways of achieving that idea with concrete implementations\/goals.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the book How to Fail at Almost Everything and Still Win Big: Kind of the Story of My Life, author Scott Adams recommends thinking in terms of systems instead&#8230;<\/p>\n","protected":false},"author":1,"featured_media":50,"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\/49"}],"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=49"}],"version-history":[{"count":1,"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/posts\/49\/revisions"}],"predecessor-version":[{"id":51,"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/posts\/49\/revisions\/51"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/media\/50"}],"wp:attachment":[{"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/media?parent=49"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/categories?post=49"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/lennycheng.com\/blog\/wp-json\/wp\/v2\/tags?post=49"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}