<?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: PrincessAnjana1996</title>
    <description>The latest articles on DEV Community by PrincessAnjana1996 (@princessanjana1996).</description>
    <link>https://dev.to/princessanjana1996</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%2F161367%2F99a861b2-e33a-4f83-a05f-5e89d1870b75.jpg</url>
      <title>DEV Community: PrincessAnjana1996</title>
      <link>https://dev.to/princessanjana1996</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/princessanjana1996"/>
    <language>en</language>
    <item>
      <title>A brief look into code quality</title>
      <dc:creator>PrincessAnjana1996</dc:creator>
      <pubDate>Wed, 19 Feb 2020 06:22:08 +0000</pubDate>
      <link>https://dev.to/princessanjana1996/a-brief-look-into-code-quality-o7e</link>
      <guid>https://dev.to/princessanjana1996/a-brief-look-into-code-quality-o7e</guid>
      <description>&lt;p&gt;When we are writing code, it should be human-readable and clean. This article is about some basics of writing readable and clean code.&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Sj7-pxwl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/ksPSIwKnG0CkdPKkORMnwtGoeXMbCGXyUONk1u8uRkWYi4_La3xFvP2dTxASCTioIxJTOtPDm7f5EczL_sksOGtNbTpdrymVNsiV1Xbt2DAMg4ou8n2rCs-uoPS4wwnpP6Gq2G73" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Sj7-pxwl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh6.googleusercontent.com/ksPSIwKnG0CkdPKkORMnwtGoeXMbCGXyUONk1u8uRkWYi4_La3xFvP2dTxASCTioIxJTOtPDm7f5EczL_sksOGtNbTpdrymVNsiV1Xbt2DAMg4ou8n2rCs-uoPS4wwnpP6Gq2G73" alt="syntax"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now let’s discuss these syntax and best practices in detail.&lt;/p&gt;

&lt;h3&gt;
  
  
  Curly Braces
&lt;/h3&gt;



&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;If (condition) {
    // do this
    // do this
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;In JavaScript language curly braces are written with the opening bracket on the same line not on a new line and there should be a space before the opening curly bracket as above example.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Curly braces are not needed for a single-line construct.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (i &amp;lt;= 0) {alert(`It should not be ${i}`);}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If it is short, we can use it without curly braces.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (i &amp;lt;= 0) return null;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Don’t split to a separate line without braces.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (i &amp;lt;= 0) 
    alert(`It should not be ${i}`);
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The best way. This is usually more readable.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (i &amp;lt;= 0) {
    alert(`It should not be ${i}`);
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Semicolon
&lt;/h3&gt;

&lt;p&gt;The majority of developers put semicolons after each statement but it is optional and rarely used. In JavaScript there are problems where a line break is not interpreted as  a semicolon, going the code vulnerable to errors.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let sum = a + b;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Indents
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Horizontal indents  &lt;/p&gt;

&lt;p&gt;2 or 4 spaces( 4 spaces = key Tab). For instance, to align the arguments with the opening bracket.&lt;br&gt;
&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function fruit(banana,
       mango,
       avocado 
    ) {

}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Vertical indents
Function can be divided into logical blocks. In the below example appears three vertically split. First one is initialization of variables, the second one main loop and the third one returning the result.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function sum(a) {
    let total = 0;

    while(a &amp;gt; 0) {
      total += a;
    }

    return total;
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If we want to make the code more readable we can add extra newline.&lt;/p&gt;

&lt;h3&gt;
  
  
  Line Length
&lt;/h3&gt;

&lt;p&gt;Don’t write long horizontal lines of code because no one prefers to read it. Back tick quotes(``) help to split the long string into multiple lines.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let pra = `
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
  Integer eu convallis sem. 
  Praesent in facilisis ligula. 
  Curabitur iaculis metus lacus, vitae dapibus odio iaculis vitae. 
  Morbi imperdiet ultricies tortor ac dignissim. 
  Quisque at mi a purus dignissim tincidunt eu eu ipsum. 
  Phasellus pharetra vitae neque id fermentum.
`;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Same as the if statement. For example,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (
  id === 10001 &amp;amp;&amp;amp;
  name === 'Anjana Kumari' &amp;amp;&amp;amp;
  address === 'Kandy'
) {
  login();
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The maximum line length is usually 80 or 120 characters but it will depend upon the team-level.&lt;/p&gt;

&lt;h3&gt;
  
  
  Nesting Level
&lt;/h3&gt;

&lt;p&gt;If we can use &lt;code&gt;continue&lt;/code&gt; directive, we can easily avoid extra nesting. For example,&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;while (i &amp;lt; 10) {
  if (!condition) continue;
  // do that
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Style Guides
&lt;/h3&gt;

&lt;p&gt;Style guides includes how to write code. If we work as a team we can use the same style guide. Then the code can see uniform. Also teams can use their own style guide too. The popular style guides are Google JavaScript Style Guide and StandardJS etc.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automated Linters
&lt;/h3&gt;

&lt;p&gt;Automated Linter tools can automatically detect the style of our code and make suggestions. Also, the linter tools can detect typos in variable names and function names. Some of the popular linting tools are JSLint, JSHint, and ESHint.&lt;/p&gt;

&lt;h3&gt;
  
  
  Summary
&lt;/h3&gt;

&lt;p&gt;Carly Braces, Semicolons, Indents, Line Length and Nesting Levels rules described aim to increase the readability of our code.&lt;/p&gt;

&lt;p&gt;We should always think about writing better code. There are two things to keep mind when we write codes. First one is  what makes the code more readable and easier to understand? And the second one is what can help us avoid errors?&lt;/p&gt;

&lt;p&gt;Finally, we should be up to date with reading the most popular style guides.&lt;/p&gt;

&lt;p&gt;Original post in my &lt;a href="https://anjanak.com/a-brief-look-into-code-quality/"&gt;personal blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codequality</category>
      <category>javascript</category>
      <category>cleancode</category>
    </item>
    <item>
      <title>ACID Properties in Databases</title>
      <dc:creator>PrincessAnjana1996</dc:creator>
      <pubDate>Wed, 19 Feb 2020 05:48:38 +0000</pubDate>
      <link>https://dev.to/princessanjana1996/acid-properties-in-databases-43aa</link>
      <guid>https://dev.to/princessanjana1996/acid-properties-in-databases-43aa</guid>
      <description>&lt;p&gt;A transaction is a logical unit of processing in a database management system which has one or more database access operations. If we need to do a transaction successfully, we must follow ACID compliance. ACID properties implement for the safety and privacy of the database data. For example, private data such as financial data and transaction or personal data. Also ACID properties can avoid less consistency data. For example, blog post comments. ACID stands for Atomicity, Consistency, Isolation, and Durability.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ktd7wxFB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh4.googleusercontent.com/4bxBwUPGStV2XtK6M_MHFY70h6-DIzRvN4au5LTZrUsYWFZtkfZ7OTHJOH_w7UmpsUCt6NJOVdshfU4sSIJw-UX0vbwZOE0tGaZ3GsGnEhf8JvY9AD9Qns9pEPGgG9OV6r-iDrz8" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ktd7wxFB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh4.googleusercontent.com/4bxBwUPGStV2XtK6M_MHFY70h6-DIzRvN4au5LTZrUsYWFZtkfZ7OTHJOH_w7UmpsUCt6NJOVdshfU4sSIJw-UX0vbwZOE0tGaZ3GsGnEhf8JvY9AD9Qns9pEPGgG9OV6r-iDrz8" alt="ACID Properties"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s see what the meaning of ACID letters,&lt;/p&gt;

&lt;h3&gt;
  
  
  Atomicity
&lt;/h3&gt;

&lt;p&gt;Atomicity needs to do each transaction which is executed in its all, or fail without any change being concerned. For instance, I transfer 5000 rupees from my Sampath bank account to my friend’s bank account. If any of the instructions fail, the all transaction should fail and rollback.&lt;/p&gt;

&lt;h3&gt;
  
  
  Consistency
&lt;/h3&gt;

&lt;p&gt;Consistency means if a transaction is successfully fulfilled, it  will take to the database from one state that is consistent to another state that is also consistent.&lt;/p&gt;

&lt;h3&gt;
  
  
  Isolation
&lt;/h3&gt;

&lt;p&gt;Multiple transactions can run at the same time in the system. Isolation guarantees that each transaction is not able to view partial results of the others. Executing multiple transactions in parallel must have the same results as running them sequentially.&lt;/p&gt;

&lt;h3&gt;
  
  
  Durability
&lt;/h3&gt;

&lt;p&gt;Durability means that the result of a committed transaction is permanent, even if the database crashes immediately or in the event of a power loss.&lt;/p&gt;

&lt;p&gt;Database files are committed every 60 seconds.&lt;br&gt;
The journal of operations is committed every 100 milliseconds.&lt;br&gt;
Relational databases such as MYSQL, SQL have ACID properties. Also from MongoDB 4.0 it also supports ACID for multi document transactions. Since MongoDB version 4.0, it was fast, flexible and powerful. MongoDB has revolutionized the database design, freeing the developers from some of the inconveniences of legacy relational databases. Also design of the databases based on rich, natural and flexible documents accessed by idiomatic programming language APIs, allowing developers to create app way faster than before. And MongoDB makes it easy to handle more data in distributed system architecture and allows have always-on services. So developers have a huge benefit to build powerful and sophisticated softwares in all industries.&lt;/p&gt;

&lt;p&gt;These are some companies which use MongoDB.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZqBoEXoX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/1Qi_M7hfOYVUgdr-r-oJvIYlgeP05GzTZapxvfsru5xNe8C4rjLAl4VGji4-HLUvn-MTQGtt2i0smKRwq__Xw9fZvW9a2PBRA3uxYKlaMVl42xsn_wffgBLqyJGxrsPnNJNTt35-" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZqBoEXoX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh5.googleusercontent.com/1Qi_M7hfOYVUgdr-r-oJvIYlgeP05GzTZapxvfsru5xNe8C4rjLAl4VGji4-HLUvn-MTQGtt2i0smKRwq__Xw9fZvW9a2PBRA3uxYKlaMVl42xsn_wffgBLqyJGxrsPnNJNTt35-" alt="some companies which use MongoDB"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Original post my &lt;a href="https://anjanak.com/acid-properties-in-database/"&gt;personal blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>acid</category>
      <category>mongodb</category>
      <category>database</category>
    </item>
  </channel>
</rss>
