In recent design notes from OpenJDK, language architect Brian Goetz hints at the next step: carrier classes — constructs that keep the expressiveness of records while restoring the flexibility of regular classes. If this lands, it could quietly reshape how we design domain models in Java. What do you think about this? How relevant is this problem in your work?
Anatol Biazruchanka’s Post
More Relevant Posts
-
Some Java features only reveal their real power once you see them applied across different concrete types. Polymorphism is one of those features, and it quietly drives half of the APIs you use every day. When you watch the JVM decide which implementation to run, especially in mixed hierarchies, the mechanics become a lot more interesting than the textbook explanation. This article walks through those edge cases where inheritance, overriding, and casting intersect. https://bit.ly/4rJLj4e
To view or add a comment, sign in
-
I wrote a blog post about "Functional Composition Patterns." If you're interested in learning how to implement them in pure Java, it's good material. You could also check out the rest of the documentation for the `dmx-fun` library. https://lnkd.in/eR5uvmHE
To view or add a comment, sign in
-
Good Monday! Let’s start the week with a deep analysis by Java luminary Brian Goetz on carrier classes, records and the future of the language as is being developed in Project Amber. Sorry about the format, it is very clumsy, maybe a copy-paste on your favorite text editor will help. https://lnkd.in/eh3BQAYy #Java #DataOrientedProgramming #Java26AndBeyond #ProjectAmber
To view or add a comment, sign in
-
The Magic of @SneakyThrows in Java: How Does It Break the Rules? Lombok’s @SneakyThrows often raises questions in code reviews. It allows us to throw a checked exception (like IOException) without adding a throws clause - something Java normally forbids. The Problem: Java forces you to catch checked exceptions or declare them. This is especially frustrating with lambdas, where adding a throws declaration isn't an option. How does this work? Lombok uses bytecode manipulation. It replaces your checked exception with a generic throw that bypasses the compiler's checks. At runtime, the exception is thrown normally, but the compiler never sees the violation. It’s a clean solution for edge cases - just use it intentionally. While @SneakyThrows makes the code look cleaner, it breaks the method signature contract. Consumers of your method won't know they need to handle that exception, which can lead to unexpected application crashes. It also violates the Principle of Least Astonishment - other developers reading the code won't expect a checked exception to appear out of nowhere, making debugging and maintenance more difficult. But despite these risks, it's hard to deny how pleasant @SneakyThrows feels to use. The code becomes so clean and readable - no more wrapping everything in try-catch blocks just to satisfy the compiler. When you're working with streams or quick scripts, that single annotation removes the noise and lets the business logic shine. Do you use @SneakyThrows in your projects? Let’s discuss below! 👇 #Java #Programming #Lombok #SoftwareDevelopment #CodingTips
To view or add a comment, sign in
-
-
Understanding Polymorphism in Java — The Backbone of Flexible System Design While strengthening my Core Java fundamentals, I revisited one of the most powerful OOP principles — Polymorphism. Polymorphism means: “One interface, multiple implementations.” In a simple Notification System example: • A base class Notification defines a send() method. • Child classes like EmailNotification and SMSNotification override that same method. • The method that gets executed is decided at runtime. Example concept: Notification notification = new EmailNotification(); notification.send("Payment Successful"); Even though the reference type is Notification, the method executed belongs to EmailNotification. This is Runtime Polymorphism (Dynamic Method Dispatch). Why this matters in real-world systems: • Enables scalable architecture • Supports plug-and-play design • Makes systems extensible without modifying existing code • Forms the foundation of Strategy Pattern • Widely used in enterprise backend systems Polymorphism is not just an academic concept — it is how large systems remain flexible and maintainable. Strong backend development starts with mastering OOP fundamentals deeply. Curious to hear from experienced developers: Where have you leveraged runtime polymorphism effectively in production systems? #Java #CoreJava #OOP #Polymorphism #BackendDevelopment #SoftwareEngineering #CleanCode #JavaDeveloper #TechCareers
To view or add a comment, sign in
-
-
You might have seen this code block in the top leetcode submission of a problem or in competitive programming solution such as codeforces. But what does it do, what's the need of it ? Let's understand this...... What's happening here ? In java as we all know a static block runs only once when the class is loaded by the JVM. So for every problem this part runs once and create a object of the "Solution" class before running any other part of the code. But what is the benefit of it, isn't it making the code slower as an extra code is running before the actual solution code? The answer is not really, instead it is making the code faster, how ? In a java program, when the program loads in the "JVM(Java Virtual Machine)", the JVM loads the "Solution" class and immediately the static blocks executes and create a object of the Solution class and calls the function multiple times with a dummy input. At that exact time what is happening is before running anything else, the program is warming up(yes warming up) by running that method 500 times. In Java, the JIT (Just-In-Time compiler) optimizes code after it runs a few times. Calling a method 500 times before using it ensures the method is "hot" (optimized) when real input comes. Why this is used ? In competitive programming, where execution time is critical, even small optimizations matter. This static warm-up trick leverages JVM behavior to gain a slight performance edge.
To view or add a comment, sign in
-
-
Encapsulation vs Abstraction in Java — Developers Often Confuse These Both are core OOP principles, but they solve different problems. Here’s the simplest way to understand 👇 Encapsulation → Hiding Data (How it works internally) Focus: Protecting and controlling access to object data. Example: Private variables + getters/setters ✔ Restricts direct access ✔ Improves security ✔ Maintains data integrity Think: “How do I protect this data?” Abstraction → Hiding Complexity (What to show) Focus: Exposing only essential behavior while hiding implementation details. Example: Interfaces / Abstract classes ✔ Reduces complexity ✔ Shows only necessary functionality ✔ Improves maintainability Think: “What does the user need to know?” Thumb Rule: Encapsulation hides data, Abstraction hides implementation complexity. 💡 Great design is not about hiding everything — it’s about hiding the right things. Sharing concepts I use in backend engineering & system design. Which one do you find harder to explain — Encapsulation or Abstraction?
To view or add a comment, sign in
-
-
🔹 Marker Interface in Java — Simple but Powerful Sometimes Java gives small concepts that look useless… but hide deep design thinking. A Marker Interface is an interface with: ❌ No methods ❌ No fields ✅ Only purpose: to mark a class with special capability It doesn’t define behavior. It defines intent. 🔹 Why Does It Exist? Before annotations (Java 5), marker interfaces were the clean way to attach metadata to a class. They provide: ✔ Type-level metadata ✔ Compile-time type safety ✔ Special JVM behavior 🔹 Real Core Java Examples • Serializable Marks a class so JVM allows object serialization. Without it → NotSerializableException • Cloneable Marks a class to allow cloning. Without it → CloneNotSupportedException • RandomAccess Used by ArrayList to signal fast index-based access. JVM optimizes algorithms based on it. 🔹 Why Not Just Use Annotations? Annotations can add metadata. But marker interfaces provide something stronger: 👉 Compile-time type enforcement Example: void saveToFile(Serializable obj) Only Serializable objects are allowed. With annotation, you cannot enforce this in method signature. That’s powerful design. 🔹 Architect-Level Thinking Marker interfaces are used when: • You need type safety • You need compile-time validation • JVM/framework must treat class differently Today, annotations replaced most use cases. But understanding marker interfaces helps you understand: 👉 Java’s type system 👉 JVM internal contracts 👉 Design philosophy evolution Sometimes Java feels mysterious. But that mystery is actually strong engineering design. #Java #Architecture #DesignPatterns #JVM #BackendDevelopment
To view or add a comment, sign in
-
Day 37 - 🚀 Rules of Method Overriding in Java Method Overriding is a key concept in Object-Oriented Programming (OOP) that allows a subclass to provide a specific implementation of a method already defined in its superclass. It helps achieve Runtime Polymorphism in Java. 📌 Important Rules of Method Overriding: 🔹 1. Same Method Name The method in the subclass must have the same name as in the superclass. 🔹 2. Same Method Parameters The number, type, and order of parameters must be exactly the same. 🔹 3. Return Type The return type must be the same or a covariant type (subtype) of the parent method. 🔹 4. Access Modifier Rule The subclass method cannot reduce visibility. Example: ✔ protected → public ✔ default → protected ❌ public → private 🔹 5. Final Methods Cannot Be Overridden If a method is declared final, it cannot be overridden. 🔹 6. Static Methods Cannot Be Overridden Static methods belong to the class and are method hidden, not overridden. 🔹 7. Private Methods Cannot Be Overridden Private methods are not inherited, so they cannot be overridden. 🔹 8. Exception Handling Rule The child class method cannot throw broader checked exceptions than the parent method. 🔹 9. Use @Override Annotation Using @Override helps the compiler check whether the method is correctly overridden. 💡 Conclusion: Method Overriding enables runtime polymorphism, making Java programs more flexible, maintainable, and scalable. #Java #OOP #MethodOverriding #JavaProgramming #ProgrammingConcepts #SoftwareDevelopment
To view or add a comment, sign in
-
-
Why "Thinking in Objects" is the Ultimate Superpower in Java 🚀 If you are just starting your journey into Object-Oriented Programming (OOP), the terminology can feel like a foreign language. "Classes," "Objects," "Methods," "Instances"—it’s a lot to take in. But if you look at this illustration, you’ll see that coding isn’t just about syntax; it’s about architecture. 1. The Class: Your Architectural Blueprint 📜 The left side of the image shows the Class House. In Java, a class is not a thing; it is a template. It defines: Attributes (Fields): Like int windows and String color—these are the characteristics every house will have. Behaviors (Methods): Like void build()—this is what the house (or the system) can do. 2. The Process: Instantiation 🏗️ Notice the arrow in the middle? That’s the "Magic Moment" called Instantiation. When you use the new keyword in Java, you are telling the computer: "Take this blueprint and actually build it in memory!". 3. The Objects: The Real-World Result 🏡 On the right, we see three distinct Objects: Object 1: A Red House. Object 2: A Yellow House. Object 3: A Blue House. Here is the key takeaway: Even though they all came from the exact same blueprint, they are unique. They each have their own "state" (different colors), but they share the same "identity" (they are all Houses). Why does this matter? By using this model, Java allows us to write code that is: ✅ Reusable: Write the blueprint once, create a thousand houses. ✅ Organized: Keep data and behavior in one neat package. ✅ Scalable: It’s much easier to manage a neighborhood when you have a standard plan to follow. What was the "Aha!" moment that helped you finally understand OOP? Drop a comment below! 👇 #Java #SoftwareEngineering #CodingLife #OOP #TechEducation #WebDevelopment
To view or add a comment, sign in
-
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development