{"id":634,"date":"2014-12-25T17:58:21","date_gmt":"2014-12-25T17:58:21","guid":{"rendered":"http:\/\/reichartonline.de\/?page_id=634"},"modified":"2020-05-10T08:22:04","modified_gmt":"2020-05-10T08:22:04","slug":"multimodal-code","status":"publish","type":"page","link":"https:\/\/reichartonline.de\/?page_id=634","title":{"rendered":"Multimodal code"},"content":{"rendered":"<h4>Introduction<\/h4>\n<p>If your favorite programming language is platform-independent in terms of runtime environment (command line interface, web), you may want to enable your code to run in both environments.<\/p>\n<h4>Conceptual approach<\/h4>\n<p>Using <a title=\"DIC\" href=\"https:\/\/www.reichartonline.de\/?page_id=533\">Dependency Injection<\/a>, the abstracted runtime environment is injected into the program on its start-up, so the program code itself does not need to be aware of the environment.<\/p>\n<h4>Abstraction of runtime environments<\/h4>\n<p>What are the aspects that make the difference between runtime environments? Just assign these aspects to variables and let the dependency injector evaluate the runtime environment on starting up the program.<\/p>\n<h5>Example<\/h5>\n<p>A carriage return linefeed (CRLF) is expressed differently in a web and in a terminal environment. Using a parameter module per runtime environment, the CRLF is assigned to a named variable. Pseudo code:<\/p>\n<p>Terminal environment<\/p>\n<pre>variable strCrlf = \"\\n\"\n<\/pre>\n<p>Web environment<\/p>\n<pre>variable strCrlf = \"&lt;br&gt;\"\n<\/pre>\n<p>Starting the program, the dependency injector evaluates the current runtime environment and loads the respective parameter module into memory. Accessing variable &#8220;strCrlf&#8221;, the program will find the appropriate value.<\/p>\n<p>This way parameters implemented or implementable in both runtime environments are abstracted. Parameters supported by either of the runtime environments (e.g. styles in a web environment) may be conditionally implemented within the program code itself (use with caution as otherwise you may end up with an excessive share of runtime environment specific code in relation to code generating content).<\/p>\n<h4>Outcome<\/h4>\n<p>An example of multimodal code is the PHLEX component version overview<\/p>\n<p>Terminal environment<\/p>\n<div id=\"attachment_630\" style=\"width: 310px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/reichartonline.de\/content\/wp-content\/uploads\/2014\/12\/dual_mode_cli.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-630\" class=\"wp-image-630 size-medium\" src=\"http:\/\/reichartonline.de\/content\/wp-content\/uploads\/2014\/12\/dual_mode_cli-300x164.png\" alt=\"Dualmode code called in terminal\" width=\"300\" height=\"164\" srcset=\"https:\/\/reichartonline.de\/content\/wp-content\/uploads\/2014\/12\/dual_mode_cli-300x164.png 300w, https:\/\/reichartonline.de\/content\/wp-content\/uploads\/2014\/12\/dual_mode_cli.png 429w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-630\" class=\"wp-caption-text\">PHLEX version called in terminal<\/p><\/div>\n<p>Web environment<\/p>\n<div id=\"attachment_631\" style=\"width: 288px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/reichartonline.de\/content\/wp-content\/uploads\/2014\/12\/dual_mode_web.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-631\" class=\"wp-image-631 size-medium\" src=\"http:\/\/reichartonline.de\/content\/wp-content\/uploads\/2014\/12\/dual_mode_web-278x300.png\" alt=\"PHLEX versions called in web\" width=\"278\" height=\"300\" srcset=\"https:\/\/reichartonline.de\/content\/wp-content\/uploads\/2014\/12\/dual_mode_web-278x300.png 278w, https:\/\/reichartonline.de\/content\/wp-content\/uploads\/2014\/12\/dual_mode_web.png 319w\" sizes=\"auto, (max-width: 278px) 100vw, 278px\" \/><\/a><p id=\"caption-attachment-631\" class=\"wp-caption-text\">PHLEX versions called in web<\/p><\/div>\n<p>Called in a web environment, styles are loaded in order to adopt a specific look.<\/p>\n<p>In web mode, the web session object is used to store the environment parameters. In terminal mode, an emulated session is created by the dependency injector.<\/p>\n<h4>Adjacent use cases<\/h4>\n<p>This abstraction concept may also be used for national language support (language parameters are just another category as environment parameters).<\/p>\n<p>English<\/p>\n<div id=\"attachment_632\" style=\"width: 170px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/reichartonline.de\/content\/wp-content\/uploads\/2014\/12\/category_cloud_english.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-632\" class=\"wp-image-632 size-full\" src=\"http:\/\/reichartonline.de\/content\/wp-content\/uploads\/2014\/12\/category_cloud_english.png\" alt=\"English category cloud\" width=\"160\" height=\"136\" \/><\/a><p id=\"caption-attachment-632\" class=\"wp-caption-text\">Category cloud with English language module<\/p><\/div>\n<p>Spanish<\/p>\n<div id=\"attachment_633\" style=\"width: 170px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/reichartonline.de\/content\/wp-content\/uploads\/2014\/12\/category_cloud_spanish.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-633\" class=\"wp-image-633 size-full\" src=\"http:\/\/reichartonline.de\/content\/wp-content\/uploads\/2014\/12\/category_cloud_spanish.png\" alt=\"Spanish category cloud\" width=\"160\" height=\"136\" \/><\/a><p id=\"caption-attachment-633\" class=\"wp-caption-text\">Category cloud with Spanish language module<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Introduction If your favorite programming language is platform-independent in terms of runtime environment (command line interface, web), you may want to enable your code to run in both environments. Conceptual approach Using Dependency Injection, the abstracted runtime environment is injected into the program on its start-up, so the program code itself does not need to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":62,"menu_order":5,"comment_status":"open","ping_status":"open","template":"","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"class_list":["post-634","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages\/634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/reichartonline.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=634"}],"version-history":[{"count":15,"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages\/634\/revisions"}],"predecessor-version":[{"id":1127,"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages\/634\/revisions\/1127"}],"up":[{"embeddable":true,"href":"https:\/\/reichartonline.de\/index.php?rest_route=\/wp\/v2\/pages\/62"}],"wp:attachment":[{"href":"https:\/\/reichartonline.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}