Java Enum Design & Generic Utility
Java Enum Design & Generic Utility1. Problem BackgroundIn many business scenarios, enums need to convert from a String value:
1StudentStatus.from("enrolled");
Without abstraction, every enum repeats the same logic:
12345for (StudentStatus s : StudentStatus.values()) { if (s.getValue().equals(value)) { return s; }}
This leads to code duplication and poor maintainability. We need to keep code dry
2. Goal
Eliminate repeated from() logic
Keep type sa ...
Python Intro
ListUsing the join() method to concatenate all elements in a list.1234567list = ["this", "is", "an", "example", "of", "using", "join()", "method"]seperator = " - "new_list = seperator.join(list)print(new_list)# this - is - an - example - of - using - join() - method
Using the split() method to split a string into a list.12print(new_list.split(seperator))# ['this', 'is', 'an ...
Leetcode Review
399. Evaluate DivisionProblem Description:
You are given an array of variable pairs equations and an array of real numbers values, where equations[i] = [Ai, Bi] and values[i] represent the equation Ai / Bi = values[i]. Each Ai or Bi is a string that represents a single variable.
You are also given some queries, where queries[j] = [Cj, Dj] represents the jth query where you must find the answer for Cj / Dj = ?.
Return the answers to all queries. If a single answer cannot be determined, return -1. ...
Global Exception Handling in Spring Boot
IntroductionWhen building projects with Spring Boot, handling complex business requirements often involves dealing with various exceptions. For example, during file I/O operations, you may encounter IOException or FileNotFoundException. When writing SQL statements or using JDBC, you may face SQLException. When working with reflection-related code, ClassCastException may occur.
In addition, there are many common exceptions such as NullPointerException, ArrayIndexOutOfBoundsException, Concurr ...
Spring Boot Integration with Redis and Redis Configuration
IntroductionWhen talking about NoSQL databases, caching systems, message queues, token-based authentication, and similar use cases, Redis is almost always part of the discussion.
As an in-memory data structure store written in C, Redis is widely known for its high performance and simplicity. Thanks to its single-threaded design, it avoids lock contention issues common in multi-threaded environments, enabling it to handle hundreds of thousands of read and write operations per second.
In addition, ...
Spring Boot Logging Integration
IntroductionUp to now, Java has developed a complete logging system, which is divided into a logging facade and specific logging implementations. The logging facade is equivalent to an interface, while the various logging frameworks are actually different implementations of that facade.
Java logging loading relies on SPI. Unlike API, in the SPI pattern the interface is on the caller’s side, while developers only provide the concrete implementations. In the API pattern, both the interface and the ...
SQL Injection Risks and Solutions in MyBatis
SQL InjectionAs a classic web security issue, SQL injection is something that almost every student who has taken a cybersecurity course has encountered to some extent.
The underlying principle is actually quite simple: by inserting specially crafted characters into an SQL statement, an attacker can manipulate the query condition into a tautology, thereby bypassing checks such as username and password validation and directly retrieving data from the database.
In more severe cases, SQL injection c ...
Hearthstone Database Summary
PrefaceThis is a full-stack project based on a front-end and back-end separation architecture. The back-end tech stack includes Spring Boot + MyBatis + MySQL. The front-end is built with Vue 3. After completion, the project was deployed on AWS cloud services, running on Ubuntu, with Nginx configured as a reverse proxy.
The entire project—from collecting the dataset, cleaning the data, integrating the database, to finally deploying it to the server—took approximately 10 days. The actual front-end ...
Summary of Design Patterns
Design PatternsDecorator PatternThe Decorator Pattern is a structural design pattern that allows you to dynamically add new behavior to an object without altering its structure or affecting other objects. This pattern works by wrapping the original object inside a “decorator” object, enabling behavior extension while keeping the original object’s type unchanged.
Object Composition: The Decorator Pattern relies on composition rather than inheritance. You wrap one object inside another to add add ...
Summary of Java Collections Principles and Underlying Data Structures
First, a Collection Hierarchy Diagram1<img src="https://pics.findfuns.org/Collections-hierarchy.png" alt="collectionsHierarchy" style="zoom:50%;" />
ListThe main characteristics of a List are ordering and allowing duplicate elements.
ArrayListArrayList allows any element, including null. Compared with Vector, it is not thread-safe. If necessary, it can be wrapped with Collections.synchronizedList() to make it thread-safe:
1List list = Collections.synchronized ...









