<?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: Emmanuel Uchenna </title>
    <description>The latest articles on DEV Community by Emmanuel Uchenna  (@emmauche001).</description>
    <link>https://dev.to/emmauche001</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%2F1287219%2F51f28dfe-30e8-41c1-87e8-877a2b53e381.png</url>
      <title>DEV Community: Emmanuel Uchenna </title>
      <link>https://dev.to/emmauche001</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/emmauche001"/>
    <language>en</language>
    <item>
      <title>10 Key Data Structures We Use Every Day</title>
      <dc:creator>Emmanuel Uchenna </dc:creator>
      <pubDate>Mon, 27 May 2024 00:13:55 +0000</pubDate>
      <link>https://dev.to/emmauche001/10-key-data-structures-we-use-every-day-2l42</link>
      <guid>https://dev.to/emmauche001/10-key-data-structures-we-use-every-day-2l42</guid>
      <description>&lt;p&gt;Data structures are like the building blocks for organizing information in our daily lives. While they might not be explicitly called out, these structures underlie many of the things we do. Here are 10 key data structures we use every day:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Lists:&lt;/strong&gt; These are ordered collections of items, like a grocery list, a to-do list, or the songs in your music playlist. You can easily add, remove, or rearrange items on a list.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Arrays:&lt;/strong&gt; Similar to lists, arrays hold a fixed number of items in a specific order. Imagine the buttons on a calculator or the channels on your TV – you access them by their position in the sequence.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Stacks:&lt;/strong&gt; These follow a "Last In, First Out" (LIFO) principle. Think of a stack of plates – you can only add or remove plates from the top. This structure is used in things like browser history (you visit the most recently accessed page first) or when undoing actions on a computer program.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Queues:&lt;/strong&gt; Unlike stacks, queues operate on a "First In, First Out" (FIFO) basis. Imagine a line at a coffee shop – the person who has been waiting the longest gets served first. Queues are used in waiting lists, task scheduling, and even traffic flow management (vehicles that enter the queue first exit first).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Trees:&lt;/strong&gt; Hierarchical structures that mimic real-world trees. Imagine a family tree or an organizational chart. They represent relationships between items, with a root element at the top and branches (sub-elements) connecting to it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Graphs:&lt;/strong&gt; These represent connections between objects. Think of a social media network where users are connected to their friends, or a map where cities are connected by roads. Graphs help us visualize and analyze relationships between different entities.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Hashes:&lt;/strong&gt; Used for fast retrieval of information. Imagine a phonebook – you look up a name (key) to find the corresponding phone number (value). Hash tables store data with unique keys for efficient access.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Sets:&lt;/strong&gt; Collections of unique items, like the unique words in a document or the different types of fruits in a fruit basket. Sets ensure no duplicates exist within the collection.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Associative Arrays (Dictionaries):&lt;/strong&gt; Similar to hash tables, these store key-value pairs but allow for more complex data types as values. Imagine a recipe book where the recipe name (key) is associated with a list of ingredients and instructions (value).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Linked Lists:&lt;/strong&gt; These are linear data structures where elements (nodes) are not stored contiguously in memory. Each node holds data and a reference (link) to the next node in the sequence. They are useful for dynamic data (frequently changing size) like managing musical playlists or social media feeds.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Understanding these underlying data structures allows us to better appreciate the organization that underpins seemingly simple aspects of our daily lives. &lt;/p&gt;

&lt;p&gt;Which data structure do you find most surprising in everyday use? Why? or Have you encountered any data structures in your hobbies or work that aren't on this list? Share your experiences!&lt;/p&gt;

</description>
      <category>data</category>
      <category>learning</category>
      <category>datastructure</category>
    </item>
    <item>
      <title>Spring Bean Scopes</title>
      <dc:creator>Emmanuel Uchenna </dc:creator>
      <pubDate>Sun, 26 May 2024 23:38:38 +0000</pubDate>
      <link>https://dev.to/emmauche001/spring-bean-scopes-j6a</link>
      <guid>https://dev.to/emmauche001/spring-bean-scopes-j6a</guid>
      <description>&lt;p&gt;Bean scope in Spring Framework refers to the &lt;u&gt;lifecycle of a Spring bean and its visibility in the context of the application.&lt;/u&gt;&lt;br&gt;
When you create a bean definition, you create a recipe for creating actual instances of the class defined by that bean definition. The idea that a bean definition is a recipe is important, because it means that, as with a class, you can create many object instances from a single recipe.&lt;/p&gt;

&lt;p&gt;Spring provides multiple scope to register and configure beans and scoping has an impact on a state management of the component.&lt;br&gt;
Singleton is the default scope of a bean, which means one instance per application context.&lt;/p&gt;

&lt;p&gt;Bean Scopes provided by Spring:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Singleton&lt;/strong&gt;  Only one instance of a bean is created and all request of that bean will receive the same instance. This is useful for beans that do not hold state or where the same state is to be shared by all users or threads. For example, a database connection pool
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Configuration
public class DataSourceConfig {

    @Bean
    public DataSource dataSource() {
        HikariConfig config = new HikariConfig();
        config.setDriverClassName("org.postgresql.Driver");
        config.setJdbcUrl("jdbc:postgresql://localhost:5432/yourdatabase");
        config.setUsername("yourusername");
        config.setPassword("yourpassword");
        config.setMaximumPoolSize(10);
        config.setMinimumIdle(2);
        config.setPoolName("HikariCP");

        return new HikariDataSource(config);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Prototype&lt;/strong&gt;  A new instance is being created each time a bean is requested from the container. Useful for stateful beans or beans that are not thread-safe, such as a bean that maintains user-specific data during an operation.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component
@Scope("prototype")
public class UserData {

    private String username;
    private String operation;

    // Getters and setters
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getOperation() {
        return operation;
    }

    public void setOperation(String operation) {
        this.operation = operation;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Request&lt;/strong&gt; This scope is Only valid in the context of a web-aware Spring ApplicationContext for a single http request. A new bean is created for each http request. For example, a bean that tracks the progress of a user's request or data specific to that request, such as user credentials or input parameters.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component
@RequestScope
public class RequestData {

    private String userId;
    private String requestStatus;

    // Getters and setters
    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public String getRequestStatus() {
        return requestStatus;
    }

    public void setRequestStatus(String requestStatus) {
        this.requestStatus = requestStatus;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Session&lt;/strong&gt; A new bean is created for each http session by the container. Also applicable in web-aware Spring ApplicationContext. Useful for user sessions in a web application, like storing a user's authenticated session or a shopping cart in an e-commerce site.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public class UserSession {
    private String username; // You can add more session-related data here

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Application&lt;/strong&gt; Scopes a single bean definition to the lifecycle of a ServletContext. Only valid in the context of a web-aware Spring ApplicationContext. For example, application-wide configuration that is web-context aware, like a cache that is shared across sessions but not across different applications.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;WebSocket&lt;/strong&gt; Scopes a single bean definition to the lifecycle of a WebSocket. Only valid in the context of a web-aware Spring ApplicationContext.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The scope of a bean affects its injection into another bean in terms of lifecycle management and statefulness:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Singleton beans&lt;/strong&gt; injected into other beans will have their state shared across the entire application, making them suitable for shared configurations or stateless services.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Prototype-scoped beans&lt;/strong&gt; ensure that a new instance is provided each time a bean is injected, suitable for stateful beans or beans that are not thread-safe.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Request, Session, Application, and Websocket scopes&lt;/strong&gt; allow beans to be tied to the lifecycle of web components, making them ideal for managing user sessions, application context, and real-time communication channels respectively.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Singleton Beans with Prototype-bean Dependencies&lt;/strong&gt;&lt;br&gt;
When you use singleton-scoped beans with dependencies on prototype beans, be aware that dependencies are resolved at instantiation time. Thus, if you dependency-inject a prototype-scoped bean into a singleton-scoped bean, a new prototype bean is instantiated and then dependency-injected into the singleton bean. The prototype instance is the sole instance that is ever supplied to the singleton-scoped bean.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Custom Scopes&lt;/strong&gt;&lt;br&gt;
The bean scoping mechanism is extensible. You can define your own scopes or even redefine existing scopes, although the latter is considered bad practice and you cannot override the built-in singleton and prototype scopes.&lt;/p&gt;

</description>
      <category>learning</category>
      <category>springboot</category>
      <category>spring</category>
    </item>
    <item>
      <title>Mastering REST API Best Practices: A Developer's Guide</title>
      <dc:creator>Emmanuel Uchenna </dc:creator>
      <pubDate>Fri, 17 May 2024 18:48:44 +0000</pubDate>
      <link>https://dev.to/emmauche001/mastering-rest-api-best-practices-a-developers-guide-4f6m</link>
      <guid>https://dev.to/emmauche001/mastering-rest-api-best-practices-a-developers-guide-4f6m</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;Introduction&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;In the realm of web development, REST APIs (Representational State Transfer Application Programming Interfaces) have become the backbone of modern applications. They provide a standardized way for different systems to communicate over HTTP, enabling seamless integration between various components. However, not all APIs are created equal. To ensure efficiency, scalability, and maintainability, it's essential to follow best practices when designing and implementing REST APIs. In this article, we'll explore some key principles and guidelines to help you craft robust and developer-friendly APIs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Designing RESTful Endpoints:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use nouns instead of verbs in endpoint URLs to represent resources.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;POST /createUser (incorrect)
POST /users (correct)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Follow a hierarchical structure for resource representation.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /users/{userId}/posts
GET /users/{userId}/posts/{postId}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Utilize HTTP methods (GET, POST, PUT, DELETE) appropriately for CRUD operations.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /users - Retrieves a list of users
POST /users - Creates a new user
GET /users/{userId} - Retrieves details of a specific user
PUT /users/{userId} - Updates details of a specific user
DELETE /users/{userId} - Deletes a specific user
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Version your APIs to maintain backward compatibility.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Response Formats and Status Codes:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Return responses in JSON format for easy consumption by clients.&lt;/li&gt;
&lt;li&gt;Use appropriate HTTP status codes to indicate the outcome of the request (e.g., 200 for success, 404 for not found, 400 for bad request).&lt;/li&gt;
&lt;li&gt;Provide meaningful error messages and adhere to standard error formats like RFC 7807 (Problem Details for HTTP APIs).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Authentication and Authorization:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implement secure authentication mechanisms such as OAuth 2.0 or JWT (JSON Web Tokens).&lt;/li&gt;
&lt;li&gt;Use HTTPS to encrypt data transmission and prevent eavesdropping.&lt;/li&gt;
&lt;li&gt;Enforce proper authorization checks to restrict access to resources based on user roles and permissions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Request and Response Payloads:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Keep request payloads concise by only including necessary data.&lt;/li&gt;
&lt;li&gt;Use query parameters for filtering, sorting, and pagination to optimize performance.&lt;/li&gt;
&lt;li&gt;Include relevant hypermedia links in responses to facilitate navigation within the API.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;5. Error Handling and Logging:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Handle errors effortlessly and provide informative error messages to assist developers with troubleshooting.&lt;/li&gt;
&lt;li&gt;Log API interactions, including requests, responses, and errors, for debugging and auditing purposes.&lt;/li&gt;
&lt;li&gt;Monitor API performance metrics such as response time, throughput, and error rates to identify and address bottlenecks.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;6. Testing and Documentation:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Write comprehensive unit tests to validate the functionality of individual API endpoints.&lt;/li&gt;
&lt;li&gt;Conduct integration tests to ensure seamless interaction between different components.&lt;/li&gt;
&lt;li&gt;Document your API thoroughly, including endpoint descriptions, request/response formats, authentication methods, and usage examples, using tools like Swagger or OpenAPI Specification.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
By adhering to these REST API best practices, developers can create robust, efficient, and developer-friendly APIs that enable seamless integration between diverse systems. Remember, the goal is not just to build an API but to empower developers to leverage it effectively. Embrace these principles, iterate based on feedback, and strive for continuous improvement to deliver exceptional API experiences.&lt;/p&gt;

</description>
      <category>java</category>
      <category>restapi</category>
      <category>api</category>
      <category>backenddevelopment</category>
    </item>
  </channel>
</rss>
