Posts

Showing posts from 2025

Handling Decimal Numbers in Java and PostgreSQL

  Handling Decimal Numbers in Java and PostgreSQL Background When working with decimal numbers such as percentages, monetary values, or other precise quantities, choosing the correct data types in both Java and PostgreSQL is critical to avoid precision loss and rounding errors. Java Data Types: Float vs BigDecimal Float and Double Use binary floating-point representation. Can introduce subtle rounding errors (e.g., 0.1 stored as 0.10000000000000001 ). Suitable for approximate scientific calculations or measurements where minor inaccuracies are acceptable. BigDecimal Uses exact decimal representation. Ideal for financial calculations, percentages, or anywhere exact decimal precision is required. Stores scale (number of digits after the decimal point) explicitly. PostgreSQL Data Types: FLOAT vs NUMERIC FLOAT (or DOUBLE PRECISION ) Approximate, binary floating-point storage. Can cause precision errors similar to Java Float / Double . ...

Kafka key Thing with Schema Validation

Image
  Producer   Consumer :   https://www.confluent.io/blog/how-schema-registry-clients-work/ https://medium.com/data-arena/schema-evolution-with-schema-registry-8d601ee84f4b

Docker

Image
  Docker Compose  a. What is Docker Compose? Docker Compose  is a  YAML file  where you define how multiple containers work together (services, volumes, networks). b. docker-compose.yml Basics services : Your app containers. volumes : Persistent storage. ports : Port mappings (host:container). networks : Group containers for communication. c. Hands-on Example docker-compose.yml Example 1  (Kafka) version: '3.8' services: kafka-broker: image: confluentinc/cp-kafka:latest container_name: kafka-broker hostname: kafka-broker ports: - "9092:9092" - "19092:19092" environment: KAFKA_BROKER_ID: 1 KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT,CONTROLLER:PLAINTEXT KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka-broker:19092,PLAINTEXT_INTERNAL://localhost:9092 KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1 KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS: 0 KAFKA_TRANSACTION...

Enterprise Design

  Pattern: Saga  https://microservices.io/patterns/data/saga.html Pattern: Transactional outbox https://microservices.io/patterns/data/transactional-outbox.html Multi-Tenant Architecture https://www.gooddata.com/blog/multi-tenant-architecture/ CQRS https://medium.com/@jpssasadara1995/cqrs-pattern-49fa3fafc825 https://waytoeasylearn.com/learn/cqrs-pattern-performance/ The Catalog of Design Patterns https://refactoring.guru/design-patterns/catalog https://waytoeasylearn.com/learn/cqrs-pattern-performance/ SN :  https://www.se.rit.edu/~swen-383/resources/RefCardz/designpatterns.pdf          https://mcdonaldland.info/files/designpatterns/designpatternscard.pdf

AWS Networking & IAM

Image
SN :  https://drive.google.com/file/d/1qBOFXGed_4v01WX8wG73mMF0yeJ0Putu/view?usp=drive_link                          AWS LB & Route53 https://towardsaws.com/network-in-aws-route53-vpc-bbf18a2ab054#:~:text=Route%2053%20is%20used%20for,user's%20location%20or%20other%20criteria.                                                              AWS IAM https://awsfundamentals.com/blog/aws-iam-roles-terms-concepts-and-examples#heading-aws-identity-center-and-federation In AWS, *users* and *roles* are two distinct concepts that serve different purposes in managing access and identity. AWS User - *Definition*: An AWS user is an entity that represents a person or application that interacts with AWS resources. - *Characteristics*:     - Users have long-term credenti...

When to Use Immutable vs. Mutable Data Structures in Java

  When to Use Immutable vs. Mutable Data Structures in Java Choosing between immutable and mutable data structures depends on the specific use case, performance considerations, and how the data will be used. 1. Immutable Data Structures Immutable data structures cannot be modified after creation. If you need to "modify" them, you create a new instance instead. When to Use Immutable Structures? ✅ Thread Safety → No race conditions or concurrent modification issues. ✅ Safe Sharing → Can be safely shared across multiple parts of the program. ✅ Predictability → No accidental modifications. ✅ Cache-Friendly → Can be safely cached without worrying about changes. Examples of Immutable Structures Immutable Records (Java 14+) javaCopyEditpublic record Person(String name, int age) {} public class Main {     public static void main(String[] args) {         Person person = new Person("Alice", 30);     ...

Optimistic vs. Pessimistic Locking in Spring Boot & JPA

  Optimistic vs. Pessimistic Locking in Spring Boot & JPA https://medium.com/@jpssasadara1995/optimistic-vs-e21af7c31de3