{"id":211,"date":"2021-03-02T12:23:30","date_gmt":"2021-03-02T04:23:30","guid":{"rendered":"https:\/\/www.tonghin.com.my\/blog\/?p=211"},"modified":"2021-03-02T12:23:32","modified_gmt":"2021-03-02T04:23:32","slug":"variables-value-change-according-to-ready-to-pick","status":"publish","type":"post","link":"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/","title":{"rendered":"Variables Value Change According to &#8220;Ready To Pick&#8221;"},"content":{"rendered":"\n<p>In my implementation, Ready To Pick works as a signaling mechanism to let other module know when they could access the sub data in current module. As I working with Ready To Pick function previously, there is new implementation to add on upon clicks on Ready To Pick button. <br><br>First of all, in order to press &#8220;Ready To Pick&#8221;  or &#8220;Undo Ready To Pick&#8221;, we will select a data\/item set for example. In this item set, there is multiple list of item will it&#8217;s own attributes. Given <code><sub><sup>availableItem <\/sup><\/sub><\/code>and <code><sub><sup>standbyItem <\/sup><\/sub><\/code>as item&#8217;s attributes, new implementation is to alter value of attributes by incrementing or decrementing the value upon status of <code><sub><sup>isReadyToPick (bool)<\/sup><\/sub><\/code>. Implementation must alter all the value for each item available in item set adding\/subtracting <code><sub><sup>itemQuantity<\/sup><\/sub><\/code>.<br><br>i) Clicking &#8220;Ready To Pick&#8221; button when <code><sub><sup>isReadyToPick = false<\/sup><\/sub><\/code>, would change it to true and alter attributes value such as below:<br><code><sub><sup>foreach (item in itemSet)<br>{<br>item.availableItem -= item.itemQuantity;<br>item.standbyItem += item.itemQuantity;<br>}<\/sup><\/sub><\/code><br><br>ii) Clicking &#8220;Ready To Pick&#8221; button when <code><sub><sup>isReadyToPick = true<\/sup><\/sub><\/code>, would change it to false and alter attributes value such as below:<br><code><sub><sup>foreach (item in itemSet)<br>{<br>item.availableItem += item.itemQuantity;<br>item.standbyItem -= item.itemQuantity;<br>}<\/sup><\/sub><\/code><br>To avoid infinite increment or decrement, implementation is done in a transaction, to make sure the logic rollback if there is error. By using transaction, all value changes for <code><sub><sup>isReadyToPick(bool)<\/sup><\/sub><\/code>, <code><sub><sup>availableItem(int)<\/sup><\/sub><\/code>, <code><sub><sup>standbyItem(int)<\/sup><\/sub><\/code>, <code><sub><sup>itemQuantity(int)<\/sup><\/sub><\/code> will be reverted upon any update failure.<br><br>Few tests is done to assert value change of <code><sub><sup>availableItem(int)<\/sup><\/sub><\/code>, <code><sub><sup>standbyItem (int)<\/sup><\/sub><\/code>. Tests assertion pass after &#8220;Ready To Pick&#8221; button is triggered, the value of attributes add or subtract value of <code><sub><sup>itemQuantity<\/sup><\/sub><\/code>. <br><br>After the implementation done, I shall continue implementation logic for situation when <code><sub><sup>item.availableItem -= item.itemQuantity<\/sup><\/sub><\/code> appears to be negative value. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>In my implementation, Ready To Pick works as a signaling mechanism to let other module know when they could access the sub data in current module. As I working with Ready To Pick function previously, there is new implementation to add on upon clicks on Ready To Pick button. First of all, in order to &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Variables Value Change According to &#8220;Ready To Pick&#8221;&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[10,60],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v15.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Variables Value Change According to &quot;Ready To Pick&quot; | Tong Hin&#039;s Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Variables Value Change According to &quot;Ready To Pick&quot; | Tong Hin&#039;s Blog\" \/>\n<meta property=\"og:description\" content=\"In my implementation, Ready To Pick works as a signaling mechanism to let other module know when they could access the sub data in current module. As I working with Ready To Pick function previously, there is new implementation to add on upon clicks on Ready To Pick button. First of all, in order to &hellip; Continue reading &quot;Variables Value Change According to &#8220;Ready To Pick&#8221;&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/\" \/>\n<meta property=\"og:site_name\" content=\"Tong Hin&#039;s Blog\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-02T04:23:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-02T04:23:32+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data1\" content=\"2 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\",\"name\":\"TONG HIN MACHINERY\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"sameAs\":[\"https:\/\/www.youtube.com\/channel\/UC60EoxJMNbu8mV0LuEGfrBg\"],\"logo\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/wp-content\/uploads\/2020\/10\/web_logo_180_180.jpg\",\"width\":180,\"height\":180,\"caption\":\"TONG HIN MACHINERY\"},\"image\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#logo\"}},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Tong Hin&#039;s Blog\",\"description\":\"Sharing About Technology\",\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/www.tonghin.com.my\/blog\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/#webpage\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/\",\"name\":\"Variables Value Change According to \\\"Ready To Pick\\\" | Tong Hin&#039;s Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#website\"},\"datePublished\":\"2021-03-02T04:23:30+00:00\",\"dateModified\":\"2021-03-02T04:23:32+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/\",\"url\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/\",\"name\":\"Variables Value Change According to &#8220;Ready To Pick&#8221;\"}}]},{\"@type\":\"Article\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/#webpage\"},\"author\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/5c3ea1c3869fc5aace6be92e60cb5daa\"},\"headline\":\"Variables Value Change According to &#8220;Ready To Pick&#8221;\",\"datePublished\":\"2021-03-02T04:23:30+00:00\",\"dateModified\":\"2021-03-02T04:23:32+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/#webpage\"},\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#organization\"},\"keywords\":\"mvvm,transaction\",\"articleSection\":\"Experiential\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.tonghin.com.my\/blog\/2021\/03\/02\/variables-value-change-according-to-ready-to-pick\/#respond\"]}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#\/schema\/person\/5c3ea1c3869fc5aace6be92e60cb5daa\",\"name\":\"Ng Ching Onn\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/www.tonghin.com.my\/blog\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5124ba2323631ad4d512f46bd9c04829?s=96&d=mm&r=g\",\"caption\":\"Ng Ching Onn\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","_links":{"self":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/211"}],"collection":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/comments?post=211"}],"version-history":[{"count":5,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/211\/revisions"}],"predecessor-version":[{"id":242,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/posts\/211\/revisions\/242"}],"wp:attachment":[{"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/media?parent=211"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/categories?post=211"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tonghin.com.my\/blog\/wp-json\/wp\/v2\/tags?post=211"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}