<?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: Musab Abdelrahman</title>
    <description>The latest articles on DEV Community by Musab Abdelrahman (@mosab9).</description>
    <link>https://dev.to/mosab9</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%2F1092392%2F3513ee32-1c47-4c14-b8c5-dbc064f5488e.jpeg</url>
      <title>DEV Community: Musab Abdelrahman</title>
      <link>https://dev.to/mosab9</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mosab9"/>
    <language>en</language>
    <item>
      <title>Object Oriented Programming in Financial System</title>
      <dc:creator>Musab Abdelrahman</dc:creator>
      <pubDate>Tue, 14 May 2024 11:11:29 +0000</pubDate>
      <link>https://dev.to/mosab9/object-oriented-programming-in-financial-system-4p6m</link>
      <guid>https://dev.to/mosab9/object-oriented-programming-in-financial-system-4p6m</guid>
      <description>&lt;p&gt;It is a programming concept based on objects having data and methods defined in the class to which it belongs.&lt;/p&gt;

&lt;p&gt;Then Concept Include: Encapsulation, Inheritance, Abstraction and Polymorphism.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Encapsulation&lt;/strong&gt;:
&lt;/h3&gt;

&lt;p&gt;It is a mechanism of wrapping the variables/data  and methods operate on the variables/data together as a single unit.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;I have Spring boot application add data into data base and I’m using Object Relational Mapping (&lt;em&gt;ORM&lt;/em&gt;), so I will define DAO - Data Access Object class to interact with data base table customerAccounts, this call will include private variables and public setters and getters.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Inheritance&lt;/strong&gt;:
&lt;/h3&gt;

&lt;p&gt;It is the mechanism in java by which one class is allowed to inherit the features(fields and methods) of another class.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;&lt;code&gt;Account&lt;/code&gt;&lt;/strong&gt; class serves as the base class, containing common functionalities such as deposit, withdraw and getBalance.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;&lt;code&gt;SavingsAccount&lt;/code&gt;&lt;/strong&gt; class adds a &lt;strong&gt;&lt;code&gt;calculateInterest&lt;/code&gt;&lt;/strong&gt; method to calculate interest specific to savings accounts, while the &lt;strong&gt;&lt;code&gt;CheckingAccount&lt;/code&gt;&lt;/strong&gt; class adds a &lt;strong&gt;&lt;code&gt;processCheck&lt;/code&gt;&lt;/strong&gt; method to handle check processing specific to checking accounts.&lt;/li&gt;
&lt;li&gt;Through inheritance, the code is more organized, and common functionalities are centralized in the base class, reducing code duplication and promoting reusability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Overriding:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;&lt;code&gt;Account&lt;/code&gt;&lt;/strong&gt; class defines common functionality for all types of accounts, including deposit and withdraw methods.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;&lt;code&gt;SavingsAccount&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;CheckingAccount&lt;/code&gt;&lt;/strong&gt; classes extend the &lt;strong&gt;&lt;code&gt;Account&lt;/code&gt;&lt;/strong&gt; class and override withdraw methods as need to calculate different fees for each account type.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Abstraction&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Allows to generalize functionality of classes without providing implementation details.&lt;/p&gt;

&lt;p&gt;Example (Interface): &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I have &lt;strong&gt;customerService&lt;/strong&gt; interface that contracts that define a set of methods that a class must implement. then I have &lt;strong&gt;customerServiceImp&lt;/strong&gt; class which implements all interface methods and give their implementation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example (Abstract): &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For banking system we have a Accounts abstract class which has abstract methods like (withdraw &amp;amp; deposit) methods and other non abstract methods (getBalance).&lt;/li&gt;
&lt;li&gt;We extend Accounts abstract class it’s provide different implementation for abstract methods and inherent non abstract methods (getBalance).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Polymorphism&lt;/strong&gt;:
&lt;/h3&gt;

&lt;p&gt;It means many forms, and we achieve this by Overloading (compile) and Overriding (runtime).&lt;/p&gt;

&lt;p&gt;Example (Overloading): &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In banking system we have*&lt;em&gt;&lt;code&gt;Transaction&lt;/code&gt;&lt;/em&gt;* class contains multiple overloaded*&lt;em&gt;&lt;code&gt;transfer()&lt;/code&gt;&lt;/em&gt;* methods, each accepting different parameters to handle different types of transactions transfer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example (Overriding):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The &lt;strong&gt;&lt;code&gt;Account&lt;/code&gt;&lt;/strong&gt; class defines common functionality for all types of accounts, including deposit and withdraw methods.&lt;/li&gt;
&lt;li&gt;The &lt;strong&gt;&lt;code&gt;SavingsAccount&lt;/code&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;code&gt;CheckingAccount&lt;/code&gt;&lt;/strong&gt; classes extend the &lt;strong&gt;&lt;code&gt;Account&lt;/code&gt;&lt;/strong&gt; class and override withdraw methods as need to calculate different fees for each account type.&lt;/li&gt;
&lt;/ul&gt;

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