{"id":1274,"date":"2023-06-15T05:41:50","date_gmt":"2023-06-15T09:41:50","guid":{"rendered":"https:\/\/blogs.mathworks.com\/matlab\/?p=1274"},"modified":"2023-06-15T06:50:11","modified_gmt":"2023-06-15T10:50:11","slug":"mathworks-releases-best-practices-for-matlab-toolbox-development","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/matlab\/2023\/06\/15\/mathworks-releases-best-practices-for-matlab-toolbox-development\/","title":{"rendered":"MathWorks releases Best Practices for MATLAB Toolbox development"},"content":{"rendered":"<div class = rtcContent><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Research<\/span><span> computing can be a messy affair and, for me at least, it often looks like the following. First, there is the exploration phase where you often have no strong idea about what you are doing. You play around with the data or simulation, see what there is to see, learning about both your subject domain and, often, the system you are developing on (<\/span><span>e.g.<\/span><span> MATLAB, Python, R <\/span><span>etc<\/span><span>) simultaneously. <\/span><span> <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>As<\/span><span> <\/span><span>our<\/span><span> understating improves, and the complexity of the narrative increases, the messy script or notebook becomes a tidier one. Structure <\/span><span>emerges<\/span><span> in the form of reusable functions and classes, initially<\/span><span> just for <\/span><span>ourselves<\/span><span>, but eventually for other people<\/span><span>.  <\/span><span>Documentation that starts out as a few scattered comments becomes more coherent and comprehensive<\/span><span>.  <\/span><span>Your test script evolves into unit tests which become part of a continuous integration process.<\/span><span> <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Your private repository becomes a public one and other people start expressing an interest in your work<\/span><span>.  <\/span><span>You turn your code into a package to allow others to <\/span><span>more easily install it<\/span><span> and a \u2018Getting started\u2019 guide to help onboard them.<\/span><span>  <\/span><span> <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>On and on it goes and the realization hits you: Now you are a software engineer as well as a researcher<\/span><span>.  <\/span><a href = \"https:\/\/society-rse.org\/\"><span style=' text-decoration: underline;'>A Research Software Engineer<\/span><\/a><span> maybe? <\/span><span>Your journey to this point may be different from the one I outlined above but the end point is usually the same:<\/span><span> <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span style=' font-weight: bold;'>You\u2019ve<\/span><span style=' font-weight: bold;'> written (or are writing) a MATLAB Toolbox and want to know what the best practices are so you can make it as good as can be<\/span><span style=' font-weight: bold;'>.  <\/span><span> <\/span><\/div><h2  style = 'margin: 20px 10px 5px 4px; padding: 0px; line-height: 20px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 20px; font-weight: 700; text-align: left; '><span>Feedback from toolbox authors<\/span><span> <\/span><\/h2><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Yesterday, we got together with a bunch of <\/span><span>prominent open-source MATLAB <\/span><span>toolbox authors and asked them \u201cWhat problems do users have<\/span><span> with your toolbox?<\/span><span>\u201d.<\/span><span>  The results were illuminating<\/span><span> <\/span><span> <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span style=' font-weight: bold;'> <\/span><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/matlab\/files\/2023\/06\/toolboxGuidelines_1.png\" width = \"1000\" height = \"400\" alt = \"\" style = \"vertical-align: baseline; width: 1000px; height: 400x;\"><\/img><span> <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Ideally, everyone could<\/span><span> develop and release toolboxes in a way that minimised these problems.<\/span><span> Wouldn\u2019t <\/span><span>it be great if MathWorks offered advice on how to go about doing that?<\/span><span> <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Well<\/span><span>, <\/span><span>we\u2019ve<\/span><span> got you covered with some new repositories on the MathWorks GitHub organisation<\/span><span> <\/span><\/div><ul  style = 'margin: 10px 0px 20px; padding-left: 0px; font-family: Helvetica, Arial, sans-serif; font-size: 14px; '><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><a href = \"https:\/\/github.com\/mathworks\/toolboxdesign\"><span style=' text-decoration: underline;'>MATLAB Toolbox Best Practices<\/span><\/a><span>: Our current set of suggestions for how a good MATLAB Toolbox should be developed and released.<\/span><span> <\/span><\/li><li  style = 'margin-left: 56px; line-height: 21px; min-height: 0px; text-align: left; white-space: pre-wrap; '><a href = \"https:\/\/github.com\/mathworks\/arithmetic\"><span style=' text-decoration: underline;'>Example MATLAB Toolbox<\/span><\/a><span>: A fictitious toolbox created solely to <\/span><span>demonstrate<\/span><span> the best practices.<\/span><span> <\/span><\/li><\/ul><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>You\u2019ll<\/span><span> learn things like how to structure your toolbox, where to put examples and documentation, how to <\/span><span>keep development code separate from shipping code and, <\/span><span>perhaps most<\/span><span> importantly, how to get all those cool badges on your repo that you see the <\/span><span>professionals<\/span><span> use<\/span><span>. Such as<\/span><span> this one<\/span><span> <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><img class = \"imageNode\" src = \"https:\/\/blogs.mathworks.com\/matlab\/files\/2023\/06\/toolboxGuidelines_2.png\" width = \"136\" height = \"21\" alt = \"\" style = \"vertical-align: baseline; width: 136px; height: 21px;\"><\/img><span> <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span>Developed by the community team at MathWorks, t<\/span><span>hese are evolving documents that <\/span><span>don\u2019t<\/span><span> yet cover everything<\/span><span>.  <\/span><span>We invite you to <\/span><a href = \"https:\/\/github.com\/mathworks\/toolboxdesign\/issues\"><span style=' text-decoration: underline;'>open an issue<\/span><\/a><span>\u202for\u202f<\/span><a href = \"https:\/\/github.com\/mathworks\/toolboxdesign\/discussions\"><span style=' text-decoration: underline;'>post to the discussions<\/span><\/a><span> if you have any questions, <\/span><span>comments<\/span><span> or suggestions about what has been done so far<\/span><span>. Also feel free to comment here or message me on <\/span><a href = \"https:\/\/www.linkedin.com\/in\/mike-croucher-32336113\/\"><span style=' text-decoration: underline;'>Linkedin<\/span><\/a><span> or <\/span><a href = \"https:\/\/twitter.com\/walkingrandomly\"><span style=' text-decoration: underline;'>twitter<\/span><\/a><span>. <\/span><span> <\/span><\/div><div  style = 'margin: 2px 10px 9px 4px; padding: 0px; line-height: 21px; min-height: 0px; white-space: pre-wrap; color: rgb(33, 33, 33); font-family: Helvetica, Arial, sans-serif; font-style: normal; font-size: 14px; font-weight: 400; text-align: left; '><span> <\/span><\/div>\r\n<\/div><script type=\"text\/javascript\">var css = ''; var head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); head.appendChild(style); style.type = 'text\/css'; if (style.styleSheet){ style.styleSheet.cssText = css; } else { style.appendChild(document.createTextNode(css)); }<\/script>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/matlab\/files\/2023\/06\/toolboxGuidelines_1.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><p>Research computing can be a messy affair and, for me at least, it often looks like the following. First, there is the exploration phase where you often have no strong idea about what you are doing.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/matlab\/2023\/06\/15\/mathworks-releases-best-practices-for-matlab-toolbox-development\/\">read more >><\/a><\/p>","protected":false},"author":176,"featured_media":1265,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[68,39,17,64,1],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/1274"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/users\/176"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/comments?post=1274"}],"version-history":[{"count":3,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/1274\/revisions"}],"predecessor-version":[{"id":1286,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/posts\/1274\/revisions\/1286"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/media\/1265"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/media?parent=1274"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/categories?post=1274"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/matlab\/wp-json\/wp\/v2\/tags?post=1274"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}