<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>ready4 – Programming - object-oriented</title>
    <link>/tags/programming-object-oriented/</link>
    <description>Recent content in Programming - object-oriented on ready4</description>
    <generator>Hugo -- gohugo.io</generator>
    <lastBuildDate>Wed, 28 Jan 2026 00:00:00 +0000</lastBuildDate>
    
	  <atom:link href="/tags/programming-object-oriented/index.xml" rel="self" type="application/rss+xml" />
    
    
      
        
      
    
    
    <item>
      <title>Docs: Provide end users with a simple and consistent syntax for using model modules</title>
      <link>/docs/tutorials/develop-models/syntax/</link>
      <pubDate>Wed, 28 Jan 2026 00:00:00 +0000</pubDate>
      
      <guid>/docs/tutorials/develop-models/syntax/</guid>
      <description>
        
        
        

&lt;div class=&#34;pageinfo pageinfo-primary&#34;&gt;
&lt;p&gt;This below section renders a vignette article from the ready4 library. You can use the following links to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://ready4-dev.github.io/ready4/articles/V_07.html&#34;&gt;view the vignette on the library website (adds useful hyperlinks to code blocks)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/ready4-dev/ready4/blob/main/vignettes/V_07.Rmd&#34;&gt;view the source file&lt;/a&gt; from that article, and;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/ready4-dev/ready4/edit/main/vignettes/V_07.Rmd&#34;&gt;edit its contents&lt;/a&gt; (requires a GitHub account).&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;

&lt;div class=&#34;highlight&#34;&gt;
&lt;/div&gt;
&lt;div class=&#34;highlight&#34;&gt;
&lt;pre class=&#39;chroma&#39;&gt;&lt;code class=&#39;language-r&#39; data-lang=&#39;r&#39;&gt;&lt;span&gt;&lt;span class=&#39;kr&#39;&gt;&lt;a href=&#39;https://rdrr.io/r/base/library.html&#39;&gt;library&lt;/a&gt;&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nv&#39;&gt;&lt;a href=&#39;https://ready4-dev.github.io/ready4/&#39;&gt;ready4&lt;/a&gt;&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;)&lt;/span&gt; &lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h2 id=&#34;motivation&#34;&gt;Motivation&lt;/h2&gt;
&lt;p&gt;Transparency is one of the underpinning principles of ethical modelling practice. One way to improve the transparency of computational health economic models is to ensure that the programs implementing model analyses can be meaningfully inspected by readers with different levels of technical expertise. Even non-technical readers should be able to follow the high-level logic implemented by model algorithms. If multiple analysis programs are written using a common simplified syntax then reviewers of those programs need to contend with relatively fewer new concepts.&lt;/p&gt;
&lt;h2 id=&#34;implementation&#34;&gt;Implementation&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;ready4&lt;/code&gt; provides a simple syntax that can be consistently applied to attach algorithms (methods) to &lt;a href=&#34;https://www.ready4-dev.com/docs/tutorials/develop-models/modularity/&#34;&gt;model modules&lt;/a&gt;. It does so by taking advantage of the &lt;a href=&#34;https://www.ready4-dev.com/docs/framework/implementation/paradigm/object-oriented/#transparent-computational-models&#34;&gt;abstraction and polymorphism features of Object Oriented Programming&lt;/a&gt; and R&amp;rsquo;s use of generic functions. Generic functions don&amp;rsquo;t implement algorithms themselves - their most salient features are a name and a high level description of the type of task that any method associated with that generic should perform. Whenever a developer creates a method for classes that use R&amp;rsquo;s S4 and S3 systems &lt;a href=&#34;https://www.ready4-dev.com/docs/tutorials/develop-models/modularity/#implementation&#34;&gt;(the types used for model modules and sub-modules)&lt;/a&gt;, they can associate that method with a generic that has a description that is a good match for the algorithm being implemented.&lt;/p&gt;
&lt;h2 id=&#34;use&#34;&gt;Use&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;ready4&lt;/code&gt; includes a number of core generic functions which describe the main types of method to be implemented by model modules. These generics correspond exactly to the &amp;ldquo;core&amp;rdquo;, &amp;ldquo;slot&amp;rdquo; and &amp;ldquo;extended&amp;rdquo; commands described in &lt;a href=&#34;https://www.ready4-dev.com/docs/tutorials/use-models/authoring-analyses/commands/&#34;&gt;another article&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Notably, the &lt;code&gt;ready4&lt;/code&gt; package does not associate any core or extended methods with the &lt;code&gt;Ready4Module&lt;/code&gt; &lt;a href=&#34;https://www.ready4-dev.com/docs/tutorials/develop-models/modularity/&#34;&gt;template module&lt;/a&gt;. Instead, model developers need to decide which core and extended generics they associate with the modules they derive from the &lt;code&gt;Ready4Module&lt;/code&gt; template. This decision is typically made when authoring the methods associated with model modules.&lt;/p&gt;
&lt;p&gt;Currently, the only methods defined for &lt;code&gt;Ready4Module&lt;/code&gt; are &lt;a href=&#34;https://www.ready4-dev.com/docs/tutorials/use-models/authoring-analyses/commands/&#34;&gt;slot-methods&lt;/a&gt;. By default, these slot methods are inherited by all modules derived from the &lt;code&gt;Ready4Module&lt;/code&gt; template. These methods can be itemised using the &lt;code&gt;get_methods&lt;/code&gt; function.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;
&lt;pre class=&#39;chroma&#39;&gt;&lt;code class=&#39;language-r&#39; data-lang=&#39;r&#39;&gt;&lt;span&gt;&lt;span class=&#39;nf&#39;&gt;&lt;a href=&#39;https://ready4-dev.github.io/ready4/reference/get_methods.html&#39;&gt;get_methods&lt;/a&gt;&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span class=&#39;c&#39;&gt;#&amp;gt;  [1] &#34;authorSlot&#34;        &#34;characterizeSlot&#34;  &#34;depictSlot&#34;        &#34;enhanceSlot&#34;       &#34;exhibitSlot&#34;       &#34;ingestSlot&#34;        &#34;investigateSlot&#34;   &#34;manufactureSlot&#34;   &#34;metamorphoseSlot&#34; &lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;span class=&#39;c&#39;&gt;#&amp;gt; [10] &#34;procureSlot&#34;       &#34;prognosticateSlot&#34; &#34;ratifySlot&#34;        &#34;reckonSlot&#34;        &#34;renewSlot&#34;         &#34;shareSlot&#34;&lt;/span&gt;&lt;/span&gt;
&lt;span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;

      </description>
    </item>
    
    <item>
      <title>Docs: Why ready4 is object oriented</title>
      <link>/docs/getting-started/implementation/paradigm/object-oriented/</link>
      <pubDate>Wed, 28 Jan 2026 00:00:00 +0000</pubDate>
      
      <guid>/docs/getting-started/implementation/paradigm/object-oriented/</guid>
      <description>
        
        
        

&lt;div class=&#34;pageinfo pageinfo-primary&#34;&gt;
&lt;p&gt;This below section renders a vignette article from the ready4 library. You can use the following links to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;https://ready4-dev.github.io/ready4/articles/V_03.html&#34;&gt;view the vignette on the library website (adds useful hyperlinks to code blocks)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/ready4-dev/ready4/blob/main/vignettes/V_03.Rmd&#34;&gt;view the source file&lt;/a&gt; from that article, and;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;https://github.com/ready4-dev/ready4/edit/main/vignettes/V_03.Rmd&#34;&gt;edit its contents&lt;/a&gt; (requires a GitHub account).&lt;/li&gt;
&lt;/ul&gt;

&lt;/div&gt;

&lt;div class=&#34;highlight&#34;&gt;
&lt;/div&gt;
&lt;div class=&#34;highlight&#34;&gt;
&lt;pre class=&#39;chroma&#39;&gt;&lt;code class=&#39;language-r&#39; data-lang=&#39;r&#39;&gt;&lt;span&gt;&lt;span class=&#39;kr&#39;&gt;&lt;a href=&#39;https://rdrr.io/r/base/library.html&#39;&gt;library&lt;/a&gt;&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;(&lt;/span&gt;&lt;span class=&#39;nv&#39;&gt;&lt;a href=&#39;https://ready4-dev.github.io/ready4/&#39;&gt;ready4&lt;/a&gt;&lt;/span&gt;&lt;span class=&#39;o&#39;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;h2 id=&#34;motivation&#34;&gt;Motivation&lt;/h2&gt;
&lt;p&gt;The practical utility and ease of use of computational health economic models are in part shaped by the choice of programming paradigm used to develop them. ready4 adopts an object oriented programming (OOP) paradigm which in practice means that the framework principally consists of classes (representations of data structures useful for modelling health systems) and methods (algorithms that can be applied to these data-structures to generate insight useful for policy-making). Adopting an OOP approach is particular useful for helping to make models &lt;a href=&#34;https://www.ready4-dev.com/docs/getting-started/motivation/&#34;&gt;transparent, reusable and updatable&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&#34;implementation&#34;&gt;Implementation&lt;/h2&gt;
&lt;h3 id=&#34;modular-computational-models&#34;&gt;Modular Computational Models&lt;/h3&gt;
&lt;p&gt;Two commonly noted features of OOP - encapsulation and inheritance are particularly useful when developing &lt;a href=&#34;https://www.ready4-dev.com/docs/tutorials/develop-models/modularity/&#34;&gt;modular computational health economic models&lt;/a&gt;.&lt;/p&gt;
&lt;h4 id=&#34;encapsulation&#34;&gt;Encapsulation&lt;/h4&gt;
&lt;p&gt;Encapsulation allows us to define the data structures (&amp;ldquo;classes&amp;rdquo;) used in computational modelling projects in a manner that allows them to be safely combined. For example, assume there are two computational health economic models, one (&lt;strong&gt;A&lt;/strong&gt;) focused on predicting the types and intensity of services used by individuals that present to health services and the other (&lt;strong&gt;B&lt;/strong&gt;) that &lt;a href=&#34;https://ready4-dev.github.io/youthu/articles/Prediction_With_Mdls.html&#34;&gt;predicts outcomes for recipients of these services&lt;/a&gt;. It may be desirable to develop a new model (&lt;strong&gt;C&lt;/strong&gt;) that combines &lt;strong&gt;A&lt;/strong&gt; and &lt;strong&gt;B&lt;/strong&gt; to model both service use and outcomes. Using encapsulated code allows all of the features and functionality of &lt;strong&gt;A&lt;/strong&gt; to be made available to &lt;strong&gt;B&lt;/strong&gt; in a manner that protects the integrity of &lt;strong&gt;A&lt;/strong&gt;. Specifically, &lt;strong&gt;B&lt;/strong&gt; can only interact with &lt;strong&gt;A&lt;/strong&gt; using the algorithms (&amp;ldquo;methods&amp;rdquo;) that have been already defined for &lt;strong&gt;A&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Furthermore, if appropriately implemented, methods associated with a class will work with any combination of input values that can be encapsulated by that class - making computational models more &lt;a href=&#34;https://www.ready4-dev.com/docs/getting-started/concepts/transferable/&#34;&gt;transferable&lt;/a&gt;. For example, imagine a class (&lt;strong&gt;X&lt;/strong&gt;) that is used to structure summary data relevant to health systems. Methods associated with &lt;strong&gt;X&lt;/strong&gt; (e.g. a method to derive an unmet need statistic) can then applied to two instances of &lt;strong&gt;X&lt;/strong&gt; - one containing data relevant to the Australian context and one with data from the UK context.&lt;/p&gt;
&lt;h4 id=&#34;inheritence&#34;&gt;Inheritence&lt;/h4&gt;
&lt;p&gt;The examples highlighted in the previous section have some potential limitations. What if the developers of &lt;strong&gt;A&lt;/strong&gt; didn&amp;rsquo;t define methods that would allow &lt;strong&gt;B&lt;/strong&gt; to interact with it in the desired way? Or what if there are a number of differences between the Australian and UK system that need to be accounted for when transferring a method from the former to the latter? These types of issues can be addressed by another key feature of OOP - inheritance. Inheritance allows for a &amp;ldquo;child&amp;rdquo; class to be created from a &amp;ldquo;parent&amp;rdquo; class. By default, the &amp;ldquo;child&amp;rdquo; inherits all of the features of the &amp;ldquo;parent&amp;rdquo; including all methods associated with the &amp;ldquo;parent&amp;rdquo; class. Importantly however, alternative or additional features can also be specified for the &amp;ldquo;child&amp;rdquo; to allow it to implement different methods where necessary. For example, when developing our new computational model &lt;strong&gt;C&lt;/strong&gt; we could create a number of new classes that are children of the classes defined in &lt;strong&gt;A&lt;/strong&gt;. We can then define any additional/alternative methods for these classes that overcome any integration issues between the classes and methods of &lt;strong&gt;A&lt;/strong&gt; and &lt;strong&gt;B&lt;/strong&gt;. In this way, we can enjoy the best of both worlds - leveraging all relevant algorithms from &lt;strong&gt;A&lt;/strong&gt; and &lt;strong&gt;B&lt;/strong&gt; (as there is no need to re-invent the wheel), while ensuring that we transparently develop the additional code required for &lt;strong&gt;C&lt;/strong&gt;. This approach also ensures that the respective contributions of the (potentially different) authorship teams behind &lt;strong&gt;A&lt;/strong&gt;, &lt;strong&gt;B&lt;/strong&gt; and &lt;strong&gt;C&lt;/strong&gt; is clearer.&lt;/p&gt;
&lt;p&gt;Similarly, inheritance would allow re-use of much of the code from a model of the Australian health system when exploring similar topics within the UK context, while making it straightforward to develop additional code that addresses relevant divergence in features between the two jurisdictions. In practical terms, this would mean developing two child classes of &lt;strong&gt;X&lt;/strong&gt; - class &lt;strong&gt;Y&lt;/strong&gt; for use with Australian data and class &lt;strong&gt;Z&lt;/strong&gt; for use in the UK system. All methods that are not specific to a particular jurisdiction are defined for &lt;strong&gt;X&lt;/strong&gt; and inherited by &lt;strong&gt;Y&lt;/strong&gt; and &lt;strong&gt;Z&lt;/strong&gt;. Methods that are only appropriate for use in the Australian context are defined for &lt;strong&gt;Y&lt;/strong&gt;, while UK specific methods are defined for &lt;strong&gt;Z&lt;/strong&gt;.&lt;/p&gt;
&lt;h3 id=&#34;transparent-computational-models&#34;&gt;Transparent Computational Models&lt;/h3&gt;
&lt;p&gt;To make modelling analysis programs more readily understood, the &lt;code&gt;ready4&lt;/code&gt; package provides a &lt;a href=&#34;https://www.ready4-dev.com/docs/framework/implementation/syntax/&#34;&gt;simple and consistent syntax&lt;/a&gt;. Such simplified approaches are facilitated by two other commonly noted features of OOP - polymorphism and abstraction.&lt;/p&gt;
&lt;h4 id=&#34;polymorphism&#34;&gt;Polymorphism&lt;/h4&gt;
&lt;p&gt;Polymorphism allows for similar concepts to be represented using consistent syntax. The same top level code can therefore be generalised to multiple model implementations, making algorithms simpler to understand and easier to re-use.&lt;/p&gt;
&lt;p&gt;Returning to a previous example, the exact same command (e.g. a call to the method &lt;a href=&#34;https://ready4-dev.github.io/ready4/reference/exhibit-methods.html&#34;&gt;exhibit&lt;/a&gt;) can be applied to both &lt;strong&gt;Y&lt;/strong&gt; (used for Australian data) and &lt;strong&gt;Z&lt;/strong&gt; (used for UK data). However, the algorithm implemented by that command can vary based on the class that each method is applied to (ie a different algorithm is applied when the data is specified as being from the UK compared to being specified as Australian).&lt;/p&gt;
&lt;h4 id=&#34;abstraction&#34;&gt;Abstraction&lt;/h4&gt;
&lt;p&gt;The simplicity enabled by polymorphism is enhanced by Abstraction, which basically means that only the briefest and easiest to comprehend parts of the code are exposed by default to potential users. Once an instance of a model module template class is created, the entire program to ingest model data, analyse it and produce a scientific summary can be represented in a few brief lines of code, readily comprehensible to non-coders. When using open source languages, the elegance and simplicity of abstraction &lt;a href=&#34;https://www.ready4-dev.com/docs/framework/use/authoring-modules/authoring-algorithms/&#34;&gt;does not restrict the ability of more technically minded users exploring the detailed workings of the underpinning code&lt;/a&gt;.&lt;/p&gt;

      </description>
    </item>
    
  </channel>
</rss>
