{"id":8299,"date":"2021-03-31T22:41:00","date_gmt":"2021-03-31T20:41:00","guid":{"rendered":"https:\/\/monodes.com\/predaelli\/?p=8299"},"modified":"2021-03-31T10:08:19","modified_gmt":"2021-03-31T08:08:19","slug":"design-by-contract-in-a-spreadsheet","status":"publish","type":"post","link":"https:\/\/monodes.com\/predaelli\/2021\/03\/31\/design-by-contract-in-a-spreadsheet\/","title":{"rendered":"Design by contract in a spreadsheet!"},"content":{"rendered":"<p>Today I wanted to format a boolean value in a spreadsheet so that true values are shown as &#8220;S\u00ec&#8221; and false as &#8220;No&#8221; (italian words for &#8220;yes&#8221; and &#8220;no&#8221;). I was easy as <a href=\"https:\/\/ask.libreoffice.org\/en\/users\/62369\/librelive\/\">librelive<\/a> describe in <em><a href=\"https:\/\/ask.libreoffice.org\/en\/question\/70835\/change-boolean-to-yesno-instead-of-truefalse\/\">Change Boolean to Yes\/No instead of True\/False &#8211; Ask LibreOffice<\/a><\/em><\/p>\n<blockquote><p>i suggest basically the same as <code class=\"\" data-line=\"\">m.a.riosv<\/code> wrote, but a little better:<\/p>\n<p>in <code class=\"\" data-line=\"\">format cells<\/code> dialogue fill <code class=\"\" data-line=\"\">format code<\/code> input with the following:<\/p>\n<p><code class=\"\" data-line=\"\">[=1]&quot;Yes&quot;;[=0]&quot;No&quot;;General<\/code> &#8211; this means it will be <code class=\"\" data-line=\"\">yes<\/code> on <code class=\"\" data-line=\"\">true<\/code>\/<code class=\"\" data-line=\"\">1<\/code> values, <code class=\"\" data-line=\"\">no<\/code> on <code class=\"\" data-line=\"\">false<\/code>\/<code class=\"\" data-line=\"\">0<\/code> values and will use <code class=\"\" data-line=\"\">general<\/code> format otherwise.<\/p>\n<p>one may even use the following string to format it as <code class=\"\" data-line=\"\">\u2713<\/code>\/<code class=\"\" data-line=\"\">\u2717<\/code> instead of <code class=\"\" data-line=\"\">yes<\/code>\/<code class=\"\" data-line=\"\">no<\/code> and color differentiation: <code class=\"\" data-line=\"\">[GREEN][=1]&quot;\u2713&quot;;[RED][=0]&quot;\u2717&quot;;[BLUE]General;[BLUE]@<\/code><\/p>\n<p><a href=\"https:\/\/ask.libreoffice.org\/en\/question\/70835\/change-boolean-to-yesno-instead-of-truefalse\/\"><img data-recalc-dims=\"1\" decoding=\"async\" class=\"alignnone size-full\" src=\"https:\/\/i0.wp.com\/monodes.com\/predaelli\/wp-content\/uploads\/sites\/4\/2021\/03\/1557951744380523.png?w=910&#038;ssl=1\" alt=\"\"\/><\/a><\/p>\n<p>this works on libreoffice calc v6.1.5.2 for ubuntu &#8211; i&#8217;ve tested<\/p>\n<p>i call it &#8220;a little bit better&#8221; solution because it implements <code class=\"\" data-line=\"\">design by contract<\/code> pattern, i.e. if for some unexpected reason the value will be something else than a boolean, then it will be displayed as usual, and not hidden, thus hiding a possible error in design!<\/p><\/blockquote>\n<p>But the real gem is finding a reference to <strong>design by contract!<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\">Today I wanted to format a boolean value in a spreadsheet so that true values are shown as &#8220;S\u00ec&#8221; and false as &#8220;No&#8221; (italian words for &#8220;yes&#8221; and &#8220;no&#8221;). I was easy as librelive describe in Change Boolean to Yes\/No instead of True\/False &#8211; Ask LibreOffice i suggest basically the same as m.a.riosv wrote, but&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/monodes.com\/predaelli\/2021\/03\/31\/design-by-contract-in-a-spreadsheet\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":"","jetpack_publicize_message":"","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}},"categories":[34,278],"tags":[],"class_list":["post-8299","post","type-post","status-publish","format-standard","hentry","category-eiffel","category-tricks"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p6daft-29R","jetpack-related-posts":[{"id":6318,"url":"https:\/\/monodes.com\/predaelli\/2019\/12\/15\/eiffels-conditional-expressions\/","url_meta":{"origin":8299,"position":0},"title":"Eiffel&#8217;s conditional expressions","author":"Paolo Redaelli","date":"2019-12-15","format":false,"excerpt":"The ternary conditional operator is a short-hand method for writing an if\/else statement. Does Python Have a Ternary Conditional Operator? Yes, it does. This remids me that Eiffel, at least \"ISE Eiffel\" does actually have conditional expressions that are the same: answer := if time < noon then \"Good morning\"\u2026","rel":"","context":"In &quot;Eiffel&quot;","block_context":{"text":"Eiffel","link":"https:\/\/monodes.com\/predaelli\/category\/eiffel\/"},"img":{"alt_text":"Jonathan Hsu","src":"https:\/\/i0.wp.com\/miro.medium.com\/fit\/c\/58\/58\/2%2A_KGzadiy9s83D4vzhsCyyg.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":8615,"url":"https:\/\/monodes.com\/predaelli\/2022\/05\/30\/let-the-compiler-dispose-of-an-expanded-value\/","url_meta":{"origin":8299,"position":1},"title":"Let the compiler dispose of an expanded value","author":"Paolo Redaelli","date":"2022-05-30","format":false,"excerpt":"Note: I wrote this notes on august 2021, but I shall publish them now in the state thay are otherwise I will lose memory of their existence yet another time... Lately I discovered that Liberty Eiffel needs expanded classes to be DISPOSABLE to get rid of a garbage collector like\u2026","rel":"","context":"In &quot;Senza categoria&quot;","block_context":{"text":"Senza categoria","link":"https:\/\/monodes.com\/predaelli\/category\/senza-categoria\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3971,"url":"https:\/\/monodes.com\/predaelli\/2018\/04\/01\/sheer-pure-evil\/","url_meta":{"origin":8299,"position":2},"title":"Sheer, pure evil","author":"Paolo Redaelli","date":"2018-04-01","format":false,"excerpt":"JavaScript: Can (a==1 && a==2 && a==3) ever evaluate to true?\u00a0Yes, it can. Understand how in this article! That's pure sheer evil, in my humble opinion as it tricks most people. Eiffel forbids this evilness, but I shall explain it better. Recently, an interesting code snippet has been making the\u2026","rel":"","context":"In &quot;Documentations&quot;","block_context":{"text":"Documentations","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":5544,"url":"https:\/\/monodes.com\/predaelli\/2019\/05\/04\/firefox-disabled-all-add-ons-because-a-certificate-expired\/","url_meta":{"origin":8299,"position":3},"title":"Firefox disabled all add-ons because a certificate expired","author":"Paolo Redaelli","date":"2019-05-04","format":"link","excerpt":"Oh my! Firefox disabled all add-ons because a certificate expired Well, only those who do nothing do not make mistakes. Here's a quick workaround: For now, there is at least one workaround, but it only applies if you're using the Firefox Developer or Nightly build. If you look under \"about:config\"\u2026","rel":"","context":"In &quot;Documentations&quot;","block_context":{"text":"Documentations","link":"https:\/\/monodes.com\/predaelli\/category\/documentations\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2233,"url":"https:\/\/monodes.com\/predaelli\/2017\/03\/05\/2233\/","url_meta":{"origin":8299,"position":4},"title":"[wp-svg-icons icon=\"podcast\" wrap=\"div\"] Never encode\u2026","author":"Paolo Redaelli","date":"2017-03-05","format":false,"excerpt":"[wp-svg-icons icon=\"podcast\" wrap=\"div\"] Never encode a constant in more than one place. So I had to resist the temptation to write code like1 [eiffel] tag_types: INDEXABLE[STRING] once Result := {FAST_ARRAY[STRING], < < \"Void\", -- GI_TYPE_TAG_VOID = 0, \"BOOLEAN\", -- GI_TYPE_TAG_BOOLEAN = 1, ... \"INTEGER_64\", -- GI_TYPE_TAG_INT64 = 8 .... >>\u2026","rel":"","context":"In &quot;Liberty Eiffel&quot;","block_context":{"text":"Liberty Eiffel","link":"https:\/\/monodes.com\/predaelli\/category\/eiffel\/liberty-eiffel\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":8216,"url":"https:\/\/monodes.com\/predaelli\/2021\/03\/01\/are-xiaomi-browsers-spyware-yes-they-are-almost-secure\/","url_meta":{"origin":8299,"position":5},"title":"Are Xiaomi browsers spyware? Yes, they are\u2026 | Almost Secure","author":"Paolo Redaelli","date":"2021-03-01","format":"link","excerpt":"https:\/\/palant.info\/2020\/05\/04\/are-xiaomi-browsers-spyware-yes-they-are...\/","rel":"","context":"In &quot;Ethics&quot;","block_context":{"text":"Ethics","link":"https:\/\/monodes.com\/predaelli\/category\/ethics\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/8299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/comments?post=8299"}],"version-history":[{"count":0,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/posts\/8299\/revisions"}],"wp:attachment":[{"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/media?parent=8299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/categories?post=8299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/monodes.com\/predaelli\/wp-json\/wp\/v2\/tags?post=8299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}