{"id":131,"date":"2020-02-10T02:28:08","date_gmt":"2020-02-10T02:28:08","guid":{"rendered":"http:\/\/spiderwiz.org\/project\/?p=131"},"modified":"2025-04-09T06:14:47","modified_gmt":"2025-04-09T06:14:47","slug":"code-encapsulation","status":"publish","type":"post","link":"https:\/\/spiderwiz.org\/project\/code-encapsulation\/","title":{"rendered":"Over the Hood \u2013 Ultimate code encapsulation with Spiderwiz"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Code encapsulation is the most useful  aspect of Object Oriented Programming. It allows to define specific functionality in one place, it bundles data with its functionality, it prevents unexpected modifications to object data by external code, and it facilitates cooperation between programmers working on the same project by letting them use each other\u2019s methods without knowing the object\u2019s internals.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Spiderwiz takes the encapsulation idea one giant step\nforward. Instead of code that is encapsulated in objects that refer to each\nother through methods, the interface is the objects themselves, strictly\nself-contained. A change in the object is broadcast when the object\u2019s <a href=\"http:\/\/spiderwiz.org\/apidocs\/org\/spiderwiz\/core\/DataObject.html#commit()\">commit()<\/a> method is called, and the change is\nhandled by implementing the object\u2019s <a href=\"http:\/\/spiderwiz.org\/apidocs\/org\/spiderwiz\/core\/DataObject.html#onEvent()\">onEvent()<\/a> method. The same object type can have\nmultiple functionalities, each of which is encapsulated in a different\nextension of the basic object.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Moreover, beyond encapsulating functionalities in objects,\nSpiderwiz facilitates the isolation of each object implementation in its own\nbuild unit. Build units interact with each other over a network in a way that\nis completely transparent to the programmers. Regardless of whether object\ninteraction is inter-process or inter-service, programmers would write exactly\nthe same code. For explanation how it works see our blog post <a href=\"http:\/\/spiderwiz.org\/project\/under-the-hood\/\">Lean and Mean\n\u2013 Under the Spiderwiz hood<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">All this implies that Spiderwiz is an ideal platform for\nbuilding systems of <em>microservices<\/em>\nthat interact in a service mesh. Actually, as every object\u2019s implementation can\nbe put in its own service, we can call them <em>nanoservices<\/em>.\nWhatever is the name, the measureless benefits to developers and system\nadministrators are apparent.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A nice demonstration of this concept can be found along our <a href=\"http:\/\/spiderwiz.org\/project\/tutorial\/\">Tutorial<\/a>. The scenario that interweaves its lessons is of a Chat system. We start by simple message broadcast, go through managing <em>chat rooms<\/em>, put in a <em>user registration<\/em> facility, add a <em>message archiving<\/em> feature, and conclude with a <em>bridge<\/em> that connects the system to another chat system that uses another technology. All is done by adding a service by service, barely touching the work of a lesson by the subsequent one, implementing each feature as a standalone building block, and putting it all together like when assembling a Lego construction.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Go ahead and see how programming is a joy when it is easy as a Lego toy<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Code encapsulation is the most useful aspect of Object Oriented Programming. Microservice mesh is the most efficient, stable and cooperative technology for applying code encapsulation. Spiderwiz takes encapsulation one giant step forward, while reducing microservices to nanoservices.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-blog"],"_links":{"self":[{"href":"https:\/\/spiderwiz.org\/project\/wp-json\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/spiderwiz.org\/project\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/spiderwiz.org\/project\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/spiderwiz.org\/project\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/spiderwiz.org\/project\/wp-json\/wp\/v2\/comments?post=131"}],"version-history":[{"count":9,"href":"https:\/\/spiderwiz.org\/project\/wp-json\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":1417,"href":"https:\/\/spiderwiz.org\/project\/wp-json\/wp\/v2\/posts\/131\/revisions\/1417"}],"wp:attachment":[{"href":"https:\/\/spiderwiz.org\/project\/wp-json\/wp\/v2\/media?parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/spiderwiz.org\/project\/wp-json\/wp\/v2\/categories?post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/spiderwiz.org\/project\/wp-json\/wp\/v2\/tags?post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}