java

Desenvolvimento Orientado a SOLID

Desenvolvimento Orientado a SOLID

No desenvolvimento de software, a manutenção, extensão e a flexibilidade do código são importantes para o sucesso a longo prazo de um projeto. Os princípios SOLID foram formulados para orientar os desenvolvedores na criação de código que seja mais fácil de entender, modificar e estender. Neste artigo, vamos falar de cada um dos cinco princípios SOLID e como usar com exemplos práticos em Java. 1. Single Responsibility Principle (Princípio da Responsabilidade Única) O Princípio da Responsabilidade Única (SRP) estabelece que uma classe deve ter apenas uma razão para mudar, ou seja, deve ter uma única responsabilidade dentro do sistema. //…
Read More
Preventing Multiple Processing of SQS Messages

Preventing Multiple Processing of SQS Messages

Introduction Amazon SQS (Simple Queue Service) is a fully managed message queuing service that enables you to decouple and scale microservices, distributed systems, and serverless applications. AWS Lambda can process messages from an SQS queue, making it a powerful combination for event-driven applications. Scenario Imagine an AWS architecure like this: Imagine a scenario where your Lambda function fails to tag an SQS message as successfully processed. By default, Lambda retries the message up to 4 times before ignoring it. This retry behavior can lead to exponential execution of your handler: First Lambda: Retries 4 times, potentially sending 4 messages to…
Read More
Sorting

Sorting

Sorting algorithms are good examples for studying algorithm design and analysis. Sorting is a classic subject in computer science. There are three reasons to study sorting algorithms. First, sorting algorithms illustrate many creative approaches to problem solving, and these approaches can be applied to solve other problems. Second, sorting algorithms are good for practicing fundamental programming techniques using selection statements, loops, methods, and arrays. Third, sorting algorithms are excellent examples to demonstrate algorithm performance. The data to be sorted might be integers, doubles, characters, or objects. Section, Sorting Arrays, presented selection sort. The selection sort algorithm was extended to sort…
Read More
Ultimate Spring Boot Interview Preparation Guide

Ultimate Spring Boot Interview Preparation Guide

1. Why Spring Boot? Spring based applications have a lot of configuration. When we use Spring MVC, we need to configure ComponentScan, DispatcherServlet, a view resolver, web jars, and more. Spring Boot is a project that is built on the top of the Spring framework. It provides a simpler and faster way to set up, configure, and run both simple and web-based applications. World is moving towards microservices and cloud-native applications. Spring Boot is the best choice for building microservices. **** ### 2. What are Spring Boot goals? Quick start to Spring. Provide opinionated 'starter' dependencies to simplify build configuration.…
Read More
Analyzing Algorithm Time Complexity

Analyzing Algorithm Time Complexity

This section analyzes the complexity of several well-known algorithms: binary search, selection sort, and Tower of Hanoi. Analyzing Binary Search The binary search algorithm presented in BinarySearch.java, searches for a key in a sorted array. Each iteration in the algorithm contains a fixed number of operations, denoted by c. Let T(n) denote the time complexity for a binary search on a list of n elements. Without loss of generality, assume n is a power of 2 and k = logn. Since a binary search eliminates half of the input after two comparisons, Ignoring constants and nondominating terms, the complexity of…
Read More
Implementing CQRS and Event Sourcing in Distributed Systems

Implementing CQRS and Event Sourcing in Distributed Systems

Introduction As software systems grow in complexity, the need for scalable and maintainable architectures becomes paramount. Two powerful patterns that address these needs are Command Query Responsibility Segregation (CQRS) and Event Sourcing. By leveraging these patterns, along with reactive principles, you can build systems that are highly responsive, resilient, and flexible. In this article, we will explore the concepts of CQRS and Event Sourcing, and provide detailed examples of how to implement them in a distributed system using Java and Spring Boot. Understanding CQRS What is CQRS? CQRS stands for Command Query Responsibility Segregation. It is a design pattern that…
Read More
Vector and Stack Classes

Vector and Stack Classes

Vector is a subclass of AbstractList, and Stack is a subclass of Vector in the Java API. The Java Collections Framework was introduced in Java 2. Several data structures were supported earlier, among them the Vector and Stack classes. These classes were redesigned to fit into the Java Collections Framework, but all their old-style methods are retained forcompatibility. Vector is the same as ArrayList, except that it contains synchronized methods for accessing and modifying the vector. Synchronized methods can prevent data corruption when a vector is accessed and modified by two or more threads concurrently. For the many applications that…
Read More
Understanding Adapters in Java for Android Development

Understanding Adapters in Java for Android Development

Adapters are a crucial part of Android development, especially when dealing with user interfaces. They act as a bridge between a data source and a user interface component, enabling the display of dynamic content in views like ListView, GridView, and RecyclerView. This article explores the concept of adapters in Java for Android Studio, illustrating their importance and usage with practical examples. Why Are Adapters Important in Android? Data Binding: Adapters facilitate the binding of data from data sources (like arrays, databases, or web services) to UI components.Dynamic Content: They allow for the dynamic display of content, making it easy to…
Read More
Wildcard Generic Types

Wildcard Generic Types

You can use unbounded wildcards, bounded wildcards, or lower-bound wildcards to specify a range for a generic type. What are wildcard generic types and why are they needed? The code below gives an example todemonstrate the needs. The example defines a generic max method for finding the maximum in a stack of numbers (lines 15–25). The main method creates a stack of integer objects, adds three integers to the stack, and invokes the max method to find the maximum number in the stack. The program above has a compile error in line 11 because intStack is not an instance of…
Read More
Text I/O vs. Binary I/O

Text I/O vs. Binary I/O

Binary I/O does not involve encoding or decoding and thus is more efficient than text I/O. Computers do not differentiate between binary files and text files. All files are stored in binary format, and thus all files are essentially binary files. Text I/O is built upon binary I/O to provide a level of abstraction for character encoding and decoding, as shown in Figure below (a). Encoding and decoding are automatically performed for text I/O. The JVM converts Unicode to a file-specific encoding when writing a character, and it converts a file-specific encoding to Unicode when reading a character. For example,…
Read More
No widgets found. Go to Widget page and add the widget in Offcanvas Sidebar Widget Area.