{"id":3321,"date":"2023-08-15T18:26:25","date_gmt":"2023-08-15T22:26:25","guid":{"rendered":"https:\/\/blog.wholetomato.com\/?p=3321"},"modified":"2023-08-15T18:29:20","modified_gmt":"2023-08-15T22:29:20","slug":"summer-codefest-what-the-hex-ports-and-adapters-architecture-with-c-recap","status":"publish","type":"post","link":"https:\/\/stage.wholetomato.com\/blog\/summer-codefest-what-the-hex-ports-and-adapters-architecture-with-c-recap\/","title":{"rendered":"Summer CodeFest: What the Hex? Ports and Adapters Architecture with C++ [Recap]"},"content":{"rendered":"<p><strong>This session has concluded <a href=\"https:\/\/youtu.be\/RqYgyYVeZPQ\">watch the replay<\/a> or download the slides below.<\/strong><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_76 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\r\n<div class=\"ez-toc-title-container\"><p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\r\n<\/div><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/stage.wholetomato.com\/blog\/summer-codefest-what-the-hex-ports-and-adapters-architecture-with-c-recap\/#Common_pitfalls_when_scaling_applications\" >Common pitfalls when scaling applications<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/stage.wholetomato.com\/blog\/summer-codefest-what-the-hex-ports-and-adapters-architecture-with-c-recap\/#Hex_structure_vs_traditional_three-layer_architecture\" >Hex structure vs traditional three-layer architecture<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/stage.wholetomato.com\/blog\/summer-codefest-what-the-hex-ports-and-adapters-architecture-with-c-recap\/#Fortifying_your_app_with_hexagonal_architecture\" >Fortifying your app with hexagonal architecture<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/stage.wholetomato.com\/blog\/summer-codefest-what-the-hex-ports-and-adapters-architecture-with-c-recap\/#Presentation_Slide_Deck\" >Presentation Slide Deck<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/stage.wholetomato.com\/blog\/summer-codefest-what-the-hex-ports-and-adapters-architecture-with-c-recap\/#Watch_the_Replay\" >Watch the Replay<\/a><\/li><\/ul><\/nav><\/div>\r\n<h2><span class=\"ez-toc-section\" id=\"Common_pitfalls_when_scaling_applications\"><\/span><span style=\"font-weight: 400;\">Common pitfalls when scaling applications<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">When scaling applications, two common pitfalls often arise: spaghetti code and a lack of proper testing. This can occur for various reasons, but one of the most common reasons is the lack of a coding style guide or an overarching design structure.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">For instance, when starting a project, it\u00e2\u20ac\u2122s fairly simple. An input and one or two outputs. However, as the project grows or the requirements expand, programmers can resort to an experimental approach each time a new component is added. They can also resort to using manual testing\u00e2\u20ac\u201dwhich works for simple unit tests for small projects but overtime becomes too cumbersome.\u00c2\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">The lack of a design structure makes projects prone to gradually growing complexity. As a result, the experimental app ends up in production as an inefficient system that demands continuous maintenance. To avoid breaking essential business logic and harming the overall business, developers allocate unnecessary development time to making one-off solutions.\u00c2\u00a0 The time and effort is compounded due the previous iteration\u00e2\u20ac\u2122s shortcomings.<\/span><\/p>\n<div id=\"attachment_3324\" style=\"width: 750px\" class=\"wp-caption alignnone\"><a href=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/Summer-CodeFest_-What-the-Hex_-Ports-and-Adapters-Architecture-with-C-Webinar-Recap-12-41-screenshot.png?ssl=1\"><img decoding=\"async\" aria-describedby=\"caption-attachment-3324\" data-attachment-id=\"3324\" data-permalink=\"https:\/\/stage.wholetomato.com\/blog\/summer-codefest-what-the-hex-ports-and-adapters-architecture-with-c-recap\/summer-codefest_-what-the-hex_-ports-and-adapters-architecture-with-c-webinar-recap-12-41-screenshot\/\" data-orig-file=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/Summer-CodeFest_-What-the-Hex_-Ports-and-Adapters-Architecture-with-C-Webinar-Recap-12-41-screenshot-e1692137978548.png?fit=1670%2C940&amp;ssl=1\" data-orig-size=\"1670,940\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Summer CodeFest_ What the Hex_ Ports and Adapters Architecture with C++ Webinar Recap 12-41 screenshot\" data-image-description=\"\" data-image-caption=\"&lt;p&gt;Using hex architecture can help address scaling issues.&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/Summer-CodeFest_-What-the-Hex_-Ports-and-Adapters-Architecture-with-C-Webinar-Recap-12-41-screenshot-e1692137978548.png?fit=300%2C169&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/Summer-CodeFest_-What-the-Hex_-Ports-and-Adapters-Architecture-with-C-Webinar-Recap-12-41-screenshot-e1692137978548.png?fit=1024%2C576&amp;ssl=1\" class=\"wp-image-3324\" src=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/Summer-CodeFest_-What-the-Hex_-Ports-and-Adapters-Architecture-with-C-Webinar-Recap-12-41-screenshot.png?resize=740%2C417&#038;ssl=1\" alt=\"\" width=\"740\" height=\"417\" data-recalc-dims=\"1\" \/><\/a><p id=\"caption-attachment-3324\" class=\"wp-caption-text\">Using hex architecture can help address scaling issues.<\/p><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Hex_structure_vs_traditional_three-layer_architecture\"><\/span><span style=\"font-weight: 400;\">Hex structure vs traditional three-layer architecture<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">There is nothing wrong with the traditional 3-layered structure composed of the presentation tier, the application tier, and the data tier. And for most applications this will usually be enough. However, theoretically, as you add more business logic and more functions, the complexity ramps up exponentially. In that case, a traditional approach may no longer be the most efficient. You can always scale and automate by expending more resources, or you can take a step back and reorganize your resources.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">A hex structure, contrary to what the name suggests, is not a 6-tiered structure. Instead, it\u00e2\u20ac\u2122s an analogy for the freedom of a developer to add ports and adapters\u00e2\u20ac\u201dsort of like a honeycomb structure where you can keep adding more hexagons and there would still be no gaps. In the traditional approach, the presentation, business, and data side flow directly to each other; in hexagonal architecture, you add interfaces (or buffers) in between fully functioning components making them semi-autonomous. You would only have to think about how what data passes from one to another and how communication is processed.<\/span><\/p>\n<p><a href=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/What-the-hex_-Ports-and-Adapters-architecture-with-C.png?ssl=1\"><img decoding=\"async\" data-attachment-id=\"3326\" data-permalink=\"https:\/\/stage.wholetomato.com\/blog\/summer-codefest-what-the-hex-ports-and-adapters-architecture-with-c-recap\/what-the-hex_-ports-and-adapters-architecture-with-c\/\" data-orig-file=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/What-the-hex_-Ports-and-Adapters-architecture-with-C.png?fit=1920%2C1080&amp;ssl=1\" data-orig-size=\"1920,1080\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"What the hex_ Ports and Adapters architecture with C++\" data-image-description=\"&lt;p&gt;#image_title&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;#image_title&lt;\/p&gt;\n\" data-medium-file=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/What-the-hex_-Ports-and-Adapters-architecture-with-C.png?fit=300%2C169&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/What-the-hex_-Ports-and-Adapters-architecture-with-C.png?fit=1024%2C576&amp;ssl=1\" class=\"alignnone wp-image-3326 size-large\" src=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/What-the-hex_-Ports-and-Adapters-architecture-with-C.png?resize=1024%2C576&#038;ssl=1\" alt=\"\" width=\"1024\" height=\"576\" srcset=\"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/What-the-hex_-Ports-and-Adapters-architecture-with-C.png?resize=1024%2C576&amp;ssl=1 1024w, https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/What-the-hex_-Ports-and-Adapters-architecture-with-C.png?resize=300%2C169&amp;ssl=1 300w, https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/What-the-hex_-Ports-and-Adapters-architecture-with-C.png?resize=768%2C432&amp;ssl=1 768w, https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/What-the-hex_-Ports-and-Adapters-architecture-with-C.png?resize=1536%2C864&amp;ssl=1 1536w, https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/What-the-hex_-Ports-and-Adapters-architecture-with-C.png?resize=360%2C203&amp;ssl=1 360w, https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/What-the-hex_-Ports-and-Adapters-architecture-with-C.png?w=1920&amp;ssl=1 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" data-recalc-dims=\"1\" \/><\/a><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Fortifying_your_app_with_hexagonal_architecture\"><\/span><span style=\"font-weight: 400;\">Fortifying your app with hexagonal architecture<\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">The Hexagonal architecture provides a solution to this problem by utilizing dependency inversion control, which separates business logic from implementation details like databases and REST clients. It also fosters a clear separation of concerns between components, ensuring a more organized and manageable application as it grows.<\/span><\/p>\n<p><b>Ports and Adapters<\/b><\/p>\n<p><span style=\"font-weight: 400;\">As the name suggests, hexagonal architecture utilizes standalone components with a functional core in the middle of the design structure. This means that expansion, maintenance, and designing is easier because the program\u00e2\u20ac\u2122s components and roles are clearly defined. Buffers between these components allow easy addition and removal as well as facilitate efficient communication among the program\u00e2\u20ac\u2122s functions.\u00c2\u00a0<\/span><\/p>\n<p><span style=\"font-weight: 400;\">So how do you initiate a program with a hexagonal design structure? Watch our short presentation hosted by Nuno Castro to get a brief introduction and some great examples. <\/span><b>This session has concluded. Browse the presentation slides and replay below.<\/b><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Presentation_Slide_Deck\"><\/span>Presentation Slide Deck<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><iframe src=\"https:\/\/docs.google.com\/presentation\/d\/e\/2PACX-1vRcn9y2ttanHdMv1g7W7kzhyi3mFA0fxhfk3D4k55NzgwTXhBRHoO3j-YpZphX4hSYL1HcVSfTnk_sC\/embed?start=false&amp;loop=false&amp;delayms=3000\" width=\"780\" height=\"540\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><span data-mce-type=\"bookmark\" style=\"display: inline-block; width: 0px; overflow: hidden; line-height: 0;\" class=\"mce_SELRES_start\">\u00ef\u00bb\u00bf<\/span><\/iframe><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Watch_the_Replay\"><\/span>Watch the Replay<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><iframe title=\"YouTube video player\" src=\"https:\/\/www.youtube.com\/embed\/RqYgyYVeZPQ\" width=\"560\" height=\"315\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This session has concluded watch the replay or download the slides below. Common pitfalls when scaling applications When scaling applications, two common pitfalls often arise: spaghetti code and a lack of proper testing. This can&#8230;<\/p>\n","protected":false},"author":213500340,"featured_media":3322,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_coblocks_attr":"","_coblocks_dimensions":"","_coblocks_responsive_height":"","_coblocks_accordion_ie_support":"","_jetpack_newsletter_access":"","_jetpack_newsletter_tier_id":0,"footnotes":""},"categories":[672,726359896],"tags":[726359925,2426,726359923,726359924],"class_list":["post-3321","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tips-and-tricks","category-webinar-recap","tag-adapters","tag-c","tag-hexagonal-architecture","tag-ports"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/stage.wholetomato.com\/blog\/wp-content\/uploads\/2023\/08\/16_WTSummer-CodeFest-Individual-Sessions_Nuno-Castro-1920x1080-1.png?fit=1920%2C1080&ssl=1","jetpack_likes_enabled":true,"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/pfhqii-Rz","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/posts\/3321","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/users\/213500340"}],"replies":[{"embeddable":true,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/comments?post=3321"}],"version-history":[{"count":7,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/posts\/3321\/revisions"}],"predecessor-version":[{"id":3334,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/posts\/3321\/revisions\/3334"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/media\/3322"}],"wp:attachment":[{"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/media?parent=3321"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/categories?post=3321"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/stage.wholetomato.com\/blog\/wp-json\/wp\/v2\/tags?post=3321"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}