Skip to content

eduanmoldeep/java-gcoen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java Workshop - Samples and Demos

This repository contains executable code samples and demonstrations for key Java concepts covered in the workshop.

📁 Structure

Samples (Core Concepts)

Located in samples/ directory:

  1. 01-memory-layout - List Memory Layout

    • ArrayList vs LinkedList internal structure
    • Memory overhead and cache locality
    • Performance comparison
    • Run: java samples/01-memory-layout/ListMemoryDemo.java
  2. 02-equals-hashcode - Equals and HashCode Contract

    • Proper implementation patterns
    • Contract violations and consequences
    • HashMap behavior demonstration
    • Run: java samples/02-equals-hashcode/EqualsHashCodeDemo.java
  3. 03-streams - Stream Pipelines

    • Declarative vs imperative programming
    • Lazy evaluation
    • Powerful collectors
    • Run: java samples/03-streams/StreamPipelineDemo.java
  4. 04-optional - Optional Container

    • Anti-patterns to avoid
    • Best practices
    • Functional style operations
    • Run: java samples/04-optional/OptionalDemo.java

Demos (Architecture)

Located in demos/ directory:

  1. 05-springboot-architecture - Spring Boot Architecture
    • Dependency Injection pattern
    • Layered architecture (Controller → Service → Repository)
    • Loose coupling benefits
    • Run: java demos/05-springboot-architecture/SpringBootArchitectureDemo.java

🚀 Quick Start

Run All Demos

# From the project root directory
./run-all-demos.sh

Run Individual Demos

# Memory Layout
java samples/01-memory-layout/ListMemoryDemo.java

# Equals and HashCode
java samples/02-equals-hashcode/EqualsHashCodeDemo.java

# Streams
java samples/03-streams/StreamPipelineDemo.java

# Optional
java samples/04-optional/OptionalDemo.java

# Spring Boot Architecture
java demos/05-springboot-architecture/SpringBootArchitectureDemo.java

📚 Workshop Topics Covered

Based on overview.md:

  • Moving beyond Java syntax to deep internals and modern patterns
  • Abstraction and design for loose coupling → Better testability and maintainability
  • Memory layout of lists → ArrayList vs LinkedList internals
  • Proper contract for equals and hashCode → HashMap behavior
  • Declarative Stream Pipelines → Functional programming in Java
  • Optional container → Null-safe programming
  • Production-grade Spring Boot architecture → Dependency injection best practices

🎯 Key Takeaways

  1. Memory Matters: Understand how data structures are laid out in memory for performance
  2. Contracts Are Critical: equals/hashCode contract must be maintained for collections
  3. Think Declaratively: Streams make code more readable and maintainable
  4. Embrace Optional: Avoid NullPointerException with functional style
  5. Design for Change: Loose coupling through DI enables testability and flexibility

📖 Learning Path

Recommended order for beginners:

  1. Start with Memory Layout to understand fundamentals
  2. Learn Equals/HashCode for collection usage
  3. Master Streams for modern Java programming
  4. Adopt Optional for null-safe code
  5. Apply Spring Boot patterns for production applications

🔧 Requirements

  • Java 11 or higher (for modern features like var, enhanced Optional methods)
  • No external dependencies required for basic samples
  • Spring Boot samples use conceptual patterns (no actual Spring dependencies)

💡 Tips

  • Each demo is self-contained and can run independently
  • Read the code comments for detailed explanations
  • Experiment by modifying the examples
  • Use these as templates for your own projects

Happy Learning! 🚀

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages