New post is up: Testing in Functional Programming. Testing looks a bit different when immutability, pure functions, and explicit effects start shaping your code. In this article, I explore some of those differences and why they matter. You can read it here: https://lnkd.in/euMhsPTm How do you approach testing when working with functional ideas in Java or other languages?
Testing in Functional Programming: Java and Beyond
More Relevant Posts
-
You do not always need a big framework or a whole new ecosystem to bring functional ideas into Java. That has been one of the motivations behind dmx-fun from the beginning: staying close to the JDK, embracing modern Java, and keeping things practical. I wrote this post because I really like the idea of JDK-first functional programming: using the platform well, reducing unnecessary complexity, and building on top of what Java already gives us instead of fighting it. Here it is: https://lnkd.in/eyhKhvNK Curious how you see it: when bringing functional programming into Java, do you prefer a minimal JDK-first approach or a more feature-rich ecosystem?
JDK-First Functional Programming: How Far Can You Go Without Dependencies? - dmx-fun domix.github.io To view or add a comment, sign in
-
🚀 Day 25/100: Mastering Constructors & the this() Keyword in Java 🏗️ Today’s focus was on a core concept in Object-Oriented Programming—Constructors—and how the this() keyword enhances code structure through constructor chaining. 🔹 What is a Constructor? A constructor is a special method used to initialize objects. It is automatically invoked when an object is created, ensuring that the object starts in a valid state. ✨ Key Characteristics: ✔ Same name as the class ✔ No return type (not even void) ✔ Executes automatically during object instantiation 🔹 Types of Constructors Default Constructor → Initializes objects with default values Parameterized Constructor → Allows initialization with specific values 🔹 Understanding this() Keyword The this() keyword is used to call one constructor from another within the same class, enabling efficient reuse of initialization logic. 👉 Benefits of using this(): ✔ Promotes code reusability ✔ Eliminates redundancy ✔ Improves code clarity and structure 🔹 Rules of this() ✔ Must be the first statement inside a constructor ✔ Can only be used within constructors ✔ Enables constructor chaining 🔹 Why Constructor Chaining Matters? Instead of duplicating initialization logic across multiple constructors, this() allows us to centralize and reuse it—resulting in cleaner, more maintainable code. 💡 Key Takeaway: A strong understanding of constructors and effective use of this() is essential for writing efficient, scalable, and professional Java applications. 📈 With each step in my #100DaysOfCode journey, I’m focusing on building a solid foundation in object-oriented design and best practices. #Day25 #100DaysOfCode #Java #JavaLearning #OOP #Constructors #Programming #JavaDeveloper #SoftwareDevelopment #CodingJourney #10000Coders
To view or add a comment, sign in
-
💻 Interface in Java — The Power of Abstraction 🚀 If you want to write flexible, scalable, and loosely coupled code, understanding Interfaces in Java is a must 🔥 This visual breaks down interfaces with clear concepts and real examples 👇 🧠 What is an Interface? An interface is a blueprint of a class that defines a contract. 👉 Any class implementing it must provide the method implementations 🔍 Key Characteristics: ✔ Methods are public & abstract by default ✔ Cannot be instantiated ✔ Supports multiple inheritance ✔ Variables are public, static, final ⚡ Why Interfaces? ✔ Achieve abstraction ✔ Enable loose coupling ✔ Improve code flexibility ✔ Allow multiple inheritance 🧩 Advanced Features (Java 8+): 🔹 Default Methods 👉 Provide implementation inside interface default void info() { System.out.println("This is a shape"); } 🔹 Static Methods 👉 Called using interface name static int add(int a, int b) { return a + b; } 🔹 Private Methods 👉 Reuse logic inside interface 🚀 Real Power: 👉 One interface → multiple implementations 👉 Same method → different behavior (Polymorphism) 🎯 Key takeaway: Interfaces are not just syntax — they define how different parts of a system communicate and scale efficiently. #Java #OOP #Interface #Programming #SoftwareEngineering #BackendDevelopment #Coding #100DaysOfCode #Learning
To view or add a comment, sign in
-
-
🛑Stop treating Abstraction and Encapsulation like they’re the same thing. Demystifying Java OOP: From Basics to the "Diamond Problem" 💎💻 If you're leveling up in Java, understanding the "How" is good—but understanding the "Why" is what makes you a Senior Developer. Let’s break down the core of Object-Oriented Programming. 🚀 1️⃣ What is OOP & The 4 Pillars? 🏗️ OOP is a way of designing software around data (objects) rather than just functions. It rests on four main concepts: ✅ Encapsulation: Protecting data. ✅ Abstraction: Hiding complexity. ✅ Inheritance: Reusing code. ✅ Polymorphism: Adapting forms. 2️⃣ Encapsulation vs. Abstraction: The Confusion 🔐 These two are often mixed up, but here is the simple split in Java: 🔹 Encapsulation is about Security. We keep variables private and use getters and setters to act as a "shield" for our data. 🔹 Abstraction is about Design. We use Interfaces or Abstract Classes to show the user what the code does while hiding the messy details of how it works. 3️⃣ The Rule of Inheritance 🌳 Inheritance allows a child class to take on the traits of a parent class. However, the catch: In Java, a class can only have ONE parent. 🚫 4️⃣ Why no Multiple Inheritance? (The Diamond Problem) 💎 Imagine Class A has a start() method. Both Class B and Class C inherit it, but they modify how it works. If Class D tries to inherit from both B and C, and we call D.start(), Java has no way of knowing which version to run! To avoid this "ambiguity" and keep your code predictable, Java forbids inheriting from multiple classes. 5️⃣ How to solve it? 🛠️ Need multiple behaviors? No problem. 👉 Interfaces: A class can implement as many interfaces as it needs. 👉 Default Methods: Since Java 8, if two interfaces have the same default method, Java forces you to override it and choose a winner. No more guesswork! 👉 Composition: Instead of "being" a class, "have" an instance of it. Mastering these rules is crucial for writing clean, maintainable, and professional Java code. 🌟 #Java #Programming #OOP #SoftwareDevelopment #CodingTips #TechCommunity #SoftwareEngineering #CareerGrowth
To view or add a comment, sign in
-
Again, a good article from Sergiy Yevtushenko. Every developer should read this - it's Java, but the lessons are useful in many modern languages. Practical, applied programming tips like many devs appreciate them. These are not just "FP style examples in Java". They are also applied ways of properly decoupling concepts and mechanisms that should remain decoupled, but which traditional OOP languages tend to force us to couple. For example: handling errors with try-catch VS handling errors with Result<>, flatMap() etc. And don't forget to follow Sergiy Yevtushenko, his programming advice is always best of class. #Java #FunctionalProgramming #Programming #Architecture
To view or add a comment, sign in
-
Aspect-Oriented Programming (AOP) in Java — The Secret Sauce for Cleaner Code! Ever felt like your business logic is getting cluttered with repetitive code like logging, security checks, or transaction handling? That’s where Aspect-Oriented Programming (AOP) steps in! 👉 AOP helps you separate cross-cutting concerns from your core business logic — making your code more modular, maintainable, and scalable. 💡 What exactly is AOP? Think of it as a way to “inject” behavior into your code without modifying the actual code itself. Instead of writing logging, authentication, or error handling everywhere, you define them once — and apply them wherever needed. --- 🔥 Key Concepts Simplified: - Aspect → The logic you want to reuse (e.g., logging, security) - Join Point → A specific point in execution (like method calls) - Advice → What you want to do (before, after, around execution) - Pointcut → Where you want to apply the logic --- ⚡ Why should you care? ✅ Cleaner and more readable code ✅ Better separation of concerns ✅ Reduced duplication (DRY principle) ✅ Easier maintenance and debugging ✅ Plug-and-play features like logging & transactions --- 🤯 Interesting Facts About AOP: 🔹 AOP is heavily used in frameworks like Spring (hello, "@Transactional" 👀) 🔹 You might already be using AOP without realizing it! 🔹 It promotes declarative programming — you define what, not how 🔹 AOP can intercept method calls at runtime using proxies (JDK Dynamic Proxy / CGLIB) 🔹 It can drastically reduce boilerplate code in enterprise applications --- 💻 Real-world Example: Instead of writing logging in 100 methods ❌ ➡️ Define one logging aspect ✅ ➡️ Apply it across your application magically ✨ Have you used AOP in your projects yet? Or planning to explore it soon? 👇 #Java #SpringBoot #AOP #CleanCode #SoftwareEngineering #BackendDevelopment #Programming
To view or add a comment, sign in
-
It started with a simple question: what can I do with the new features shipping in Java 25? I have always loved functional programming. The way it pushes you to think in terms of transformations, immutability, and composition just makes code easier to reason about. So when modern Java started shipping features that genuinely enable functional idioms — record patterns, Stream Gatherers, sealed types — I saw an opportunity I could not ignore: take the principles I care about and express them using the best of what the language now offers. I wanted a playground — something concrete enough to exercise those ideas in practice. I was not planning to build a library. I was planning to experiment for a weekend. A few weeks later I had Option<T>, Result<V,E>, Try<V>, Validated<E,A>, Tuple2, Tuple3, Tuple4, Lazy<T>, zip combinators, checked functional interfaces, and a test suite with more than 500 tests. At some point it stopped being a playground and became something I was actually reaching for in my personal projects. That felt like a signal worth following — if it was useful to me it might be useful to others. So here we are. dmx-fun is a small, opinionated functional programming library for Java, built to be read and understood, not just consumed. And this post is about where it is going. https://lnkd.in/ez2EUrFR
To view or add a comment, sign in
-
Every Java program uses two memory areas at runtime: the stack and the heap. They serve very different purposes and understanding the distinction is one of those things that separates developers who write code from developers who understand what their code actually does. The stack is where method calls live. Every time you call a method, the JVM pushes a new frame onto the stack containing local variables, parameters, and the return address. When the method finishes, the frame gets popped off. It's fast because there's no searching involved, just a pointer moving up and down. Each thread gets its own stack, so there's no synchronization overhead. The heap is shared memory where objects live. When you write new Person(), that object gets allocated on the heap, and a reference (essentially a pointer) gets stored on the stack. This is why Java is "pass by value" but it feels like "pass by reference" for objects. You're passing the value of the reference, not the object itself. The garbage collector only operates on the heap. It periodically scans for objects that no longer have any references pointing to them and reclaims that memory. The heap is further divided into generations. Young Gen handles short-lived objects (most objects die young), and Old Gen stores objects that survived multiple GC cycles. This generational approach is why modern JVMs can handle millions of allocations efficiently. Stack overflows happen when you have too many nested method calls (usually infinite recursion). OutOfMemoryErrors happen when the heap runs out of space. Knowing which memory area is involved tells you exactly where to look when debugging. #java #coding #programming
To view or add a comment, sign in
-
-
💻 Exception Handling in Java — Write Robust Code 🚀 Handling errors properly is what separates basic code from production-ready applications. This visual breaks down Exception Handling in Java in a simple yet technical way 👇 🧠 What is an Exception? An exception is an unexpected event that occurs during program execution and disrupts the normal flow. 👉 Example: Division by zero → ArithmeticException 🔍 Exception Hierarchy: Object ↳ Throwable ↳ Error (System-level, not recoverable) ↳ Exception (Can be handled) ✔ Checked Exceptions (Compile-time) ✔ Unchecked Exceptions (Runtime) ⚡ Types of Exceptions: ✔ Checked → Must be handled (IOException, SQLException) ✔ Unchecked → Runtime errors (NullPointerException, ArrayIndexOutOfBoundsException) 🔄 Try-Catch-Finally Flow: 1️⃣ try → Code that may cause exception 2️⃣ catch → Handle the exception 3️⃣ finally → Always executes (cleanup resources) 🛠 Throw vs Throws: throw → Explicitly throw an exception throws → Declare exceptions in method signature 🧪 Custom Exceptions: Create your own exceptions for business logic validation → improves readability & control ⚠️ Common Exceptions: ArithmeticException NullPointerException ArrayIndexOutOfBoundsException IOException 🔥 Best Practices: ✔ Handle specific exceptions (avoid generic catch) ✔ Use meaningful error messages ✔ Always release resources (finally / try-with-resources) ✔ Don’t ignore exceptions silently ✔ Use custom exceptions where needed 🎯 Key takeaway: Exception handling is not just about avoiding crashes — it’s about building reliable, maintainable, and user-friendly applications. #Java #ExceptionHandling #Programming #SoftwareEngineering #BackendDevelopment #Coding #100DaysOfCode #Learning
To view or add a comment, sign in
-
-
Most Java mistakes I see in code reviews come from the same 20 misunderstandings. After reviewing thousands of pull requests, these patterns keep showing up, especially from developers in their first 2 years. Here is what trips people up the most: → Using == instead of .equals() for String comparison → Mutating Date objects when LocalDate exists → Throwing checked exceptions for programming errors → Using raw types instead of generics → Concatenating Strings in loops instead of StringBuilder → Writing nested null checks instead of using Optional → Defaulting to arrays when ArrayList gives you flexibility → Wrapping everything in synchronized when ConcurrentHashMap exists → Catching Exception instead of the specific type you expect → Making utility methods static when they should be instance methods → Using new String("hello") instead of string literals → Using Integer when int would suffice → Repeating type args instead of using the diamond operator → Manual close() in finally instead of try-with-resources → Using static final int constants instead of enums → Writing verbose for-if-add loops instead of streams → Using Arrays.asList when List.of gives true immutability → Spelling out full types when var keeps code clean → Writing boilerplate classes when records do the job → Concatenating strings with \n instead of using text blocks None of these are hard to fix once you see the pattern. The real problem is that nobody points them out early enough. Save this for your next code review. #Java #SoftwareDevelopment #Programming #CleanCode #CodingTips
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