<?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: Isurumax26</title>
    <description>The latest articles on DEV Community by Isurumax26 (@isurumax26).</description>
    <link>https://dev.to/isurumax26</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%2F612298%2F2b539978-97c9-4eed-a239-3f29911fbeb9.jpg</url>
      <title>DEV Community: Isurumax26</title>
      <link>https://dev.to/isurumax26</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/isurumax26"/>
    <language>en</language>
    <item>
      <title>Guide To Choose A Database For Your Next Design</title>
      <dc:creator>Isurumax26</dc:creator>
      <pubDate>Sun, 26 May 2024 18:51:20 +0000</pubDate>
      <link>https://dev.to/isurumax26/guide-to-choose-a-database-for-your-next-design-5cam</link>
      <guid>https://dev.to/isurumax26/guide-to-choose-a-database-for-your-next-design-5cam</guid>
      <description>&lt;h2&gt;
  
  
  Why we need to choose a database?
&lt;/h2&gt;

&lt;p&gt;A database is an organized collections of data that can be managed and accessed easily. Each provider has applied these modifications to data stores differently, depending on the type of database and how the database engine is configured. As a result, we are unable to store certain data structures in one type of database but in another.&lt;/p&gt;

&lt;p&gt;As an illustration, a relational database cannot hold a graph data structure. These kinds of data structures are intended to be stored in different kinds of databases. Therefore, it is crucial to select the appropriate database for your needs at the design phase rather than selecting the incorrect database type and changing it later on in the development process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Types Of Databases
&lt;/h2&gt;

&lt;p&gt;We can choose between traditional relational databases and non-relational databases. More than these two words you may have heard SQL and NO SQL databases. Non-relational databases are referred to as NO SQL and relational databases as SQL.&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%2Fjlhcc0l9wifwrfe0kpdu.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%2Fjlhcc0l9wifwrfe0kpdu.png" alt="types of databases"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's talk about the various factors we took into account before deciding on a database for our designs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Relational Databases
&lt;/h2&gt;

&lt;p&gt;Relational databases have been around here for more than 40 years and it is the default choice of software professionals for structured data storages. You might have heard about ACID principles. In order to maintain consistency in databases, before and after the transactions, certain properties are followed. These are called ACID properties. One of the greatest powers of the relational database is its abstractions of ACID transactions and related programming semantics.&lt;/p&gt;

&lt;p&gt;Some of the important features of relational database are&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;ACID compliance&lt;br&gt;
The general principle is if one change fails, the whole transaction will fail, and the database will remain in the state it was in before the transaction was attempted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduced redundancy - Normalization&lt;br&gt;
The information related to a specific entity is stored in one table and relent data is stored in another table linked to that by a foreign key. As an example, product related information are stored in a one table and customer who brought the product stored in another table and linked to the production table by a foreign key. This process is called normalization and has the additional benefit of removing anomalies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Concurrency&lt;br&gt;
Database concurrency is a unique characteristic enabling two or more users to retrieve information from the database at the same time without affecting data integrity. Common issues during concurrent database transactions include dirty reads and  lost data updates (dirty reads - This issue arises when a particular transaction accesses a data object written or updated by another uncommitted transaction in the database.). Concurrency in a relational database is handled through transactional access to the data.&lt;br&gt;
If your database is running this transaction as one whole atomic unit, and the system fails due to a power outage, the transaction can be undone, reverting your database to its original state.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Back Up and Disaster Recovery&lt;br&gt;
Relational databases guarantee the state of data is consistent at any time. The export and import operations make backup and restoration easier. Most cloud-based relational databases perform continuous mirroring to avoid loss of data and make the restoration process easier and quicker.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So If our use case required above features then we should consider going with a relational database.&lt;/p&gt;

&lt;p&gt;So are there any drawbacks of relational databases?&lt;br&gt;
Yeah of course, let’s discuss some drawbacks of relational databases&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Lack of scalability&lt;br&gt;
While using the relational database over multiple servers, its structure changes and becomes difficult to handle, especially when the quantity of the data is large. Due to this, the data is not scalable on different physical storage servers. Ultimately, its performance is affected.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Complexity in Structure&lt;br&gt;
Relational databases can only store data in tabular form which makes it difficult to represent complex relationships between objects. This is an issue because many applications require more than one table to store all the necessary data required by their application logic.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Non-Relational Databases
&lt;/h2&gt;

&lt;p&gt;These databases are used in applications that require a large volume of semi-structured and unstructured data, low latency, and flexible data models. This can be achieved by relaxing some of the data consistency restrictions of other databases.&lt;br&gt;
Following are some of the characteristics of the NOSQL database&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Simple Design&lt;br&gt;
Unlike SQL databases, NoSQL databases are not complicated. They store data in an unstructured or a semi-structured form that requires no relational or tabular arrangement. For example storing all the customer related information in a one document instead of multiple tables which require join operations. So less code , debug and maintain.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Horizontal Scaling&lt;br&gt;
As stated above scaling is one of the drawbacks in the relational databases. But scaling is one of the prominent features in non-relational databases. Because we can represent all of the customer related information in a one document instead of multiple tables over several nodes like in relational databases, we scale NoSQL databases pretty easily.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Availability&lt;br&gt;
Most of the non-relational databases support replication to support availability.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Independent Of Schema&lt;br&gt;
Non-relational databases don’t need a schema at the time of database configuration or data writes. As an example, mongo db which store the data in document (JSON, XML) allow different fields in different documents. So Number of fields in different documents can be different&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Following are some of drawback of Non-relational databases.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;No Support for ACID implicitly&lt;br&gt;
They don’t support ACID (atomicity, consistency, isolation, durability) transactions across multiple documents. But currently there are some newer versions of No-SQL databases which supports ACID properties to some extent. (MongoDB added support for multi-document ACID transactions in the 4.0 release, and extended them in 4.2 to span sharded clusters.)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Relatively Large Storage&lt;br&gt;
In terms of storage utilization, No SQL databases needs more storage because they focus more on query optimization than considering the storage. So there are lot of duplicates data in No-SQL databases&lt;br&gt;
NoSQL databases are divided into various categories based on the nature of the operations and features, including document store, columnar database, key-value store, and graph database.&lt;br&gt;
So we discussed about different pros and cons of relational and non-relational databases. So how do we choose the right database for our requirement.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Choose the right database
&lt;/h2&gt;

&lt;p&gt;Various factors affect the choice of database to be used in an application. A comparison between the relational and non-relational databases is shown in the following table to help us choose:&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%2F2wovm6xvd6i5zkfjyy8t.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%2F2wovm6xvd6i5zkfjyy8t.png" alt="sql vs nosql"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;By taking above table as a guidance we will go through some scenarios&lt;/p&gt;

&lt;p&gt;Which database should we use when we have unstructured data and there’s a need for high performance?&lt;br&gt;
So type of data is unstructured and needs high performance. So, it should be No SQL database. NoSQL database like MongoDB would be a perfect choice for this&lt;/p&gt;

&lt;p&gt;Which database should we use when we have a financial application, like stock trading application, and we need our data to be consistent all times?&lt;br&gt;
In a stock trading application data will be structured and we need high consistency too. So these are the features of relational database.&lt;/p&gt;

&lt;p&gt;What kind of database should we use if we make a retail store application that requires storing the data in tabular format?&lt;br&gt;
if we have tabular data that means we have structured data. Hence, a relational database is the right choice&lt;/p&gt;

&lt;p&gt;Which kind of database should we use for making an application like Reddit/Facebook?&lt;br&gt;
The data generated by the these social media applications are mostly unstructured which requires a non-relational databases.&lt;/p&gt;

&lt;p&gt;For a web multiplayer game?&lt;br&gt;
In this scenario we need to store data in the database as same as the object in the game so we can deserialize later. Hence, best choice is document oriented NoSQL database.&lt;/p&gt;

</description>
      <category>database</category>
      <category>systemdesign</category>
      <category>sql</category>
      <category>nosql</category>
    </item>
    <item>
      <title>Creating A Maven Plugin</title>
      <dc:creator>Isurumax26</dc:creator>
      <pubDate>Sat, 12 Aug 2023 19:15:03 +0000</pubDate>
      <link>https://dev.to/isurumax26/creating-a-maven-plugin-1cgg</link>
      <guid>https://dev.to/isurumax26/creating-a-maven-plugin-1cgg</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here, we'll make a Maven plugin to run a method of a different project from the plugin. Instead of POJO, this custom plugin is known as MOJO (Mavan Old Java Object).&lt;br&gt;
I'll walk you through the steps involved in making this plugin in this blog.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating a Plugin&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll build the &lt;em&gt;make-sound&lt;/em&gt; plugin, which accepts an object from a consumer project, initializes it there, executes the &lt;em&gt;makeSound&lt;/em&gt; method in the consumer, and publishes the results to the console.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We create the plugin&lt;/li&gt;
&lt;li&gt;Install it in the maven repo(.m2)&lt;/li&gt;
&lt;li&gt;Consumer projects will consume it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F802fkkuq5rhaxmr1lcj0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F802fkkuq5rhaxmr1lcj0.jpg" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To do this, first create a plugin-util module in your project. A few dependencies should be added to the project, and your pom file should appear as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;dependencies&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.apache.maven&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;maven-plugin-api&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;3.6.3&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.apache.maven.plugin-tools&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;maven-plugin-annotations&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;3.6.0&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
        &amp;lt;dependency&amp;gt;
            &amp;lt;groupId&amp;gt;org.apache.maven&amp;lt;/groupId&amp;gt;
            &amp;lt;artifactId&amp;gt;maven-core&amp;lt;/artifactId&amp;gt;
            &amp;lt;version&amp;gt;3.9.2&amp;lt;/version&amp;gt;
            &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;
        &amp;lt;/dependency&amp;gt;
    &amp;lt;/dependencies&amp;gt;

    &amp;lt;build&amp;gt;
        &amp;lt;plugins&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;maven-plugin-plugin&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;3.7.0&amp;lt;/version&amp;gt;
            &amp;lt;/plugin&amp;gt;
        &amp;lt;/plugins&amp;gt;
    &amp;lt;/build&amp;gt;

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

&lt;/div&gt;



&lt;p&gt;Make sure dependencies are compatible with your java version.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;groupId&amp;gt;org.example&amp;lt;/groupId&amp;gt;
 &amp;lt;artifactId&amp;gt;plugin-util&amp;lt;/artifactId&amp;gt;
 &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
 &amp;lt;packaging&amp;gt;maven-plugin&amp;lt;/packaging&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;maven-plugin-api&lt;/strong&gt; – necessary classes and interfaces to create our mojo&lt;br&gt;
&lt;strong&gt;maven-plugin-annotation&lt;/strong&gt; – handy to use annotations in our class&lt;br&gt;
&lt;strong&gt;maven-project&lt;/strong&gt; – lets us access the information about the project&lt;/p&gt;

&lt;p&gt;&lt;em&gt;packaging tag&lt;/em&gt; also very important because if not by default maven will package this as  jar module&lt;/p&gt;

&lt;p&gt;Then we need to create our Mojo class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Mojo(name = "make-sound", defaultPhase = LifecyclePhase.COMPILE)

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

&lt;/div&gt;



&lt;p&gt;Our custom class should extends the AbstractMojo class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;@Mojo&lt;/strong&gt; – This provides us with our mojo's execution name and phase information. I've listed the mojo for the compilation process here. There are other steps, such as testing and deployment, among others.&lt;/p&gt;

&lt;p&gt;Then we need to override the execute() method of the super class AbstractMojo&lt;/p&gt;

&lt;p&gt;During the execution plugin will execute this method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Override
    public void execute() throws MojoExecutionException, MojoFailureException {

        try {
            Class&amp;lt;?&amp;gt; requiredClass = getClassLoader().loadClass(className);

            Animal animal = null;

            for (Constructor&amp;lt;?&amp;gt; constructor : requiredClass.getDeclaredConstructors()) {
                if (constructor.getParameterCount() == 0) {
                    animal = (Animal) constructor.newInstance();
                }
                else if (constructor.getParameterCount() == 1) {
                    animal = (Animal) constructor.newInstance();
                }
                else {
                    throw new IllegalAccessException();
                }

            }
            animal.makeSound();
        } catch (ClassNotFoundException | IllegalAccessException | InvocationTargetException | InstantiationException e) {
            throw new RuntimeException(e);
        }


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

&lt;/div&gt;



&lt;p&gt;The plugin will only have access to its class loader during execution, which is crucial to keep in mind. It is unable to reach the consumer's class loader. At compile time, a ClassNotFoundException will be thrown if a consumer class is referenced in the plugin.&lt;/p&gt;

&lt;p&gt;Therefore, during execution, you must add the class loader of the consumer to the class loader of the plugin. Using project objects, Maven offers a method for accomplishing this. We must include a MavenProject as a parameter in order to access the project data.&lt;br&gt;
The approach I developed to include the consumer's class loader in the plugin's class loader is shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; public ClassLoader getClassLoader() {
        try {
            Set&amp;lt;URL&amp;gt; urls = new HashSet&amp;lt;&amp;gt;();
            List&amp;lt;String&amp;gt; elements = project.getTestClasspathElements();
            //getRuntimeClasspathElements()
            //getCompileClasspathElements()
            //getSystemClasspathElements()
            for (String element : elements) {
                urls.add(new File(element).toURI().toURL());
            }

            ClassLoader contextClassLoader = URLClassLoader.newInstance(
                    urls.toArray(new URL[0]),
                    Thread.currentThread().getContextClassLoader());

            Thread.currentThread().setContextClassLoader(contextClassLoader);
            return Thread.currentThread().getContextClassLoader();


        } catch (DependencyResolutionRequiredException | MalformedURLException e) {
            return this.getClass().getClassLoader();
        }
    }

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

&lt;/div&gt;



&lt;p&gt;You can now access the consumer classes. The consumer object in the plugin class must then be initialized, based on your requirements. The code snippet I used to create the consumer object in the plugin is provided below.&lt;/p&gt;

&lt;p&gt;We normally overload constructors in java classes. In those circumstances, we must notify the plugin of the constructor to which we must refer.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;try {
            Class&amp;lt;?&amp;gt; requiredClass = getClassLoader().loadClass(className);

            Animal animal = null;

            for (Constructor&amp;lt;?&amp;gt; constructor : requiredClass.getDeclaredConstructors()) {
                if (constructor.getParameterCount() == 0) {
                    animal = (Animal) constructor.newInstance();
                }
                else if (constructor.getParameterCount() == 1) {
                    animal = (Animal) constructor.newInstance();
                }
                else {
                    throw new IllegalAccessException();
                }

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

&lt;/div&gt;



&lt;p&gt;We now need to install the plugin module in the Maven repository after developing it. As a result, other modules will be able to use it as well.&lt;/p&gt;

&lt;p&gt;So how we do it?&lt;/p&gt;

&lt;p&gt;Just run the maven goals form clean -------&amp;gt; install then jar of the plugin will be installed to the maven repo&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Adding the Plugin to the consumer module&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This procedure is simple and straightforward. The name of your plugin goal, which you specify in the @Mojo annotation, is all that has to be done to add the plugin to the maven repo goal. A plugin may have multiple goals. We must define the plugin-specific parameters inside the configuration tag. I've included the class path for the class that I need to initialize here using the plugin's class Loader.&lt;/p&gt;

&lt;p&gt;Keep in mind that we added the consumer's classLoader to the plugin's classLoader.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; &amp;lt;build&amp;gt;
        &amp;lt;plugins&amp;gt;
            &amp;lt;plugin&amp;gt;
                &amp;lt;groupId&amp;gt;org.example&amp;lt;/groupId&amp;gt;
                &amp;lt;artifactId&amp;gt;plugin-util&amp;lt;/artifactId&amp;gt;
                &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;
                &amp;lt;executions&amp;gt;
                    &amp;lt;execution&amp;gt;
                        &amp;lt;goals&amp;gt;
                            &amp;lt;goal&amp;gt;make-sound&amp;lt;/goal&amp;gt;
                        &amp;lt;/goals&amp;gt;
                    &amp;lt;/execution&amp;gt;
                &amp;lt;/executions&amp;gt;
                &amp;lt;configuration&amp;gt;
                    &amp;lt;className&amp;gt;org.example.Cat&amp;lt;/className&amp;gt;
                &amp;lt;/configuration&amp;gt;
            &amp;lt;/plugin&amp;gt;
        &amp;lt;/plugins&amp;gt;
    &amp;lt;/build&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you have created the plugin module and added it to the consumer class. You just need to build the consumer.&lt;br&gt;
Run the consumer module from clean -------&amp;gt; test phase. Now check console output if you output anything you can see those in the console&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyv6k2f36k3e3lu9tudrd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyv6k2f36k3e3lu9tudrd.png" alt="Image description" width="800" height="259"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The plugin has output "meow" as you can see. This came from the Cat class's makeSound method.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  public void makeSound() {
        System.out.println("meow");
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Congratulations you have built a nice maven plugin !&lt;/p&gt;

</description>
      <category>java</category>
      <category>webdev</category>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>The Hidden Hero of Java: A Deep Dive into the Java Virtual Machine</title>
      <dc:creator>Isurumax26</dc:creator>
      <pubDate>Sat, 25 Mar 2023 06:32:32 +0000</pubDate>
      <link>https://dev.to/isurumax26/the-hidden-hero-of-java-a-deep-dive-into-the-java-virtual-machine-1da9</link>
      <guid>https://dev.to/isurumax26/the-hidden-hero-of-java-a-deep-dive-into-the-java-virtual-machine-1da9</guid>
      <description>&lt;p&gt;The JVM executes Java bytecode, a compact and platform-independent representation of Java code. When you compile a Java program, it is converted into bytecode, which can then be executed by any JVM that supports the Java language specification. The JVM translates bytecode into machine code that can be executed by the host machine using a combination of interpretation and JIT compilation.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkzr4r9hpnc6bq6jtm21w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkzr4r9hpnc6bq6jtm21w.png" alt="Image description" width="669" height="588"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The class loader, bytecode verifier, runtime data area, execution engine, and garbage collector are all key components of the JVM's architecture. Each of these components has a distinct role to play in the execution of Java programs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Class loader&lt;/strong&gt;:  Class loader is in charge of loading Java class files into memory. It loads the classes as the program references them and ensures that the classes are loaded only once.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bytecode Verifier&lt;/strong&gt;: The bytecode verifier ensures that the bytecode can be executed safely and that it adheres to the Java language specification. It checks the bytecode for errors and ensures that no security constraints are violated.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Runtime Data Area&lt;/strong&gt;: The runtime data area is the memory space used by the JVM to store data at runtime. It is divided into several components, including the method area, heap, stack, and program counter&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Execution Engine&lt;/strong&gt;: The execution engine is in charge of interpreting bytecode and running it on the host machine. It optimizes the performance of the Java program by combining interpretation and JIT compilation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Garbage Collector&lt;/strong&gt;: The garbage collector is responsible for automatically managing the memory used by the Java program. It identifies objects that are no longer in use and frees up the memory used by those objects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of the JVM&lt;/strong&gt;&lt;br&gt;
The use of the JVM provides several key benefits to Java developers and users. Some of the most notable benefits include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Platform Independence&lt;/strong&gt;: Java programs can run on any 
platform that supports the JVM thanks to the JVM. This means 
that developers can write code once and deploy it on multiple 
platforms without changing it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance Optimization&lt;/strong&gt;: The ability of the JVM to perform 
JIT compilation allows it to optimize the performance of Java 
programs. As a result, execution times are reduced and overall 
performance is improved.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Memory Management&lt;/strong&gt;: The JVM's garbage collector automates 
memory management, freeing developers from having to manually 
manage memory allocation and deallocation.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security&lt;/strong&gt;: The JVM enforces security policies and prevents 
malicious code from executing, making Java a popular choice for 
developing applications that require a high level of security.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
The JVM is an essential component of the Java platform that offers numerous advantages to developers and users. Its ability to execute bytecode, perform JIT compilation, automatically manage memory, and enforce security policies makes it an effective tool for developing high-performance and secure Java applications. Developers can use the JVM's capabilities to create robust and reliable Java programs by understanding how it works and its key features and benefits&lt;/p&gt;

</description>
      <category>java</category>
      <category>webdev</category>
      <category>programming</category>
      <category>performance</category>
    </item>
    <item>
      <title>Immutability in java</title>
      <dc:creator>Isurumax26</dc:creator>
      <pubDate>Sun, 13 Mar 2022 08:15:37 +0000</pubDate>
      <link>https://dev.to/isurumax26/immutability-in-java-4el4</link>
      <guid>https://dev.to/isurumax26/immutability-in-java-4el4</guid>
      <description>&lt;p&gt;An immutable object is an object whose internal state remains constant after it has been entirely created. &lt;/p&gt;

&lt;p&gt;In other words immutable object means whose content cannot be changed. So mutable object means whose content can be changed.&lt;/p&gt;

&lt;p&gt;This means that the public API of an immutable object guarantees us that it will behave in the same way during its whole lifetime.&lt;/p&gt;

&lt;p&gt;Sometimes we want to create an object whose content cannot be changed after it has been created. Such an object is called immutable object and class which made that object is called immutable class.&lt;br&gt;
 Ex - String objects are immutable object and String class is an &lt;br&gt;
      immutable class.&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;Immutable class&lt;/strong&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;All data fields must be private.&lt;/li&gt;
&lt;li&gt;There can't be any setter methods.&lt;/li&gt;
&lt;li&gt;No getter fields can return a data field that is mutable.
&lt;em&gt;If there is are getter methods all of them should return an 
immutable object&lt;/em&gt;
Class should satisfy all of these conditions to be an immutable class.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The best way to understand this is through examples. Let's see some  examples.&lt;br&gt;
&lt;strong&gt;Exmples 1&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class A1 {

    private int x;

    public A1(int x) {
        this.x = x;
    }

    public int getX() {
        return this.x;
    }
 }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Is this immutable or not? Check with the rules&lt;br&gt;
all the data fields are private&lt;br&gt;
no any setter methods&lt;br&gt;
getter method doesn't return a immutable object&lt;br&gt;
So this class is a immutable class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 2&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class A2 {

    private int x;

    public A2(int x) {
        this.x = x;
    }

    public int getX() {
        return x;
    }

    public void setX(int x) {
        this.x = x;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Check with the rules&lt;br&gt;
all the data fields are private&lt;br&gt;
one setter method is there&lt;br&gt;
So this class is not immutable.&lt;/p&gt;

&lt;p&gt;I think now you have an good idea about immutable classes. let's see one more example&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 3&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class A1 {
    private int x;
    private A2 a2;

    public A1(int x, A2 a2) {
        this.x = x;
        this.a2 = a2;
    }

    public int getX() {
        return x;
    }

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

&lt;/div&gt;



&lt;p&gt;In the previous example I showed you that class A2 is not an immutable class. But keep it aside and go through the rules.&lt;/p&gt;

&lt;p&gt;all the data fields are private&lt;br&gt;
no setter methods are there&lt;br&gt;
does getter method return any non immutable object? No&lt;/p&gt;

&lt;p&gt;So this is an immutable class.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example 4&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class A1 {
    private int x;
    private A2 a2;

    public A1(int x, A2 a2) {
        this.x = x;
        this.a2 = a2;
    }

    public int getX() {
        return x;
    }

    public A2 getA2() {
        return this.a2;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;all the data fields are private&lt;br&gt;
no setter methods are there&lt;br&gt;
does getter method return any non immutable object? Yes it does.&lt;/p&gt;

&lt;p&gt;So this is not an immutable class.&lt;/p&gt;

&lt;p&gt;you might ask why this is not immutable. So no other way to explain that let's try to create an object of this class A1&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; public static void main(String[] args) {
        A1 a1 = new A1(2, new A2(3));
        A2 a2 = a1.getA2(); // returning a immutable object
        a2.setX(5); // changing the value
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;See x field of a2 is 3 previously. But from the line 3 we modified it to the 5. change is not a word with immutable object. Actually immutable means no change. It is the definition of immutable objects.&lt;/p&gt;

&lt;p&gt;I think now you have a good idea about immutable object. There is keyword related with immutability in java that is final keyword. Simply final keyword won't let us change the value of a final variable. It will be a compile error. But we should remember that final only forbids us from changing the reference the variable holds, it doesn't protect us from changing the internal state of the object it refers to by using its public API.&lt;/p&gt;

&lt;p&gt;I think this article will be too long if i talk about that in this article. &lt;/p&gt;

&lt;p&gt;So if you have any questions please let me know in the comment section. I'm more than happy to help.&lt;/p&gt;

</description>
      <category>java</category>
      <category>beginners</category>
      <category>programming</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Stream API Java</title>
      <dc:creator>Isurumax26</dc:creator>
      <pubDate>Mon, 17 Jan 2022 09:44:30 +0000</pubDate>
      <link>https://dev.to/isurumax26/stream-api-java-4b6i</link>
      <guid>https://dev.to/isurumax26/stream-api-java-4b6i</guid>
      <description>&lt;p&gt;As we all know java introduces set of new features in its version 8.&lt;br&gt;
Stream API is one of that.&lt;br&gt;
First we will see how to create an stream :&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stream Creation&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Collections to stream
Let's see how we can convert a list into a stream.In this way we can create collection, set to a stream&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;List&amp;lt;String&amp;gt; cities = Arrays.asList("London", "Tokyo", "Manila");&lt;br&gt;
        Stream&amp;lt;String&amp;gt; cityStream = cities.stream();&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the following code snippet you can see how we can convert an array into a stream.&lt;br&gt;
&lt;code&gt;String[] foods = {"Pizza", "Egg", "Chicken"};&lt;br&gt;
        Stream&amp;lt;String&amp;gt; foodsStream = Arrays.stream(foods);&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
We can also create an stream out of a part of an array&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Stream&amp;lt;String&amp;gt; foodsStream = Arrays.stream(foods, 1, 3);&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Map to a Stream
In this snippet I'm going to show you how we can convert a java collection type map in to a stream. In this code first i convert the map to a entryset and then to a stream&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;Map&amp;lt;String, Integer&amp;gt; hm = new HashMap&amp;lt;&amp;gt;();&lt;br&gt;
        Stream&amp;lt;Map.Entry&amp;lt;String, Integer&amp;gt;&amp;gt; entryStream = hm.entrySet().stream();&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;One of a best practise when using stream instance is that if you want to return null object. Just return a empty stream (This is a good for other collections as well. Such as list, set, map)&lt;br&gt;
&lt;code&gt;Stream.empty()&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;we often use empty() method upon creation to avoid returning null for streams with no element.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;public Stream&amp;lt;String&amp;gt; streamOf(List&amp;lt;String&amp;gt; list) {&lt;br&gt;
    return list == null || list.isEmpty() ? Stream.empty() : list.stream();&lt;br&gt;
}&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using  builder method
We can create a stream using this method too. Remember when you are using this method you have to specify the type too. If not it will return an instances of Stream.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;Stream&amp;lt;String&amp;gt; streamBuilder =&lt;br&gt;
  Stream.&amp;lt;String&amp;gt;builder().add("a").add("b").add("c").build();&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;but according to my knowledge we don't often use this type of creation.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Streams of primitives
we can create streams out of int, long and double. Main advantage of this is we can avoid unnecessary usage of auto unboxing. It will increase the performances of your code.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;IntStream intStream = IntStream.range(1, 3);&lt;br&gt;
LongStream longStream = LongStream.rangeClosed(1, 3);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;In the first method it doesn't include the value of second parameter(one value less than the second parameter)&lt;/p&gt;

&lt;p&gt;But in the second method it include that value as well.&lt;/p&gt;

&lt;p&gt;Remember that stream is literally a stream. If you get to a point you can't move back likewise &lt;strong&gt;after you created a stream you can't again reuse that stream&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Optional&amp;lt;String&amp;gt; anyElement = stream.findAny();&lt;br&gt;
Optional&amp;lt;String&amp;gt; firstElement = stream.findFirst();&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
It will throw an IlleagalStateException which is a Runtime exception.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
Stream API is one of the powerful feature in java 8. You have to remember that all the methods which i have used are running in a single thread. But stream API allows you create parallels streams in multiple threads as well. We will check all those in future series.This is just a beginning of a series let's dig deep in to the streams in the following articles. will meet u soon -:D&lt;/p&gt;

&lt;p&gt;Let me know your suggestion and improvement for this series. &lt;/p&gt;

</description>
      <category>java</category>
      <category>programming</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Mainframe Testing</title>
      <dc:creator>Isurumax26</dc:creator>
      <pubDate>Mon, 16 Aug 2021 05:44:19 +0000</pubDate>
      <link>https://dev.to/isurumax26/mainframe-testing-2dge</link>
      <guid>https://dev.to/isurumax26/mainframe-testing-2dge</guid>
      <description>&lt;p&gt;&lt;strong&gt;Mainframe&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;mainframes are high-performance computers (ASP 400 –IBM) with large amounts of memory and processors that process billions of simple calculations and transactions in real time. The mainframe is critical to commercial databases, transaction servers, and applications that require high resiliency, security, and agility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mainframe testing&lt;/strong&gt;&lt;br&gt;
Mainframe testing is connected with two main concepts.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Outbound transfer&lt;/li&gt;
&lt;li&gt; Inbound transfer&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Outbound transfer&lt;/strong&gt;&lt;br&gt;
As the name suggests outbound transfer means transferring files from mainframe to the outside(Applications). In a real world application we don’t transfer a single file during a transaction mostly it is bulk of files (batch processing).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Inbound transfer&lt;/strong&gt;&lt;br&gt;
This is the opposite of outbound transfer. Files are transferring from outside (Applications) to mainframe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Testing Methodologies&lt;/strong&gt;&lt;br&gt;
Mainframe testing is like any other testing procedure starting from Requirement gathering, test design, test execution and result reporting. Mainframe application testing is a time taking process. A clear test schedule should be followed for test design, data setup and execution.&lt;/p&gt;

&lt;p&gt;In mainframe testing we are using manual testing technique. Because we have to determine files are transferred successfully or not. We can’t necessarily  do this with automation tools. But there are tools we can do this, it depends on our requirements.&lt;br&gt;
According to the requirements we have to choose whether we are testing for a single file or batch of files. In most of the cases it is batch of files. But in some cases you have to perform a test case for a single test file.&lt;/p&gt;

&lt;p&gt;In Mainframe testing, the Software or an application are retrieved by end-users in a way, which is diverse from Web applications.&lt;br&gt;
And the application tester should know these significant differences, which are shown below:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Web Applications&lt;/strong&gt;&lt;br&gt;
The web applications are acquired via two-tier architecture [Client/Server] or three-tier architecture [Presentation/apps/DB storage layers]&lt;br&gt;
The web applications retrieve across Browser or UI.&lt;br&gt;
In this, the testing can be performed straight on the application screen.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Mainframe Applications&lt;/strong&gt;&lt;br&gt;
In the mainframe application, the end-user must log into the system directly.&lt;br&gt;
Terminal Emulator must retrieve the web applications.&lt;br&gt;
In this, the tester should have precise knowledge of mainframe operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test Cases&lt;/strong&gt;&lt;br&gt;
• Outbound transfer&lt;br&gt;
Steps&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; x.dat is sending from mainframe to application&lt;/li&gt;
&lt;li&gt; x.dat file trigger the daemon program&lt;/li&gt;
&lt;li&gt; x.dat file send via the gateway&lt;/li&gt;
&lt;li&gt; Verify the delivery notifications. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;• Inbound transfer&lt;br&gt;
Steps&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Trigger x.ack file from application to gateway&lt;/li&gt;
&lt;li&gt; Verify the file is present in input directory.&lt;/li&gt;
&lt;li&gt; Verify the file moved to the Archive directory&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Common issues occurring in mainframe testing&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;I/O error&lt;br&gt;
Reading at the end of the file, file length error, attempt to write into read-only file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Error occurred during OPEN&lt;br&gt;
Gateway is down&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Operation Exception&lt;br&gt;
Unable to open file, missing DD card&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>testing</category>
      <category>mainframe</category>
      <category>programming</category>
      <category>testdev</category>
    </item>
    <item>
      <title>How to use POM in software testing</title>
      <dc:creator>Isurumax26</dc:creator>
      <pubDate>Tue, 04 May 2021 05:25:13 +0000</pubDate>
      <link>https://dev.to/isurumax26/how-to-use-pom-in-software-testing-4i3e</link>
      <guid>https://dev.to/isurumax26/how-to-use-pom-in-software-testing-4i3e</guid>
      <description>&lt;p&gt;What is POM?&lt;/p&gt;

&lt;p&gt;POM is a design pattern which is commonly used in Selenium for Automating the Test Cases. This design pattern can be used with any kind of framework like keyword-driven, Data-driven, hybrid framework, etc. I think you have an idea about the above frameworks Anyway I'll talk about them later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1qtfsuh84rssro3qprs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy1qtfsuh84rssro3qprs.png" alt="Alt Text" width="800" height="530"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Project hierarchy?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgyxrp1776o1mu8fkbyy5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgyxrp1776o1mu8fkbyy5.png" alt="image" width="312" height="564"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Under this model, for each web page in the application, there should be a corresponding Page Class. This Page class will identify the WebElements of that web page and also contains Page methods which perform operations on those WebElements. Name of these methods should be given as per the task they are performing, i.e., if loader needs to search something using the search box the method name will be setSearchBox(String item).&lt;/p&gt;

&lt;p&gt;Consider following  script for search some thing&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9uz6biv2t3z5q7psfwhv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9uz6biv2t3z5q7psfwhv.png" alt="image" width="686" height="245"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see all we are doing in this script is finding the web elements and setting the methods to fill those values. Above code is under the package pages&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc2861m7x8agewirmfmgu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc2861m7x8agewirmfmgu.png" alt="image" width="568" height="143"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;what we are doing here is filling the search box with values we provided(Test cases). Internal logic of these methods are implemented with the separate classes in the page package.&lt;/p&gt;

&lt;p&gt;The chief problem with script maintenance is that if 10 different scripts are using the same page element, with any change in that element, you need to change all 10 scripts. This is time consuming and error prone.&lt;/p&gt;

&lt;p&gt;A better approach to script maintenance is to create a separate class file which would find web elements, fill them or verify them. This class can be reused in all the scripts using that element. In future, if there is a change in the web element, we need to make the change in just 1 class file and not 10 different scripts. That is the page object model(POM)&lt;/p&gt;

&lt;p&gt;Summary&lt;/p&gt;

&lt;p&gt;Developing a maintainable automation code is one of the keys to a successful test-automation project. When developing Selenium WebDriver tests(Or any other framework), We can use the page object model pattern, This pattern helps enhances the tests by making them highly maintainable, reducing the code duplication, building a layer of abstraction, and hiding the inner implementation from tests. &lt;/p&gt;

</description>
      <category>testing</category>
      <category>selenium</category>
      <category>programming</category>
      <category>java</category>
    </item>
  </channel>
</rss>
