<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Naveen Honest Raj</title>
    <description>The latest articles on DEV Community by Naveen Honest Raj (@nav_devl).</description>
    <link>https://dev.to/nav_devl</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F32689%2F39277a23-6ace-4a16-8ad7-d4c38152b7ad.jpg</url>
      <title>DEV Community: Naveen Honest Raj</title>
      <link>https://dev.to/nav_devl</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nav_devl"/>
    <language>en</language>
    <item>
      <title>Case study on Ruby Gem Contribution: activeadmin-mongoid</title>
      <dc:creator>Naveen Honest Raj</dc:creator>
      <pubDate>Sat, 26 Jun 2021 08:30:42 +0000</pubDate>
      <link>https://dev.to/nav_devl/case-study-on-ruby-gem-contribution-activeadmin-mongoid-9jg</link>
      <guid>https://dev.to/nav_devl/case-study-on-ruby-gem-contribution-activeadmin-mongoid-9jg</guid>
      <description>&lt;p&gt;&lt;a href="https://naveenhonestraj.in/posts/case-study-on-ruby-gem-contribution-activeadmin-mongoid" rel="noopener noreferrer"&gt;&lt;em&gt;This article is originally posted here. Checkout the article and related articles here.&lt;/em&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For the people who are very much in the Rails development, you definitely should've used Activeadmin on one of your projects. If not, please &lt;a href="https://github.com/activeadmin/activeadmin" rel="noopener noreferrer"&gt;have a look at it.&lt;/a&gt; It is an amazing gem ran by a very understanding community.&lt;/p&gt;

&lt;p&gt;For those who aren't familiar with Rails, this gem provides us to build admin controlled management side for the models present in the application quickly. Provides set of conventions and working along those lines, you can quickly get your admin dashboard ready. For Django-familiar people, it is similar to django-admin.&lt;/p&gt;

&lt;p&gt;The gem &lt;code&gt;activeadmin&lt;/code&gt; sits very well with the relational DB using Rails &lt;code&gt;activerecord&lt;/code&gt; and for the projects that uses NoSQL DB like Mongo, there is another gem under the same umbrella - &lt;code&gt;activeadmin-mongoid&lt;/code&gt; (&lt;a href="https://github.com/activeadmin/activeadmin-mongoid" rel="noopener noreferrer"&gt;https://github.com/activeadmin/activeadmin-mongoid&lt;/a&gt;)&lt;/p&gt;

&lt;h2&gt;
  
  
  Little story behind activeadmin-mongoid
&lt;/h2&gt;

&lt;p&gt;ActiveAdmin is holding off on pulling Mongoid support into the core ActiveAdmin application. Maybe in future activeadmin will provide support for NoSQL directly through its gem.&lt;/p&gt;

&lt;p&gt;This gem's repo was pulled into the ActiveAdmin org from previous work done by &lt;strong&gt;Elia Schito&lt;/strong&gt;. Currently, it is maintained by &lt;strong&gt;Grzegorz Jakubiak, Nic Boie, JD Guzman, Elia Schito&lt;/strong&gt; and other ActiveAdmin and community members.&lt;/p&gt;

&lt;h2&gt;
  
  
  Quick technical glimpse about the activeadmin-mongoid
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;Mongoid&lt;/code&gt; based Rails projects mostly won't require &lt;code&gt;activerecord&lt;/code&gt; in their model methods and also wouldn't need any migration because we aren't dealing with the usual ideas of the SQL world.&lt;/p&gt;

&lt;p&gt;Similarly, &lt;code&gt;activeadmin-mongoid&lt;/code&gt; as a gem also avoids to require Rails's &lt;code&gt;activerecord&lt;/code&gt; related elements. This is something to be considered when introducing any new additions to the gem. &lt;em&gt;(atleast at the time of writing)&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What was the issue
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;activeadmin-mongoid&lt;/code&gt; depends on the &lt;code&gt;activeadmin&lt;/code&gt; and holds the generator calls like &lt;code&gt;rake activeadmin:install&lt;/code&gt; to generate the initializer files. By default, the activeadmin generates configuration files and a db migration file as well.&lt;/p&gt;

&lt;p&gt;So like we mentioned, db migration is valid in the world of SQL (within our context of explanation), but considering with Mongoid, that file is completely unnecessary and users were deleting them after it gets generated because it makes no sense and no use.&lt;/p&gt;

&lt;p&gt;One user pointed that out and raised an issue on that. &lt;a href="https://github.com/activeadmin/activeadmin-mongoid/issues/137" rel="noopener noreferrer"&gt;https://github.com/activeadmin/activeadmin-mongoid/issues/137&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So I was a little bit curious to try solving that out. There were little discussions went on the thread and &lt;a href="https://github.com/boie0025" rel="noopener noreferrer"&gt;Nic Boie&lt;/a&gt;, one of the maintainers gave it a shot and added what he tried and what was the result. That helped me to set the first direction towards solving the issue. Thanks to Nic!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fnaveenhonestraj.in%2Fstatic%2Fmedia%2Fnic-boie-solution.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fnaveenhonestraj.in%2Fstatic%2Fmedia%2Fnic-boie-solution.png" alt="Nic Boie's solution"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Towards solution
&lt;/h2&gt;

&lt;p&gt;Ideally, Nic Boie's solution solved the problem. It stopped the command from generating the migration file. But, while trying to open the class and override the method to make it do nothing, he has to require certain files and these files required has dependent requires and one of them brought in the &lt;code&gt;activerecord&lt;/code&gt; related files. So, now my task is to do the exact thing what Nic did, but without letting the &lt;code&gt;activerecord&lt;/code&gt; getting required through any dependent calls or so.&lt;/p&gt;

&lt;p&gt;This is the solution Nic provided&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;require 'active_admin/mongoid'
require 'generators/active_admin/install/install_generator.rb'

ActiveAdmin::Generators::InstallGenerator.class_eval do

  # Make this a no-op so the AR migrations are not installed when ActiveAdmin-Mongoid is used.
  def create_migrations;end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Reading through the activeadmin gem
&lt;/h2&gt;

&lt;p&gt;So, I took my time to read through the activeadmin gem and see for the class that Nic used above to override with &lt;code&gt;class_eval&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Studying the class &lt;code&gt;ActiveAdmin::Generators::InstallGenerator&lt;/code&gt; &lt;a href="https://github.com/activeadmin/activeadmin/blob/master/lib/generators/active_admin/install/install_generator.rb#L5" rel="noopener noreferrer"&gt;from here helped me&lt;/a&gt; to understand that the current class is the one which requires &lt;code&gt;activerecord&lt;/code&gt; related files, but the parent class of this class doesn't requires any of those.&lt;/p&gt;

&lt;p&gt;So the solution I came up with was, to go change the parent class of &lt;code&gt;ActiveAdmin::Generators::InstallGenerator&lt;/code&gt; to do the following:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;When a class subclasses from it, I need to change the way the subclass is described.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Then either override the method definition or disallow it from overriding.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  self.inherited method
&lt;/h2&gt;

&lt;p&gt;Ruby has a wonderful hook on class called &lt;code&gt;inherited&lt;/code&gt; which will be called when a class is used by another class to derive itself. Using that &lt;code&gt;inherited&lt;/code&gt; you can control specific way of the derived class. Cool, isn't it? I even tweeted about it here &lt;a href="https://twitter.com/nav_devl/status/1405329547701096452" rel="noopener noreferrer"&gt;https://twitter.com/nav_devl/status/1405329547701096452&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The only caveat with the idea I had was, I assumed when the self.inherited was called, the subclass will be fully defined and I can just remove/override the definition of &lt;code&gt;create_migrations&lt;/code&gt; method. But turns out, when the self.inherited was called, there are no user defined methods present. Only after the self.inherited is finished the the class implements all other user definied methods. 😔&lt;/p&gt;
&lt;h2&gt;
  
  
  self.method_added
&lt;/h2&gt;

&lt;p&gt;Again, Ruby as charming as always, provides us with a hook called &lt;code&gt;method_added&lt;/code&gt; and this is called every time a new method method definition is added to a class. Now can you see where we are heading towards?&lt;/p&gt;

&lt;p&gt;So we are going to combine the advantage of  &lt;code&gt;self.inherited&lt;/code&gt; and &lt;code&gt;self.method_added&lt;/code&gt; 🤯&lt;/p&gt;
&lt;h2&gt;
  
  
  Moving with solving
&lt;/h2&gt;

&lt;p&gt;So, now our next set of action is very simple.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Define an empty &lt;code&gt;create_migrations&lt;/code&gt; in the parent class.&lt;/li&gt;
&lt;li&gt;When a class is derived from it, we are redefining the &lt;code&gt;self.method_added&lt;/code&gt;'s definition. Classy, right? 😎&lt;/li&gt;
&lt;li&gt;So, if the derived class's name is &lt;code&gt;ActiveAdmin::Generators::InstallGenerator&lt;/code&gt; we are redefining the &lt;code&gt;self.method_added&lt;/code&gt; of that subclass to remove the method definition of &lt;code&gt;create_migration&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;remove_method&lt;/code&gt; will remove only the method definition scoped to that class, so our derived class will now lookup to parent class for definition when &lt;code&gt;create_migration&lt;/code&gt; is called.&lt;/li&gt;
&lt;li&gt;And we have an empty NO ACTION definition in our parent class.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No activerecord related items&lt;/strong&gt; are required while doing this.&lt;/li&gt;
&lt;li&gt;Bam! 🎉🎉&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Code
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Rails::Generators::NamedBase.class_eval do
  def create_migrations
  end
  def self.inherited(klass)
    super
    if klass.name == "ActiveAdmin::Generators::InstallGenerator"
      klass.class_eval do 
        def self.method_added(method_name)
          super
          remove_method method_name if method_name == :create_migrations
        end
      end
    end
  end
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fnaveenhonestraj.in%2Fstatic%2Fmedia%2Factiveadmin-mongoid-pr-screenshot.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fnaveenhonestraj.in%2Fstatic%2Fmedia%2Factiveadmin-mongoid-pr-screenshot.png" alt="Pull request on the activeadmin-mongoid repo"&gt;&lt;/a&gt;&lt;br&gt;
This is my implementation and the PR is here (&lt;a href="https://github.com/activeadmin/activeadmin-mongoid/pull/164" rel="noopener noreferrer"&gt;https://github.com/activeadmin/activeadmin-mongoid/pull/164&lt;/a&gt;) It is yet to be merged. 2/3 reviewer approved and hopefully I think it gets approved and merged. &lt;/p&gt;

</description>
      <category>ruby</category>
      <category>rails</category>
      <category>activeadmin</category>
    </item>
    <item>
      <title>Help with getting started in building bot for Slack</title>
      <dc:creator>Naveen Honest Raj</dc:creator>
      <pubDate>Wed, 16 Sep 2020 17:47:38 +0000</pubDate>
      <link>https://dev.to/nav_devl/help-with-getting-started-in-building-bot-for-slack-27c0</link>
      <guid>https://dev.to/nav_devl/help-with-getting-started-in-building-bot-for-slack-27c0</guid>
      <description>&lt;p&gt;I am trying to build a bot for Slack. I somehow managed to do the MVP version of it using Python's slack event API library &lt;code&gt;slackeventsapi&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;Today in an evening discussion, my friend suggested that I should probably try my hands with Hubot or Bolt framework in JS for building slackbot because those frameworks makes use of RTM(Real time messaging). The discussion couldn't go further because of some time constraint. Now I have been googling around to try and understand what kind of pros I'll get over choosing one over other and why?&lt;/p&gt;

&lt;p&gt;If someone could help me by explaining it in a bit easier terms, it would be so helpful. Thanks a lot :))&lt;/p&gt;

</description>
      <category>help</category>
      <category>beginners</category>
      <category>slack</category>
    </item>
    <item>
      <title>Running own private email server and the problems?</title>
      <dc:creator>Naveen Honest Raj</dc:creator>
      <pubDate>Fri, 10 Jul 2020 12:58:00 +0000</pubDate>
      <link>https://dev.to/nav_devl/running-own-private-email-server-and-the-problems-2jo5</link>
      <guid>https://dev.to/nav_devl/running-own-private-email-server-and-the-problems-2jo5</guid>
      <description>&lt;p&gt;I created my own email server using postfix and implemented a catch-all email approach. I am a beginner in creating and running my own email server but read few articles and successfully ran it.&lt;/p&gt;

&lt;p&gt;The approach I followed is written in here &lt;a href="https://naveenhonestraj.in/creating-an-incoming-email-server-and-sending-data/"&gt;https://naveenhonestraj.in/creating-an-incoming-email-server-and-sending-data/&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;My end goal is to catch all the email sent to a specific domain, say (@example.com) and make a POST call(something like a webhook action) with payloads that contains all the information of the email sent.&lt;/p&gt;

&lt;p&gt;I successfully made this and now can make those POST call with proper payload, but I am not aware of the problems/cons along running own server with the catch-all approach.&lt;/p&gt;

&lt;p&gt;If somebody who worked on the similar lines can share their thoughts and opinions on this, it would be very very helpful. Thanks. &lt;/p&gt;

</description>
      <category>help</category>
      <category>discuss</category>
      <category>postfix</category>
    </item>
    <item>
      <title>Timeout with a third party library or another server - How to handle?</title>
      <dc:creator>Naveen Honest Raj</dc:creator>
      <pubDate>Tue, 23 Jun 2020 12:35:06 +0000</pubDate>
      <link>https://dev.to/nav_devl/timeout-with-a-third-party-library-or-another-server-how-to-handle-5g9b</link>
      <guid>https://dev.to/nav_devl/timeout-with-a-third-party-library-or-another-server-how-to-handle-5g9b</guid>
      <description>&lt;p&gt;This example I am stating obviously a rare scenario, but I would like to understand how this would be handled? (or they should be totally avoided?)&lt;/p&gt;

&lt;p&gt;Consider there's two application server (AS1 and AS2) having their own databases(DB1 and DB2). An HTTP call to one AS1 will internally make HTTP call to AS2. Once AS2 validated the payload from AS1, it will write to DB2 and returns an hash, which AS1 will store in DB1. &lt;/p&gt;

&lt;p&gt;Looks very simple to construct, but how can we handle this following scenario. Say, AS1's internal HTTP call to AS2 has a specific timeout (let's assume 15seconds). In that time period, AS2 writes to DB2 but didn't return before the timeout, so AS1 don't have the hash and now it cannot make a duplicate call to do AS2 again.&lt;/p&gt;

&lt;p&gt;How should this be handled? I know the scenario looks vague for few of you. But let's pop up some discussion further if needed. Thanks.&lt;/p&gt;

</description>
      <category>help</category>
      <category>architecture</category>
      <category>server</category>
      <category>python</category>
    </item>
    <item>
      <title>Writing your first Business Model in Hyperledger Composer</title>
      <dc:creator>Naveen Honest Raj</dc:creator>
      <pubDate>Wed, 21 Feb 2018 04:53:44 +0000</pubDate>
      <link>https://dev.to/skcript/writing-your-first-business-model-in-hyperledger-composer--4pk0</link>
      <guid>https://dev.to/skcript/writing-your-first-business-model-in-hyperledger-composer--4pk0</guid>
      <description>&lt;p&gt;This article focuses on creating a simple business model that helps you with visualizing the abstract nature of Hyperledger Composer’s language.&lt;/p&gt;

&lt;p&gt;If you are confused on where to start or wasted a lot of your time in getting started with Hyperledger Composer, you should read this article. My co-worker, Varun has explained it in such a simple way that anyone can understand it.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Business Network Definition?
&lt;/h2&gt;

&lt;p&gt;The Business Network Definition is the core definition that holds the Hyperledger Composer’s programming model. In short, it controls the model definition, the relationship between them, the access control over them and the actions that could be performed on/with them.&lt;/p&gt;

&lt;p&gt;BND has three core components : &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The Model written in .cto files&lt;/li&gt;
&lt;li&gt;The Business Logic written in .js files&lt;/li&gt;
&lt;li&gt;The Access Control Logic written in .acl files&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;(Optional) There is a Query file written in .qry files that help us to query over the persistent DB.&lt;/p&gt;

&lt;p&gt;These three components are easy to maintain and they govern our whole business application on the Composer. &lt;/p&gt;

&lt;p&gt;Let’s see how to write a manageable simple model file that helps anyone understand most of our business logic. We will implement this in the business logic file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding The Key Concepts Of A Model
&lt;/h2&gt;

&lt;p&gt;Before writing our own model, let us understand the key concepts of it. In a model file, you will be defining the following, &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A namespace
namespace org.skcript.svr&lt;/li&gt;
&lt;li&gt;Resources, which includes

&lt;ol&gt;
&lt;li&gt;Participants&lt;/li&gt;
&lt;li&gt;Assets&lt;/li&gt;
&lt;li&gt;Transactions&lt;/li&gt;
&lt;li&gt;Events&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;

&lt;li&gt;Optional import statements that are used to inherit or import other model files.&lt;/li&gt;

&lt;/ol&gt;

&lt;h2&gt;
  
  
  Resources Are Everything In A CTO File
&lt;/h2&gt;

&lt;p&gt;A ‘Participant’ denotes the person who does the action (in simple terms). This is to whom the ID is issued and this is the one who performs transactions.&lt;/p&gt;

&lt;p&gt;For example: Consider the example&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;participant Author identified by id {
    o Integer id
    o String name
    o String email
    o String specialized_in 
    o Double age
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the above example, we see there’s a participant named &lt;code&gt;Author&lt;/code&gt; and the keyword &lt;code&gt;identified by&lt;/code&gt; is used to select the primary key. Here, it is &lt;code&gt;id&lt;/code&gt; field that acts as a primary key. We will know the wide applications of having this &lt;code&gt;identified by&lt;/code&gt; on right field to have an easy and readable access to the model.&lt;/p&gt;

&lt;p&gt;The circles are nothing but lower case ‘o’ (The O, yeah ! ).  Composer’s model file has a unique way of representing a new key in their object. But you will get used to it.&lt;/p&gt;

&lt;p&gt;Assets are the resource which our business model has. Considering our above example, &lt;code&gt;Author&lt;/code&gt; is a participant, then &lt;code&gt;Post&lt;/code&gt; will be the asset that he holds. And we know that every post will always belong to an author. There can never be an asset that won’t belong to an author. This can be done by creating a relationship between our participant and asset. This is easy-peasy because of the CTO’s modeling language. &lt;/p&gt;

&lt;p&gt;P.S. You should be careful with relationship because it is unidirectional and you can’t do the vice versa which you can do in most of the application frameworks.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
* An enumerated type
*/
enum Category {
  o AI
  o BLOCKCHAIN
  o WEB-DEVELOPMENT
  o BACKEND
  o DESIGN
  o FUN
}

/**
 * A post asset.
 */
asset Post identified by id {
  o String id
  o String title
  o Category category
  o DateTime timestamp
  --&amp;gt; Author author
  --&amp;gt; Author coAuthor optional
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the above example, as we learned earlier &lt;code&gt;identified by&lt;/code&gt; is used with &lt;code&gt;id&lt;/code&gt; as primary key which makes sense. Right? Now you can understand.&lt;/p&gt;

&lt;p&gt;But where’s the new thing coming up? No rush. Let’s take it slow. &lt;br&gt;
Let’s see the &lt;code&gt;Line 21&lt;/code&gt; - we see an arrow. Okay. I didn’t write it because it looks good on the code and it’s not a comment too. That’s again our Composer’s modeling language’s weird way of writing relationship. So we should read it as Post belongs to Author. That’s simple. Done.&lt;br&gt;
In &lt;code&gt;Line 22&lt;/code&gt; , we can see there’s a new keyword &lt;code&gt;optional&lt;/code&gt;. This helps us avoid mandatory entry to create an asset. This is defined as optional by thinking that there may or may not be a coauthor for a particular post.&lt;/p&gt;

&lt;p&gt;Next, why &lt;code&gt;enum&lt;/code&gt; ? It’s for managing a neat code. As our articles goal is not only to learn how to write a model but also to write a good one that can be easy to read and update.&lt;br&gt;
So enum holds the possible values our field can take. So we defined an &lt;code&gt;enum&lt;/code&gt; called &lt;code&gt;Category&lt;/code&gt; and we gave it all the possible values it can take. Now in &lt;code&gt;Line 19&lt;/code&gt; we used it and created a category of &lt;code&gt;enum Category&lt;/code&gt; . &lt;/p&gt;

&lt;p&gt;Transactions are the process in which our participants do the operation on assets. Considering our scenario, author creating a post is also a transaction. &lt;br&gt;
Example:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;transaction createPost {
  --&amp;gt; Author owner
  o String title
  o Category category
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The above transaction definition emphasizes that we are creating a post by pointing out the author of the post. We also provide title and category while creating the post.&lt;/p&gt;

&lt;p&gt;P.S: In our next post, we will learn more about the transactions and transaction processor functions. &lt;/p&gt;

&lt;p&gt;Events are used to trigger some other third party application. You can write the logic for the event which will help you to send an email about the author’s new post. These events can be used to help you to send emails if and only if you subscribed to the particular author which helps to avoid spam and improves integrity. Events are also defined the same as transactions. The purpose is only different. Used with &lt;code&gt;event&lt;/code&gt; keyword for declaration.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Endless Possibilities Of The CTO File
&lt;/h2&gt;

&lt;p&gt;You can still segregate the model declaration by &lt;code&gt;abstract&lt;/code&gt;  keyword which won’t create participant or asset in the registry, rather is used to inherit from the other resources.&lt;/p&gt;

&lt;p&gt;Example: Considering the same scenario, try to understand the following code&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;abstract Participant UserInformation identified by name {
  o String name
  o String address
  o String email
  o Integer age
}

participant Author identified by id {
    o Integer id
    o String specialized_in 
    o UserInformation user_information
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We created an &lt;code&gt;abstract&lt;/code&gt; participant which holds most information about a user and we inherit and use that in our &lt;code&gt;Author&lt;/code&gt; participant. This helps us have a clean model that still maintains Single Responsibility Principle. We can do abstract type for assets and transactions too. &lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;There are much more magical things like &lt;code&gt;extends&lt;/code&gt; that we can do with CTO file. But let’s end it clean and easy here. After you write your first model, you will figure out most of the conventions you might need to follow to have a maintainable code. Wish you a good luck, readers.&lt;/p&gt;

</description>
      <category>hyperledger</category>
      <category>composer</category>
      <category>fabric</category>
      <category>blockchain</category>
    </item>
  </channel>
</rss>
