<?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: Fajar Zuhri Hadiyanto</title>
    <description>The latest articles on DEV Community by Fajar Zuhri Hadiyanto (@fajarzuhrihadiyanto).</description>
    <link>https://dev.to/fajarzuhrihadiyanto</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%2F720744%2F057c73e6-77b8-4bc2-ab88-f9bca1772f92.png</url>
      <title>DEV Community: Fajar Zuhri Hadiyanto</title>
      <link>https://dev.to/fajarzuhrihadiyanto</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fajarzuhrihadiyanto"/>
    <language>en</language>
    <item>
      <title>Database Normalization</title>
      <dc:creator>Fajar Zuhri Hadiyanto</dc:creator>
      <pubDate>Sun, 17 Oct 2021 05:30:07 +0000</pubDate>
      <link>https://dev.to/fajarzuhrihadiyanto/database-normalization-jil</link>
      <guid>https://dev.to/fajarzuhrihadiyanto/database-normalization-jil</guid>
      <description>&lt;p&gt;Database normalization is a process of restructuring database tables in order to minimize data redundancy and avoid data anomalies such as insert anomaly, delete anomaly, and update anomaly.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa7ubg8q8lj76y5yocm6l.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa7ubg8q8lj76y5yocm6l.png" alt="Example"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Insert anomaly&lt;/strong&gt; occurs when we have to insert unnecessary similar data. for example when we have the data above. in that case, if we want to add another student that has the same course, then we have to add the same course information such as the lecturer's name, even though that is unnecessarily needed, because, for each same course, the lecturer will be the same.&lt;/p&gt;

&lt;p&gt;Next, there is a &lt;strong&gt;delete anomaly&lt;/strong&gt; that occurs when we want to delete data in a certain domain and it affects the loss of other data domains. let's take the previous table as an example. when all students in the fundamental programming course have passed the course, we might delete those students' information because we don't need those students in that table anymore. When we remove the data, it will impact the loss of course information, such as who teaches that course. In this case, we will lose the information on who teaches the fundamental programming course.&lt;/p&gt;

&lt;p&gt;And then, there is an &lt;strong&gt;update anomaly&lt;/strong&gt; that occurs when we have to replace all same existing data that belongs to the same data in a data domain. let's take the previous table again as an example. Just imagine that somehow, the lecture that teaches the fundamental programming course (Mr. Marc Whitfield) cannot teach the fundamental programming anymore and have to be replaced by another lecturer, just call him mr. Trystan Mccall. Because of that, we have to replace all lecturer data that belongs to the fundamental programming course (Mr. Marc Whitfield) with mr. Trystan Mccall.&lt;/p&gt;

&lt;p&gt;There are some steps to normalize the database table, which are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1NF&lt;/li&gt;
&lt;li&gt;2NF&lt;/li&gt;
&lt;li&gt;3NF&lt;/li&gt;
&lt;li&gt;BCNF&lt;/li&gt;
&lt;li&gt;4NF&lt;/li&gt;
&lt;li&gt;5NF&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  1NF &lt;a&gt;&lt;/a&gt;
&lt;/h2&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faycskzj4samv77l83ox9.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faycskzj4samv77l83ox9.png" alt="Original Table"&gt;&lt;/a&gt;in order to make the table satisfy the first normal form, there is one simple rule that has to be applied for each table, which is to make every attribute or column in each table store a single &lt;strong&gt;atomic data, not a group of data&lt;/strong&gt;. In the example above, a student have more than one course which is violae the first normal form. we can separate those course data into different rows without the loss of the student and lecturer information, so the table will look like this. &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvmo77iknxabqldfze8au.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvmo77iknxabqldfze8au.png" alt="First Normal Form Table"&gt;&lt;/a&gt; The table above satisfies the first normal form of a database table, but there is partial dependency and transitive dependency which will be discussed in the higher normal form.&lt;/p&gt;

&lt;h2&gt;
  
  
  2NF &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;In order to make the table satisfy the second normal form, the table must be in the first normal form. Then, there is an additional rule, the table has &lt;strong&gt;no partial dependency&lt;/strong&gt;. Partial dependency is the dependency of a non-primary attribute which only on a part of a composite primary key, not a whole composite primary key. In the previous table, there is a composite primary key formed by &lt;em&gt;student_number&lt;/em&gt; and &lt;em&gt;course_code&lt;/em&gt; attribute. There are some attributes that depend only on one primary key, such as &lt;em&gt;student_name&lt;/em&gt; that depends only on the &lt;em&gt;student_number&lt;/em&gt; attribute, and &lt;em&gt;course_name&lt;/em&gt; that depends only on the &lt;em&gt;course_code&lt;/em&gt;. These attributes violate the second normal form.&lt;/p&gt;

&lt;p&gt;To get rid of that problem, we have to &lt;strong&gt;separate the partial dependent attribute&lt;/strong&gt; into a new table with the corresponding primary key. So, the tables will look like this.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1gmgrj4jmrxkk8sohym.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1gmgrj4jmrxkk8sohym.png" alt="Second Normal Form Tables"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  3NF &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;In order to make the table satisfy the third normal form, the table must be in the second normal form. Then, there is an additional rule, the table has &lt;strong&gt;no transitive dependency&lt;/strong&gt;. Transitive dependency is the dependency of a non-primary attribute on another non-primary attribute. In the previous table, we get rid of student_name and course name that depends on one of the composite primary key, but what about the &lt;em&gt;lecturer_name&lt;/em&gt; attribute? it doesn't depend on any of a composite primary key, but instead, it depends on &lt;em&gt;lecturer_code&lt;/em&gt; which is not a part of composite primary key nor a single primary key itself.&lt;/p&gt;

&lt;p&gt;to convert the table to satisfy the third normal form, we have to &lt;strong&gt;separate the transitive dependent attribute&lt;/strong&gt; into a new table with the corresponding primary key, so the table will look like this.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvk2ix5d2i1h3kwac7x5f.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvk2ix5d2i1h3kwac7x5f.png" alt="Third Normal Form Table"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  BCNF (Boyce-Codd Normal Form) &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The table should be converted to BCNF only if the table is in the third normal form and &lt;strong&gt;every determinant attribute in the table is a candidate key&lt;/strong&gt;. In the previous table, besides the &lt;em&gt;student_number&lt;/em&gt; and &lt;em&gt;course_code&lt;/em&gt; that were chosen to be a composite key, there is also another determinant attribute that is also a candidate key, that is &lt;em&gt;lecturer_code&lt;/em&gt;, but for some reason, it was not chosen to be a part of the composite primary key. If we observe, one course can be taught by many lecturers, but one lecturer only teaches one course, which means that the course depends on another non-primary key attribute. This condition obviously violates the BCNF.&lt;/p&gt;

&lt;p&gt;To convert the table into a BCNF, we can &lt;strong&gt;modify the composite primary key&lt;/strong&gt; from &lt;em&gt;student_number&lt;/em&gt; + &lt;em&gt;course_code&lt;/em&gt; into &lt;em&gt;student_number&lt;/em&gt; + &lt;em&gt;lecturer_code&lt;/em&gt;, then we move attribute course code into the lecturer's table. Therefore, there is no candidate key and the tables will look like this.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwvb9xagfam7mzbe91ogq.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwvb9xagfam7mzbe91ogq.png" alt="Boyce-Codd Normal Form"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4NF &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;To achieve the fourth normal level of a database table, the table must have &lt;strong&gt;no multivalued dependency&lt;/strong&gt;. Multivalued dependency is a dependency of two or more non-primary keys on a primary key or composite of it, where these non-primary keys are independent of each other. Let's take another example in the table below.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4590ffbhuljq3z8nvnds.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4590ffbhuljq3z8nvnds.png" alt="Multivalued Dependency Example"&gt;&lt;/a&gt;In that table, there are language and skill attribute that depend on the same primary key (EmployeeId), but those attributes are not related to each other. In other words, the dependency of those attributes violates the fourth normal form of the database table. To deal with this, we can &lt;strong&gt;separate both dependent attribut&lt;/strong&gt; into a new table with the primary key, so the table will look like this&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5pri7ky51x11tkjb9ytr.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5pri7ky51x11tkjb9ytr.png" alt="Fourth Normal Form Tables"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5NF &lt;a&gt;&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The table can satisfy the fifth normal form if the table is in the fourth normal form and &lt;strong&gt;the table cannot be decomposed into some smaller tables without losing some information&lt;/strong&gt;. It's a bit complicated to understand, but let's try to take a look at the table of relationship between brand, distributor and the customer.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3osrriz0rp36sx1xppki.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3osrriz0rp36sx1xppki.png" alt="Original Table"&gt;&lt;/a&gt;There are some relationships that exist between the data, such as distributors that sell stuff with a certain brand name, customers that buy stuff from distributors, and customers that buy stuff with a certain brand name. Let's try to decompose the table into three different tables that represent those relationships.&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F11ns2h2or8xppgb6nngf.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F11ns2h2or8xppgb6nngf.png" alt="Decomposed Table"&gt;&lt;/a&gt; From the Brand Customer table, we can see that Reggie Pearson buys stuff with brand ASUS. Now let's find out from which distributor Reggie Pearson buys ASUS stuff. If we observe the Distributor Customer Table, Reggie Pearson only buys stuff from distributors AAX, KGR, and BGC. If we observe the Brand Distributor table, only distributors AAX, KGR, and BGC that sell ASUS stuff. From this information, we know that Reggie Pearson might buy ASUS stuff from distributors AAX, KGR, or BGC, but if we take a look back at the original table, Reggie Pearson only buys ASUS stuff from distributor AAX. This misleading information might be caused by some conditions, maybe there is someone that buy ASUS stuff from distributor KGR and BGC, or maybe there is another brand that bought by Reggie Pearson from distributor KGR and BGC. That's why we cannot decompose the original table into some smaller tables because we lose information on who is actually buying stuff with which brand name from which distributor. In other words, the original table already satisfies the fifth normal form.&lt;/p&gt;

</description>
      <category>database</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Types of Relation Between Classes in Object Oriented Programming</title>
      <dc:creator>Fajar Zuhri Hadiyanto</dc:creator>
      <pubDate>Thu, 07 Oct 2021 08:07:52 +0000</pubDate>
      <link>https://dev.to/fajarzuhrihadiyanto/types-of-relation-between-classes-in-object-oriented-programming-551m</link>
      <guid>https://dev.to/fajarzuhrihadiyanto/types-of-relation-between-classes-in-object-oriented-programming-551m</guid>
      <description>&lt;p&gt;Object-oriented programming is a programming paradigm that sees everything as an object. Object-oriented programming is adapted from a real-world problem. For example, you have a cat, so do i. Your cat and mine have the same properties, such as weight and color. Your cat and mine also have similar behavior, such as eating, sleeping, and walking. Your cat is an object and mine is another object. We can classify these objects into one class, just say it Cat class.&lt;/p&gt;

&lt;p&gt;In object-oriented programming, class is a blueprint for objects that we want to create. One class can be related to another class or not. Generally, there are some relations between classes in oop, which are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;aggregation&lt;/li&gt;
&lt;li&gt;composition&lt;/li&gt;
&lt;li&gt;inheritance&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Aggregation &lt;a&gt;&lt;/a&gt;
&lt;/h2&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcuat83eulk17ubj0g17x.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcuat83eulk17ubj0g17x.PNG" alt="Aggregation"&gt;&lt;/a&gt; Aggregation is a Has-A relationship between two objects where each object can exist without another object. In other words, these objects are independent. For example, the relationship between employee and department. An employee can stand alone without a department, so does the department.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Employee&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;salary&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Employee&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Department&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;Employee&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;employees&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Department&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;The source code above is an example of the implementation of aggregation in java. The Department class has a relationship with the Employee class. Department object can have a list of employees or not at all. Employee object might belong to Department object or not. There is no restriction in the aggregation relationship.&lt;/p&gt;

&lt;h2&gt;
  
  
  Composition &lt;a&gt;&lt;/a&gt;
&lt;/h2&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19gfhwac7xtuy59bgsxo.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F19gfhwac7xtuy59bgsxo.PNG" alt="Composition"&gt;&lt;/a&gt; Composition is a Has-A relationship between classes where both classes are dependent on each other. One object cannot exist without the existence of another object. For example, the relation between Laptop and its Processor. A laptop cannot exist without its processor.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Processor&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;modelName&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;frequency&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Processor&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Laptop&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
   &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Processor&lt;/span&gt; &lt;span class="n"&gt;processor&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Processor&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;

   &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Laptop&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;The source code above is an example of the implementation of composition in java. The Laptop class has a relationship with the Processor class. When a laptop object is created, a processor object that belongs to that laptop is automatically created.&lt;/p&gt;

&lt;h2&gt;
  
  
  Inheritance &lt;a&gt;&lt;/a&gt;
&lt;/h2&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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F42b2jtyyzoadw5u0er0i.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%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F42b2jtyyzoadw5u0er0i.PNG" alt="Inheritance"&gt;&lt;/a&gt; Inheritance is an Is-A relationship between classes where parent class is a general class and child class is a specific class. For example, the relation between cat, dog, and its general class, which is animal. An animal can be specified as a cat or dog. Cat and dog can be generalized as an animal.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Animal&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;weight&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;protected&lt;/span&gt; &lt;span class="n"&gt;color&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Animal&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;talk&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"It is animal"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Cat&lt;/span&gt; &lt;span class="n"&gt;extend&lt;/span&gt; &lt;span class="nc"&gt;Animal&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Cat&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;talk&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"meow"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Dog&lt;/span&gt; &lt;span class="n"&gt;extend&lt;/span&gt; &lt;span class="nc"&gt;Animal&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Dog&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;talk&lt;/span&gt; &lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;System&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;out&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;println&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"bark"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;The source code above is an example of the implementation of inheritance in java. The Cat and The Dog both have properties of weight and color. To generalize those properties of Cat and Dog, we can create one parent class that can represent both cat and dog with those properties, which is Animal class.&lt;/p&gt;

</description>
      <category>oop</category>
      <category>java</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
