{"id":25726,"date":"2016-01-24T23:06:28","date_gmt":"2016-01-24T23:06:28","guid":{"rendered":"http:\/\/osmeusapontamentos.com\/?p=25726"},"modified":"2016-01-24T23:06:28","modified_gmt":"2016-01-24T23:06:28","slug":"pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2","status":"publish","type":"post","link":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/","title":{"rendered":"Pragmatic Choices &#8211; Web Application Development with WordPress and CMB2 #2"},"content":{"rendered":"<p>When you choose to use some kind of component you are accepting that even though this component may not be perfect, considering all the pros and cons, it&#8217;s still a better solution (in time, cost, etc.) than developing your own solution from scratch. This also means that sometimes you end up doing things that feel kind of strange, when you compare to what you would do if you were starting with a &#8220;blank sheet&#8221; of code.<\/p>\n<p>How far you can stretch that strangeness usually depends on how pragmatic your programmer can be. Is he the type of guy that really just wants to get things done, even if it means you end up with some kind of technical debt or is he the kind guy that would rather work extra-time to make that code really clean, beautiful and also effective?<\/p>\n<p>In our time tracking application we have, for now, 2 main dependencies, WordPress and CMB2, and we&#8217;re trying to make the most of them. This means that we&#8217;re trying to use all the functionalities they give us and also implement some requirements in a way that makes the most sense for those components.<\/p>\n<p>In our 2nd week of development we&#8217;ve ran into a situation that, I think, represents this kind of choice and that has to do with Roles and Capabilities.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-25737 aligncenter\" src=\"https:\/\/osmeusapontamentos.com\/wp-content\/uploads\/2016\/01\/Reuselogo-300x129.jpg\" alt=\"Reuselogo\" width=\"300\" height=\"129\" \/><\/p>\n<p>One of the goals of our time entry application is to register\u00a0on what projects \/ subjects our consultants worked during the day. So we have something like consultant, subject, client, date, worktime, and so on. Relevant to this issue we also have the concept of\u00a0teams and team lead. A simple consultant can only register something that he did but team leaders can\u00a0register entries\u00a0on behalf of their\u00a0team members. On our roadmap is also the idea of logging changes in records, that is register who made some change to a specific record.<\/p>\n<p>There were some options to\u00a0solve this. One would be to simply use post_author\u00a0to record who was\u00a0registering the time entry. This\u00a0solution would have the added benefit of allowing the\u00a0use of the\u00a0WordPress capabilities and reduce the number of tables we would have to include to filter tasks by consultants, we could simply use wp_quer.\u00a0But since team leaders can\u00a0also register on behalf of their\u00a0team members\u00a0and also because we wanted to keep track of who made the changes this wasn&#8217;t possible.<\/p>\n<p>The other solution would be to simply ignore post_author and create 2\u00a0post metas, one\u00a0to save\u00a0the user that was recording the time entry and the other to register the consultant associated with the time entry. This would be a totally viable option, and since we&#8217;re building an application to track tasks and times and we&#8217;re not really doing anything with posts there was no reason to consider fields like post_author. This option would however\u00a0make some queries a bit more complex and probably more cpu intensive since we would have to include not only the posts table but also post_meta with its &#8220;infinite&#8221; number of records.<\/p>\n<p>Since, after data entry, data selection and filtering is a huge part of our application, and\u00a0having to reimplement all of this requirements didn&#8217;t seemed to make sense to us, we chose to use an hybrid solution and so we ended up using post_author to record the consultant associated with this time entry and we&#8217;ve created a post_meta to save the user that registered this entry. Best of both worlds? We will see, but in the meantime\u00a0if you think we could have done differently feel free to tell us.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Reuse, Adjust and Dependencies or how to make the most of the components you use<\/p>\n","protected":false},"author":1,"featured_media":25737,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7,10],"tags":[688],"class_list":["post-25726","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-ler-ver-ouvir-passear","category-worklife","tag-wordpress-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Pragmatic Choices - Web Application Development with WordPress and CMB2 #2 - Os Meus Apontamentos<\/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:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/\" \/>\n<meta property=\"og:locale\" content=\"pt_PT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Pragmatic Choices - Web Application Development with WordPress and CMB2 #2 - Os Meus Apontamentos\" \/>\n<meta property=\"og:description\" content=\"Reuse, Adjust and Dependencies or how to make the most of the components you use\" \/>\n<meta property=\"og:url\" content=\"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/\" \/>\n<meta property=\"og:site_name\" content=\"Os Meus Apontamentos\" \/>\n<meta property=\"article:published_time\" content=\"2016-01-24T23:06:28+00:00\" \/>\n<meta name=\"author\" content=\"Vitor Silva\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vitorsilva\" \/>\n<meta name=\"twitter:site\" content=\"@vitorsilva\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Vitor Silva\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tempo estimado de leitura\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/\"},\"author\":{\"name\":\"Vitor Silva\",\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/#\\\/schema\\\/person\\\/d508df9c3ffc8b4e64a18dbf0ba18dd8\"},\"headline\":\"Pragmatic Choices &#8211; Web Application Development with WordPress and CMB2 #2\",\"datePublished\":\"2016-01-24T23:06:28+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/\"},\"wordCount\":617,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/#\\\/schema\\\/person\\\/d508df9c3ffc8b4e64a18dbf0ba18dd8\"},\"image\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/#primaryimage\"},\"thumbnailUrl\":\"\",\"keywords\":[\"WordPress development\"],\"articleSection\":[\"Ler\\\/ Ver\\\/ Ouvir\\\/ Passear\",\"Programa\u00e7\u00e3o\"],\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/\",\"url\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/\",\"name\":\"Pragmatic Choices - Web Application Development with WordPress and CMB2 #2 - Os Meus Apontamentos\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/#primaryimage\"},\"thumbnailUrl\":\"\",\"datePublished\":\"2016-01-24T23:06:28+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/#breadcrumb\"},\"inLanguage\":\"pt-PT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/#primaryimage\",\"url\":\"\",\"contentUrl\":\"\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/index.php\\\/2016\\\/01\\\/24\\\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"In\u00edcio\",\"item\":\"https:\\\/\\\/osmeusapontamentos.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Pragmatic Choices &#8211; Web Application Development with WordPress and CMB2 #2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/#website\",\"url\":\"https:\\\/\\\/osmeusapontamentos.com\\\/\",\"name\":\"Os Meus Apontamentos\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/#\\\/schema\\\/person\\\/d508df9c3ffc8b4e64a18dbf0ba18dd8\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/osmeusapontamentos.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"pt-PT\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/osmeusapontamentos.com\\\/#\\\/schema\\\/person\\\/d508df9c3ffc8b4e64a18dbf0ba18dd8\",\"name\":\"Vitor Silva\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"pt-PT\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g\",\"caption\":\"Vitor Silva\"},\"logo\":{\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g\"},\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/vitormrsilva\",\"https:\\\/\\\/x.com\\\/vitorsilva\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Pragmatic Choices - Web Application Development with WordPress and CMB2 #2 - Os Meus Apontamentos","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/","og_locale":"pt_PT","og_type":"article","og_title":"Pragmatic Choices - Web Application Development with WordPress and CMB2 #2 - Os Meus Apontamentos","og_description":"Reuse, Adjust and Dependencies or how to make the most of the components you use","og_url":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/","og_site_name":"Os Meus Apontamentos","article_published_time":"2016-01-24T23:06:28+00:00","author":"Vitor Silva","twitter_card":"summary_large_image","twitter_creator":"@vitorsilva","twitter_site":"@vitorsilva","twitter_misc":{"Escrito por":"Vitor Silva","Tempo estimado de leitura":"3 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/#article","isPartOf":{"@id":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/"},"author":{"name":"Vitor Silva","@id":"https:\/\/osmeusapontamentos.com\/#\/schema\/person\/d508df9c3ffc8b4e64a18dbf0ba18dd8"},"headline":"Pragmatic Choices &#8211; Web Application Development with WordPress and CMB2 #2","datePublished":"2016-01-24T23:06:28+00:00","mainEntityOfPage":{"@id":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/"},"wordCount":617,"commentCount":0,"publisher":{"@id":"https:\/\/osmeusapontamentos.com\/#\/schema\/person\/d508df9c3ffc8b4e64a18dbf0ba18dd8"},"image":{"@id":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/#primaryimage"},"thumbnailUrl":"","keywords":["WordPress development"],"articleSection":["Ler\/ Ver\/ Ouvir\/ Passear","Programa\u00e7\u00e3o"],"inLanguage":"pt-PT","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/","url":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/","name":"Pragmatic Choices - Web Application Development with WordPress and CMB2 #2 - Os Meus Apontamentos","isPartOf":{"@id":"https:\/\/osmeusapontamentos.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/#primaryimage"},"image":{"@id":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/#primaryimage"},"thumbnailUrl":"","datePublished":"2016-01-24T23:06:28+00:00","breadcrumb":{"@id":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/#breadcrumb"},"inLanguage":"pt-PT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/"]}]},{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/#primaryimage","url":"","contentUrl":""},{"@type":"BreadcrumbList","@id":"https:\/\/osmeusapontamentos.com\/index.php\/2016\/01\/24\/pragmatic-choices-web-application-development-with-wordpress-and-cmb2-2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"In\u00edcio","item":"https:\/\/osmeusapontamentos.com\/"},{"@type":"ListItem","position":2,"name":"Pragmatic Choices &#8211; Web Application Development with WordPress and CMB2 #2"}]},{"@type":"WebSite","@id":"https:\/\/osmeusapontamentos.com\/#website","url":"https:\/\/osmeusapontamentos.com\/","name":"Os Meus Apontamentos","description":"","publisher":{"@id":"https:\/\/osmeusapontamentos.com\/#\/schema\/person\/d508df9c3ffc8b4e64a18dbf0ba18dd8"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/osmeusapontamentos.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"pt-PT"},{"@type":["Person","Organization"],"@id":"https:\/\/osmeusapontamentos.com\/#\/schema\/person\/d508df9c3ffc8b4e64a18dbf0ba18dd8","name":"Vitor Silva","image":{"@type":"ImageObject","inLanguage":"pt-PT","@id":"https:\/\/secure.gravatar.com\/avatar\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g","caption":"Vitor Silva"},"logo":{"@id":"https:\/\/secure.gravatar.com\/avatar\/f81f58ad909e8a213ab0a690f6ed65e5c0e0e2274bf35ac49ff31d7988d483ce?s=96&d=mm&r=g"},"sameAs":["https:\/\/www.linkedin.com\/in\/vitormrsilva","https:\/\/x.com\/vitorsilva"]}]}},"_links":{"self":[{"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/posts\/25726","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/comments?post=25726"}],"version-history":[{"count":0,"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/posts\/25726\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/"}],"wp:attachment":[{"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/media?parent=25726"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/categories?post=25726"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/osmeusapontamentos.com\/index.php\/wp-json\/wp\/v2\/tags?post=25726"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}