<?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: Marouane</title>
    <description>The latest articles on DEV Community by Marouane (@elya_marouane).</description>
    <link>https://dev.to/elya_marouane</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%2F520179%2Fa2958761-07a1-44d1-a102-4734d7e0af4d.png</url>
      <title>DEV Community: Marouane</title>
      <link>https://dev.to/elya_marouane</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/elya_marouane"/>
    <language>en</language>
    <item>
      <title>How to handle exceptions in Java ?</title>
      <dc:creator>Marouane</dc:creator>
      <pubDate>Mon, 20 Feb 2023 14:01:16 +0000</pubDate>
      <link>https://dev.to/elya_marouane/how-to-handle-exceptions-in-java--131k</link>
      <guid>https://dev.to/elya_marouane/how-to-handle-exceptions-in-java--131k</guid>
      <description>&lt;p&gt;Exceptions are used in Java to handle errors and unusual situations that may occur during program execution. To handle exceptions these execeptions, you can use a combination of try, catch, and finally blocks.&lt;/p&gt;

&lt;p&gt;The try block contains code that may throw an exception so if an exception is thrown, the program executes to insructions in the catch block  which contains the code for handling the exception, otherwise the catch block is skipped if no exception is thrown.&lt;/p&gt;

&lt;p&gt;Here's an example of a try-catch block:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;try {&lt;br&gt;
// code that might throw an exception&lt;br&gt;
} catch (ExceptionType1 e1) {&lt;br&gt;
    // code to handle ExceptionType1&lt;br&gt;
} catch (ExceptionType2 e2) {&lt;br&gt;
    // code to handle ExceptionType2&lt;br&gt;
} finally {&lt;br&gt;
    // code that will always be executed, regardless of whether an exception is thrown or not&lt;br&gt;
}&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;In this example, if an exception of type ExceptionType1 is thrown in the try block, the program will jump to the first catch block and execute the code there and if an exception of type ExceptionType2 is thrown, the program will jump to the second catch block and execute the code there. But if no exception is thrown, the program will skip both catch blocks and execute the finally block.&lt;/p&gt;

&lt;p&gt;The finally block is optional, but it is useful for cleaning up resources, such as closing files or releasing locks, that were acquired in the try block.&lt;/p&gt;

&lt;p&gt;It's important to remember that catch blocks are executed sequentially, so arrange your catch blocks in the order of the most specific to the least specific to be sure that the most specific catch block for the corresponding exception is executed.&lt;/p&gt;

&lt;p&gt;This article was originally posted on &lt;a href="http://www.devcorner.blog" rel="noopener noreferrer"&gt;www.devcorner.blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>challenge</category>
      <category>devchallenge</category>
      <category>community</category>
      <category>backend</category>
    </item>
    <item>
      <title>Understanding and Implementing Inversion of Control in Java</title>
      <dc:creator>Marouane</dc:creator>
      <pubDate>Thu, 05 Jan 2023 08:26:27 +0000</pubDate>
      <link>https://dev.to/elya_marouane/understanding-and-implementing-inversion-of-control-in-java-46</link>
      <guid>https://dev.to/elya_marouane/understanding-and-implementing-inversion-of-control-in-java-46</guid>
      <description>&lt;p&gt;IOC (Inversion of Control) is a design pattern that is used to decouple the dependencies between objects in a software system. It is based on the principle that an object should not create or manage its own dependencies, but rather should have them injected into it.&lt;/p&gt;

&lt;p&gt;In an IOC container, the dependencies of an object are defined and managed externally, and the object is given references to its dependencies when it is created. This allows the object to focus on its core functionality and logic, rather than on the management of its dependencies.&lt;/p&gt;

&lt;p&gt;IOC is often implemented using an IOC container, which is a framework that manages the dependencies of an application and injects them into the objects that need them. There are several popular IOC containers available, such as Spring and Guice, which can be used to implement IOC in Java applications.&lt;/p&gt;

&lt;p&gt;Suppose we have a class EmailService that sends emails, and it has a dependency on a Configuration class that provides it with the necessary configuration data, such as the SMTP server to use.&lt;/p&gt;

&lt;p&gt;Without IOC, the EmailService class might create and manage its own Configuration object:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class EmailService {
  private Configuration config;

  public EmailService() {
    config = new Configuration();
  }

  public void sendEmail(String recipient, String subject, String message) {
    // use the config object to send the email
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With IOC, the management of the Configuration object is instead handled by an IOC container, which creates and injects the object into the EmailService class as needed. The EmailService class does not need to worry about creating or managing its own dependencies, and can focus on its core functionality.&lt;/p&gt;

&lt;p&gt;Here is an example of how the EmailService class might be used with an IOC container:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class EmailService {
  private Configuration config;

  public EmailService(Configuration config) {
    this.config = config;
  }

  public void sendEmail(String recipient, String subject, String message) {
    // use the config object to send the email
  }
}

// create the IOC container and configure it
IocContainer container = new IocContainer();
container.bind(Configuration.class, new Configuration());

// create the EmailService object using the IOC container
EmailService emailService = container.getInstance(EmailService.class);

// use the EmailService object to send an email
emailService.sendEmail("recipient@example.com", "Subject", "Message");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In this example, the IOC container creates and injects the Configuration object into the EmailService object when it is created, allowing the EmailService object to focus on its core functionality without worrying about managing its dependencies. This can make the code easier to test and maintain, as it allows different implementations of the Configuration class to be easily swapped in and out as needed. It also allows the dependencies between objects to be more easily managed and controlled.&lt;/p&gt;

&lt;p&gt;In summary, IOC is a design pattern that decouples the dependencies between objects in a software system by injecting them into the objects that need them, rather than having the objects manage their own dependencies. It is often implemented using an IOC container.&lt;/p&gt;

&lt;p&gt;This article has been originally posted on &lt;a href="http://www.devcorner.blog" rel="noopener noreferrer"&gt;www.devcorner.blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>Comparing REST API and SOAP: Understanding the Key Differences</title>
      <dc:creator>Marouane</dc:creator>
      <pubDate>Wed, 04 Jan 2023 08:17:13 +0000</pubDate>
      <link>https://dev.to/elya_marouane/comparing-rest-api-and-soap-understanding-the-key-differences-3cgh</link>
      <guid>https://dev.to/elya_marouane/comparing-rest-api-and-soap-understanding-the-key-differences-3cgh</guid>
      <description>&lt;p&gt;REST (Representational State Transfer) and SOAP (Simple Object Access Protocol) are two popular web service protocols that handle communication between systems over the internet.&lt;/p&gt;

&lt;p&gt;REST is a lightweight and flexible architecture that was designed to be easily implemented and used over the internet. It is based on the HTTP protocol, which is the foundation of data communication on the web. REST APIs use HTTP requests to send and receive data and operate using the standard HTTP verbs such as GET, POST, PUT, and DELETE.&lt;/p&gt;

&lt;p&gt;One of the main advantages of REST is that it is easy to use and understand, making it a popular choice for developers. REST APIs are also highly scalable, making them suitable for use in high-traffic applications.&lt;/p&gt;

&lt;p&gt;On the other hand, SOAP is a more rigid protocol that was designed to provide a secure way to exchange structured data over the internet. It is based on the XML format and requires the use of complex message headers to transmit data. SOAP APIs also operate using HTTP, but the request and response messages are more structured and contain more information.&lt;/p&gt;

&lt;p&gt;One of the main advantages of SOAP is that it is highly secure, as it includes built-in features such as message encryption and authentication. It is also very flexible, as it can be used to transmit data over a variety of different protocols, including HTTP, SMTP, and TCP.&lt;/p&gt;

&lt;p&gt;While both REST and SOAP are popular choices for web service protocols, they each have their own strengths and weaknesses. REST is generally preferred for its simplicity and ease of use, while SOAP is preferred for its security and flexibility. Ultimately, the choice between the two protocols will depend on the specific requirements of the application.&lt;/p&gt;

&lt;p&gt;This article has been originally posted on &lt;a href="http://www.devcorner.blog"&gt;www.devcorner.blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>rest</category>
      <category>api</category>
      <category>soap</category>
      <category>webservice</category>
    </item>
    <item>
      <title>Hibernate vs JPA</title>
      <dc:creator>Marouane</dc:creator>
      <pubDate>Tue, 03 Jan 2023 09:34:56 +0000</pubDate>
      <link>https://dev.to/elya_marouane/hibernate-vs-jpa-5ea1</link>
      <guid>https://dev.to/elya_marouane/hibernate-vs-jpa-5ea1</guid>
      <description>&lt;p&gt;Java Persistence API (JPA) and Hibernate are two popular technologies used in the Java ecosystem for object-relational mapping (ORM). While they are often used interchangeably, there are some key differences between the two that developers should understand.&lt;/p&gt;

&lt;p&gt;JPA is a specification for ORM in Java, defined by the Java Community Process (JCP). It provides a standard set of APIs and annotations for mapping Java objects to and from a database. JPA is a part of the Java Enterprise Edition (Java EE) platform, and it is designed to be used in enterprise applications.&lt;/p&gt;

&lt;p&gt;Hibernate is an open-source Java library that implements the JPA specification. It provides a powerful and flexible way to map Java objects to and from a database, and it is widely used in Java applications. Hibernate offers additional features beyond those provided by the JPA specification, such as support for advanced querying and fetching strategies, and the ability to generate a database schema from Java objects.&lt;/p&gt;

&lt;p&gt;One key difference between JPA and Hibernate is that JPA is a specification, while Hibernate is a particular implementation of that specification. This means that JPA defines a set of APIs and annotations that must be implemented by any ORM solution that claims to be compliant with the JPA specification. Hibernate is one such solution, but there are others, such as EclipseLink and Apache OpenJPA.&lt;/p&gt;

&lt;p&gt;Another difference between JPA and Hibernate is the level of abstraction they provide. JPA is a higher-level API, which means that it abstracts away many of the details of working with a database. This makes it easier to write code that is independent of the underlying database, but it also means that you have less control over the SQL queries that are generated by the ORM. Hibernate, on the other hand, provides more control over the SQL queries that are generated, but this also means that you need to be more familiar with SQL and the database you are using.&lt;/p&gt;

&lt;p&gt;In conclusion, JPA and Hibernate are two popular technologies used in the Java ecosystem for ORM. JPA is a specification that defines a standard set of APIs and annotations for mapping Java objects to and from a database, while Hibernate is a popular implementation of that specification that provides additional features and functionality. Developers should choose between JPA and Hibernate based on the level of abstraction and control they need over the ORM process.&lt;/p&gt;

&lt;p&gt;This article was originally posted on devcorner.blog&lt;/p&gt;

</description>
      <category>emptystring</category>
    </item>
    <item>
      <title>POJO vs Java Bean vs Spring Bean</title>
      <dc:creator>Marouane</dc:creator>
      <pubDate>Mon, 02 Jan 2023 13:16:44 +0000</pubDate>
      <link>https://dev.to/elya_marouane/pojo-vs-java-bean-vs-spring-bean-1dm9</link>
      <guid>https://dev.to/elya_marouane/pojo-vs-java-bean-vs-spring-bean-1dm9</guid>
      <description>&lt;p&gt;In Java, a Plain Old Java Object (POJO) is a Java object that does not have any special structure or behavior. It is simply a Java object with instance variables and getter/setter methods.&lt;/p&gt;

&lt;p&gt;Here is an example of a Plain Old Java Object (POJO) in Java:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Person {
  private String name;
  private int age;

  public Person() {
  }

  public Person(String name, int age) {
    this.name = name;
    this.age = age;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }
}

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

&lt;/div&gt;



&lt;p&gt;A Java Bean is a POJO that follows certain conventions, such as having a default constructor, implementing the Serializable interface, and having getter and setter methods for its instance variables. Java Beans are often used in Java application frameworks, such as JavaServer Faces (JSF), to provide a standard way of representing data and logic in a reusable and consistent way.&lt;/p&gt;

&lt;p&gt;Here is an example of a Java Bean in Java:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class Person implements Serializable {
  private String name;
  private int age;

  public Person() {
  }

  public Person(String name, int age) {
    this.name = name;
    this.age = age;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }
}

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

&lt;/div&gt;



&lt;p&gt;A Spring Bean is a Java object that is managed by the Spring Framework. In the Spring Framework, a bean is an object that is instantiated, assembled, and otherwise managed by a Spring IoC container. The Spring Framework provides a range of features for dependency injection, transaction management, and other services that can be applied to a bean.&lt;/p&gt;

&lt;p&gt;Here is an example of a Spring Bean in Java:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component
public class Person {
  private String name;
  private int age;

  @Autowired
  private Configuration config;

  public Person() {
  }

  public Person(String name, int age) {
    this.name = name;
    this.age = age;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getAge() {
    return age;
  }

  public void setAge(int age) {
    this.age = age;
  }
}

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

&lt;/div&gt;



&lt;p&gt;This &lt;strong&gt;&lt;code&gt;Person&lt;/code&gt;&lt;/strong&gt; class is a Spring Bean because it is annotated with the &lt;strong&gt;&lt;code&gt;@Component&lt;/code&gt;&lt;/strong&gt; annotation, which tells the Spring Framework to manage it as a bean. It also has a dependency on a &lt;strong&gt;&lt;code&gt;Configuration&lt;/code&gt;&lt;/strong&gt; object, which is annotated with the &lt;strong&gt;&lt;code&gt;@Autowired&lt;/code&gt;&lt;/strong&gt; annotation, indicating that it should be injected by the Spring Framework.&lt;/p&gt;

&lt;p&gt;Spring Beans are managed by the Spring Framework and can be injected into other objects using dependency injection. They can be easily accessed and manipulated using the Spring Framework APIs, and can benefit from the various features and services offered by the Spring Framework, such as dependency injection, transaction management, and others.&lt;/p&gt;

&lt;p&gt;So, in summary, a POJO is a basic Java object, a Java Bean is a POJO that follows certain conventions, and a Spring Bean is a Java object that is managed by the Spring Framework.&lt;/p&gt;

&lt;p&gt;This article was originally posted on &lt;a href="http://www.devcorner.blog" rel="noopener noreferrer"&gt;www.devcorner.blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Why did I decide to start blogging?</title>
      <dc:creator>Marouane</dc:creator>
      <pubDate>Sat, 01 May 2021 16:53:22 +0000</pubDate>
      <link>https://dev.to/elya_marouane/why-did-i-decide-to-start-blogging-2hbc</link>
      <guid>https://dev.to/elya_marouane/why-did-i-decide-to-start-blogging-2hbc</guid>
      <description>&lt;p&gt;&lt;em&gt;This article was originally posted &lt;a href="https://elyamarouane.hashnode.dev/why-did-i-decide-to-start-blogging"&gt;here&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Last year, I had the idea to start a blog, and each time I say that I don’t have time for that. But in reality, it was a question of time management. I had to make time for it.&lt;/p&gt;

&lt;p&gt;So why did I make this decision to start blogging?&lt;/p&gt;

&lt;p&gt;First of all, I'll start by introducing myself, I am Marouane, and I am a junior software engineer. Programming is my passion, I like bringing ideas to life. &lt;/p&gt;

&lt;p&gt;I decided to start a blog for many reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To document and share my journey as a developer.&lt;/li&gt;
&lt;li&gt;To learn new things and be always searching for subjects to write about. When you write about a topic you reinforce your knowledge about it.&lt;/li&gt;
&lt;li&gt;To help people who are learning about the topic I am writing about.&lt;/li&gt;
&lt;li&gt;To create a digital reputation because it is a must.&lt;/li&gt;
&lt;li&gt;To improve my writing skills.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion:
&lt;/h3&gt;

&lt;p&gt;If you are passionate about something I recommend you start blogging about it. Don’t wait for the right time, because the perfect time is now.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Photo by &lt;a href="https://unsplash.com/@dancounsell?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Dan Counsell&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/blogger?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>My 1st post</title>
      <dc:creator>Marouane</dc:creator>
      <pubDate>Fri, 30 Apr 2021 17:58:03 +0000</pubDate>
      <link>https://dev.to/elya_marouane/my-1st-post-24if</link>
      <guid>https://dev.to/elya_marouane/my-1st-post-24if</guid>
      <description>&lt;p&gt;Hello everyone, 👋&lt;/p&gt;

&lt;p&gt;Let me introduce myself, I am a 26 years old junior full-stack developer and I’ve been here for a couple of months as a reader but I decided to take a step forward and be also a writer. ✒️&lt;br&gt;
So my first article will be about the reasons that made me take this decision.&lt;/p&gt;

&lt;p&gt;I’m really happy to be part of this great community and be able to share and learn from everyone. 💖&lt;/p&gt;

&lt;p&gt;Here is my Twitter: &lt;a href="https://twitter.com/elyamarouane"&gt;@elyamarouane&lt;/a&gt;. Let's connect 🤝&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>java</category>
      <category>angular</category>
      <category>blogging</category>
    </item>
  </channel>
</rss>
