<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by mkonca on Medium]]></title>
        <description><![CDATA[Stories by mkonca on Medium]]></description>
        <link>https://medium.com/@mkonca?source=rss-e6afd92b93db------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*RUvDZCNCdIem6dwjh0RsqQ.png</url>
            <title>Stories by mkonca on Medium</title>
            <link>https://medium.com/@mkonca?source=rss-e6afd92b93db------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 04:26:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mkonca/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[From Junior to Senior Java Developer]]></title>
            <link>https://medium.com/@mkonca/from-junior-to-senior-java-developer-b21287f1eb44?source=rss-e6afd92b93db------2</link>
            <guid isPermaLink="false">https://medium.com/p/b21287f1eb44</guid>
            <category><![CDATA[career-advice]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[features]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[mkonca]]></dc:creator>
            <pubDate>Fri, 04 Dec 2026 07:15:03 GMT</pubDate>
            <atom:updated>2026-12-04T07:15:03.087Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Build Skills That Create Value</strong></p><p><strong>You Graduated. What’s Next?</strong></p><p>You’ve graduated from university. You know the basics of programming. Maybe you’ve learned Java, written a few projects, and started exploring Spring Boot.</p><p>Then you look at job descriptions.</p><p>Java, Spring Boot, Microservices, Kafka, Docker, Kubernetes, Redis, AWS, SQL, NoSQL…</p><p>It feels like everyone expects you to know everything before you even get your first job.</p><p>And now there is another factor: AI.</p><p>You can ask an AI assistant to generate a Spring Boot application, create REST endpoints, write database entities, prepare unit tests, or explain an unfamiliar Java concept.</p><p>Things that once took days can sometimes be done in minutes.</p><p>That’s an incredible opportunity, especially for someone starting a career.</p><p>But it also creates a new challenge.</p><p><strong>You can produce code much faster than you can develop the engineering skills needed to understand and maintain it.</strong></p><p>So, what should your goal be?</p><p>It shouldn’t be to learn every technology or to generate as much code as possible.</p><p>Your goal should be to become a developer who can solve increasingly difficult problems, understand the solutions, and create real value.</p><p>Let’s look at how to get there.</p><p><strong>1. Start With Java, Not With Frameworks</strong></p><p>It’s tempting to jump directly into Spring Boot. It’s popular, widely used, and appears in many job descriptions.</p><p>But frameworks change. Programming fundamentals stay with you.</p><p>Before focusing on frameworks, build a strong understanding of Java.</p><p>Start with:</p><ul><li>Variables, data types, operators, and control flow</li><li>Object-oriented programming: encapsulation, inheritance, polymorphism, abstraction</li><li>Interfaces, abstract classes, and composition</li><li>Collections: List, Set, Map, and their implementations</li><li>Generics and exception handling</li><li>equals() and hashCode()</li><li>Lambda expressions and Stream API</li><li>Optional and immutability</li><li>Basic concurrency and thread safety</li></ul><p>Don’t just memorize definitions.</p><p>Understand why you’d choose a HashMap instead of a List. Understand why mutable shared state can cause problems. Know when an exception should be handled and when it should be propagated.</p><p>AI can explain all these concepts, generate examples, and help you understand unfamiliar code. Use that advantage.</p><p>But don’t skip the thinking process.</p><p>If an AI tool generates a solution, try to explain every important line yourself. Change the requirements and see whether you can adapt the code without asking AI to do everything again.</p><p><strong>Your first milestone:</strong> You should be able to read, understand, debug, and write a small Java application without following a tutorial or depending entirely on AI.</p><p><strong>2. Learn to Build Real Backend Applications</strong></p><p>Once your Java fundamentals are solid, move into backend development.</p><p>Spring Boot is a natural next step for Java developers.</p><p>Learn:</p><ul><li>Spring Core and Dependency Injection</li><li>Spring Boot configuration and application structure</li><li>REST API design</li><li>HTTP methods and status codes</li><li>DTOs and request validation</li><li>Spring Data JPA and Hibernate</li><li>SQL, joins, indexes, and transactions</li><li>Unit and integration testing</li><li>Maven or Gradle</li><li>Git and basic Linux commands</li></ul><p>But don’t learn these topics independently. Connect them through a project.</p><p>For example, build an employee management application.</p><p>It should include:</p><ul><li>User registration and authentication</li><li>Employee and department management</li><li>REST endpoints</li><li>Database relationships</li><li>Validation and exception handling</li><li>Pagination and sorting</li><li>Unit and integration tests</li><li>Docker-based local execution</li></ul><p>AI can help you create the initial project structure, generate DTOs, prepare repositories, and write repetitive code.</p><p>This can save a lot of time.</p><p>However, the important part is what you do after the code is generated.</p><p>Ask yourself:</p><ul><li>Why is this class a service rather than a controller?</li><li>Is this transaction boundary correct?</li><li>What happens if two users update the same record?</li><li>What happens if the database is unavailable?</li><li>How do I prevent unauthorized access?</li><li>How can I identify why an API request failed?</li><li>What happens when the application receives invalid data?</li></ul><p>These questions move you beyond simply implementing endpoints.</p><p>They teach you to think about software as a running system.</p><p><strong>3. Understand What Creates Value in Software Development</strong></p><p>This is probably the most important lesson in your career.</p><p>Companies don’t pay developers simply because they know Java, Spring Boot, or Kafka.</p><p>They pay for the value those skills help create.</p><p>Think about two developers.</p><p>Developer A says:</p><p>“I know Spring Boot, Hibernate, Kafka, Redis, and Docker.”</p><p>Developer B says:</p><p>“I reduced an API response time from 2 seconds to 300 milliseconds by identifying an inefficient database query and adding an appropriate index. I also added tests to prevent the issue from returning.”</p><p>Which developer has demonstrated more value?</p><p>Developer B.</p><p>Not because knowing technologies is unimportant, but because the developer can explain how technical knowledge solved a real problem.</p><p>Value can take different forms:</p><p><strong>What you do Value you create</strong></p><p>Improve database queries Faster applications</p><p>Write automated tests Fewer production defects</p><p>Improve error handling More reliable systems</p><p>Add monitoring and logging Faster incident investigation</p><p>Improve security Reduced business risk</p><p>Automate repetitive tasks Lower operational cost</p><p>Simplify complex code Easier maintenance</p><p>Improve API design Better integration between systems</p><p>Notice something?</p><p>Many valuable improvements don’t require a new framework.</p><p>Sometimes the most valuable thing you can do is remove unnecessary complexity, fix a slow query, or prevent a recurring production incident.</p><p>AI makes this distinction even more important.</p><p>If everyone can generate a basic REST API in a few minutes, simply knowing how to create one becomes less differentiating.</p><p>The value shifts toward understanding requirements, choosing the right design, verifying correctness, handling failure scenarios, and improving the system.</p><p><strong>A good developer writes code that works. A valuable developer understands why it matters and what happens when it fails.</strong></p><p><strong>4. Learn Production Engineering, Not Just Application Development</strong></p><p>A project that works on your laptop is not necessarily ready for production.</p><p>Real applications have to deal with unreliable networks, database failures, concurrent requests, unexpected traffic, security threats, and operational problems.</p><p>As you gain experience, start learning the following areas.</p><p><strong>Database and performance</strong></p><ul><li>SQL execution plans</li><li>Indexing strategies</li><li>Connection pooling</li><li>Transaction isolation</li><li>N+1 query problems</li><li>Pagination</li><li>Database bottlenecks</li></ul><p><strong>Reliability</strong></p><ul><li>Timeouts and retries</li><li>Circuit breakers</li><li>Idempotency</li><li>Graceful error handling</li><li>Message delivery guarantees</li><li>Caching strategies</li></ul><p><strong>Deployment and operations</strong></p><ul><li>Docker</li><li>CI/CD pipelines</li><li>Environment-based configuration</li><li>Application logging</li><li>Metrics and monitoring</li><li>Basic Kubernetes concepts</li></ul><p>You don’t need to master all of these in your first year.</p><p>But you should gradually understand how your code behaves outside your development environment.</p><p>For example, knowing how to write a database query is useful.</p><p>Understanding why an application becomes slow when its database connection pool is exhausted is a much more valuable skill.</p><p>AI can help investigate logs, explain stack traces, suggest performance improvements, and generate diagnostic code.</p><p>But it cannot automatically know your complete production environment, business constraints, traffic patterns, or operational history.</p><p>Treat its suggestions as hypotheses to investigate, not facts to deploy.</p><p><strong>5. Follow a Learning Path Instead of Collecting Technologies</strong></p><p>A common mistake is trying to learn everything at once.</p><p>You don’t need Kafka before understanding HTTP. You don’t need Kubernetes before knowing how to package and run an application. You don’t need microservices before understanding how to design a good modular application.</p><p>Build knowledge in layers.</p><p><strong>A practical Java career roadmap</strong></p><p><strong>Period Main focus Expected capability</strong></p><p>0–6 months Java fundamentals, OOP, SQL, Git Write and understand Java applications 6–12 months Spring Boot, REST, JPA, testing</p><p>Build complete backend applications 1–2 years Security, debugging, Docker, CI/CD, performance Develop and maintain production features 2–3 years</p><p>Messaging, caching, distributed systems Solve cross-service problems 3–5 years</p><p>JVM, system design, architecture, cloud, reliability Make and justify technical decisions</p><p>These are learning milestones, not guaranteed promotion dates. Your progress depends on the opportunities you get, the problems you solve, and how deeply you understand your work.</p><p>AI may help you move through some of these stages faster.</p><p>You can explore unfamiliar frameworks, generate sample applications, compare implementation approaches, and understand concepts without waiting for someone to explain every detail.</p><p>But don’t confuse faster exposure with deeper expertise.</p><p>Building a working Kafka example with AI assistance doesn’t mean you understand message ordering, delivery guarantees, consumer groups, retries, and failure recovery.</p><p>You still need to learn what happens when things go wrong.</p><p><strong>A useful rule</strong></p><p>Don’t learn a technology just because it’s popular.</p><p>Learn it when you understand the problem it solves.</p><p>For example:</p><ul><li>Learn Redis when you need to understand caching and shared state.</li><li>Learn Kafka when you need asynchronous communication and event-driven processing.</li><li>Learn Kubernetes when you need to understand container orchestration and application operations.</li><li>Learn microservices when you understand the limitations and trade-offs of distributed architectures.</li></ul><p>Technology should be the answer to a problem, not the starting point of every learning decision.</p><p><strong>6. Build Projects That Demonstrate Your Ability</strong></p><p>A portfolio project should demonstrate more than your ability to follow a tutorial.</p><p>Build one meaningful application and improve it gradually.</p><p>For example, create an order management system using:</p><ul><li>Java and Spring Boot</li><li>PostgreSQL</li><li>Spring Data JPA</li><li>Spring Security</li><li>REST APIs</li><li>JUnit and Mockito</li><li>Docker</li><li>GitHub Actions or another CI/CD tool</li></ul><p>Then improve it over time.</p><p><strong>First version:</strong> Implement basic order and customer operations.</p><p><strong>Second version:</strong> Add authentication, authorization, and validation.</p><p><strong>Third version:</strong> Add tests, logging, and error handling.</p><p><strong>Fourth version:</strong> Investigate slow queries and improve performance.</p><p><strong>Fifth version:</strong> Add asynchronous processing for a suitable business operation.</p><p><strong>Sixth version:</strong> Containerize the application and automate its build and deployment.</p><p>AI can help you accelerate each step. But make sure you can explain the decisions behind the implementation.</p><p>For every significant AI-generated change, ask:</p><ul><li>Does this code actually solve the requirement?</li><li>Are there simpler alternatives?</li><li>Are edge cases covered?</li><li>Are the tests meaningful?</li><li>Are there security or performance concerns?</li><li>Can I maintain this code without the AI tool?</li></ul><p>Your GitHub repository should also explain:</p><ul><li>What problem does the application solve?</li><li>How is it structured?</li><li>Why did you choose this architecture?</li><li>How can someone run it?</li><li>How are errors and security handled?</li><li>What improvements did you make and why?</li></ul><p>A well-documented project gives an interviewer something meaningful to discuss.</p><p><strong>7. AI Can Accelerate Your Career — But It Can Also Slow Your Growth</strong></p><p>This deserves special attention.</p><p>AI coding assistants have changed the way software is developed.</p><p>A junior developer can now ask for:</p><ul><li>A Spring Boot project structure</li><li>REST controllers and service classes</li><li>JPA entities and repositories</li><li>Unit and integration tests</li><li>SQL queries</li><li>Docker configuration</li><li>CI/CD pipeline examples</li><li>Explanations of unfamiliar code</li></ul><p>This can dramatically reduce the time required to build something.</p><p>It can also make learning more accessible. You can ask questions without worrying about asking a colleague repeatedly. You can compare alternatives, explore unfamiliar libraries, and get immediate feedback.</p><p>Used correctly, AI can become a powerful learning partner.</p><p>But there is a trap.</p><p><strong>If AI does the thinking for you, you may become faster at producing code while becoming weaker at engineering.</strong></p><p>Consider these common risks.</p><p><strong>1. Copying code without understanding it</strong></p><p>AI may generate a complete implementation that looks professional.</p><p>But what happens when the requirements change? What happens when an unexpected exception occurs? Can you debug the code?</p><p>If you cannot explain the implementation, you don’t fully own it.</p><p><strong>2. Accepting incorrect solutions</strong></p><p>AI can produce outdated APIs, incorrect assumptions, inefficient database queries, and code that compiles but doesn’t satisfy the business requirement.</p><p>Generated code is not automatically correct code.</p><p>Compile it, test it, inspect it, and verify it against official documentation where necessary.</p><p><strong>3. Creating hidden technical debt</strong></p><p>A generated solution may introduce unnecessary abstractions, duplicate logic, excessive dependencies, or complicated designs.</p><p>The application may work today but become difficult to maintain tomorrow.</p><p>Don’t accept complexity simply because AI generated it.</p><p><strong>4. Ignoring security and privacy</strong></p><p>Generated code may contain insecure authentication logic, unsafe SQL construction, improper input validation, or exposed secrets.</p><p>You should also understand your organization’s rules for sharing source code, credentials, customer data, and internal documents with external AI services.</p><p>Never assume that generated code is secure.</p><p><strong>5. Losing the ability to solve problems independently</strong></p><p>This is particularly important for new graduates.</p><p>If you ask AI to solve every error before trying to understand it, you lose valuable opportunities to develop debugging and analytical skills.</p><p>At some point, you may face an unfamiliar production problem where AI cannot access the relevant environment or provide a reliable answer.</p><p>You still need to investigate it.</p><p><strong>A better way to use AI</strong></p><p>Instead of asking:</p><p>“Build this entire application for me.”</p><p>Try a different approach:</p><ol><li>Describe the problem and ask AI to explain possible solutions.</li><li>Choose an approach and understand its trade-offs.</li><li>Implement a small part yourself.</li><li>Ask AI to review your implementation.</li><li>Compare suggestions with documentation and project requirements.</li><li>Write tests, including failure scenarios.</li><li>Verify the final behavior.</li></ol><p>You can also ask AI to act as a reviewer or mentor:</p><ul><li>Explain why this implementation uses a particular design pattern.</li><li>What could go wrong with this transaction?</li><li>Are there concurrency issues here?</li><li>What tests are missing?</li><li>Can you show me a simpler implementation?</li><li>What would you investigate if this API became slow?</li></ul><p>This turns AI into a learning partner instead of a replacement for your thinking.</p><p><strong>Use AI to increase the speed of your learning, not to skip the learning itself.</strong></p><p><strong>8. Develop Skills That Make You Different</strong></p><p>Technical skills are essential, but they are not the only factors that influence your career.</p><p>Some skills become increasingly valuable as you gain experience.</p><p><strong>English</strong></p><p>You don’t need perfect English to start your career.</p><p>But you should gradually become comfortable with technical documentation, issue discussions, architecture articles, and communication with international teams.</p><p>English can expand the number of companies, teams, and opportunities available to you.</p><p><strong>Problem-solving</strong></p><p>When something breaks, don’t immediately search for a solution or ask an AI tool to fix it.</p><p>First:</p><ol><li>Understand the problem.</li><li>Reproduce it if possible.</li><li>Read the logs and error messages.</li><li>Identify possible causes.</li><li>Test your assumptions.</li><li>Implement and verify the solution.</li></ol><p>The ability to investigate unfamiliar problems is one of the most important skills a developer can develop.</p><p><strong>Communication</strong></p><p>A developer should be able to explain:</p><ul><li>What problem they are solving</li><li>Why they chose a particular approach</li><li>What alternatives they considered</li><li>What risks they identified</li><li>What the expected impact will be</li></ul><p>Good technical decisions lose much of their value if you cannot explain them to your team.</p><p><strong>Continuous learning</strong></p><p>Java evolves. Frameworks change. Infrastructure becomes more sophisticated. AI tools are changing development workflows.</p><p>You don’t need to follow every trend.</p><p>But you should develop the habit of learning continuously and evaluating new technologies based on actual problems.</p><p><strong>9. How Does All This Translate Into Salary?</strong></p><p>Let’s talk about something many new graduates are thinking about but may hesitate to ask.</p><p>How do these skills increase your salary?</p><p>There is no automatic formula. Learning Spring Boot doesn’t guarantee a raise. Knowing Kubernetes doesn’t automatically make you a senior developer.</p><p>Salary is influenced by several factors:</p><ul><li>Technical depth</li><li>Ability to solve business problems</li><li>Independence and ownership</li><li>Experience with production systems</li><li>Communication and teamwork</li><li>Industry and company</li><li>Market demand and negotiation</li></ul><p>Consider the difference between these two statements:</p><p>“I developed a REST API using Spring Boot.”</p><p>And:</p><p>“I designed and implemented a REST API, improved its database access patterns, added automated tests, introduced appropriate error handling, and helped reduce recurring production issues.”</p><p>The second statement communicates ownership and impact.</p><p>As AI makes code generation more accessible, this distinction becomes even more important.</p><p>When basic implementation becomes faster, employers increasingly need developers who can understand requirements, evaluate generated solutions, make technical decisions, and take responsibility for the outcome.</p><p>As your skills grow, try to document your contributions.</p><p>Keep track of:</p><ul><li>Performance improvements</li><li>Production incidents you helped resolve</li><li>Manual processes you automated</li><li>Defects you prevented</li><li>Systems you improved</li><li>Technical decisions you contributed to</li></ul><p>These examples help during performance reviews, promotion discussions, and job interviews.</p><p><strong>Your salary should not be the only measure of your development, but your ability to create measurable value gives you stronger grounds to negotiate it.</strong></p><p><strong>10. Your First 12 Months: A Practical Action Plan</strong></p><p>If you’re starting today, here is a realistic plan.</p><p><strong>Months What to do</strong></p><p>1–2 Strengthen Java, OOP, Collections, and exception handling</p><p>3–4 Learn SQL, Git, Maven, and build a small Java application</p><p>5–6 Learn Spring Boot, REST APIs, and JPA</p><p>7–8 Add validation, security, and automated tests</p><p>9–10 Learn Docker, logging, and basic CI/CD</p><p>11–12 Improve your project, investigate performance, and document technical decisions</p><p>Use AI throughout this journey, but make it part of your learning process.</p><p>For example, ask it to explain a concept, challenge your implementation, generate test scenarios, or review your code.</p><p>Don’t let it complete every exercise before you’ve had a chance to think.</p><p>At the end of the year, you should have more than a list of technologies.</p><p>You should have a working project, an understanding of the decisions behind it, and examples of problems you can solve independently.</p><p>If you already have a job, apply these steps to real tasks at work. If you’re still looking for your first job, use your portfolio to demonstrate the same capabilities.</p><p><strong>11. Think Beyond Your First Job</strong></p><p>Your first job is important, but it doesn’t define your entire career.</p><p>When evaluating an opportunity, don’t look only at the salary.</p><p>Ask yourself:</p><ul><li>Will I work with experienced developers?</li><li>Will I participate in code reviews?</li><li>Will I understand how applications are deployed?</li><li>Will I have opportunities to investigate real problems?</li><li>Will I learn about databases, performance, and security?</li><li>Will I be able to take ownership of features?</li></ul><p>A position that gives you meaningful learning opportunities can be a valuable starting point.</p><p>However, learning opportunities should not become an excuse for accepting poor working conditions or indefinitely undervaluing your contribution.</p><p>Your career is a long-term investment. Evaluate both what you earn today and what you can learn and contribute tomorrow.</p><p><strong>Final Thoughts: Become a Developer Who Creates Value</strong></p><p>If you’re a new graduate, you don’t need to know everything.</p><p>You need a direction, consistency, and the willingness to understand problems deeply.</p><p>Start with Java fundamentals. Learn Spring Boot. Understand databases. Build real applications. Learn testing, debugging, security, and deployment. Gradually move toward distributed systems and architecture.</p><p>Use AI to learn faster, explore more ideas, and improve your productivity. But never give up your responsibility to understand, verify, and maintain the code you deliver.</p><p>The technology landscape will continue to change. Some tasks that require hours today may take minutes tomorrow.</p><p>But the ability to understand a business problem, evaluate alternatives, make sound technical decisions, and take responsibility for the outcome will remain valuable.</p><p>The purpose of learning all these technologies isn’t to make your CV longer.</p><p>It’s to become someone who can:</p><ul><li>Understand a business problem.</li><li>Choose an appropriate technical solution.</li><li>Build it reliably.</li><li>Recognize its limitations.</li><li>Improve it when things go wrong.</li><li>Evaluate AI-generated code instead of blindly accepting it.</li><li>Explain the value it creates.</li></ul><p>That’s how you move from writing code to engineering software.</p><p>And that’s how you build a career in which your skills, responsibilities, and compensation can grow together.</p><p><strong>Don’t aim to be the developer who generates the most code. Aim to be the developer who creates the most value.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b21287f1eb44" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Junior’dan Senior Java Developer’a]]></title>
            <link>https://medium.com/@mkonca/juniordan-senior-java-developer-a-bafc554e0be2?source=rss-e6afd92b93db------2</link>
            <guid isPermaLink="false">https://medium.com/p/bafc554e0be2</guid>
            <category><![CDATA[yazilim-gelistirme]]></category>
            <category><![CDATA[yazılım-mühendisliği]]></category>
            <category><![CDATA[programlama]]></category>
            <category><![CDATA[kariyer]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[mkonca]]></dc:creator>
            <pubDate>Thu, 03 Dec 2026 11:30:56 GMT</pubDate>
            <atom:updated>2026-12-03T11:30:56.937Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Değer Üreten Bir Yazılımcı Olmanın Yol Haritası</strong></p><p><strong>Mezun Oldun. Şimdi Ne Yapmalısın?</strong></p><p>Üniversiteden mezun oldun. Programlamanın temellerini biliyorsun. Belki Java öğrendin, birkaç proje geliştirdin ve Spring Boot dünyasına adım attın.</p><p>Sonra iş ilanlarına bakıyorsun.</p><p>Java, Spring Boot, Microservices, Kafka, Docker, Kubernetes, Redis, AWS, SQL, NoSQL…</p><p>Daha ilk işine başlamadan bütün teknolojileri bilmen gerekiyormuş gibi hissediyorsun.</p><p>Üstelik artık başka bir gerçek daha var: Yapay zekâ.</p><p>Bir AI aracından Spring Boot uygulaması oluşturmasını, REST servisleri yazmasını, veritabanı modelleri hazırlamasını, test üretmesini veya bilmediğin bir Java konusunu açıklamasını isteyebiliyorsun.</p><p>Eskiden günler sürebilecek bazı işler artık dakikalar içinde tamamlanabiliyor.</p><p>Bu, özellikle kariyerine yeni başlayan bir yazılımcı için büyük bir fırsat.</p><p>Ancak beraberinde yeni bir sorun da getiriyor:</p><p><strong>Kod üretme hızın, o kodu anlayabilecek ve sürdürebilecek mühendislik becerilerini geliştirme hızından çok daha yüksek olabilir.</strong></p><p>Peki nasıl ilerlemelisin?</p><p>Hedefin her teknolojiyi öğrenmek veya mümkün olduğunca fazla kod üretmek olmamalı.</p><p>Hedefin, giderek daha karmaşık problemleri çözebilen, geliştirdiği çözümü anlayan ve gerçek değer üreten bir yazılımcı olmak olmalı.</p><p>Gelin, bu yolculuğu birlikte inceleyelim.</p><p><strong>1. Önce Java, Sonra Framework’ler</strong></p><p>Doğrudan Spring Boot öğrenmeye başlamak cazip gelebilir. Popülerdir, iş ilanlarında sıkça karşına çıkar ve Java ekosisteminin önemli bir parçasıdır.</p><p>Ancak framework’ler değişir. Programlama temelleri ise seninle kalır.</p><p>Framework’lere yoğunlaşmadan önce Java konusunda sağlam bir temel oluşturmalısın.</p><p>Öncelikle şu konuları öğren:</p><ul><li>Değişkenler, veri tipleri, operatörler ve kontrol yapıları</li><li>Nesne yönelimli programlama: Encapsulation, Inheritance, Polymorphism, Abstraction</li><li>Interface, abstract class ve composition</li><li>Collections: List, Set, Map ve bunların implementasyonları</li><li>Generics ve Exception Handling</li><li>equals() ve hashCode()</li><li>Lambda ifadeleri ve Stream API</li><li>Optional ve immutability</li><li>Temel concurrency ve thread safety</li></ul><p>Bu kavramları sadece tanımlarıyla ezberleme.</p><p>Neden List yerine HashMap kullanman gerektiğini anlamaya çalış. Paylaşılan mutable bir nesnenin neden sorun oluşturabileceğini öğren. Bir exception’ın ne zaman yakalanması, ne zaman üst katmana iletilmesi gerektiğini kavra.</p><p>Bunlar uygulamaların büyüdükçe daha önemli hale gelecek kararlarıdır.</p><p>Yapay zekâdan bu konuları açıklamasını, örnekler üretmesini ve bilmediğin kodları anlatmasını isteyebilirsin. Bu avantajı kullan.</p><p>Ancak düşünme sürecini tamamen devretme.</p><p>AI tarafından üretilen bir çözümde önemli satırların ne yaptığını kendin açıklamaya çalış. Gereksinimleri değiştir ve AI’dan yardım almadan kodu uyarlayıp uyarlayamadığını gör.</p><p><strong>İlk hedefin:</strong> Bir eğitim videosunu adım adım takip etmeden ve tamamen yapay zekâya bağımlı olmadan küçük bir Java uygulamasını yazabilmek, okuyabilmek ve hata ayıklayabilmek olmalı.</p><p><strong>2. Gerçek Backend Uygulamaları Geliştirmeyi Öğren</strong></p><p>Java temellerini oturttuktan sonra backend geliştirme tarafına geçebilirsin.</p><p>Java geliştiricileri için Spring Boot doğal bir sonraki adımdır.</p><p>Öğrenmen gereken konular:</p><ul><li>Spring Core ve Dependency Injection</li><li>Spring Boot yapılandırması ve uygulama mimarisi</li><li>REST API tasarımı</li><li>HTTP metotları ve durum kodları</li><li>DTO ve request validation</li><li>Spring Data JPA ve Hibernate</li><li>SQL, JOIN, index ve transaction</li><li>Unit ve integration test</li><li>Maven veya Gradle</li><li>Git ve temel Linux komutları</li></ul><p>Ancak bu konuları birbirinden bağımsız öğrenme. Hepsini bir projede birleştir.</p><p>Örneğin bir personel yönetim uygulaması geliştir.</p><p>Uygulamada şunlar bulunsun:</p><ul><li>Kullanıcı kaydı ve kimlik doğrulama</li><li>Personel ve departman yönetimi</li><li>REST servisleri</li><li>Veritabanı ilişkileri</li><li>Validation ve exception handling</li><li>Sayfalama ve sıralama</li><li>Unit ve integration testler</li><li>Docker ile yerel ortamda çalıştırma</li></ul><p>Yapay zekâdan başlangıç proje yapısını oluşturmasını, DTO sınıflarını hazırlamasını, repository katmanını yazmasını ve tekrarlayan kodları üretmesini isteyebilirsin.</p><p>Bu sana ciddi zaman kazandırabilir.</p><p>Ancak asıl önemli olan, kod üretildikten sonra ne yaptığındır.</p><p>Kendine şu soruları sor:</p><ul><li>Bu sınıf neden controller değil de service katmanında?</li><li>Transaction sınırı doğru belirlenmiş mi?</li><li>İki kullanıcı aynı kaydı güncellerse ne olur?</li><li>Veritabanına erişilemezse uygulama nasıl davranır?</li><li>Yetkisiz erişimi nasıl engellerim?</li><li>Bir API isteğinin neden başarısız olduğunu nasıl tespit ederim?</li><li>Uygulamaya geçersiz veri gönderilirse ne olur?</li></ul><p>Bu sorular seni yalnızca endpoint geliştiren bir yazılımcı olmaktan çıkarır.</p><p>Yazılımı çalışan bir sistem olarak düşünmeni sağlar.</p><p><strong>3. Kod Yazmak Yetmez, Değer Üret</strong></p><p>Bence kariyerin boyunca aklında tutman gereken en önemli konu bu.</p><p>Şirketler geliştiricilere yalnızca Java, Spring Boot veya Kafka bildikleri için ödeme yapmaz.</p><p>Bu teknolojileri kullanarak oluşturdukları değer için ödeme yaparlar.</p><p>İki yazılımcıyı düşünelim.</p><p><strong>Geliştirici A:</strong></p><p>“Spring Boot, Hibernate, Kafka, Redis ve Docker biliyorum.”</p><p><strong>Geliştirici B:</strong></p><p>“Verimsiz bir veritabanı sorgusunu tespit edip uygun bir index ekleyerek API yanıt süresini 2 saniyeden 300 milisaniyeye düşürdüm. Ayrıca problemin tekrar oluşmasını önlemek için testler ekledim.”</p><p>Sence hangisi daha fazla değer ürettiğini gösterebiliyor?</p><p>Geliştirici B.</p><p>Bunun nedeni teknoloji bilmenin önemsiz olması değil. Teknik bilgisini gerçek bir problemi çözmek için kullanabildiğini gösterebilmesi.</p><p>Yazılım geliştirmede değer farklı şekillerde ortaya çıkabilir:</p><p><strong>Yaptığın çalışma Oluşturduğun değer</strong></p><p>Veritabanı sorgularını iyileştirmek Daha hızlı uygulamalar</p><p>Otomatik testler yazmak Daha az üretim hatası</p><p>Hata yönetimini geliştirmek Daha güvenilir sistemler</p><p>Monitoring ve logging eklemek Daha hızlı problem analizi</p><p>Güvenliği iyileştirmek Daha düşük iş riski</p><p>Tekrarlayan işleri otomatikleştirmek Daha düşük operasyon maliyeti</p><p>Karmaşık kodları sadeleştirmek Daha kolay bakım</p><p>API tasarımını iyileştirmek Daha sağlıklı sistem entegrasyonu</p><p>Dikkat edersen birçok değerli iyileştirme için yeni bir framework öğrenmen gerekmiyor.</p><p>Bazen yapabileceğin en değerli çalışma gereksiz karmaşıklığı kaldırmak, yavaş bir sorguyu düzeltmek veya sürekli tekrarlanan bir üretim problemini ortadan kaldırmaktır.</p><p>Yapay zekâ bu ayrımı daha da önemli hale getiriyor.</p><p>Herkes birkaç dakika içinde temel bir REST API üretebiliyorsa, yalnızca REST API yazabiliyor olmak seni diğer geliştiricilerden ayırmakta yetersiz kalabilir.</p><p>Değer artık gereksinimi anlamaya, doğru tasarımı seçmeye, çözümün doğruluğunu kontrol etmeye, hata senaryolarını yönetmeye ve sistemin tamamını iyileştirmeye kayıyor.</p><p><strong>İyi bir yazılımcı çalışan kod yazar. Değer üreten bir yazılımcı ise o kodun neden önemli olduğunu ve başarısız olduğunda neler yaşanacağını bilir.</strong></p><p><strong>4. Gerçek Dünya Koddan Fazlasını İster</strong></p><p>Bilgisayarında çalışan bir proje, üretim ortamına hazır bir uygulama anlamına gelmez.</p><p>Gerçek uygulamalar güvenilir olmayan ağlarla, veritabanı kesintileriyle, eş zamanlı isteklerle, beklenmedik trafikle, güvenlik tehditleriyle ve operasyonel problemlerle karşılaşır.</p><p>Deneyim kazandıkça şu alanları öğrenmeye başla.</p><p><strong>Veritabanı ve performans</strong></p><ul><li>SQL execution plan</li><li>Index stratejileri</li><li>Connection pooling</li><li>Transaction isolation</li><li>N+1 query problemleri</li><li>Pagination</li><li>Veritabanı darboğazları</li></ul><p><strong>Güvenilirlik</strong></p><ul><li>Timeout ve retry</li><li>Circuit breaker</li><li>Idempotency</li><li>Hata yönetimi</li><li>Mesaj teslim garantileri</li><li>Caching stratejileri</li></ul><p><strong>Deployment ve operasyon</strong></p><ul><li>Docker</li><li>CI/CD pipeline</li><li>Ortama göre yapılandırma</li><li>Uygulama logları</li><li>Metrics ve monitoring</li><li>Temel Kubernetes kavramları</li></ul><p>Bunların hepsinde ilk yıl uzmanlaşman gerekmiyor.</p><p>Ancak geliştirdiğin kodun geliştirme ortamı dışındaki davranışını zamanla anlamalısın.</p><p>Örneğin SQL sorgusu yazabilmek faydalıdır.</p><p>Veritabanı connection pool tükendiğinde uygulamanın neden yavaşladığını anlayabilmek ise çok daha değerli bir beceridir.</p><p>Yapay zekâ logları incelemene, stack trace’leri anlamana, performans iyileştirmeleri önermesine ve teşhis kodları üretmene yardımcı olabilir.</p><p>Ancak senin üretim ortamının tamamını, iş kurallarını, trafik yapısını ve geçmiş operasyonel problemlerini kendiliğinden bilemez.</p><p>AI önerilerini doğrudan uygulanacak gerçekler olarak değil, araştırılması gereken varsayımlar olarak değerlendir.</p><p><strong>5. Her Teknolojiyi Öğrenmeye Çalışma</strong></p><p>Yaygın hatalardan biri her şeyi aynı anda öğrenmeye çalışmaktır.</p><p>HTTP’yi anlamadan Kafka öğrenmen gerekmiyor. Bir uygulamayı paketleyip çalıştırmayı bilmeden Kubernetes öğrenmen gerekmiyor. İyi bir modüler uygulama tasarlamayı anlamadan microservices öğrenmen gerekmiyor.</p><p>Bilgini katman katman oluştur.</p><p><strong>Java kariyer gelişim yol haritası</strong></p><p><strong>Dönem Odak noktası Beklenen yetkinlik</strong></p><p>0–6 ay Java temelleri, OOP, SQL, Git Java uygulamaları geliştirmek ve anlamak</p><p>6–12 ay Spring Boot, REST, JPA, test Baştan sona backend uygulaması geliştirmek</p><p>1–2 yıl Security, debugging, Docker, CI/CD, performans Üretim özelliklerini geliştirmek ve sürdürebilmek</p><p>2–3 yıl Messaging, caching, distributed systems Servisler arası problemleri çözebilmek</p><p>3–5 yıl JVM, system design, mimari, cloud, reliability Teknik kararlar alabilmek ve gerekçelendirmek</p><p>Bunlar öğrenme hedefleridir. İlerlemen elde ettiğin fırsatlara, çözdüğün problemlere ve konuları ne kadar derinlemesine anladığına bağlıdır.</p><p>Yapay zekâ bu aşamaların bazılarında daha hızlı ilerlemene yardımcı olabilir.</p><p>Bilmediğin framework’leri keşfedebilir, örnek uygulamalar üretebilir, farklı yaklaşımları karşılaştırabilir ve bir konuyu öğrenmek için sürekli birilerinin açıklama yapmasını beklemek zorunda kalmayabilirsin.</p><p>Ancak hızlıca bir konuya maruz kalmak ile o konuda uzmanlaşmayı birbirine karıştırma.</p><p>AI yardımıyla çalışan bir Kafka örneği geliştirmek; message ordering, delivery guarantees, consumer groups, retry ve failure recovery konularını anladığın anlamına gelmez.</p><p>Gerçek sistemlerde nelerin ters gidebileceğini de öğrenmelisin.</p><p><strong>Basit bir kural</strong></p><p>Bir teknolojiyi sadece popüler olduğu için öğrenme.</p><p>Çözdüğü problemi anladığında öğren.</p><p>Örneğin:</p><ul><li>Redis’i caching ve paylaşılan durum yönetimini anlaman gerektiğinde öğren.</li><li>Kafka’yı asenkron iletişim ve event-driven mimari ihtiyacını anladığında öğren.</li><li>Kubernetes’i container orchestration ve uygulama operasyonlarını anlamak istediğinde öğren.</li><li>Microservices’i dağıtık mimarinin sınırlarını ve getirdiği maliyetleri kavradığında öğren.</li></ul><p>Teknoloji her zaman bir problemin çözümü olmalı; her öğrenme sürecinin başlangıç noktası değil.</p><p><strong>6. Seni Öne Çıkaracak Projeler Geliştir</strong></p><p>Bir portföy projesi, eğitim videosunu takip edebildiğini göstermekten daha fazlasını sunmalı.</p><p>Anlamlı bir uygulama geliştir ve zaman içinde iyileştir.</p><p>Örneğin şu teknolojileri kullanan bir sipariş yönetim sistemi oluştur:</p><ul><li>Java ve Spring Boot</li><li>PostgreSQL</li><li>Spring Data JPA</li><li>Spring Security</li><li>REST API</li><li>JUnit ve Mockito</li><li>Docker</li><li>GitHub Actions veya başka bir CI/CD aracı</li></ul><p>Sonra projeyi aşama aşama geliştir.</p><p><strong>İlk sürüm:</strong> Temel sipariş ve müşteri işlemlerini gerçekleştir.</p><p><strong>İkinci sürüm:</strong> Kimlik doğrulama, yetkilendirme ve validation ekle.</p><p><strong>Üçüncü sürüm:</strong> Test, logging ve hata yönetimini geliştir.</p><p><strong>Dördüncü sürüm:</strong> Yavaş sorguları incele ve performansı iyileştir.</p><p><strong>Beşinci sürüm:</strong> Uygun bir iş süreci için asenkron işlem ekle.</p><p><strong>Altıncı sürüm:</strong> Uygulamayı container haline getir ve build/deployment sürecini otomatikleştir.</p><p>Yapay zekâ bu aşamaların her birini hızlandırabilir. Ancak geliştirdiğin çözümün arkasındaki kararları açıklayabildiğinden emin ol.</p><p>AI tarafından üretilen her önemli değişiklik için kendine şu soruları sor:</p><ul><li>Bu kod gerçekten gereksinimi karşılıyor mu?</li><li>Daha basit bir alternatif var mı?</li><li>Sınır durumları ele alınmış mı?</li><li>Testler anlamlı mı?</li><li>Güvenlik veya performans riski var mı?</li><li>AI aracı olmadan bu kodun bakımını yapabilir miyim?</li></ul><p>GitHub projen ayrıca şu sorulara cevap vermeli:</p><ul><li>Uygulama hangi problemi çözüyor?</li><li>Nasıl yapılandırılmış?</li><li>Bu mimariyi neden seçtin?</li><li>Nasıl çalıştırılır?</li><li>Hatalar ve güvenlik nasıl yönetiliyor?</li><li>Hangi iyileştirmeleri yaptın ve neden?</li></ul><p>İyi dokümante edilmiş bir proje, iş görüşmesinde üzerinde konuşulabilecek gerçek bir çalışma sunar.</p><p><strong>7. AI ile Hızlan, Ama Düşünmeyi Bırakma</strong></p><p>Bu konuya özellikle dikkat etmek gerekiyor.</p><p>AI coding assistant araçları yazılım geliştirme biçimini değiştirdi.</p><p>Artık yeni mezun bir yazılımcı şunları isteyebilir:</p><ul><li>Spring Boot proje yapısı</li><li>REST controller ve service sınıfları</li><li>JPA entity ve repository sınıfları</li><li>Unit ve integration testler</li><li>SQL sorguları</li><li>Docker yapılandırması</li><li>CI/CD pipeline örnekleri</li><li>Bilinmeyen kodların açıklanması</li></ul><p>Bu imkânlar geliştirme süresini ciddi ölçüde azaltabilir.</p><p>Öğrenmeyi de daha erişilebilir hale getirir. Bir ekip arkadaşına sürekli soru sormak zorunda kalmadan konuları araştırabilir, alternatifleri karşılaştırabilir ve hızlı geri bildirim alabilirsin.</p><p>Doğru kullanıldığında yapay zekâ güçlü bir öğrenme arkadaşı olabilir.</p><p>Ancak burada bir tuzak var.</p><p><strong>Düşünme işini yapay zekâya bırakırsan kod üretme hızın artarken mühendislik becerilerin zayıflayabilir.</strong></p><p>Bunun birkaç önemli riski bulunuyor.</p><p><strong>1. Anlamadan kod kopyalamak</strong></p><p>AI sana profesyonel görünen, eksiksiz bir implementasyon üretebilir.</p><p>Ancak gereksinimler değiştiğinde ne olacak? Beklenmeyen bir exception oluştuğunda ne yapacaksın? Kodun hatasını kendin bulabilecek misin?</p><p>Geliştirdiğin çözümü açıklayamıyorsan o kodun sorumluluğunu tam olarak üstlenmiş sayılmazsın.</p><p><strong>2. Yanlış çözümleri kabul etmek</strong></p><p>AI eski API’ler, hatalı varsayımlar, verimsiz SQL sorguları veya derlendiği halde iş gereksinimini karşılamayan kodlar üretebilir.</p><p>Üretilen kod otomatik olarak doğru kod değildir.</p><p>Derle, test et, incele ve gerektiğinde resmi dokümantasyonla doğrula.</p><p><strong>3. Gizli teknik borç oluşturmak</strong></p><p>AI gereksiz soyutlamalar, tekrarlanan kodlar, fazla bağımlılıklar veya karmaşık tasarımlar önerebilir.</p><p>Uygulama bugün çalışabilir ancak yarın bakımı zor hale gelebilir.</p><p>Sırf yapay zekâ üretti diye karmaşıklığı kabul etme.</p><p><strong>4. Güvenlik ve gizliliği göz ardı etmek</strong></p><p>Üretilen kodda güvensiz kimlik doğrulama, hatalı SQL oluşturma, yetersiz veri doğrulama veya açıkta kalan gizli bilgiler bulunabilir.</p><p>Ayrıca kaynak kodunu, şifreleri, müşteri verilerini ve kurum içi dokümanları harici AI servisleriyle paylaşırken kurumunun kurallarını bilmelisin.</p><p>Üretilen kodun güvenli olduğunu varsayma.</p><p><strong>5. Bağımsız problem çözme yeteneğini kaybetmek</strong></p><p>Bu konu özellikle yeni mezunlar için önemli.</p><p>Her hata aldığında önce kendin anlamaya çalışmadan AI’dan çözmesini istersen debugging ve analitik düşünme becerilerini geliştirebileceğin fırsatları kaçırırsın.</p><p>Bir gün AI aracının ilgili ortama erişemediği veya güvenilir bir cevap veremediği gerçek bir üretim problemiyle karşılaşabilirsin.</p><p>O problemi yine senin araştırman gerekecek.</p><p><strong>Yapay zekâyı daha doğru nasıl kullanmalısın?</strong></p><p>Şöyle sormak yerine:</p><p>“Bu uygulamanın tamamını benim için geliştir.”</p><p>Farklı bir yaklaşım dene:</p><ol><li>Problemi açıkla ve olası çözümleri anlatmasını iste.</li><li>Bir yaklaşım seç ve teknik avantajlarını, dezavantajlarını anla.</li><li>Küçük bir bölümü kendin geliştir.</li><li>Implementasyonunu AI’a incelet.</li><li>Önerileri dokümantasyon ve proje gereksinimleriyle karşılaştır.</li><li>Hata senaryolarını da kapsayan testler yaz.</li><li>Son davranışı doğrula.</li></ol><p>AI’dan bir mentor veya kod inceleyici gibi de yararlanabilirsin:</p><ul><li>Bu implementasyon neden bu tasarım yaklaşımını kullanıyor?</li><li>Bu transaction ile ilgili neler ters gidebilir?</li><li>Burada concurrency problemi var mı?</li><li>Hangi testler eksik?</li><li>Daha basit bir implementasyon mümkün mü?</li><li>Bu API yavaşlarsa ilk olarak neleri incelerdin?</li></ul><p>Böylece yapay zekâyı düşünmenin yerine koymak yerine öğrenme sürecinin bir parçası haline getirirsin.</p><p><strong>Yapay zekâyı öğrenmeyi atlamak için değil, öğrenme hızını artırmak için kullan.</strong></p><p><strong>8. Seni Diğer Yazılımcılardan Ayıracak Yetkinlikleri Geliştir</strong></p><p>Teknik beceriler önemli ancak kariyerini etkileyen tek faktör bunlar değil.</p><p>Deneyim kazandıkça bazı yetkinlikler çok daha değerli hale gelir.</p><p><strong>İngilizce</strong></p><p>Kariyerine başlamak için kusursuz İngilizce bilmen gerekmiyor.</p><p>Ancak teknik dokümantasyonları, issue tartışmalarını, mimari yazıları okuyabilecek ve uluslararası ekiplerle iletişim kurabilecek seviyeye gelmeye çalışmalısın.</p><p>İngilizce bilmek, başvurabileceğin şirket ve fırsatların sayısını artırabilir.</p><p><strong>Problem çözme</strong></p><p>Bir şey bozulduğunda hemen çözüm arama veya AI aracından düzeltmesini isteme.</p><p>Önce:</p><ol><li>Problemi anla.</li><li>Mümkünse tekrar oluştur.</li><li>Logları ve hata mesajlarını incele.</li><li>Olası nedenleri belirle.</li><li>Varsayımlarını test et.</li><li>Çözümü uygula ve doğrula.</li></ol><p>Karşılaştığın yeni problemleri araştırabilme yeteneği, bir yazılımcının geliştirebileceği en önemli becerilerden biridir.</p><p><strong>İletişim</strong></p><p>Bir yazılımcı şu konuları açıklayabilmelidir:</p><ul><li>Hangi problemi çözüyor?</li><li>Neden belirli bir yaklaşımı seçti?</li><li>Hangi alternatifleri değerlendirdi?</li><li>Hangi riskleri belirledi?</li><li>Beklenen sonuç ne?</li></ul><p>Teknik kararlarını ekibine açıklayamıyorsan doğru kararların bile değeri azalabilir.</p><p><strong>Sürekli öğrenme</strong></p><p>Java gelişiyor. Framework’ler değişiyor. Altyapılar daha karmaşık hale geliyor. Yapay zekâ araçları yazılım geliştirme süreçlerini dönüştürüyor.</p><p>Her yeni trendin peşinden koşman gerekmiyor.</p><p>Ancak sürekli öğrenme ve yeni teknolojileri gerçek ihtiyaçlara göre değerlendirme alışkanlığı kazanmalısın.</p><p><strong>9. Bütün Bunlar Maaşına Nasıl Yansır?</strong></p><p>Yeni mezunların merak ettiği ama bazen sormaya çekindiği bir konuya gelelim.</p><p>Bu yetkinlikler maaşını nasıl artırır?</p><p>Bunun otomatik bir formülü yok. Spring Boot öğrenmek zam garantisi vermez. Kubernetes bilmek de seni otomatik olarak senior yapmaz.</p><p>Maaşı etkileyen birçok faktör bulunur:</p><ul><li>Teknik bilgi derinliği</li><li>İş problemlerini çözebilme yeteneği</li><li>Bağımsız çalışabilme ve sorumluluk alma</li><li>Üretim ortamı deneyimi</li><li>İletişim ve takım çalışması</li><li>Sektör ve şirket</li><li>Piyasa talebi ve ücret pazarlığı</li></ul><p>Şu iki ifadeyi karşılaştıralım:</p><p>“Spring Boot kullanarak bir REST API geliştirdim.”</p><p>Ve:</p><p>“Bir REST API tasarlayıp geliştirdim, veritabanı erişimlerini iyileştirdim, otomatik testler ekledim, hata yönetimini geliştirdim ve tekrarlanan üretim problemlerinin azaltılmasına katkıda bulundum.”</p><p>İkinci ifade sorumluluk ve etkiyi daha iyi anlatır.</p><p>AI kod üretimini kolaylaştırdıkça bu fark daha da önemli hale geliyor.</p><p>Temel implementasyon işleri hızlandığında işverenler; gereksinimleri anlayabilen, üretilen çözümleri değerlendirebilen, teknik kararlar verebilen ve ortaya çıkan sonucun sorumluluğunu üstlenebilen geliştiricilere daha fazla ihtiyaç duyabilir.</p><p>Geliştirdiğin yetkinliklerle birlikte katkılarını da kayıt altına almaya çalış.</p><p>Şunları takip et:</p><ul><li>Performans iyileştirmeleri</li><li>Çözümüne katkıda bulunduğun üretim problemleri</li><li>Otomatikleştirdiğin manuel süreçler</li><li>Önlediğin hatalar</li><li>İyileştirdiğin sistemler</li><li>Katkıda bulunduğun teknik kararlar</li></ul><p>Bu örnekler performans değerlendirmelerinde, terfi görüşmelerinde ve iş mülakatlarında sana yardımcı olur.</p><p><strong>Maaşın gelişiminin tek ölçütü olmamalı. Ancak ölçülebilir değer üretebilmen, ücret pazarlığında elini güçlendirir.</strong></p><p><strong>10. İlk 12 Ay: Adım Adım Gelişim Planı</strong></p><p>Bugün başlıyorsan aşağıdaki planı uygulayabilirsin.</p><p><strong>Aylar Yapılacaklar</strong></p><p>1–2 Java, OOP, Collections ve exception handling konularını sağlamlaştır</p><p>3–4 SQL, Git, Maven öğren ve küçük bir Java uygulaması geliştir</p><p>5–6 Spring Boot, REST API ve JPA öğren</p><p>7–8 Validation, security ve otomatik testler ekle</p><p>9–10 Docker, logging ve temel CI/CD öğren</p><p>11–12 Projeni iyileştir, performansı incele ve teknik kararlarını dokümante et</p><p>Bu yolculuk boyunca AI kullanabilirsin ancak onu öğrenme sürecinin bir parçası haline getir.</p><p>Örneğin bir kavramı açıklamasını iste, implementasyonunu sorgulat, test senaryoları ürettir veya kodunu incelet.</p><p>Ancak sen düşünme fırsatı bulamadan her egzersizi tamamlamasına izin verme.</p><p>Bir yılın sonunda elinde yalnızca bir teknoloji listesi olmamalı.</p><p>Çalışan bir projen, arkasındaki teknik kararları anlayabilecek bilgin ve bağımsız olarak çözebildiğin problemlere dair örneklerin olmalı.</p><p>Eğer çalışıyorsan bu adımları gerçek işlerinde uygula. Henüz ilk işini arıyorsan portföyünle aynı yetkinlikleri göstermeye çalış.</p><p><strong>11. İlk İşinden Sonrasını Planla</strong></p><p>İlk işin önemlidir ancak bütün kariyerini belirlemez.</p><p>Bir iş fırsatını değerlendirirken sadece maaşına bakma.</p><p>Kendine şu soruları sor:</p><ul><li>Deneyimli yazılımcılarla çalışacak mıyım?</li><li>Code review süreçlerine katılabilecek miyim?</li><li>Uygulamaların nasıl deploy edildiğini görebilecek miyim?</li><li>Gerçek problemleri araştırma fırsatım olacak mı?</li><li>Veritabanı, performans ve güvenlik konularında deneyim kazanabilecek miyim?</li><li>Geliştirdiğim özelliklerin sorumluluğunu üstlenebilecek miyim?</li></ul><p>Öğrenme fırsatları sunan bir pozisyon kariyerin için değerli bir başlangıç olabilir.</p><p>Ancak öğrenme fırsatları, kötü çalışma koşullarını kabul etmek veya emeğinin karşılığını sürekli ertelemek için bir gerekçe olmamalı.</p><p>Kariyerin uzun vadeli bir yatırımdır. Hem bugün kazandıklarını hem de yarın öğrenebileceklerini ve üretebileceklerini birlikte değerlendir.</p><p><strong>Sonuç: Sonuç: Kod Değil, Değer Üret</strong></p><p>Yeni mezunsan her şeyi bilmek zorunda değilsin.</p><p>Bir yönün, istikrarlı bir çalışma alışkanlığın ve problemleri derinlemesine anlama isteğin olmalı.</p><p>Java temelleriyle başla. Spring Boot öğren. Veritabanlarını anla. Gerçek uygulamalar geliştir. Test, debugging, güvenlik ve deployment konularında kendini geliştir. Zamanla distributed systems ve mimari konularına ilerle.</p><p>Yapay zekâyı daha hızlı öğrenmek, farklı fikirleri keşfetmek ve verimliliğini artırmak için kullan. Ancak geliştirdiğin kodu anlama, doğrulama ve sürdürme sorumluluğundan vazgeçme.</p><p>Teknoloji dünyası değişmeye devam edecek. Bugün saatler süren bazı işler yarın dakikalar içinde tamamlanabilecek.</p><p>Ancak bir iş problemini anlamak, alternatifleri değerlendirmek, doğru teknik kararları vermek ve ortaya çıkan sonucun sorumluluğunu üstlenmek her zaman değerli bir mühendislik becerisi olarak kalacak.</p><p>Bütün bu teknolojileri öğrenmenin amacı CV’ni uzatmak değil.</p><p>Şunları yapabilen bir yazılımcıya dönüşmek:</p><ul><li>İş problemini anlayabilmek.</li><li>Uygun teknik çözümü seçebilmek.</li><li>Güvenilir şekilde geliştirebilmek.</li><li>Çözümün sınırlarını görebilmek.</li><li>Bir şeyler ters gittiğinde iyileştirebilmek.</li><li>Yapay zekâ tarafından üretilen kodu sorgulamadan kabul etmek yerine değerlendirebilmek.</li><li>Oluşturduğu değeri açıklayabilmek.</li></ul><p>Kod yazmaktan yazılım mühendisliğine geçiş böyle başlar.</p><p>Yetkinliklerinin, sorumluluklarının ve kazancının birlikte geliştiği bir kariyer de böyle inşa edilir.</p><p><strong>En fazla kod üreten yazılımcı olmayı hedefleme. En anlamlı değeri üreten yazılımcı olmayı hedefle.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bafc554e0be2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Harness Engineering: The Missing Piece of AI Coding Agents]]></title>
            <link>https://medium.com/@mkonca/harness-engineering-the-missing-piece-of-ai-coding-agents-23af4a979bfa?source=rss-e6afd92b93db------2</link>
            <guid isPermaLink="false">https://medium.com/p/23af4a979bfa</guid>
            <category><![CDATA[ai-coding-agent]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[agent-harness-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[harness-engineering]]></category>
            <dc:creator><![CDATA[mkonca]]></dc:creator>
            <pubDate>Mon, 30 Nov 2026 08:43:25 GMT</pubDate>
            <atom:updated>2026-11-30T08:43:25.900Z</atom:updated>
            <content:encoded><![CDATA[<p><em>AI can write code. But can we trust it? The real challenge may not be choosing the right model, but building the right environment around it.</em></p><p><em>AI can write code. But can we trust it? The real challenge may not be choosing the right model, but building the right environment around it.</em></p><p>Imagine a new software developer joining your company.</p><p>Would it be enough to give them a laptop and say, “Here is the project. Make the necessary changes and let me know when you are done”?</p><p>Probably not.</p><p>They need to understand the architecture, coding standards, available systems, security rules, and how their changes should be tested. Without that context, even a skilled developer can make the wrong decisions.</p><p>The same applies to AI coding agents.</p><p>Today’s AI models can write code, modify files, execute terminal commands, and run tests. But being able to perform these actions does not mean they will always produce correct or safe results.</p><p>This is where <strong>Harness Engineering</strong> comes in.</p><p><strong>What Is Harness Engineering?</strong></p><p>Harness Engineering is the practice of designing the environment around an AI agent so it can complete tasks correctly, safely, and in a controlled way.</p><p>It helps to distinguish three related concepts:</p><ul><li><strong>Prompt Engineering:</strong> Telling the agent what to do.</li><li><strong>Context Engineering:</strong> Providing the information it needs to do the job.</li><li><strong>Harness Engineering:</strong> Designing the tools, workspace, permissions, rules, and verification mechanisms that govern how it works.</li></ul><p>In simple terms, the prompt gives the agent a task. Context helps it understand what it needs to know. The harness defines how it can perform that task and within which boundaries.</p><p><strong>Harness Architecture: Control Plane and Execution Plane</strong></p><p>In an enterprise software development environment, it is useful to think of Harness Engineering in two main layers.</p><p><strong>1. Control Plane</strong></p><p>The control layer defines how the agent is allowed to operate.</p><ul><li>Project instructions and coding standards</li><li>Context and memory management</li><li>MCP and tool registry</li><li>Authorization and security policies</li><li>Human approval workflows</li></ul><p><strong>2. Execution Plane</strong></p><p>The execution layer is where the agent performs actual work.</p><ul><li>Git repository and filesystem</li><li>Terminal and Maven/Gradle</li><li>Unit and integration tests</li><li>Static code analysis and security checks</li><li>External systems accessed through MCP</li><li>Isolated workspace and sandbox</li></ul><p>Together, these layers allow an agent to do more than generate code. They provide the foundation for a controlled software engineering workflow.</p><p><strong>Architecture Overview</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/944/1*IyV9HiATtA62KtSgTTTVnw.png" /></figure><p>The important idea is that the AI model should not be a component with unrestricted access to every system. Its resources and available actions should be limited through the control layer.</p><p><strong>How Should an AI Agent Work? The Agentic Loop</strong></p><p>A coding agent should not be treated as a simple prompt-and-response tool.</p><p>A real software development task usually involves a continuous cycle:</p><ol><li><strong>Observe:</strong> Inspect the repository and existing code structure.</li><li><strong>Plan:</strong> Define the changes needed to complete the task.</li><li><strong>Retrieve:</strong> Gather relevant documentation and context.</li><li><strong>Execute:</strong> Modify code and run the required commands.</li><li><strong>Verify:</strong> Execute tests and quality checks.</li><li><strong>Reflect:</strong> Evaluate the results and fix problems.</li><li><strong>Complete:</strong> Report the changes and verification results.</li></ol><p>The verification step is particularly important.</p><p>An agent saying “Task completed” does not prove that the work is correct. We need a successful Maven build, passing tests, static analysis results, and a reviewable Git diff.</p><p><strong>A Practical Java Example</strong></p><p>Imagine asking an AI agent to refactor the payment service in a Spring Boot application.</p><p>Simply giving it this instruction is not enough:</p><p>Refactor the payment service and improve its code quality.</p><p>The agent first needs to understand the project architecture, dependencies, and existing tests. It should then plan the changes, modify only the necessary files, and verify the results.</p><p>A repository-level AGENTS.md file can provide project instructions:</p><p># Project Rules</p><p>## Architecture</p><p>- Follow existing package structure.</p><p>- Keep REST and SOAP contracts compatible.</p><p>- Do not bypass service-layer rules.</p><p>## Java</p><p>- Use Java 21.</p><p>- Follow existing Spring conventions.</p><p>- Avoid unnecessary dependencies.</p><p>## Testing</p><p>- Add unit tests for business logic.</p><p>- Run Maven tests before completing a task.</p><p>- Do not remove tests just to make the build pass.</p><p>## Security</p><p>- Never access production credentials.</p><p>- Do not execute destructive database operations.</p><p>- Ask for approval before changing deployment configuration.</p><p>This file explains the project’s expectations and constraints. But there is an important detail: AGENTS.md is not a security mechanism. Simply expecting the agent to follow instructions is not enough. File access, command execution, and system connections must also be restricted technically.</p><p>For example, the agent’s workflow could look like this:</p><ul><li>Inspect the relevant Java module and its dependencies.</li><li>Run the existing tests.</li><li>Create a change plan.</li><li>Refactor the necessary parts of the payment service.</li><li>Add new unit tests.</li><li>Execute mvn clean test.</li><li>Run static analysis and API contract checks.</li><li>Report changed files and test results.</li></ul><p>This way, we evaluate the agent not only by the code it produces, but also by the evidence it provides.</p><p><strong>Two Harness Engineering Approaches in the Same Project</strong></p><p>So far, we have looked at the architecture and how an agent works. But how could we apply these ideas to a real project?</p><p>Imagine a Spring Boot payment application. The source code is hosted on GitLab, tasks are managed in Jira, dependencies come from Nexus, and code quality is checked with SonarQube.</p><p>A new development request arrives:</p><p>Improve the retry mechanism in the payment service, add the necessary tests, and check code quality.</p><p>There are two different architectural approaches we could use to handle this task.</p><p><strong>Solution 1: A Single Agent with MCP Integrations</strong></p><p>In the first approach, we use a single AI Coding Agent. The agent accesses the enterprise systems it needs through MCP.</p><p>For example:</p><ul><li>It reads the development task and acceptance criteria through Jira MCP.</li><li>It inspects the repository and relevant branch through GitLab MCP.</li><li>It checks project dependencies and artifact information through Nexus.</li><li>It retrieves code quality results from SonarQube.</li><li>It modifies the code and runs tests using the terminal and Maven.</li></ul><p>The agent manages the entire workflow itself. It analyzes the task, creates a plan, changes the code, and evaluates the test results.</p><p><strong>Architecture overview:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*2paEUakcQWEBjtc5rcyNjw.png" /></figure><p>The biggest advantage of this approach is simplicity. A centralized workflow can be managed through one agent. Since there is no need to coordinate multiple agents, the initial implementation cost and operational complexity are lower.</p><p>However, as the agent’s responsibilities grow, it may become harder for one agent to manage planning, coding, testing, and review. Context management and task separation become particularly important in larger repositories.</p><p><strong>When should we choose this approach?</strong></p><ul><li>Small and medium-sized projects</li><li>When only a limited number of tool integrations are needed</li><li>When tasks can be managed by a single agent</li><li>When a quick start and lower operational complexity are priorities</li></ul><p><strong>Solution 2: A Multi-Agent Architecture</strong></p><p>In the second approach, instead of assigning the entire development task to one agent, we distribute responsibilities among specialized agents.</p><p>For example:</p><ul><li><strong>Planner Agent:</strong> Analyzes the Jira task, extracts acceptance criteria, and creates a development plan.</li><li><strong>Developer Agent:</strong> Modifies the Java code according to the plan.</li><li><strong>Tester Agent:</strong> Prepares and runs unit and integration tests, then evaluates the results.</li><li><strong>Reviewer Agent:</strong> Reviews code changes from an architectural and code quality perspective.</li><li><strong>Security Agent:</strong> Checks security risks and permission violations.</li></ul><p>Each agent handles its own responsibility, while a central Orchestrator manages the overall workflow.</p><p><strong>Architecture overview:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/945/1*tOLJY-2fCboSU-N05JeLtg.png" /></figure><p>One important distinction: Multi-Agent architecture is not a replacement for MCP. MCP is the tool and integration layer that allows agents to access external systems. Multi-Agent is a way of distributing tasks and responsibilities across agents.</p><p>Therefore, the second solution can also use MCP. In fact, giving agents controlled access to shared tools through a common integration layer can make the architecture easier to manage.</p><p>The main advantage is specialization. For example, having an independent Reviewer Agent inspect code produced by the Developer Agent introduces a different verification layer than asking one agent to review its own output.</p><p>But this comes at a cost. Communication between agents, task handoffs, shared context management, token consumption, and failure handling make the system more complex. An incorrect output from one agent can also influence the decisions of subsequent agents.</p><p><strong>When should we choose this approach?</strong></p><ul><li>Large and complex repositories</li><li>When responsibilities can be separated into distinct areas of expertise</li><li>When code review, testing, and security verification need to be performed independently</li><li>When parallel agent execution provides a measurable benefit</li></ul><p><strong>Which Approach Should We Choose?</strong></p><p>Both solutions can solve the same development problem. The main difference is how responsibilities are managed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*mgDJ9mB_9fUi6unZ2TCB0g.png" /></figure><p>I would not start every project with a Multi-Agent architecture. A more practical approach is to begin with a single agent using MCP integrations, and establish tool access, permissions, testing, and verification workflows first.</p><p>When a real need emerges, responsibilities such as reviewing, testing, or security analysis can be moved to separate agents. The architecture then grows where it actually adds value.</p><p>The important question is not how many agents we use. It is what each agent is allowed to do, what responsibility it owns, and how its output is verified.</p><p><strong>Security and Control in Enterprise Environments</strong></p><p>When we give an AI agent permission to modify a repository, execute terminal commands, or connect to external systems, we are no longer dealing with just a code assistant.</p><p>Some controls become essential in enterprise environments:</p><ul><li><strong>Least Privilege:</strong> The agent should have only the permissions it needs.</li><li><strong>Sandboxing:</strong> Operations should run in isolated workspaces.</li><li><strong>Human Approval:</strong> Critical or difficult-to-reverse actions should require human approval.</li><li><strong>Audit Trail:</strong> Record which tools the agent used, when, and for what purpose.</li><li><strong>Observability:</strong> Monitor errors, execution time, token usage, and tool calls.</li><li><strong>Evaluation:</strong> Measure results against predefined acceptance criteria.</li></ul><p>In particular, agents should not be allowed to independently execute critical operations involving production access, database changes, deployments, or security configuration.</p><p><strong>The Future of Software Development and Harness Engineering</strong></p><p>Over the next five years, I expect AI coding agents to be used not only for writing new code, but also for understanding and transforming existing software systems.</p><p>This could be especially important for legacy applications that have been running for years. Understanding the dependencies, SOAP integrations, database access patterns, and architectural boundaries of a Java 8 application can require significant engineering effort. In the future, agents may continuously analyze these systems, suggest modernization options, prepare migration changes for newer Java versions, and identify risks based on test results. However, deciding which architectural direction is appropriate and approving critical changes will remain responsibilities for human engineers.</p><p>The development of new applications may also change. Instead of manually writing every class and test scenario, developers may spend more time defining business requirements, architectural boundaries, data models, security policies, and acceptance criteria. Agents could scaffold projects, implement features, and prepare tests. This may make architectural thinking even more important, because someone still needs to define the boundaries within which generated code should operate.</p><p>AI coding agents may also evolve from tools that simply suggest code into systems that plan tasks, use tools, collaborate with specialized agents, and verify their own outputs. But as their capabilities increase, so will the areas that need to be controlled. More tools, more access, and more autonomy also mean greater requirements for security, traceability, and verification.</p><p>Of course, these are predictions based on current developments, not guaranteed outcomes. But one thing seems likely to remain true: as AI makes writing code easier, designing the right system, defining its boundaries, and reliably verifying the results will become even more important.</p><p>That is where Harness Engineering delivers its real value. The goal is not simply to make AI write code. It is to make the changes produced by AI a reliable part of the software engineering process.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23af4a979bfa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Practical Lessons for Writing Better Java Code — From Java 8 to Java 25]]></title>
            <link>https://medium.com/@mkonca/java-best-practices-10-mistakes-to-avoid-61833f337abf?source=rss-e6afd92b93db------2</link>
            <guid isPermaLink="false">https://medium.com/p/61833f337abf</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[java21]]></category>
            <category><![CDATA[java-best-practices]]></category>
            <category><![CDATA[java25]]></category>
            <category><![CDATA[clean-code]]></category>
            <dc:creator><![CDATA[mkonca]]></dc:creator>
            <pubDate>Wed, 25 Nov 2026 07:14:39 GMT</pubDate>
            <atom:updated>2026-11-26T12:59:38.064Z</atom:updated>
            <content:encoded><![CDATA[<p><em>From Java 8 to Java 25: Practical lessons for junior and senior developers building reliable, maintainable, and production-ready applications.</em></p><p>Writing Java code that works is relatively easy.</p><p>Writing Java code that remains reliable under thousands of requests, survives unexpected failures, handles concurrency, and can be maintained by another developer five years later is a different challenge.</p><p>Most developers learn Java by writing classes, methods, loops, and collections. But real-world software development requires much more than knowing the language.</p><p>Some mistakes are common among junior developers. Others appear in complex enterprise applications written by experienced engineers.</p><p>This handbook focuses on ten common Java mistakes, explains why they matter, and demonstrates how to avoid them with practical examples.</p><p>The examples cover Java 8 and modern Java versions, including Java 11, 17, 21, and 25.</p><p>The goal is simple:</p><p><strong>Write code that works today without creating problems for tomorrow.</strong></p><h3>Java version guide: What has changed?</h3><p>Before looking at the mistakes, it is useful to understand how Java has evolved.</p><h3>Java Versions — Important Features Every Developer Should Know</h3><h3>☕ Java 8</h3><ul><li>Lambda Expressions</li><li>Stream API</li><li>Optional</li><li>Modern Date &amp; Time API (java.time)</li><li>CompletableFuture</li></ul><h3>☕ Java 9</h3><ul><li>Collection Factory Methods (List.of(), Set.of(), Map.of())</li><li>Improved Stream API</li><li>Java Platform Module System</li></ul><h3>☕ Java 10</h3><ul><li>Local Variable Type Inference (var)</li></ul><h3>☕ Java 11</h3><ul><li>String.isBlank()</li><li>String.strip()</li><li>Standard HTTP Client</li></ul><h3>☕ Java 14</h3><ul><li>Switch Expressions</li></ul><h3>☕ Java 15</h3><ul><li>Text Blocks</li></ul><h3>☕ Java 16</h3><ul><li>Records</li><li>Pattern Matching for instanceof</li></ul><h3>☕ Java 17</h3><ul><li>Sealed Classes</li></ul><h3>☕ Java 21</h3><ul><li>Virtual Threads</li><li>Record Patterns</li><li>Pattern Matching for switch</li><li>Sequenced Collections</li></ul><h3>☕ Java 25</h3><ul><li>Module Import Declarations</li><li>Compact Source Files</li><li>Flexible Constructor Bodies</li></ul><p>Not every new feature should be adopted immediately. The right choice depends on the application’s target Java version, dependencies, runtime environment, and team conventions.</p><h3>1. Comparing Strings and Objects Incorrectly</h3><p>One of the first mistakes Java developers encounter is comparing strings using ==.</p><p><strong>Wrong:</strong></p><pre>String username = new String(&quot;admin&quot;);<br><br>if (username == &quot;admin&quot;) {<br>    System.out.println(&quot;Authorized&quot;);<br>}</pre><p>The == operator compares object references, not string contents.</p><p><strong>Better:</strong></p><pre>if (&quot;admin&quot;.equals(username)) {<br>    System.out.println(&quot;Authorized&quot;);<br>}</pre><p>Using the constant on the left also prevents a NullPointerException if username is null.</p><p>But there is another related mistake: overriding equals() without overriding hashCode().</p><p>Objects used as keys in HashMap or elements in HashSet depend on both methods.</p><p><strong>Modern Java approach:</strong></p><pre>public record CustomerInfo(<br>        Long id,<br>        String name,<br>        String email<br>) {}</pre><p>Records automatically provide appropriate equals() and hashCode() implementations based on their components.</p><p><strong>Java version differences:</strong></p><ul><li>Java 8: Implement equals() and hashCode() manually or use IDE-generated methods.</li><li>Java 16+: Records can simplify immutable data-carrier classes.</li><li>Java 17+: Sealed classes can also help model restricted domain hierarchies.</li></ul><p><strong>Best practices:</strong></p><ul><li>Use .equals() for value comparison.</li><li>Use == for primitive values and intentional reference identity checks.</li><li>Keep equals() and hashCode() consistent.</li><li>Avoid mutable objects as hash-based collection keys.</li><li>Use records when their generated equality semantics match the domain.</li></ul><h3>2. Ignoring Null and Misusing Optional</h3><p>Null-related errors are among the most common sources of runtime failures.</p><p><strong>Wrong:</strong></p><pre>public String getCustomerName(Customer customer) {<br>    return customer.getName().toUpperCase();<br>}</pre><p>What happens if customer or its name is null?</p><p><strong>Better:</strong></p><pre>public String getCustomerName(Customer customer) {</pre><pre>    Objects.requireNonNull(customer, &quot;customer&quot;);</pre><pre>    return Optional.ofNullable(customer.getName())<br>            .map(String::toUpperCase)<br>            .orElse(&quot;UNKNOWN&quot;);<br>}</pre><p>However, Optional should not become a universal replacement for null.</p><p>It is particularly useful as a return type when a value may be absent.</p><p><strong>Java version differences:</strong></p><p>Java 8 introduced Optional, so it is available even in legacy Java 8 projects.</p><p>Java 9 added useful methods such as:</p><pre>Optional&lt;String&gt; name = Optional.of(&quot;Java&quot;);</pre><pre>name.ifPresentOrElse(<br>        System.out::println,<br>        () -&gt; System.out.println(&quot;Not found&quot;)<br>);</pre><p>Java 10 introduced var, which can make local declarations shorter, but it does not change the null behavior of an object.</p><p><strong>Best practices:</strong></p><ul><li>Define nullability expectations at API boundaries.</li><li>Validate incoming data.</li><li>Avoid ambiguous null return values.</li><li>Use Optional selectively, especially for return values.</li><li>Avoid Optional as a general-purpose entity field or method parameter.</li><li>Prefer immutable objects with valid states.</li></ul><h3>3. Catching Exceptions and Hiding Errors</h3><p>This is one of the most dangerous patterns in production applications.</p><p><strong>Wrong:</strong></p><pre>try {<br>    paymentService.process(payment);<br>} catch (Exception e) {<br>    // Ignore<br>}</pre><p>The application continues as if nothing happened.</p><p>The payment may not have been processed, but the caller might believe it was successful.</p><p><strong>Better:</strong></p><pre>try {<br>    paymentService.process(payment);</pre><pre>} catch (PaymentException e) {</pre><pre>    log.error(<br>            &quot;Payment processing failed. paymentId={}&quot;,<br>            payment.getId(),<br>            e<br>    );</pre><pre>    throw e;<br>}</pre><p>Do not catch exceptions unless you can handle them, translate them, add meaningful context, or recover safely.</p><p><strong>Java version differences:</strong></p><p>Java 7 introduced try-with-resources and improved exception handling.</p><p>Java 9 allows effectively final variables to be used directly in try-with-resources:</p><pre>InputStream input = Files.newInputStream(path);</pre><pre>try (input) {<br>    // Read data<br>}</pre><p>Java 14 introduced switch expressions, which can simplify some error or status mapping logic:</p><pre>String message = switch (status) {<br>    case SUCCESS -&gt; &quot;Completed&quot;;<br>    case FAILED -&gt; &quot;Failed&quot;;<br>    case PENDING -&gt; &quot;Waiting&quot;;<br>};</pre><p><strong>Best practices:</strong></p><ul><li>Never silently ignore exceptions.</li><li>Catch the most specific exception possible.</li><li>Preserve the original cause when wrapping exceptions.</li><li>Do not expose internal stack traces to API consumers.</li><li>Log enough context to investigate failures.</li><li>Avoid using exceptions for normal business control flow.</li></ul><h3>4. Not Closing Resources Properly</h3><p>Database connections, streams, files, and network resources must be released.</p><p><strong>Wrong:</strong></p><pre>FileInputStream input =<br>        new FileInputStream(&quot;data.txt&quot;);</pre><pre>int value = input.read();</pre><p>If an exception occurs, the stream may remain open.</p><p><strong>Better:</strong></p><pre>try (InputStream input =<br>        Files.newInputStream(Path.of(&quot;data.txt&quot;))) {</pre><pre>    int value = input.read();<br>}</pre><p>Try-with-resources automatically closes resources, including when an exception occurs.</p><p><strong>Java version differences:</strong></p><ul><li>Java 7+: Try-with-resources.</li><li>Java 8: Lambda-based resource handling can be combined with existing APIs.</li><li>Java 9+: An effectively final resource variable can be used directly in the resource declaration.</li><li>Java 11+: Files.readString() and Files.writeString() simplify common text-file operations.</li></ul><p>Java 11 example:</p><pre>String content = Files.readString(<br>        Path.of(&quot;data.txt&quot;),<br>        StandardCharsets.UTF_8<br>);</pre><p><strong>Best practices:</strong></p><ul><li>Use try-with-resources for AutoCloseable resources.</li><li>Avoid manually managing resource lifecycles.</li><li>Do not close resources owned by another component.</li><li>Monitor database connection pools and resource leaks.</li><li>Remember that connection pools should manage database connections; application code should release borrowed connections promptly.</li></ul><h3>5. Using double for Financial Calculations</h3><p>Floating-point types are not appropriate for exact decimal financial calculations.</p><p><strong>Wrong:</strong></p><pre>double total = 0.1 + 0.2;</pre><pre>System.out.println(total);</pre><p>The result may not be exactly 0.3.</p><p><strong>Better:</strong></p><pre>BigDecimal total = new BigDecimal(&quot;0.1&quot;)<br>        .add(new BigDecimal(&quot;0.2&quot;));</pre><p>For financial calculations, define rounding behavior explicitly:</p><pre>BigDecimal amount = new BigDecimal(&quot;125.567&quot;);</pre><pre>BigDecimal rounded = amount.setScale(<br>        2,<br>        RoundingMode.HALF_UP<br>);</pre><p><strong>Java version differences:</strong></p><p>This is not a problem that newer Java versions automatically solve. BigDecimal is available in Java 8 and remains the appropriate choice in Java 25 for exact decimal arithmetic.</p><p>Modern Java records can make monetary value objects easier to model:</p><pre>public record Money(<br>        BigDecimal amount,<br>        Currency currency<br>) {}</pre><p>For a production domain model, also validate the amount and define supported currencies and rounding rules.</p><p><strong>Best practices:</strong></p><ul><li>Use BigDecimal for monetary values.</li><li>Avoid constructing it from a double.</li><li>Define scale and rounding rules explicitly.</li><li>Understand the difference between equals() and compareTo() for BigDecimal.</li><li>Keep currency and amount together in the domain model when appropriate.</li></ul><h3>6. Ignoring Time Zones and Using Legacy Date APIs</h3><p>Date and time handling becomes complicated when applications operate across multiple regions.</p><p><strong>Risky:</strong></p><pre>Date now = new Date();</pre><p>This does not communicate whether a value represents a date, local time, or an instant in time.</p><p><strong>Better:</strong></p><pre>Instant createdAt = Instant.now();</pre><pre>LocalDate paymentDate = LocalDate.now();</pre><pre>ZonedDateTime scheduledTime =<br>        ZonedDateTime.now(<br>                ZoneId.of(&quot;Europe/Istanbul&quot;)<br>        );</pre><p>Each type has a different purpose:</p><ul><li>Instant: A point on the global timeline.</li><li>LocalDate: A calendar date without time.</li><li>LocalDateTime: A local date and time without a time zone.</li><li>ZonedDateTime: A date and time with a time-zone context.</li></ul><p><strong>Java version differences:</strong></p><p>Java 8 introduced the modern java.time API. It is available in Java 8 and later.</p><p>Java 11 added no replacement for this API; java.time remains the recommended approach.</p><p>For example, use:</p><pre>Instant timestamp = Instant.now();</pre><p>rather than:</p><pre>Date timestamp = new Date();</pre><p>when representing an event timestamp.</p><p><strong>Best practices:</strong></p><ul><li>Use java.time instead of legacy Date and Calendar for new code.</li><li>Use Instant for timestamps.</li><li>Use LocalDate for calendar dates.</li><li>Use ZonedDateTime when time-zone rules matter.</li><li>Do not assume the server’s default time zone is the business time zone.</li><li>Store and exchange timestamps consistently, typically using UTC instants.</li></ul><h3>7. Using Mutable Collections and Exposing Internal State</h3><p>Mutable objects can create unexpected side effects when multiple parts of an application share the same reference.</p><p><strong>Risky:</strong></p><pre>public class Customer {</pre><pre>    private List&lt;String&gt; roles;</pre><pre>    public List&lt;String&gt; getRoles() {<br>        return roles;<br>    }<br>}</pre><p>Any caller can modify the internal list.</p><p><strong>Better:</strong></p><pre>public class Customer {</pre><pre>    private final List&lt;String&gt; roles;</pre><pre>    public Customer(List&lt;String&gt; roles) {<br>        this.roles = List.copyOf(roles);<br>    }</pre><pre>    public List&lt;String&gt; getRoles() {<br>        return roles;<br>    }<br>}</pre><p><strong>Java version differences:</strong></p><p>Java 8:</p><pre>List&lt;String&gt; roles =<br>        Collections.unmodifiableList(<br>                new ArrayList&lt;&gt;(source)<br>        );</pre><p>Java 9 and later:</p><pre>List&lt;String&gt; roles = List.of(<br>        &quot;ADMIN&quot;,<br>        &quot;USER&quot;<br>);</pre><p>Java 10 and later:</p><pre>List&lt;String&gt; roles = List.copyOf(source);</pre><p>These factory methods produce unmodifiable collections. They do not guarantee deep immutability of the objects inside the collection.</p><p>Java 21 also introduced sequenced collection interfaces, providing consistent operations for accessing first and last elements in supported collection types.</p><p><strong>Best practices:</strong></p><ul><li>Prefer immutable data where practical.</li><li>Avoid exposing internal mutable collections.</li><li>Use defensive copies at API boundaries.</li><li>Understand that unmodifiable collections are not necessarily deeply immutable.</li><li>Do not use mutable fields in hash-based collection keys.</li></ul><h3>8. Creating Uncontrolled Threads and Ignoring Thread Safety</h3><p>Creating a new thread for every task can exhaust system resources.</p><p><strong>Wrong:</strong></p><pre>new Thread(() -&gt; processOrder()).start();</pre><p>Repeated uncontrolled thread creation is difficult to manage.</p><p><strong>Better for traditional Java applications:</strong></p><pre>ExecutorService executor =<br>        Executors.newFixedThreadPool(10);</pre><pre>executor.submit(this::processOrder);</pre><p>The executor must also have a lifecycle and shutdown strategy.</p><h3>What changes in modern Java?</h3><p>Java 8 applications commonly use platform threads, executors, and CompletableFuture.</p><p>Java 21 introduced virtual threads as a permanent feature.</p><pre>try (var executor =<br>        Executors.newVirtualThreadPerTaskExecutor()) {</pre><pre>    executor.submit(this::processOrder);<br>}</pre><p>Virtual threads make it easier to write highly concurrent applications with blocking I/O operations.</p><p>But they do not make CPU-intensive work faster, eliminate database connection limits, or make shared mutable state thread-safe.</p><p>There is another common mistake in Spring applications: storing request-specific mutable state in singleton service fields.</p><p><strong>Risky:</strong></p><pre>@Service<br>public class PaymentService {</pre><pre>    private int requestCount;</pre><pre>    public void process() {<br>        requestCount++;<br>    }<br>}</pre><p>Multiple threads can update this field concurrently.</p><p>If a counter is genuinely required:</p><pre>private final AtomicInteger requestCount =<br>        new AtomicInteger();</pre><pre>public void process() {<br>    requestCount.incrementAndGet();<br>}</pre><p>An atomic counter solves this specific problem, but it does not make every multi-step business operation thread-safe.</p><p><strong>Best practices:</strong></p><ul><li>Keep singleton service beans stateless where possible.</li><li>Use immutable data.</li><li>Manage concurrency explicitly.</li><li>Use virtual threads for suitable blocking workloads.</li><li>Understand atomicity and visibility.</li><li>Configure database pools according to downstream capacity.</li><li>Handle timeouts, cancellation, and failures.</li></ul><h3>9. Building Unsafe SQL Queries and Ignoring Database Performance</h3><p>This mistake combines two problems that frequently appear together: security and performance.</p><h3>SQL injection</h3><p><strong>Wrong:</strong></p><pre>String sql =<br>        &quot;SELECT * FROM users WHERE username = &#39;&quot;<br>        + username + &quot;&#39;&quot;;</pre><p>This creates SQL injection risks.</p><p><strong>Better:</strong></p><pre>String sql =<br>        &quot;SELECT * FROM users WHERE username = ?&quot;;</pre><pre>try (PreparedStatement statement =<br>        connection.prepareStatement(sql)) {</pre><pre>    statement.setString(1, username);<br>}</pre><p>Using JPA or Hibernate does not automatically eliminate every injection risk. Dynamic JPQL, HQL, and native SQL still require safe parameter handling.</p><h3>Database performance</h3><p>An application may work perfectly with 100 records and fail under production-scale data.</p><p>Common problems include:</p><ul><li>N+1 queries</li><li>Missing indexes</li><li>Loading unnecessary columns</li><li>Fetching entire tables</li><li>Unbounded result sets</li><li>Long-running transactions</li></ul><p><strong>Risky:</strong></p><pre>List&lt;Order&gt; orders =<br>        orderRepository.findAll();</pre><p>What happens when the table contains millions of rows?</p><p><strong>Better:</strong></p><pre>Page&lt;Order&gt; orders =<br>        orderRepository.findAll(<br>                PageRequest.of(0, 50)<br>        );</pre><h3>Transaction boundaries matter too</h3><p>A transaction is not just an annotation.</p><p><strong>Risky:</strong></p><pre>@Transactional<br>public void createPayment() {<br>    savePayment();<br>    callExternalPaymentGateway();<br>    sendEmail();<br>}</pre><p>The database transaction may remain open while waiting for an external service. It also does not make the external API call part of the database transaction.</p><p><strong>Best practices:</strong></p><ul><li>Use parameterized queries.</li><li>Validate untrusted input.</li><li>Use pagination where appropriate.</li><li>Inspect generated SQL.</li><li>Measure query performance.</li><li>Review indexes using actual query patterns.</li><li>Avoid long-running external calls inside database transactions.</li><li>Use idempotency for retryable operations.</li><li>Consider the outbox pattern for reliable event publication.</li></ul><p><strong>Java version differences:</strong></p><p>These are primarily database and framework design concerns rather than language-version features. The same principles apply to Java 8, 17, 21, and 25.</p><p>Newer Java syntax does not make unsafe SQL safe or automatically improve database query performance.</p><h3>10. Writing Tests Only for Code Coverage</h3><p>High test coverage does not automatically mean high-quality tests.</p><p><strong>Weak test:</strong></p><pre>@Test<br>void shouldCreatePayment() {<br>    paymentService.createPayment();<br>}</pre><p>The test may execute the method without checking whether the behavior is correct.</p><p><strong>Better:</strong></p><pre>@Test<br>void shouldRejectPaymentWhenAmountIsInvalid() {</pre><pre>    PaymentRequest request =<br>            new PaymentRequest(<br>                    new BigDecimal(&quot;-10&quot;)<br>            );</pre><pre>    assertThrows(<br>            InvalidPaymentException.class,<br>            () -&gt; paymentService.createPayment(request)<br>    );<br>}</pre><p>A good test verifies expected behavior, including failure scenarios.</p><h3>Java version differences</h3><p>The Java language version does not determine the quality of a test. However, newer Java versions provide more convenient ways to write test data and test code.</p><p>Java 8:</p><pre>Customer customer =<br>        new Customer(1L, &quot;Alice&quot;);</pre><p>Java 16 and later:</p><pre>Customer customer =<br>        new Customer(1L, &quot;Alice&quot;);</pre><p>If the domain model is suitable, the second declaration can use a record:</p><pre>public record Customer(<br>        Long id,<br>        String name<br>) {}</pre><p>The same principle applies to test fixtures: use the simplest representation that expresses the intended behavior.</p><p>For Spring Boot applications, use an appropriate test scope:</p><p><strong>Test type Purpose</strong></p><p>Unit test Business logic in isolation</p><p>@WebMvcTestMVC/controller layer</p><p>@DataJpaTest JPA persistence layer</p><p>@SpringBootTest Full application integration</p><p><strong>Best practices:</strong></p><ul><li>Test behavior, not implementation details.</li><li>Cover boundary conditions.</li><li>Test failure scenarios.</li><li>Use integration tests for important system interactions.</li><li>Keep unit tests fast and deterministic.</li><li>Avoid relying exclusively on code coverage metrics.</li></ul><h3>What Makes a Good Java Developer?</h3><p>A junior developer becomes stronger by learning the language, understanding common mistakes, and developing good coding habits.</p><p>A senior developer becomes stronger by recognizing the consequences of those mistakes across an entire system: reliability, scalability, security, maintainability, and operational cost.</p><p>The difference is not simply how much Java syntax someone knows.</p><p>It is how well they understand the behavior of the software they build.</p><p>A good Java developer does not just ask:</p><p><strong>“Does this code work?”</strong></p><p>They also ask:</p><ul><li>What happens when the database is unavailable?</li><li>What happens when two requests update the same data?</li><li>What happens when an external API responds slowly?</li><li>What happens when the application receives ten times more traffic?</li><li>Can another developer safely change this code next year?</li><li>Will this implementation still work after a Java upgrade?</li><li>These questions turn ordinary Java code into production-ready software.</li></ul><p><strong>Write code for the happy path. Design for everything else.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61833f337abf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Moving to Spring Boot 4]]></title>
            <link>https://medium.com/@mkonca/moving-to-spring-boot-4-dc82b01e4cf4?source=rss-e6afd92b93db------2</link>
            <guid isPermaLink="false">https://medium.com/p/dc82b01e4cf4</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[openrewrite]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[mkonca]]></dc:creator>
            <pubDate>Fri, 20 Nov 2026 13:46:24 GMT</pubDate>
            <atom:updated>2026-11-20T13:46:24.201Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What Should We Watch Out For?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*6UXKBUZGROqguzMNrye0xQ.gif" /></figure><blockquote><em>From dependency changes and Jackson 3 to Jakarta EE and testing updates — what developers should know before upgrading, and how OpenRewrite can help.</em></blockquote><p>Moving to Spring Boot 4 is not just about changing the version in pom.xml.</p><p>There are quite a few changes across the Spring ecosystem. The modular starter structure, Jackson 3, Jakarta EE updates, and changes in the testing infrastructure can all affect existing applications.</p><p>So, where should we begin?</p><p><strong>1. Start with the basics</strong></p><p>Spring Boot 4 requires Java 17 or later. It is also built on Spring Framework 7 and Jakarta EE 11.</p><p>Before upgrading, check:</p><ul><li>The Java version</li><li>Maven or Gradle version</li><li>Third-party library compatibility</li><li>Application server and runtime environment</li></ul><p>For existing applications, I would not jump straight into Boot 4. First, move to the latest Spring Boot 3.5 release. This makes it easier to identify problems coming from the old version before dealing with the new migration changes.</p><p><strong>2. Starter dependencies are changing</strong></p><p>One of the noticeable changes in Spring Boot 4 is its more modular structure.</p><p>For example, the old dependency:</p><p>&lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;</p><p>is replaced by:</p><p>&lt;artifactId&gt;spring-boot-starter-webmvc&lt;/artifactId&gt;</p><p>The Web Services starter is now named spring-boot-starter-webservices. OAuth2 starters also use the security- prefix.</p><p>At first, this may look like a simple naming change. But the new structure makes us declare the modules we actually need more explicitly.</p><p>If your application has been relying on transitive dependencies for a long time, you may need to add some starters yourself.</p><p><strong>3. Jackson 3 is another important change</strong></p><p>Jackson 3 comes with a different package structure.</p><p>For example:</p><pre>// Jackson 2<br>import com.fasterxml.jackson.databind.ObjectMapper;<br><br>// Jackson 3<br>import tools.jackson.databind.ObjectMapper;</pre><p>Not every Jackson package has changed, though. Annotation classes, for example, are still under com.fasterxml.jackson.annotation.</p><p>So, changing imports alone may not be enough. Custom serializers, deserializers, date handling, and Jackson modules should also be reviewed.</p><p>This is especially important for enterprise applications that communicate with multiple REST services.</p><p><strong>4. Don’t forget Jakarta EE</strong></p><p>The javax to jakarta migration that started with Spring Boot 3 continues in Boot 4.</p><p>For example:</p><pre>javax.servlet<br>javax.validation</pre><p>become:</p><pre>jakarta.servlet<br>jakarta.validation</pre><p>One thing to keep in mind: not every javax package needs to change. Java SE packages such as javax.sql and javax.crypto remain as they are.</p><p>That is why a blind search-and-replace is not a good migration strategy.</p><p><strong>5. Tests need attention too</strong></p><p>There are a few changes on the testing side.</p><p>For example, @MockBean is replaced by @MockitoBean, and @SpyBean is replaced by @MockitoSpyBean.</p><p>There is another detail worth mentioning: @SpringBootTest no longer provides MockMvc support automatically.</p><p>If your tests use MockMvc, add:</p><pre>@AutoConfigureMockMvc</pre><p>These changes may not be obvious until the test suite runs, so make sure to execute all tests after the migration.</p><p><strong>6. Review configuration and dependencies</strong></p><p>Some configuration properties have also been renamed.</p><p>For example:</p><pre>spring.dao.exceptiontranslation.enabled</pre><p>becomes:</p><pre>spring.persistence.exceptiontranslation.enabled</pre><p>Some Spring Session Redis properties have changed as well.</p><p>The spring-boot-properties-migrator dependency can help identify outdated properties during the migration. Once the migration is complete, remove it.</p><p>You should also review the compatibility of the technologies used by your application:</p><ul><li>Spring Security 7</li><li>Spring Data and Hibernate</li><li>Tomcat and Servlet 6.1</li><li>Spring Batch JDBC metadata</li><li>Spring Kafka and AMQP retry configuration</li><li>OpenAPI and Jackson 3</li></ul><p>One important detail: Undertow support has been removed in Spring Boot 4.0.</p><p>If you use JDBC-based Spring Batch metadata, also evaluate the spring-boot-starter-batch-jdbc option.</p><p><strong>7. OpenRewrite can make the migration easier</strong></p><p>Manually applying all these changes can take a lot of time, especially when you have multiple applications to migrate.</p><p>This is where OpenRewrite becomes useful.</p><p>The Spring Boot 4 migration recipe can automatically update dependencies and handle several code and configuration changes.</p><p>You can run it with Maven:</p><pre>mvn -U org.openrewrite.maven:rewrite-maven-plugin:run \<br>  -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-spring:RELEASE \<br>  -Drewrite.activeRecipes=org.openrewrite.java.spring.boot4.UpgradeSpringBoot_4_0 \<br>  -Drewrite.exportDatatables=true</pre><p>For enterprise environments, I would pin a verified recipe version instead of relying on RELEASE. Also check the recipe’s distribution and licensing terms, along with access to the required artifact repositories.</p><p>OpenRewrite can help with:</p><ul><li>Updating Spring Boot dependencies.</li><li>Replacing selected old API usages.</li><li>Migrating @MockBean and @SpyBean.</li><li>Updating supported configuration properties.</li><li>Coordinating related Spring Framework and Spring Security migrations.</li></ul><p>But it cannot validate everything.</p><p>It will not know whether your custom Jackson logic still behaves correctly, whether your REST/SOAP contracts are intact, or whether database transactions and runtime behavior are still correct.</p><p>That is why reviewing the generated changes is essential:</p><pre>git status --short<br>git diff -- pom.xml<br>git diff -- src/main src/test</pre><p>I would treat OpenRewrite as part of a controlled migration process, not as a tool that upgrades everything automatically.</p><p><strong>8. A migration plan that works</strong></p><p>For larger applications, making all changes at once can be risky. An incremental approach is usually easier to manage.</p><p>Here is the sequence I would follow:</p><ol><li>Upgrade to the latest Spring Boot 3.5 release.</li><li>Check dependency compatibility with Boot 4.</li><li>Run OpenRewrite on a separate migration branch.</li><li>Review the generated code and dependency changes.</li><li>Complete the Jackson, Jakarta, starter, and testing updates.</li><li>Run unit and integration tests.</li><li>Verify REST/SOAP integrations, database operations, and security flows.</li><li>Finish with load and performance tests.</li></ol><p><strong>Final thoughts</strong></p><p>Spring Boot 4 should not be treated as just another framework version upgrade.</p><p>It affects dependency management, testing, JSON processing, and the runtime environment. OpenRewrite can save a lot of time, but reviewing the changes and validating the application are still our responsibility.</p><p>My approach is simple: <strong>Transform with OpenRewrite, review with Git diff, validate with tests, and deploy in a controlled manner.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dc82b01e4cf4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managing High-Traffic Java Applications with Virtual Threads: Backpressure and Resilience]]></title>
            <link>https://medium.com/@mkonca/managing-high-traffic-java-applications-with-virtual-threads-backpressure-and-resilience-6cf9288e6fcf?source=rss-e6afd92b93db------2</link>
            <guid isPermaLink="false">https://medium.com/p/6cf9288e6fcf</guid>
            <category><![CDATA[resilience4j]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[virtual-threads]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[mkonca]]></dc:creator>
            <pubDate>Mon, 16 Nov 2026 11:39:31 GMT</pubDate>
            <atom:updated>2026-11-16T11:39:31.756Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BDUMd_rJ6F44w8IN0PFIsg.png" /></figure><p><strong>1. Are Virtual Threads Enough?</strong></p><p>Introduced in Java 21, Virtual Threads make it easier to achieve high concurrency, especially in I/O-intensive applications. However, handling more concurrent requests does not mean that databases and external services have the same capacity.</p><p>Consider the following example:</p><p><strong>Parameter &amp; Value</strong></p><ul><li><strong>Incoming HTTP Requests:</strong> 10,000</li><li><strong>Maximum Database Connections:</strong> 200</li><li><strong>Application Pods:</strong> 4</li><li><strong>Application Connection Budget:</strong> 160</li><li><strong>Target Concurrent DB Operations:</strong> 140</li></ul><p>If all 10,000 requests attempt to access the database simultaneously, the connection pool becomes exhausted, waiting requests increase, and response times grow. Timeouts and uncontrolled retries can make the situation even worse.</p><p><strong>The key principle:</strong> Manage incoming traffic, application resources, and downstream dependencies independently.</p><p><strong>2. A Three-Layer Protection Architecture</strong></p><p>A high-traffic application needs three main protection layers:</p><pre>CLIENT REQUESTS<br>                    |<br>                    v<br>             API GATEWAY<br>          Rate Limit / Load Shed<br>                    |<br>                    v<br>             SPRING BOOT<br>             Virtual Threads<br>                    |<br>          +---------+---------+<br>          |                   |<br>          v                   v<br>      DATABASE           EXTERNAL APIs<br>      Semaphore             Bulkhead<br>      HikariCP              RestClient<br>          |                   |<br>          v                   v<br>       DATABASE          DEPENDENT SERVICES<br><br>          TIMEOUT / RETRY / CIRCUIT BREAKER<br>                    |<br>                    v<br>              METRICS / JFRAPI GATEWAY</pre><p>Each mechanism has a different responsibility:</p><p><strong>Mechanism &amp; Responsibility</strong></p><ul><li><strong>Rate Limiting:</strong> Controlling request rates</li><li><strong>Load Shedding:</strong> Rejecting requests under excessive load</li><li><strong>Admission Control:</strong> Limiting accepted concurrent work</li><li><strong>Semaphore:</strong> Limiting concurrent database operations</li><li><strong>HikariCP:</strong> Managing physical DB connections</li><li><strong>Bulkhead:</strong> Isolating external services</li><li><strong>Circuit Breaker:</strong> Temporarily stopping calls to failing services</li><li><strong>Timeout:</strong> Limiting waiting time</li><li><strong>Retry:</strong> Retrying transient failures in a controlled manner</li></ul><p><strong>3. Traffic Management and Backpressure</strong></p><p>The first control point should be the API Gateway or Ingress.</p><p>For example, if the limit is 100 requests per second and 150 requests arrive, 100 are accepted and the remaining 50 are rejected with HTTP 429.</p><p>A Redis-based Rate Limiter can be configured in Spring Cloud Gateway.</p><p>However, accepting a request at the Gateway does not mean that the application must always accept it.</p><p>Application-level Admission Control can limit concurrent work:</p><pre>private final Semaphore permits =<br>    new Semaphore(500);<br><br>public &lt;T&gt; T execute(Supplier&lt;T&gt; operation) {<br>    if (!permits.tryAcquire()) {<br>        throw new ServiceOverloadedException();<br>    }<br><br>    try {<br>        return operation.get();<br>    } finally {<br>        permits.release();<br>    }<br>}</pre><p>When no permit is available, the request is rejected. HTTP 503 can be used when the application cannot accept additional work due to capacity constraints.</p><p>The distinction is important:</p><ul><li>Rate Limiting controls request rates.</li><li>Admission Control limits concurrent work.</li><li>Load Shedding rejects requests when capacity is exceeded.</li><li>Backpressure controls the flow of work according to system capacity.</li></ul><p>An unbounded queue is not backpressure. It simply moves the bottleneck into memory.</p><p><strong>4. Managing Database Capacity</strong></p><p>Let&#39;s allocate the database&#39;s 200 connections as follows:</p><p><strong>Usage &amp; Connections</strong></p><ul><li><strong>Application:</strong> 160 connections</li><li><strong>Other Applications:</strong> 30 connections</li><li><strong>Operations and Monitoring:</strong> 10 connections</li><li><strong>Total:</strong> 200 connections</li></ul><p>With four application pods:</p><p>160 / 4 = 40 connections per pod</p><p>The HikariCP maximum pool size can therefore be set to 40 per pod.</p><p>If we additionally limit concurrent DB operations to 35 using a Semaphore:</p><p>35 x 4 pods = 140 concurrent DB operations</p><p>This leaves a margin of 20 connections within the application&#39;s 160-connection budget.</p><p>These mechanisms have different responsibilities:</p><ul><li>Semaphore limits DB operations before they reach the connection pool.</li><li>HikariCP limits the number of physical connections.</li></ul><p>Using a Semaphore is not mandatory in every application. HikariCP already controls connection capacity. A Semaphore is useful when it reduces connection-pool waiting and provides earlier application-level load rejection.</p><p><strong>Important:</strong> The Semaphore permit should remain held until the database transaction completes. Admission control and the @Transactional method can be implemented in separate Spring beans to ensure that the permit is not released prematurely.</p><p>A Semaphore operates within a single JVM. If the number of pods increases to eight:</p><p>8 x 35 = 280</p><p>This exceeds the database&#39;s total capacity. Kubernetes HPA must therefore be planned together with per-pod connection and Semaphore limits.</p><p><strong>5. Protecting External Services with Resilience4j</strong></p><p>An application may depend on several services, such as Payment, Identity, and Address.</p><p>To prevent a slow Payment Service from affecting other dependencies, each service should have an independent Bulkhead limit.</p><p>For example:</p><p><strong>Service &amp; Concurrent call limit</strong></p><ul><li><strong>Payment:</strong> 30 concurrent calls</li><li><strong>Identity:</strong> 50 concurrent calls</li><li><strong>Address:</strong> 20 concurrent calls</li></ul><p>The main Resilience4j mechanisms are:</p><p><strong>Timeout:</strong> Preventing indefinite waits for external responses. Connection and response timeouts should be configured in the HTTP client.</p><p><strong>Circuit Breaker:</strong> Temporarily stopping new calls when the failure rate reaches a defined threshold.</p><p><strong>Retry:</strong> Retrying only transient failures, with a limited number of attempts and Exponential Backoff + Jitter.</p><p><strong>Bulkhead:</strong> Defining an independent concurrency limit for each external dependency.</p><p>Important considerations:</p><ul><li>Automatic retries for side-effecting operations such as payments require an idempotency key.</li><li>Retries must stay within the total request-time budget.</li><li>Business and validation errors, such as HTTP 400, should not be retried.</li><li>If Bulkhead limits are defined per pod, the total capacity must be calculated across all pods.</li><li>The decoration order of Circuit Breaker and Retry must be chosen deliberately.</li></ul><p><strong>6. Virtual Threads and Operational Observability</strong></p><p>Virtual Threads reduce platform-thread consumption while waiting for I/O. However, they do not accelerate CPU-bound operations or increase limited resources such as database connections.</p><p>Spring Boot configuration:</p><p>spring.threads.virtual.enabled=true</p><p>JEP 491, introduced in Java 24, significantly reduced Virtual Thread pinning caused by synchronized. Nevertheless, native methods and certain special cases should still be monitored with JFR.</p><p>Key metrics to monitor:</p><p><strong>Area &amp; Metrics</strong></p><ul><li><strong>HTTP:</strong> RPS, p95/p99, 429, 503</li><li><strong>Database:</strong> Active connections, pending requests, acquisition time</li><li><strong>Admission:</strong> Available Semaphore permits, rejected requests</li><li><strong>Resilience:</strong> Retries, timeouts, Bulkhead rejections, Circuit Breaker state</li><li><strong>JVM:</strong> CPU, Heap, GC, Virtual Thread pinning</li></ul><p>Application metrics can be monitored using Micrometer, Prometheus, and Grafana. JFR/JMC can be used to investigate JVM and Virtual Thread behavior.</p><p><strong>7. Conclusion: Managing Capacity Instead of Simply Increasing It</strong></p><p>Virtual Threads provide high concurrency, but they do not make system resources unlimited.</p><p>The right approach for high-traffic Java applications is to:</p><ol><li>Apply Rate Limiting at the Gateway.</li><li>Protect application capacity with Admission Control and Load Shedding.</li><li>Execute accepted work efficiently using Virtual Threads.</li><li>Manage database access with Semaphore and HikariCP.</li><li>Isolate external services with Bulkhead.</li><li>Use Timeout, Circuit Breaker, and controlled Retry.</li><li>Recalculate total capacity when the number of pods changes.</li><li>Continuously monitor the system using JFR and application metrics.</li></ol><p><strong>A resilient system is not one that accepts every request. It is one that behaves predictably when capacity is reached, isolates failures in dependent services, and returns to normal operation when those failures are resolved.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6cf9288e6fcf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Records]]></title>
            <link>https://medium.com/@mkonca/java-records-e4e2a5aeaaa8?source=rss-e6afd92b93db------2</link>
            <guid isPermaLink="false">https://medium.com/p/e4e2a5aeaaa8</guid>
            <category><![CDATA[java-records]]></category>
            <category><![CDATA[java-21-features]]></category>
            <category><![CDATA[dto]]></category>
            <dc:creator><![CDATA[mkonca]]></dc:creator>
            <pubDate>Fri, 30 Oct 2026 13:16:56 GMT</pubDate>
            <atom:updated>2026-10-30T13:16:56.613Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Java Records: Daha Sade, Güvenli ve Okunabilir Veri Modelleri Geliştirmek</strong></p><p><em>Java 21 ile record kullanımını anlamak, immutable veri modelleri oluşturmak ve kurumsal uygulamalarda doğru tasarım kararları vermek.</em></p><p><strong>Giriş: Her veri nesnesi için neden bu kadar fazla kod yazıyoruz?</strong></p><p>Java ile geliştirme yaparken sık karşılaştığımız ihtiyaçlardan biri, belirli verileri bir arada taşımaktır. Bir müşterinin bilgilerini, bir API isteğini, bir servis yanıtını veya bir işlem sonucunu temsil etmek için genellikle sınıflar oluştururuz.</p><p>Örneğin basit bir müşteri veri nesnesi hazırlamak istediğimizi düşünelim:</p><pre>public class CustomerDto {<br><br>    private final Long id;<br>    private final String firstName;<br>    private final String lastName;<br>    private final String email;<br><br>    public CustomerDto(<br>            Long id,<br>            String firstName,<br>            String lastName,<br>            String email) {<br>        this.id = id;<br>        this.firstName = firstName;<br>        this.lastName = lastName;<br>        this.email = email;<br>    }<br><br>    public Long getId() {<br>        return id;<br>    }<br><br>    public String getFirstName() {<br>        return firstName;<br>    }<br><br>    public String getLastName() {<br>        return lastName;<br>    }<br><br>    public String getEmail() {<br>        return email;<br>    }<br><br>    // equals(), hashCode() ve toString()<br>    // metotlarının da eklenmesi gerekir.<br>}</pre><p>Burada dikkat edersek sınıfın temel amacı yalnızca dört alanı bir arada taşımak. Buna rağmen constructor, getter, equals(), hashCode() ve toString() gibi tekrar eden kodlarla uğraşıyoruz.</p><p>Peki, bu tür veri nesnelerini çok daha az kodla tanımlayabilir miyiz?</p><p>Java 14 ile preview olarak sunulan ve Java 16 ile kalıcı hale gelen record özelliği tam olarak bu ihtiyaca cevap veriyor.</p><p>Record sayesinde veri taşıma amacıyla kullanılan sınıfları daha kısa, anlaşılır ve varsayılan olarak immutable olacak şekilde tanımlayabiliriz.</p><p>Java 21 ile birlikte record kullanımı artık modern Java uygulamalarında değerlendirilmesi gereken temel dil özelliklerinden biridir.</p><p><strong>1. Record nedir ve nasıl çalışır?</strong></p><p>Record, Java’da veri taşıyan nesneleri tanımlamak için kullanılan özel bir sınıf türüdür.</p><p>Yukarıdaki müşteri sınıfını record ile yeniden yazalım:</p><pre>public record CustomerDto(<br>        Long id,<br>        String firstName,<br>        String lastName,<br>        String email) {<br>}</pre><p>Dikkat ederseniz daha önce onlarca satırda tanımladığımız veri nesnesini artık tek bir tanımlamayla oluşturabiliyoruz.</p><p>Java derleyicisi record için otomatik olarak aşağıdaki üyeleri oluşturur:</p><ul><li>Her bileşen için private ve final bir alan.</li><li>Bütün bileşenleri parametre olarak alan canonical constructor.</li><li>Her bileşen için erişim metodu.</li><li>equals() ve hashCode() metotları.</li><li>toString() metodu.</li></ul><p>Kullanımı ise oldukça basittir:</p><pre>CustomerDto customer = new CustomerDto(<br>        1001L,<br>        &quot;Ahmet&quot;,<br>        &quot;Yılmaz&quot;,<br>        &quot;ahmet@example.com&quot;<br>);<br><br>System.out.println(customer.firstName());<br>System.out.println(customer.email());</pre><p>Burada önemli bir farklılık var. Geleneksel Java sınıflarındaki getFirstName() yerine record bileşeninin adıyla tanımlanan firstName() metodunu kullanıyoruz.</p><p>Record bileşenlerine doğrudan erişim sağlanmaz; bu metotlar ilgili alanların değerini döndürür.</p><p>Peki, bu kadar az kod yazmamızın arkasında nasıl bir davranış var?</p><p>Record sınıfları java.lang.Record sınıfından örtük olarak türetilir. Tanımladığımız bileşenler constructor ve erişim metotlarıyla birlikte sınıfın temel veri modelini oluşturur.</p><p><strong>2. Record neden immutable olarak kabul edilir?</strong></p><p>Record kullanımının en önemli avantajlarından biri, veri nesnelerinin değiştirilemez (immutable) bir yapıda tanımlanmasını kolaylaştırmasıdır.</p><p>Örneğin:</p><pre>CustomerDto customer = new CustomerDto(<br>        1001L,<br>        &quot;Ahmet&quot;,<br>        &quot;Yılmaz&quot;,<br>        &quot;ahmet@example.com&quot;<br>);<br><br>customer.firstName = &quot;Mehmet&quot;; // Derleme hatası</pre><p>Record bileşenlerine karşılık gelen alanlar private final olarak oluşturulduğu için doğrudan değer ataması yapılamaz.</p><p>Ayrıca record içerisinde bileşenlere karşılık gelen alanları yeniden tanımlayamayız veya bunlara setter metotları ekleyemeyiz.</p><p>Bu özellik özellikle çok katmanlı ve eşzamanlı çalışan kurumsal uygulamalarda faydalıdır. Bir servis tarafından oluşturulan veri nesnesinin başka bir katmanda beklenmedik biçimde değiştirilmesi engellenir.</p><p>Ancak burada önemli bir ayrıntı var: Record’un immutable olması, içerisindeki bütün nesnelerin de otomatik olarak immutable olduğu anlamına gelmez.</p><p>Örneğin:</p><p>public record OrderDto(</p><p>List&lt;String&gt; products) {</p><p>}</p><p>Bu record içerisindeki products alanına yeni bir liste atayamayız. Ancak record oluşturulduktan sonra listeye yeni eleman eklenebilir:</p><p>List&lt;String&gt; products = new ArrayList&lt;&gt;();</p><p>products.add(“Laptop”);</p><p>OrderDto order = new OrderDto(1L, products);</p><p>order.products().add(“Keyboard”);</p><p>Bu kod çalışır. Çünkü record alanının referansı değiştirilemez; ancak referansın gösterdiği liste değiştirilebilir.</p><p>Gerçek anlamda daha güvenli bir veri modeli oluşturmak için defensive copy kullanabiliriz:</p><p>public record OrderDto(</p><p>Long id,</p><p>List&lt;String&gt; products) {</p><p>public OrderDto {</p><p>products = List.copyOf(products);</p><p>}</p><p>}</p><p>Artık dışarıdan gönderilen liste kopyalanarak değiştirilemez bir listeye dönüştürülür.</p><p>List&lt;String&gt; products = new ArrayList&lt;&gt;();</p><p>products.add(“Laptop”);</p><p>OrderDto order = new OrderDto(1L, products);</p><p>products.add(“Keyboard”);</p><p>System.out.println(order.products());</p><p>// [Laptop]</p><p>Burada kullandığımız List.copyOf() yalnızca listenin yapısını korur. Liste elemanları mutable nesneler ise onların iç durumlarının değişmesini engellemez.</p><p>Dolayısıyla record kullanırken yalnızca alanların final olmasına değil, içerdikleri nesnelerin değiştirilebilir olup olmadığına da dikkat etmeliyiz.</p><p><strong>3. Constructor ve validation kullanımı</strong></p><p>Record’lar yalnızca veri taşımak için kullanılan basit yapılar olmak zorunda değildir. Nesne oluşturulurken geçerlilik kontrolleri de yapabiliriz.</p><p>Bunun için compact constructor özelliğini kullanabiliriz.</p><p>Örneğin bir müşterinin e-posta adresinin boş olmaması gerektiğini düşünelim:</p><p>public record CustomerDto(</p><p>Long id,</p><p>String firstName,</p><p>String lastName,</p><p>String email) {</p><p>public CustomerDto {</p><p>if (id == null || id &lt;= 0) {</p><p>throw new IllegalArgumentException(</p><p>“Customer id must be positive”);</p><p>}</p><p>if (email == null || email.isBlank()) {</p><p>throw new IllegalArgumentException(</p><p>“Email cannot be empty”);</p><p>}</p><p>}</p><p>}</p><p>Burada constructor parametrelerini ayrıca tanımlamadığımıza dikkat edin. Compact constructor içerisinde record bileşenlerine doğrudan erişebiliriz.</p><p>Java, constructor tamamlandığında bu parametreleri ilgili alanlara atar.</p><p>Bu yaklaşım sayesinde nesnenin geçersiz bir durumda oluşturulmasını engelleyebiliriz.</p><p>Daha geleneksel bir constructor da tanımlayabiliriz:</p><p>public record Money(</p><p>BigDecimal amount,</p><p>String currency) {</p><p>public Money(BigDecimal amount, String currency) {</p><p>if (amount == null || amount.signum() &lt; 0) {</p><p>throw new IllegalArgumentException(</p><p>“Invalid amount”);</p><p>}</p><p>if (currency == null || currency.isBlank()) {</p><p>throw new IllegalArgumentException(</p><p>“Currency is required”);</p><p>}</p><p>this.amount = amount;</p><p>this.currency = currency;</p><p>}</p><p>}</p><p>Burada canonical constructor’ın bütün bileşenleri aynı sırayla ve aynı türlerle karşılaması gerekir.</p><p>Peki, Spring Boot uygulamalarında Bean Validation kullanmak istersek ne yapmalıyız?</p><p>Record bileşenlerine standart validation anotasyonları ekleyebiliriz:</p><p>public record CreateCustomerRequest(</p><p>@NotBlank</p><p>String firstName,</p><p>@NotBlank</p><p>String lastName,</p><p>@NotBlank</p><p>@Email</p><p>String email) {</p><p>}</p><p>Controller tarafında ise normal DTO kullanımına benzer biçimde doğrulama yapabiliriz:</p><p>@RestController</p><p>@RequestMapping(“/api/customers”)</p><p>class CustomerController {</p><p>@PostMapping</p><p>public ResponseEntity&lt;Void&gt; create(</p><p>@Valid @RequestBody CreateCustomerRequest request) {</p><p>return ResponseEntity.accepted().build();</p><p>}</p><p>}</p><p>Bunun için Spring Boot uygulamasında uygun Bean Validation bağımlılığının bulunması gerekir.</p><p>Burada constructor doğrulaması ile Bean Validation arasında bir ayrım vardır. Constructor doğrulaması nesnenin her oluşturulma girişiminde çalışırken, Bean Validation ilgili nesne doğrulama mekanizması çağrıldığında devreye girer.</p><p><strong>4. Record içerisinde metot tanımlayabilir miyiz?</strong></p><p>Record yalnızca alanlardan oluşan bir veri yapısı değildir. Normal sınıflarda olduğu gibi metotlar da tanımlayabiliriz.</p><p>Örneğin müşterinin tam adını döndüren bir metot ekleyelim:</p><p>public record CustomerDto(</p><p>Long id,</p><p>String firstName,</p><p>String lastName,</p><p>String email) {</p><p>public String fullName() {</p><p>return firstName + “ “ + lastName;</p><p>}</p><p>}</p><p>Kullanımı:</p><p>CustomerDto customer = new CustomerDto(</p><p>1001L,</p><p>“Ahmet”,</p><p>“Yılmaz”,</p><p>“ahmet@example.com”</p><p>);</p><p>System.out.println(customer.fullName());</p><p>Ayrıca static metotlar ve static alanlar da tanımlayabiliriz.</p><p>public record Temperature(double value) {</p><p>public static Temperature fromCelsius(double value) {</p><p>return new Temperature(value);</p><p>}</p><p>public double toFahrenheit() {</p><p>return (value * 9 / 5) + 32;</p><p>}</p><p>}</p><p>Bu örnekte record hem veri taşımakta hem de veriye bağlı bir dönüşüm davranışı sunmaktadır.</p><p>Ancak record’u kapsamlı iş mantığı barındıran bir sınıfa dönüştürmek yerine, temel veri modelini ve onunla doğrudan ilişkili davranışları tanımlamak daha anlaşılır bir tasarım sağlar.</p><p><strong>5. Record ile interface kullanabilir miyiz?</strong></p><p>Evet. Record sınıfları interface implement edebilir.</p><p>Örneğin farklı ödeme türlerini ortak bir sözleşme üzerinden temsil etmek istediğimizi düşünelim:</p><p>public interface PaymentMethod {</p><p>String description();</p><p>}</p><p>Record kullanarak kredi kartı ödeme modelini tanımlayabiliriz:</p><p>public record CreditCardPayment(</p><p>String cardHolder,</p><p>String lastFourDigits)</p><p>implements PaymentMethod {</p><p>@Override</p><p>public String description() {</p><p>return “Credit card ending with “ + lastFourDigits;</p><p>}</p><p>}</p><p>Aynı interface’i başka bir record da uygulayabilir:</p><p>public record BankTransferPayment(</p><p>String iban)</p><p>implements PaymentMethod {</p><p>@Override</p><p>public String description() {</p><p>return “Bank transfer: “ + iban;</p><p>}</p><p>}</p><p>Böylece farklı veri modellerini ortak bir interface üzerinden kullanabiliriz.</p><p>Record’lar başka bir sınıftan türetilemez; çünkü zaten örtük olarak java.lang.Record sınıfından türetilirler. Ancak interface implement edebilirler.</p><p>Bu özellik, özellikle farklı veri tiplerinin ortak bir sözleşme üzerinden yönetildiği uygulamalarda faydalıdır.</p><p><strong>6. Record ile DTO tasarlamak</strong></p><p>Record kullanımının en yaygın ve faydalı alanlarından biri DTO (Data Transfer Object) tasarımıdır.</p><p>Özellikle REST API geliştirdiğimiz Spring Boot uygulamalarında request ve response modellerini record ile tanımlayabiliriz.</p><p>Örneğin müşteri oluşturma isteği:</p><p>public record CreateCustomerRequest(</p><p>String firstName,</p><p>String lastName,</p><p>String email) {</p><p>}</p><p>Servis yanıtı:</p><p>public record CustomerResponse(</p><p>Long id,</p><p>String fullName,</p><p>String email) {</p><p>}</p><p>Controller:</p><p>@RestController</p><p>@RequestMapping(“/api/customers”)</p><p>class CustomerController {</p><p>private final CustomerService customerService;</p><p>CustomerController(CustomerService customerService) {</p><p>this.customerService = customerService;</p><p>}</p><p>@PostMapping</p><p>public ResponseEntity&lt;CustomerResponse&gt; create(</p><p>@Valid @RequestBody CreateCustomerRequest request) {</p><p>CustomerResponse response =</p><p>customerService.create(request);</p><p>return ResponseEntity.ok(response);</p><p>}</p><p>}</p><p>Bu kullanımda request ve response modelleri yalnızca veri taşımakla görevli oldukları için record oldukça uygun bir seçenektir.</p><p>Jackson gibi modern JSON kütüphaneleri record desteği sunar. Dolayısıyla uygun sürümlerde ekstra getter veya özel constructor yapılandırması olmadan JSON dönüşümü gerçekleştirilebilir.</p><p>Örneğin aşağıdaki JSON içeriği:</p><p>{</p><p>“id”: 1001,</p><p>“fullName”: “Ahmet Yılmaz”,</p><p>“email”: “ahmet@example.com”</p><p>}</p><p>CustomerResponse record nesnesine dönüştürülebilir.</p><p>Bununla birlikte kullanılan Jackson sürümünün record desteği ve özel JSON isimlendirme gereksinimleri kontrol edilmelidir.</p><p><strong>7. Record ile JPA Entity oluşturabilir miyiz?</strong></p><p>Bu konu özellikle kurumsal Java uygulamalarında dikkat edilmesi gereken noktalardan biridir.</p><p>İlk bakışta JPA entity sınıflarını da record olarak tanımlamak cazip gelebilir. Çünkü entity içerisinde de alanlar, constructor ve veri erişim metotları bulunur.</p><p>Ancak standart JPA entity gereksinimleri record yapısıyla uyumlu değildir.</p><p>JPA entity sınıfları genel olarak:</p><ul><li>Final olmamalıdır.</li><li>Public veya protected parametresiz constructor içermelidir.</li><li>Persistence provider tarafından yönetilmeye uygun olmalıdır.</li><li>Proxy ve lazy loading gibi mekanizmalarla uyumlu olmalıdır.</li></ul><p>Record sınıfları ise final’dır, final olmayan bir entity gibi genişletilemez ve record bileşenlerinin oluşturulma biçimi standart entity gereksinimleriyle uyuşmaz.</p><p>Bu nedenle standart JPA entity’leri record olarak tanımlamak doğru yaklaşım değildir.</p><p>Bunun yerine entity ve DTO ayrımını koruyabiliriz:</p><p>@Entity</p><p>@Table(name = “CUSTOMER”)</p><p>public class CustomerEntity {</p><p>@Id</p><p>private Long id;</p><p>private String firstName;</p><p>private String lastName;</p><p>private String email;</p><p>protected CustomerEntity() {</p><p>}</p><p>// Constructor, getter ve diğer metotlar</p><p>}</p><p>Veritabanından aldığımız veriyi API katmanına aktarırken record kullanabiliriz:</p><p>public record CustomerResponse(</p><p>Long id,</p><p>String fullName,</p><p>String email) {</p><p>}</p><p>Dönüşüm işlemi:</p><p>public CustomerResponse toResponse(CustomerEntity entity) {</p><p>return new CustomerResponse(</p><p>entity.getId(),</p><p>entity.getFirstName() + “ “ + entity.getLastName(),</p><p>entity.getEmail()</p><p>);</p><p>}</p><p>Bu yaklaşımda JPA entity yaşam döngüsü ile API veri modeli birbirinden ayrılmış olur.</p><p>Özetle record, DTO ve projection gibi veri taşıma modellerinde güçlü bir seçenektir; standart JPA entity sınıflarının yerine kullanılmamalıdır.</p><p><strong>8. Record ile Generic veri modelleri oluşturmak</strong></p><p>Record’ların bir diğer avantajı generic tiplerle birlikte kullanılabilmeleridir.</p><p>Örneğin API yanıtlarının ortak bir formatta dönmesini istediğimizi düşünelim.</p><p>Her servis için ayrı response sınıfı oluşturmak yerine generic bir record tanımlayabiliriz:</p><p>public record ApiResponse&lt;T&gt;(</p><p>boolean success,</p><p>T data,</p><p>String message) {</p><p>}</p><p>Bu modeli farklı veri türleriyle kullanabiliriz:</p><p>ApiResponse&lt;CustomerResponse&gt; customerResponse =</p><p>new ApiResponse&lt;&gt;(</p><p>true,</p><p>new CustomerResponse(</p><p>1001L,</p><p>“Ahmet Yılmaz”,</p><p>“ahmet@example.com”),</p><p>“Customer retrieved successfully”</p><p>);</p><p>Liste dönen bir servis için de kullanabiliriz:</p><p>ApiResponse&lt;List&lt;CustomerResponse&gt;&gt; response =</p><p>new ApiResponse&lt;&gt;(</p><p>true,</p><p>customerList,</p><p>“Customers retrieved successfully”</p><p>);</p><p>Bu yaklaşım API yanıtlarının standartlaştırılmasına yardımcı olur.</p><p>Ancak her API yanıtını aynı generic yapıya zorlamak da doğru olmayabilir. Hata yanıtları, sayfalama bilgileri ve farklı iş gereksinimleri için ayrı modeller daha anlaşılır olabilir.</p><p><strong>9. Record ve equals/hashCode davranışı</strong></p><p>Record kullanırken önemli avantajlardan biri, equals() ve hashCode() metotlarının otomatik oluşturulmasıdır.</p><p>Normal sınıflarda bu metotları çoğu zaman kendimiz yazmak veya IDE üzerinden üretmek zorunda kalırız.</p><p>Record içerisinde ise bileşenlerin değerleri karşılaştırılır.</p><p>public record Product(</p><p>Long id,</p><p>String name,</p><p>BigDecimal price) {</p><p>}</p><p>İki farklı nesne oluşturalım:</p><p>Product product1 =</p><p>new Product(1L, “Laptop”, new BigDecimal(“45000”));</p><p>Product product2 =</p><p>new Product(1L, “Laptop”, new BigDecimal(“45000”));</p><p>System.out.println(product1.equals(product2));</p><p>// true</p><p>Nesnelerin referansları farklı olsa da bileşen değerleri eşit olduğu için sonuç true olur.</p><p>Bu özellik record’ları özellikle Map anahtarı, Set elemanı ve değer nesnesi (Value Object) olarak kullanırken faydalı hale getirir.</p><p>Ancak bir ayrıntıya dikkat etmeliyiz: BigDecimal.equals() ölçek bilgisini de dikkate alır. Örneğin 10.0 ile 10.00 değerleri equals() açısından eşit değildir. Dolayısıyla record’un değer karşılaştırması, bileşenlerin kendi eşitlik davranışlarını kullanır.</p><p><strong>10. Record kullanırken performans kazanır mıyız?</strong></p><p>Record kullanımının temel amacı daha hızlı kod çalıştırmak değildir. Esas kazanım, daha sade ve güvenli veri modelleri oluşturmaktır.</p><p>Record kullanmak otomatik olarak daha az bellek tüketimi veya daha hızlı uygulama anlamına gelmez. Record nesneleri de JVM üzerinde normal nesneler gibi oluşturulur ve garbage collection süreçlerine tabidir.</p><p>Bununla birlikte record kullanımının dolaylı faydaları olabilir:</p><ul><li>Tekrarlanan constructor ve getter kodları ortadan kalkar.</li><li>Veri modelleri daha kolay okunur.</li><li>Gereksiz setter metotları oluşturulmaz.</li><li>Değer tabanlı eşitlik davranışı hazır gelir.</li><li>Immutable veri modeli oluşturmak kolaylaşır.</li></ul><p>Özellikle yüksek hacimli veri işleyen batch uygulamalarında record kullanmak, veri taşıma modellerini sadeleştirebilir. Ancak performans kazanımı beklentisi varsa gerçek iş yükü üzerinden JMH gibi benchmark araçlarıyla ölçüm yapılmalıdır.</p><p><strong>11. Java 21 ile Record kullanımını nasıl değerlendirmeliyiz?</strong></p><p>Java 21, record kullanımının yerleşik ve olgun bir dil özelliği olarak değerlendirilebildiği bir sürümdür. Record’ların yanında Java 21 ile gelen pattern matching özellikleri de veri modellerinin kullanımını kolaylaştırır.</p><p>Örneğin instanceof pattern matching ile record türlerini daha sade biçimde kontrol edebiliriz:</p><p>public void process(Object value) {</p><p>if (value instanceof CustomerResponse customer) {</p><p>System.out.println(customer.fullName());</p><p>}</p><p>}</p><p>Java 21&#39;de switch pattern matching de kalıcı bir özelliktir. Record pattern ise Java 21&#39;de preview kapsamındadır ve kullanılabilmesi için preview özelliklerinin etkinleştirilmesi gerekir.</p><p>Bu nedenle üretim projelerinde record pattern kullanmadan önce derleme ve çalışma zamanı yapılandırması değerlendirilmelidir.</p><p>Özellikle Java 21&#39;e geçiş yapan kurumsal uygulamalarda record kullanımı, DTO ve değer nesnelerinin sadeleştirilmesi için iyi bir başlangıç noktasıdır.</p><p><strong>12. Hangi durumlarda Record kullanmalıyız?</strong></p><p>Artık record’un ne olduğunu ve nasıl çalıştığını gördük. Peki, her Java sınıfını record olarak tanımlamak doğru mudur?</p><p>Elbette hayır.</p><p>Record özellikle nesnenin temel amacının veri taşımak olduğu durumlarda tercih edilmelidir.</p><p>Örneğin aşağıdaki kullanım alanları oldukça uygundur:</p><ul><li>REST API request ve response modelleri</li><li>DTO sınıfları</li><li>Değer nesneleri (Value Object)</li><li>Servisler arasında taşınan immutable veri modelleri</li><li>Raporlama ve sorgu sonuçları</li><li>Event ve mesaj payload’ları</li><li>Hesaplama sonuçlarını temsil eden veri yapıları</li></ul><p>Buna karşılık aşağıdaki durumlarda normal sınıflar daha uygun olabilir:</p><ul><li>Durumu zaman içinde değişen nesneler</li><li>Karmaşık yaşam döngüsüne sahip domain nesneleri</li><li>Standart JPA entity sınıfları</li><li>Kalıtım gerektiren sınıf hiyerarşileri</li><li>Setter ve proxy davranışına ihtiyaç duyan nesneler</li></ul><p>Buradaki temel tasarım kriteri basittir: Bir nesne esas olarak değerleri temsil ediyorsa record güçlü bir seçenektir. Ancak nesnenin değişen bir durumu, yaşam döngüsü veya karmaşık davranışları varsa normal sınıf kullanmak daha doğru olabilir.</p><p><strong>Sonuç: Daha az kod, daha net veri modelleri</strong></p><p>Java record özelliği, uzun süredir Java geliştiricilerinin karşılaştığı tekrar eden veri taşıma sınıfı problemlerine sade bir çözüm sunuyor.</p><p>Constructor, getter, equals(), hashCode() ve toString() gibi tekrar eden kodların otomatik oluşturulması sayesinde veri modelleri daha okunabilir hale geliyor. Ayrıca final alanlar ve değer tabanlı eşitlik davranışı, immutable tasarımları kolaylaştırıyor.</p><p>Özellikle Java 21 ve Spring Boot tabanlı kurumsal uygulamalarda DTO, API response, projection ve Value Object tasarımlarında record kullanımı önemli bir avantaj sağlayabilir.</p><p>Ancak her sınıfı record’a dönüştürmek doğru bir yaklaşım değildir. JPA entity’leri, değiştirilebilir domain nesneleri ve karmaşık yaşam döngüsüne sahip sınıflar için geleneksel sınıf yapısı hâlâ gereklidir.</p><p><strong>Önemli olan daha az kod yazmak değil, nesnenin sorumluluğunu en doğru şekilde ifade eden Java yapısını seçmektir. Record, veri odaklı modeller için bu seçimi oldukça kolaylaştırır.</strong></p><p><strong>Kaynaklar</strong></p><ol><li><a href="https://docs.oracle.com/en/java/javase/21/language/records.html">Oracle Java 21 Documentation — Records</a></li><li><a href="https://openjdk.org/jeps/395">JEP 395 — Records</a></li><li><a href="https://openjdk.org/jeps/440">JEP 440 — Record Patterns</a></li><li><a href="https://openjdk.org/jeps/441">JEP 441 — Pattern Matching for switch</a></li><li><a href="https://jakarta.ee/specifications/persistence/">Jakarta Persistence Specification</a></li><li><a href="https://github.com/FasterXML/jackson-databind">Jackson Databind Documentation</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e4e2a5aeaaa8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Testing Java Architecture with ArchUnit]]></title>
            <link>https://medium.com/@mkonca/testing-java-architecture-with-archunit-26c6feb54c58?source=rss-e6afd92b93db------2</link>
            <guid isPermaLink="false">https://medium.com/p/26c6feb54c58</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[archunit]]></category>
            <category><![CDATA[layered-architecture]]></category>
            <category><![CDATA[modernization]]></category>
            <dc:creator><![CDATA[mkonca]]></dc:creator>
            <pubDate>Wed, 28 Oct 2026 06:31:36 GMT</pubDate>
            <atom:updated>2026-10-28T06:31:36.897Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Enforcing Architectural Rules Through Code</strong></p><p><em>How to protect architectural boundaries, control dependencies, and detect architectural drift automatically in CI/CD pipelines.</em></p><p><strong>Introduction: Our Tests Pass, but What About Our Architecture?</strong></p><p>Imagine we are developing a Java application. Our unit tests pass, our integration tests run successfully, and the application behaves as expected. Over time, however, new classes are introduced, existing services grow, and different teams begin working on different parts of the codebase.</p><p>Eventually, we may notice that some of the architectural rules we established at the beginning are gradually being violated. Controllers may start accessing repositories directly, the domain layer may become dependent on the application framework, or packages that were originally designed to remain independent may develop circular dependencies.</p><p>The interesting part is that our existing unit and integration tests may continue to pass throughout this process. That is because these tests primarily verify what the application does, rather than how its components are allowed to depend on one another.</p><p>So, how can we ensure that our architectural decisions remain valid as the codebase grows? Instead of relying exclusively on architecture documents or code reviews, can we turn these decisions into automated checks?</p><p>In the Java ecosystem, ArchUnit is one tool that helps us answer these questions.</p><p><strong>What Exactly Does ArchUnit Do?</strong></p><p>ArchUnit is a Java library that analyzes dependencies between classes and packages, allowing us to express architectural rules as executable tests.</p><p>In other words, we can translate certain design decisions directly into code. If we decide that controllers must not access repositories directly, for example, we can define an ArchUnit test to enforce that restriction.</p><p>When a developer introduces code that violates the rule, we do not have to wait for someone to discover the problem during code review. The violation can be detected automatically.</p><p>There is an important distinction to keep in mind: ArchUnit does not design our architecture for us. It does not automatically determine which dependencies are good or bad. We define the architectural rules, and ArchUnit checks whether our code complies with them.</p><p>This approach is particularly useful for layered architectures, modular monoliths, and enterprise Java applications where maintaining clear dependency boundaries is essential.</p><p><strong>Getting Started: Adding ArchUnit to a Java Project</strong></p><p>Let’s use Java 21, Maven, and JUnit 5 for our examples.</p><p>To get started, we can add the following dependency to our project’s pom.xml:</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;com.tngtech.archunit&lt;/groupId&gt;<br>    &lt;artifactId&gt;archunit-junit5&lt;/artifactId&gt;<br>    &lt;version&gt;${archunit.version}&lt;/version&gt;<br>    &lt;scope&gt;test&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><p>The archunit.version property should point to a verified, approved ArchUnit version. Since the dependency uses the test scope, ArchUnit is available during testing without requiring it as a production runtime dependency.</p><p>With this in place, we can define architectural rules in much the same way as ordinary tests.</p><p><strong>Protecting Boundaries in a Layered Architecture</strong></p><p>Let’s start with a familiar example. Suppose our application has the following package structure:</p><pre>com.example.application<br>├── controller<br>├── service<br>├── repository<br>├── domain<br>└── config</pre><p>In this design, controllers handle incoming requests, services implement business operations, and repositories manage data access.</p><p>We want to prevent controllers from accessing repositories directly. Otherwise, business rules implemented in the service layer could be bypassed, and the responsibilities of different layers could gradually become mixed.</p><p>How can we express this requirement with ArchUnit?</p><pre>@AnalyzeClasses(packages = &quot;com.example.application&quot;)<br>class ArchitectureTest {<br><br>    @ArchTest<br>    static final ArchRule controllersShouldNotAccessRepositories =<br>        noClasses()<br>            .that().resideInAPackage(&quot;..controller..&quot;)<br>            .should().dependOnClassesThat()<br>            .resideInAPackage(&quot;..repository..&quot;);<br>}</pre><p>The rule is straightforward: no class in the controller package should depend on a class in the repository package.</p><p>For example, directly injecting a CustomerRepository into a controller would violate this rule. We can detect the architectural violation without having to execute the corresponding business workflow.</p><p>We can apply the same principle to other layers as well. The key is to define which layers are allowed to depend on which others.</p><p><strong>Should the Domain Layer Remain Independent of Frameworks?</strong></p><p>Another important consideration in layered architecture is the responsibility of the domain layer.</p><p>The domain layer represents business concepts and business rules. If it becomes directly dependent on a framework such as Spring, the business logic may become unnecessarily tied to a particular technology.</p><p>Of course, complete framework independence is not a requirement for every project. However, if it is one of our architectural goals, we can enforce it automatically.</p><pre>@ArchTest<br>static final ArchRule domainShouldNotDependOnSpring =<br>    noClasses()<br>        .that().resideInAPackage(&quot;..domain..&quot;)<br>        .should().dependOnClassesThat()<br>        .resideInAPackage(&quot;org.springframework..&quot;);</pre><p>This rule prevents classes in the domain package from depending on Spring packages.</p><p>If someone introduces a Spring annotation or another Spring dependency into the domain layer, the architecture test can flag the change.</p><p>The benefit goes beyond keeping packages clean. It also helps us test business rules more independently and reduces the impact of potential technology changes on the domain model.</p><p><strong>Another Common Problem: Circular Dependencies Between Packages</strong></p><p>As an application grows, circular dependencies can become increasingly difficult to manage.</p><p>Imagine that the customer package depends on the order package, the order package depends on the payment package, and the payment package depends on the customer package again.</p><p>What initially looks like a minor dependency issue can make components harder to understand, test, and develop independently.</p><p>A change in one package may affect several others. Testing becomes more complicated, and separating modules later can become significantly more expensive.</p><p>ArchUnit provides the slices API to check for cycles between packages:</p><pre>@ArchTest<br>static final ArchRule packagesShouldBeFreeOfCycles =<br>    slices()<br>        .matching(&quot;com.example.application.(*)..&quot;)<br>        .should().beFreeOfCycles();</pre><p>In this example, ArchUnit groups packages into slices according to the matching pattern and checks that these slices do not have circular dependencies.</p><p>The matching expression must reflect the actual package structure. Otherwise, ArchUnit may not analyze the intended modules in the way we expect.</p><p>The broader lesson is that we do not have to rely exclusively on code reviews to identify dependency cycles. We can establish an automated rule that detects them as part of our regular testing process.</p><p><strong>Is ArchUnit Only Useful for Layered Architectures?</strong></p><p>Not at all. One of the areas where ArchUnit becomes particularly valuable is the modular monolith architecture.</p><p>A modular monolith can run as a single deployable application while organizing its code into distinct business modules, such as customer, order, and payment.</p><p>For example, our package structure might look like this:</p><pre>com.example<br>├── customer<br>│   ├── api<br>│   ├── application<br>│   ├── domain<br>│   └── infrastructure<br>├── order<br>│   ├── api<br>│   ├── application<br>│   ├── domain<br>│   └── infrastructure<br>└── payment<br>    ├── api<br>    ├── application<br>    ├── domain<br>    └── infrastructure</pre><p>Creating these packages is only the first step. Even when modules are separated structurally, their boundaries can gradually disappear if one module is allowed to access another module’s internal implementation details directly.</p><p>Suppose we want to prevent the order module from accessing the customer module’s infrastructure classes.</p><p>We can define the following rule:</p><pre>@ArchTest<br>static final ArchRule orderShouldNotAccessCustomerInfrastructure =<br>    noClasses()<br>        .that().resideInAPackage(&quot;..order..&quot;)<br>        .should().dependOnClassesThat()<br>        .resideInAPackage(&quot;..customer.infrastructure..&quot;);</pre><p>This rule prevents the order module from depending on classes in customer.infrastructure.</p><p>Does this mean the order module must never obtain information from the customer module? Of course not. The goal is not to eliminate all communication between modules, but to make that communication explicit and controlled.</p><p>Modules can interact through defined APIs or appropriate service interfaces. This allows the internal implementation of one module to evolve without unnecessarily affecting the others.</p><p>This becomes particularly important in large enterprise applications. The long-term maintainability of a modular monolith depends not only on defining modules, but also on preserving their boundaries.</p><p><strong>Can ArchUnit Help with Legacy Java Modernization?</strong></p><p>Absolutely. Architectural tests can be especially useful when modernizing long-running enterprise Java applications.</p><p>When migrating an application to Java 21 or moving it from an application server such as WebSphere to another runtime, resolving compilation errors is not the only concern. We also need to understand and control dependencies on legacy APIs and runtime-specific technologies.</p><p>For example, suppose we want to prevent the domain layer from depending on the Servlet API. We could define the following rule:</p><pre>@ArchTest<br>static final ArchRule domainShouldNotDependOnJavaxServlet =<br>    noClasses()<br>        .that().resideInAPackage(&quot;..domain..&quot;)<br>        .should().dependOnClassesThat()<br>        .resideInAPackage(&quot;javax.servlet..&quot;);</pre><p>This rule prevents classes in the domain layer from depending on the javax.servlet package.</p><p>There is an important detail here: we should not treat every javax.* package as obsolete. During the transition from Java EE to Jakarta EE, some APIs moved to the jakarta.* namespace, while certain Java SE javax packages remain valid. The restrictions must therefore reflect the project’s actual modernization objectives.</p><p>Similarly, if we want to prevent business-layer code from depending on application-server-specific APIs, we can create rules that restrict access to the relevant packages.</p><p>ArchUnit’s role should be clearly understood in this context. It helps us inspect where dependencies occur and whether they violate our architectural boundaries. It does not manage dependency versions or independently scan for known security vulnerabilities. Those responsibilities belong to complementary tools, such as Maven Enforcer and software composition analysis solutions.</p><p><strong>What If the Existing Project Already Contains Architectural Violations?</strong></p><p>In a large application that has been developed for many years, it may be unrealistic to expect every architectural rule to be satisfied from day one. Once we introduce ArchUnit, we may discover a considerable number of existing violations.</p><p>Instead of trying to fix everything at once, a gradual approach is usually more practical.</p><p>We can begin by examining the existing dependency structure and identifying the most critical architectural boundaries. Then we can introduce rules that prevent new violations while addressing existing problems according to their priority.</p><p>For example, we might start by controlling direct dependencies between controllers and repositories and eliminating circular package dependencies. In subsequent stages, we can restrict access between modules and introduce rules governing legacy API usage.</p><p>This approach makes architectural improvement part of the ongoing development process rather than turning it into a large, risky rewrite.</p><p>It is important to remember that ArchUnit does not automatically repair existing violations. It identifies situations that break the rules we have defined; resolving those violations still requires deliberate architectural and development decisions.</p><p><strong>Integrating Architecture Tests into CI/CD</strong></p><p>After defining our ArchUnit rules, we should not limit their execution to developers’ local environments. Their real value becomes more apparent when they are integrated into continuous integration.</p><p>In a Maven project, we can execute the tests with the following command:</p><p>mvn clean verify</p><p>ArchUnit tests run as part of the Maven verification process. If an architectural rule is violated, the corresponding test fails.</p><p>For example, we could define a GitLab CI job as follows:</p><pre>stages:<br>  - test<br>  - verify<br><br>architecture-test:<br>  stage: verify<br>  image: maven:3-eclipse-temurin-21<br>  script:<br>    - mvn --batch-mode clean verify</pre><p>This is a basic example. In an enterprise environment, we should use approved Java and Maven images and configure access to the organization’s dependency repository. We should also consider whether mvn clean verify would repeat tests that are already executed elsewhere in the pipeline.</p><p>The next step is to make successful architecture tests a requirement for merging changes. This allows us to detect architectural violations before code reaches the main branch.</p><p>At that point, architectural compliance becomes more than a documented expectation. It becomes a verifiable condition in the software delivery process.</p><p><strong>Is ArchUnit Enough on Its Own?</strong></p><p>ArchUnit can play a central role in architectural testing, but we should not expect one tool to cover every software quality requirement.</p><p>We can use ArchUnit to validate dependencies between packages, Maven Enforcer to enforce dependency-management rules, and OWASP Dependency-Check or another suitable software composition analysis tool to identify known vulnerabilities. Unit, integration, and system tests remain necessary to verify runtime behavior.</p><p>Each tool should have a clearly defined responsibility. ArchUnit’s strength lies in checking whether the code respects the architectural boundaries we have established.</p><p>We should also avoid turning every conceivable design preference into a test. Rules that do not correspond to meaningful architectural requirements, or that repeatedly produce unnecessary failures, can eventually undermine the team’s confidence in the testing process.</p><p>A better approach is to identify the most important architectural decisions and protect them with clear, maintainable tests.</p><p><strong>Conclusion: Architectural Decisions Should Be Testable</strong></p><p>Software architecture is not limited to the decisions made during the initial design phase. As a codebase grows, new modules are introduced, and different teams contribute to development, those decisions need to be preserved.</p><p>ArchUnit allows us to turn architectural rules into automated tests by analyzing dependencies between Java classes and packages. We can protect layer boundaries, detect circular dependencies, and prevent modules in a modular monolith from accessing one another’s internal implementation details without control.</p><p>This approach is particularly valuable for large enterprise Java applications and modernization initiatives, where it is important not only to preserve the existing architecture but also to ensure that new development remains aligned with the target design.</p><p>Ultimately, designing a good architecture is only part of the challenge. We also need mechanisms that help us preserve it over time.</p><p><strong>That is where ArchUnit delivers its core value: instead of leaving architectural rules in documentation, we express them as executable tests that can be validated with every change.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=26c6feb54c58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Resilient Systems with Java]]></title>
            <link>https://medium.com/@mkonca/building-resilient-systems-with-java-fcbecd516b68?source=rss-e6afd92b93db------2</link>
            <guid isPermaLink="false">https://medium.com/p/fcbecd516b68</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[resilience4j]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[mkonca]]></dc:creator>
            <pubDate>Fri, 23 Oct 2026 08:53:33 GMT</pubDate>
            <atom:updated>2026-10-23T08:53:33.002Z</atom:updated>
            <content:encoded><![CDATA[<p>A Guide to Resilience4j and Circuit Breakers</p><p><em>A practical guide to Circuit Breaker, Retry, Bulkhead, Timeout, and Graceful Degradation in Java applications.</em></p><h3>1. Introduction</h3><p>Failures are inevitable in distributed systems.</p><p>A remote API may become unavailable. Database responses may slow down. Network connections can fail, and sudden traffic spikes can exhaust application resources.</p><p>In distributed architectures, a failure in one service can spread to other services and trigger cascading failures if appropriate safeguards are not in place.</p><p>This is why <strong>resilience</strong> — the ability of a system to handle failures, limit their impact, and recover gracefully — is an essential aspect of modern Java application development.</p><p>In the Java ecosystem, Resilience4j is a modular library that provides mechanisms such as Circuit Breaker, Retry, Rate Limiter, Bulkhead, and Time Limiter.</p><p>In this guide, we will explore these mechanisms through practical examples, configuration snippets, and production-oriented recommendations.</p><p>We will cover:</p><ul><li>Resilience concepts and fundamental design principles</li><li>Setting up Resilience4j with Maven</li><li>Circuit Breaker and Retry patterns</li><li>Bulkhead, Rate Limiter, and Timeout</li><li>Fallback and Graceful Degradation</li><li>Monitoring and testing strategies</li></ul><h3>2. What Is Resilience?</h3><p>Resilience is a system’s ability to preserve critical functionality under failure conditions and recover when dependencies become available again.</p><p>Consider an e-commerce application consisting of the following services:</p><ul><li>OrderService: Manages orders.</li><li>PaymentService: Processes payments.</li><li>InventoryService: Checks product availability.</li><li>RecommendationService: Provides product recommendations.</li><li>NotificationService: Sends notifications.</li></ul><p>If the recommendation service becomes unavailable, the entire product page does not necessarily need to fail. The application can continue displaying product information without recommendations.</p><p>Critical operations, such as payment processing and inventory validation, require different safeguards and business rules.</p><p>Resilience patterns address different problems:</p><h3><strong>Mechanism Purpose</strong></h3><p><strong>Timeout </strong>Prevent operations from waiting indefinitely</p><p><strong>Retry Retry</strong> operations after transient failures</p><p><strong>Circuit Breaker</strong> Prevent repeated calls to an unhealthy dependency</p><p><strong>Bulkhead </strong>Isolate and limit resource consumption</p><p><strong>Rate Limiter</strong> Control request frequency</p><p><strong>Fallback </strong>Provide an alternative response or behavior</p><p><strong>Observability </strong>Measure failures and recovery behavior</p><p>These mechanisms complement one another, but they are not interchangeable.</p><p>For example, a circuit breaker does not automatically impose a timeout on an HTTP request. Likewise, retrying an operation does not guarantee that repeating it is safe.</p><h3>3. Setting Up Resilience4j with Maven</h3><p>Resilience4j can be integrated into Spring Boot applications through a dedicated Spring integration starter.</p><p>The following Maven configuration illustrates a setup targeting Spring Boot 3 and Java 17 or later.</p><h3>Maven dependencies</h3><pre>&lt;properties&gt;<br>    &lt;java.version&gt;17&lt;/java.version&gt;<br>    &lt;resilience4j.version&gt;YOUR_COMPATIBLE_VERSION&lt;/resilience4j.version&gt;<br>&lt;/properties&gt;<br><br>&lt;dependencies&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-aop&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br><br>    &lt;dependency&gt;<br>        &lt;groupId&gt;io.github.resilience4j&lt;/groupId&gt;<br>        &lt;artifactId&gt;resilience4j-spring-boot3&lt;/artifactId&gt;<br>        &lt;version&gt;${resilience4j.version}&lt;/version&gt;<br>    &lt;/dependency&gt;<br><br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br>&lt;/dependencies&gt;</pre><p>Replace YOUR_COMPATIBLE_VERSION with a verified Resilience4j release compatible with your Java and Spring Boot versions.</p><p>Resilience4j 2.x requires Java 17 or later. Applications using Spring Boot 2 should use the appropriate Boot 2 integration rather than the Boot 3 starter.</p><p>Reference: Resilience4j — Getting Started</p><h3>4. Circuit Breaker: Preventing Cascading Failures</h3><p>A Circuit Breaker prevents an application from repeatedly calling a dependency that is experiencing failures.</p><p>It operates in three primary states.</p><h3>Closed</h3><p>Calls are allowed, and their success or failure is recorded.</p><h3>Open</h3><p>When the configured failure conditions are met, the circuit opens. New calls are rejected without executing the protected operation.</p><h3>Half-open</h3><p>After a configured waiting period, a limited number of test calls are permitted.</p><p>If the dependency has recovered, the circuit closes. If failures continue, the circuit opens again.</p><h3>Configuring a Circuit Breaker</h3><p>Add the following configuration to application.yml:</p><pre>resilience4j:<br>  circuitbreaker:<br>    instances:<br>      inventoryService:<br>        slidingWindowType: COUNT_BASED<br>        slidingWindowSize: 10<br>        minimumNumberOfCalls: 5<br>        failureRateThreshold: 50<br>        waitDurationInOpenState: 5s<br>        permittedNumberOfCallsInHalfOpenState: 2</pre><p>his configuration means:</p><ul><li>The sliding window contains up to 10 calls.</li><li>At least 5 calls are required before the failure rate is evaluated.</li><li>The circuit can open when the failure rate reaches 50%.</li><li>The circuit remains open for 5 seconds before transitioning toward recovery.</li><li>Up to 2 calls are permitted in the half-open state.</li></ul><p>These values are illustrative. Production thresholds should be based on traffic patterns, latency, and service-level objectives.</p><h3>Using @CircuitBreaker</h3><pre>io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;<br>org.springframework.stereotype.Service;<br>@Service<br>public class InventoryService {<br><br>    @CircuitBreaker(<br>        name = &quot;inventoryService&quot;,<br>        fallbackMethod = &quot;inventoryFallback&quot;<br>    )<br>    public String checkInventory(String productId) {<br>        return callInventoryApi(productId);<br>    }<br><br>    private String inventoryFallback(<br>            String productId,<br>            Throwable throwable) {<br><br>        return &quot;Inventory service temporarily unavailable&quot;;<br>    }<br><br>    private String callInventoryApi(String productId) {<br>        // Implement the actual remote API call.<br>        return &quot;Inventory available&quot;;<br>    }<br>}</pre><p>The @CircuitBreaker annotation protects the method using the named circuit breaker configuration.</p><p>The fallback method must have compatible parameters: the original method arguments followed by a compatible exception parameter. Its return type must also match the protected method’s return type.</p><p>In production, fallback responses must respect business rules. Assuming that a product is in stock when inventory cannot be verified could lead to incorrect orders.</p><p>For this reason, the example returns an explicit message indicating that the inventory status is unavailable.</p><p>For further reading, see Baeldung — A Quick Guide to Spring Cloud Circuit Breaker.</p><h3>5. Retry: Handling Transient Failures</h3><p>Not all failures are permanent.</p><p>A network connection may reset, a remote service may temporarily return an overload response, or a short-lived infrastructure issue may cause a request to fail.</p><p>The Retry pattern allows an operation to be attempted again under controlled conditions.</p><h3>Configuring Retry</h3><pre>resilience4j:<br>  retry:<br>    instances:<br>      paymentService:<br>        maxAttempts: 3<br>        waitDuration: 500ms</pre><p>Here, maxAttempts: 3 means three attempts in total, including the initial call.</p><p>The example uses a fixed waiting interval between attempts. In high-traffic systems, exponential backoff and randomized jitter may be more appropriate.</p><h3>Using @Retry</h3><pre>io.github.resilience4j.retry.annotation.Retry;<br>org.springframework.stereotype.Service;<br><br>@Service<br>public class PaymentService {<br><br>    @Retry(<br>        name = &quot;paymentService&quot;,<br>        fallbackMethod = &quot;paymentFallback&quot;<br>    )<br>    public String processPayment(String orderId) {<br>        return callPaymentGateway(orderId);<br>    }<br><br>    private String paymentFallback(<br>            String orderId,<br>            Throwable throwable) {<br><br>        return &quot;Payment outcome could not be confirmed&quot;;<br>    }<br><br>    private String callPaymentGateway(String orderId) {<br>        // Implement the actual payment gateway call.<br>        return &quot;Payment processed&quot;;<br>    }<br>}</pre><p>This example demonstrates a fallback when the operation continues to fail after retry processing.</p><p>However, retrying payment operations requires special care.</p><p>The server may successfully process a payment while the response never reaches the client. If the client sends the request again, a duplicate charge may occur.</p><p>To prevent this, use an idempotency key or an equivalent deduplication mechanism. Also distinguish between a confirmed failure and an operation whose outcome is unknown.</p><p>Not every failure should be retried. Invalid requests and permanent business-rule violations are generally unsuitable for retry.</p><p>Reference: Baeldung — Exponential Backoff and Jitter.</p><h3>6. Bulkhead: Isolating Resources</h3><p>The Bulkhead pattern prevents a slow or overloaded service from exhausting resources needed by other parts of an application.</p><p>Imagine an application that calls both a payment service and a recommendation service.</p><p>If recommendation requests consume all available execution resources, payment requests may also become delayed or rejected.</p><p>Bulkhead limits help isolate these workloads.</p><p>Resilience4j provides two primary approaches:</p><ul><li>SemaphoreBulkhead: Limits concurrent calls using a semaphore.</li><li>FixedThreadPoolBulkhead: Uses a dedicated thread pool and a bounded queue.</li></ul><h3>Configuration Example</h3><pre>resilience4j:<br>  bulkhead:<br>    instances:<br>      recommendationService:<br>        maxConcurrentCalls: 10<br>        maxWaitDuration: 100ms</pre><p>This configuration limits concurrent calls for the named bulkhead. The actual resource behavior depends on the selected bulkhead implementation.</p><p>A semaphore-based approach may be sufficient when only a concurrency limit is needed. A thread-pool bulkhead can be considered when a separate execution pool is appropriate.</p><p>A bulkhead does not make a service faster. Its purpose is to limit the damage a slow dependency can cause to the rest of the application.</p><p>Reference: Resilience4j — Bulkhead.</p><h3>7. Rate Limiter: Controlling Request Frequency</h3><p>A Rate Limiter restricts the number of calls permitted within a specified period.</p><p>It can help applications comply with external API quotas and prevent excessive traffic from overwhelming a service.</p><h3>Configuration Example</h3><pre>resilience4j:<br>  ratelimiter:<br>    instances:<br>      catalogService:<br>        limitForPeriod: 20<br>        limitRefreshPeriod: 1s<br>        timeoutDuration: 0</pre><p>This example permits up to 20 calls per one-second refresh period for the configured limiter.</p><p>With timeoutDuration: 0, a call that cannot immediately obtain permission is rejected rather than waiting.</p><p>Rate limiting and bulkheads solve different problems:</p><ul><li>Rate limiting controls the frequency of calls.</li><li>Bulkheads control concurrent execution or isolate resource consumption.</li></ul><p>Depending on the workload, both mechanisms can be used together.</p><p>Reference: Resilience4j — RateLimiter.</p><h3>8. Timeout: Limiting Waiting Time</h3><p>A timeout limits how long an application waits for an operation to complete.</p><p>Without appropriate timeouts, an unresponsive dependency can occupy threads or connections for longer than necessary.</p><p>Resilience4j provides a TimeLimiter module, particularly for supported asynchronous operations involving Future and CompletionStage.</p><h3>Configuration Example</h3><pre>resilience4j:<br>  timelimiter:<br>    instances:<br>      remoteOperation:<br>        timeoutDuration: 2s<br>        cancelRunningFuture: true</pre><p>The cancellation setting applies to supported future-based execution models. Cancelling a future does not guarantee that the underlying network operation or remote server has stopped processing the request.</p><p>For HTTP clients, connection and request timeouts should also be configured separately.</p><p>A robust design considers the following together:</p><ul><li>An appropriate timeout for the network call.</li><li>An overall deadline for the operation.</li><li>A retry policy bounded by the remaining time budget.</li><li>Explicit error handling when the deadline is exceeded.</li></ul><p>Timeouts, retries, and circuit breakers should not be configured independently of one another.</p><h3>9. Graceful Degradation and Fallback</h3><p>Graceful degradation allows an application to preserve critical functionality when a dependency becomes unavailable.</p><p>For example, product information can remain visible even when the recommendation service fails.</p><pre>public ProductPage loadProductPage(String productId) {<br>    Product product = productService.getProduct(productId);<br><br>    List&lt;Product&gt; recommendations;<br><br>    try {<br>        recommendations =<br>                recommendationService.getRecommendations(productId);<br>    } catch (RecommendationServiceException exception) {<br>        recommendations = List.of();<br>    }<br><br>    return new ProductPage(product, recommendations);<br>}</pre><p>In this example, an empty recommendation list is returned when the recommendation service fails. The product information remains available to the user.</p><p>A fallback may also use cached data or another response that respects the application’s business rules.</p><p>However, fallback behavior must be appropriate for the operation. A payment failure must not be handled in the same way as an optional recommendation failure.</p><p>Avoid catching all exceptions indiscriminately. Expected dependency failures should be handled deliberately, while unexpected programming errors should remain visible.</p><h3>10. Monitoring and Observability</h3><p>Resilience mechanisms must be monitored to provide value in production.</p><p>A circuit breaker may open too frequently. A retry policy may generate unnecessary traffic. A bulkhead may reject requests because its capacity is too low.</p><p>Useful metrics include:</p><ul><li>Request success and failure rates.</li><li>p95 and p99 latency.</li><li>Timeout counts.</li><li>Retry attempts.</li><li>Circuit breaker state transitions.</li><li>Bulkhead rejections.</li><li>Rate limiter rejections.</li><li>Fallback execution counts.</li></ul><p>Resilience4j supports metrics integration through Micrometer. Spring Boot Actuator can help expose these metrics to monitoring infrastructure when configured appropriately.</p><p>Reference: Baeldung — Resilience4j Events Endpoints.</p><p>A good observability strategy should answer three questions:</p><ol><li>Which dependency is failing?</li><li>Which resilience mechanism is being activated?</li><li>Is the system recovering while maintaining its service-level objectives?</li></ol><h3>11. Combining Resilience Mechanisms</h3><p>Each mechanism targets a different failure mode. Combining them can provide stronger protection, but their configuration must be deliberate.</p><p>A practical strategy for a remote service call may include:</p><ol><li>Define an overall time budget for the operation.</li><li>Configure the HTTP client’s timeout values.</li><li>Apply bounded retries only to appropriate transient failures.</li><li>Use a circuit breaker to avoid repeatedly calling an unhealthy dependency.</li><li>Consider a bulkhead to limit concurrent resource consumption.</li><li>Apply rate limiting when necessary.</li><li>Define fallback behavior that respects business rules.</li><li>Monitor failures and recovery through metrics.</li></ol><p>The interaction between Retry and Circuit Breaker is particularly important.</p><p>For example, should the circuit breaker count every retry attempt individually, or should it evaluate the outcome of the complete retry process? The answer depends on the application’s failure-handling policy.</p><p>Resilience4j’s annotation-based integration has a defined aspect order that can be configured. When more precise control is required, its programmatic decorator APIs can be considered.</p><p>Reference: Resilience4j — Getting Started.</p><h3>12. Testing Resilience</h3><p>A system that works under normal conditions has not necessarily demonstrated resilience.</p><p>The following scenarios should be tested:</p><ul><li>A remote service responds slowly.</li><li>A dependency becomes completely unavailable.</li><li>Requests fail repeatedly.</li><li>The circuit breaker opens.</li><li>The dependency recovers.</li><li>The bulkhead reaches its capacity.</li><li>The rate limit is exceeded.</li><li>The fallback returns the expected response.</li></ul><p>Tests should verify recovery behavior as well as failure handling.</p><p>For example, an automated test can confirm that a product page remains accessible when the recommendation service is unavailable.</p><p>Performance tests should also evaluate latency, resource consumption, and retry behavior under heavy load.</p><h3>Conclusion</h3><p>Resilience is a fundamental part of building reliable Java applications.</p><p>Timeouts prevent indefinite waiting. Retries help recover from transient failures. Circuit breakers reduce calls to unhealthy dependencies. Bulkheads isolate resource consumption. Rate limiters control request frequency, while graceful degradation preserves critical functionality.</p><p>Resilience4j provides modular implementations of these patterns and integrates with the Spring ecosystem.</p><p>However, adding a few annotations does not automatically make an application resilient.</p><p><strong>A resilient system is designed to handle failures in a controlled manner, protect critical functionality, and recover predictably.</strong></p><p>The most important engineering decision is not simply which library to use, but how the application should behave when its dependencies fail.</p><h3>References</h3><ol><li>Baeldung — A Quick Guide to Spring Cloud Circuit Breaker</li><li>Baeldung — Guide to Resilience4j With Spring Boot</li><li>Baeldung — Exponential Backoff and Jitter</li><li>Baeldung — Resilience4j Events Endpoints</li><li>Resilience4j — Getting Started</li><li>Resilience4j — CircuitBreaker</li><li>Resilience4j — Retry</li><li>Resilience4j — Bulkhead</li><li>Resilience4j — RateLimiter</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fcbecd516b68" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java ile Dayanıklı Sistemler Geliştirmek]]></title>
            <link>https://medium.com/@mkonca/java-ile-dayan%C4%B1kl%C4%B1-sistemler-geli%C5%9Ftirmek-19f832dd27a3?source=rss-e6afd92b93db------2</link>
            <guid isPermaLink="false">https://medium.com/p/19f832dd27a3</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[resilience]]></category>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[spring-boot]]></category>
            <dc:creator><![CDATA[mkonca]]></dc:creator>
            <pubDate>Thu, 22 Oct 2026 14:00:58 GMT</pubDate>
            <atom:updated>2026-10-22T14:00:58.150Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Resilience4j ve Circuit Breaker Rehberi</strong></p><p><em>Java uygulamalarında Circuit Breaker, Retry, Bulkhead, Timeout ve Graceful Degradation mekanizmalarına uygulamalı bir bakış.</em></p><p><strong>1. Giriş</strong></p><p>Dağıtık sistemlerde hatalar kaçınılmazdır.</p><p>Uzak bir API erişilemez hâle gelebilir. Veritabanı yanıtları yavaşlayabilir. Ağ bağlantıları kesilebilir veya ani trafik artışları uygulama kaynaklarını tüketebilir.</p><p>Dağıtık mimarilerde tek bir serviste meydana gelen hata, gerekli önlemler alınmadığında diğer servislere yayılabilir ve zincirleme arızalara (<em>cascading failures</em>) neden olabilir.</p><p>Bu nedenle <strong>resilience</strong>, yani bir sistemin arızaları yönetebilme, etkilerini sınırlandırabilme ve kontrollü biçimde toparlanabilme yeteneği, modern Java uygulamalarının önemli bir parçasıdır.</p><p>Java ekosisteminde Resilience4j; circuit breaker, retry, rate limiter, bulkhead ve time limiter gibi mekanizmaları uygulamak için kullanılan modüler bir kütüphanedir.</p><p>Bu rehberde aşağıdaki konuları uygulamalı örneklerle inceleyeceğiz:</p><ul><li>Resilience kavramı ve temel tasarım ilkeleri</li><li>Maven ile Resilience4j kurulumu</li><li>Circuit Breaker ve Retry mekanizmaları</li><li>Bulkhead, Rate Limiter ve Timeout</li><li>Fallback ve Graceful Degradation</li><li>Monitoring ve test stratejileri</li></ul><p><strong>2. Resilience Nedir?</strong></p><p>Resilience, bir sistemin hata koşullarında kritik işlevlerini koruyabilmesi ve arızalardan toparlanabilmesidir.</p><p>Örneğin bir e-ticaret uygulamasında şu servislerin bulunduğunu düşünelim:</p><ul><li>OrderService: Siparişleri yönetir.</li><li>PaymentService: Ödeme işlemlerini gerçekleştirir.</li><li>InventoryService: Stok durumunu kontrol eder.</li><li>RecommendationService: Ürün önerileri sunar.</li><li>NotificationService: Bildirim gönderir.</li></ul><p>Ürün öneri servisi çalışmadığında ürün sayfasının tamamen kullanılamaz hâle gelmesi gerekli değildir. Uygulama, önerileri göstermeden de ürün bilgilerini sunmaya devam edebilir.</p><p>Buna karşılık stok veya ödeme gibi kritik işlemlerde farklı güvenlik ve iş kuralları uygulanmalıdır.</p><p>Resilience mekanizmaları farklı sorunlara çözüm sunar:</p><p><strong>Mekanizma Kullanım amacı</strong></p><p><strong>Timeout </strong>Bir işlemin süresiz beklemesini önlemek</p><p><strong>RetryGeçici </strong>hatalarda işlemi yeniden denemek</p><p><strong>Circuit Breaker</strong> Arızalı servise sürekli istek gönderilmesini önlemek</p><p><strong>Bulkhead </strong>Kaynak tüketimini sınırlandırmak ve izole etmek</p><p><strong>Rate Limiter </strong>İstek sıklığını kontrol etmek</p><p><strong>Fallback </strong>Alternatif bir yanıt veya davranış sağlamak</p><p><strong>Observability </strong>Hataları ve toparlanma davranışını ölçmek</p><p>Bu mekanizmalar birbirini tamamlar; ancak birbirlerinin yerine geçmez.</p><p>Örneğin circuit breaker, bir HTTP isteğine otomatik olarak timeout uygulamaz. Retry ise bir işlemin tekrar çalıştırılmasının güvenli olduğunu garanti etmez.</p><p><strong>3. Maven ile Resilience4j Kurulumu</strong></p><p>Spring Boot uygulamalarında Resilience4j, Spring entegrasyonu sağlayan bir starter üzerinden kullanılabilir.</p><p>Aşağıdaki örnek, Spring Boot 4 ve Java 17 veya üzerini hedefleyen bir Maven yapılandırmasını gösterir.</p><p><strong>Maven bağımlılıkları</strong></p><pre>&lt;properties&gt;<br>    &lt;java.version&gt;17&lt;/java.version&gt;<br>    &lt;resilience4j.version&gt;2.1.0&lt;/resilience4j.version&gt;<br>&lt;/properties&gt;<br><br>&lt;dependencies&gt;<br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-aop&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br><br>    &lt;dependency&gt;<br>        &lt;groupId&gt;io.github.resilience4j&lt;/groupId&gt;<br>        &lt;artifactId&gt;resilience4j-spring-boot3&lt;/artifactId&gt;<br>        &lt;version&gt;${resilience4j.version}&lt;/version&gt;<br>    &lt;/dependency&gt;<br><br>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-actuator&lt;/artifactId&gt;<br>    &lt;/dependency&gt;<br>&lt;/dependencies&gt;</pre><p>2.1.0 yerine Java ve Spring Boot sürümleriyle uyumlu, doğrulanmış bir Resilience4j sürümü yazılmalıdır.</p><p>Resilience4j 2.x, Java 17 veya üzerini gerektirir. Spring Boot 2 kullanan projelerde uygun Boot 2 entegrasyonu tercih edilmelidir.</p><p>Resmî kaynak: <a href="https://resilience4j.readme.io/docs/getting-started">Resilience4j — Getting Started</a></p><p><strong>4. Circuit Breaker: Zincirleme Arızaları Önlemek</strong></p><p>Circuit Breaker, başarısız olduğu gözlemlenen bir bağımlılığa sürekli istek gönderilmesini engellemeyi amaçlar.</p><p>Üç temel durumda çalışır.</p><p><strong>Closed — Kapalı</strong></p><p>İsteklere izin verilir. Başarı ve hata sonuçları kaydedilir.</p><p><strong>Open — Açık</strong></p><p>Belirlenen hata koşulları gerçekleştiğinde devre açılır. Yeni çağrılar korunan işlemi çalıştırmadan reddedilir.</p><p><strong>Half-open — Yarı açık</strong></p><p>Belirlenen bekleme süresinden sonra sınırlı sayıda deneme çağrısına izin verilir.</p><p>Bağımlılık toparlandıysa devre kapanır. Hatalar devam ediyorsa yeniden açılır.</p><p><strong>Circuit Breaker yapılandırması</strong></p><p>application.yml dosyasına aşağıdaki örnek yapılandırma eklenebilir:</p><pre>resilience4j:<br>  circuitbreaker:<br>    instances:<br>      inventoryService:<br>        slidingWindowType: COUNT_BASED<br>        slidingWindowSize: 10<br>        minimumNumberOfCalls: 5<br>        failureRateThreshold: 50<br>        waitDurationInOpenState: 5s<br>        permittedNumberOfCallsInHalfOpenState: 2<br>Bu yapılandırma şu anlama gelir:<br><br>Değerlendirme penceresi en fazla 10 çağrıyı kapsar.<br>Hata oranı değerlendirilmeden önce en az 5 çağrı gerekir.<br>Hata oranı yüzde 50&#39;ye ulaştığında devre açılabilir.<br>Açık durumda 5 saniye beklenir.<br>Yarı açık durumda en fazla 2 deneme çağrısına izin verilir.</pre><p>Bu değerler örnektir. Üretim ortamındaki eşikler, servis trafiğine, gecikmelere ve hizmet hedeflerine göre belirlenmelidir.</p><p><strong>@CircuitBreaker kullanımı</strong></p><p>io.github.resilience4j.circuitbreaker.annotation.CircuitBreaker;</p><p>org.springframework.stereotype.Service;</p><pre>@Service<br>public class InventoryService {<br><br>    @CircuitBreaker(<br>        name = &quot;inventoryService&quot;,<br>        fallbackMethod = &quot;inventoryFallback&quot;<br>    )<br>    public String checkInventory(String productId) {<br>        return callInventoryApi(productId);<br>    }<br><br>    private String inventoryFallback(<br>            String productId,<br>            Throwable throwable) {<br><br>        return &quot;Stok servisi geçici olarak kullanılamıyor&quot;;<br>    }<br><br>    private String callInventoryApi(String productId) {<br>        // Gerçek uzak API çağrısı burada yapılır.<br>        return &quot;Stok mevcut&quot;;<br>    }<br>}</pre><p>Bu örnekte @CircuitBreaker, metodu tanımlanan circuit breaker yapılandırmasıyla korur.</p><p>Fallback metodunun parametreleri, orijinal metodun parametrelerini ve ardından uyumlu bir istisna parametresini içermelidir. Dönüş tipi de korunan metodun dönüş tipiyle uyumlu olmalıdır.</p><p>Üretim ortamında fallback yanıtı iş kurallarına uygun olmalıdır. Stok bilgisi alınamadığında ürünün stokta olduğunu varsaymak yanlış siparişlere neden olabilir.</p><p>Bu nedenle örnekte stok durumu bilinmiyorsa kullanıcıya açık bir mesaj döndürülmektedir.</p><p>Daha fazla bilgi: <a href="https://www.baeldung.com/spring-cloud-circuit-breaker">Baeldung — Spring Cloud Circuit Breaker Rehberi</a></p><p><strong>5. Retry: Geçici Hataları Yönetmek</strong></p><p>Bazı hatalar kalıcı değildir.</p><p>Ağ bağlantısı sıfırlanabilir, uzak servis geçici bir aşırı yük yanıtı verebilir veya kısa süreli bir altyapı sorunu çağrının başarısız olmasına neden olabilir.</p><p>Retry mekanizması, uygun koşullarda bir işlemin yeniden denenmesini sağlar.</p><p><strong>Retry yapılandırması</strong></p><pre>resilience4j:<br>  retry:<br>    instances:<br>      paymentService:<br>        maxAttempts: 3<br>        waitDuration: 500ms</pre><p>Buradaki maxAttempts: 3, ilk çağrı dâhil toplam üç deneme anlamına gelir.</p><p>Örnekte her deneme arasında sabit 500 milisaniye beklenir. Yüksek trafikli sistemlerde üstel bekleme (<em>exponential backoff</em>) ve rastgele gecikme (<em>jitter</em>) daha uygun olabilir.</p><p><strong>@Retry kullanımı</strong></p><p>io.github.resilience4j.retry.annotation.Retry;</p><p>org.springframework.stereotype.Service;</p><pre>@Service<br>public class PaymentService {<br><br>    @Retry(<br>        name = &quot;paymentService&quot;,<br>        fallbackMethod = &quot;paymentFallback&quot;<br>    )<br>    public String processPayment(String orderId) {<br>        return callPaymentGateway(orderId);<br>    }<br><br>    private String paymentFallback(<br>            String orderId,<br>            Throwable throwable) {<br><br>        return &quot;Ödeme sonucu doğrulanamadı&quot;;<br>    }<br><br>    private String callPaymentGateway(String orderId) {<br>        // Gerçek ödeme sağlayıcısı çağrısı burada yapılır.<br>        return &quot;Ödeme tamamlandı&quot;;<br>    }<br>}</pre><p>Bu örnek, retry sonrasında da başarısızlık devam ederse fallback metodunun çalışmasını gösterir.</p><p>Ancak ödeme işlemlerinde tekrar deneme özellikle dikkat gerektirir.</p><p>Sunucu ödemeyi gerçekleştirmiş ancak yanıt istemciye ulaşmamış olabilir. İstek yeniden gönderildiğinde ikinci bir ödeme oluşabilir.</p><p>Bunu önlemek için idempotency key veya eşdeğer bir tekilleştirme mekanizması kullanılmalı; geçici hata ile sonucu belirsiz işlem birbirinden ayrılmalıdır.</p><p>Her hata yeniden denenmemelidir. Geçersiz istekler ve kalıcı iş kuralı ihlalleri çoğunlukla retry için uygun değildir.</p><p>Kaynak: <a href="https://www.baeldung.com/resilience4j-backoff-jitter">Baeldung — Exponential Backoff ve Jitter</a></p><p><strong>6. Bulkhead: Kaynakları İzole Etmek</strong></p><p>Bulkhead deseni, yavaş veya aşırı yüklenmiş bir servisin uygulamanın diğer bölümlerinde kaynak tükenmesine neden olmasını önlemeyi amaçlar.</p><p>Bir uygulamanın ödeme servisi ve ürün öneri servisi çağırdığını düşünelim.</p><p>Öneri istekleri bütün kullanılabilir yürütme kaynaklarını tüketirse ödeme istekleri de gecikebilir veya reddedilebilir.</p><p>Bulkhead, bu tür etkileşimleri sınırlandırmak için kullanılır.</p><p>Resilience4j iki temel yaklaşım sunar:</p><ul><li>SemaphoreBulkhead: Eşzamanlı çağrı sayısını semaphore kullanarak sınırlar.</li><li>FixedThreadPoolBulkhead: Ayrı bir thread havuzu ve sınırlı bir kuyruk kullanır.</li></ul><p><strong>Yapılandırma örneği</strong></p><pre>resilience4j:<br>  bulkhead:<br>    instances:<br>      recommendationService:<br>        maxConcurrentCalls: 10<br>        maxWaitDuration: 100ms</pre><p>Bu yapılandırma, ilgili bulkhead için eşzamanlı çağrı kapasitesini sınırlar. Kullanılan uygulamanın gerçek kaynak davranışı, seçilen bulkhead türüne bağlıdır.</p><p>Semaphore tabanlı yaklaşım, yalnızca eşzamanlılık sınırı gerektiğinde yararlı olabilir. Ayrı bir yürütme havuzuna ihtiyaç duyulduğunda thread-pool yaklaşımı değerlendirilebilir.</p><p>Bulkhead, servisi hızlandırmaz. Amacı, yavaş bir bağımlılığın uygulamanın geri kalanına verebileceği zararı sınırlandırmaktır.</p><p>Kaynak: <a href="https://resilience4j.readme.io/docs/bulkhead">Resilience4j — Bulkhead</a></p><p><strong>7. Rate Limiter: İstek Sıklığını Kontrol Etmek</strong></p><p>Rate limiter, belirli bir zaman aralığında yapılabilecek çağrı sayısını sınırlar.</p><p>Dış servislerin kota sınırlarına uymak veya bir servise aşırı trafik gönderilmesini engellemek için kullanılabilir.</p><p><strong>Yapılandırma örneği</strong></p><pre>resilience4j:<br>  ratelimiter:<br>    instances:<br>      catalogService:<br>        limitForPeriod: 20<br>        limitRefreshPeriod: 1s<br>        timeoutDuration: 0</pre><p>Bu örnekte her bir saniyelik yenileme döneminde en fazla 20 izin verilir.</p><p>timeoutDuration: 0 olduğunda izin hemen alınamıyorsa çağrı beklemek yerine reddedilir.</p><p>Rate limiter ile bulkhead farklı sorunları çözer:</p><ul><li>Rate limiter, çağrı sıklığını sınırlar.</li><li>Bulkhead, eşzamanlı yürütmeyi veya kaynak kullanımını sınırlar.</li></ul><p>İhtiyaca göre iki mekanizma birlikte kullanılabilir.</p><p>Kaynak: <a href="https://resilience4j.readme.io/docs/ratelimiter">Resilience4j — RateLimiter</a></p><p><strong>8. Timeout: Bekleme Süresini Sınırlandırmak</strong></p><p>Timeout, bir işlemin tamamlanması için beklenecek süreyi sınırlar.</p><p>Uzak servis çağrılarında timeout kullanılmaması, yanıt vermeyen bir bağımlılığın thread&#39;leri veya bağlantıları gereğinden uzun süre meşgul etmesine neden olabilir.</p><p>Resilience4j, özellikle Future ve CompletionStage gibi desteklenen asenkron işlemler için TimeLimiter modülünü sunar.</p><p><strong>Yapılandırma örneği</strong></p><pre>resilience4j:<br>  timelimiter:<br>    instances:<br>      remoteOperation:<br>        timeoutDuration: 2s<br>        cancelRunningFuture: true</pre><p>İptal ayarı, desteklenen future tabanlı yürütme modeline uygulanır. Bir future&#39;ın iptal edilmesi, alttaki ağ işleminin veya uzak sunucunun çalışmayı kesin olarak durdurduğu anlamına gelmez.</p><p>HTTP istemcilerinde bağlantı ve istek timeout değerleri ayrıca yapılandırılmalıdır.</p><p>Sağlam bir tasarım şu bileşenleri birlikte ele alır:</p><ul><li>Ağ çağrısı için uygun timeout.</li><li>İşlemin tamamı için genel bir zaman sınırı.</li><li>Kalan zaman bütçesiyle sınırlı retry politikası.</li><li>Zaman sınırı aşıldığında uygulanacak açık hata davranışı.</li></ul><p>Timeout, retry ve circuit breaker yapılandırmaları birbirinden bağımsız düşünülmemelidir.</p><p><strong>9. Graceful Degradation ve Fallback</strong></p><p>Graceful degradation, bir bağımlılık çalışmadığında uygulamanın kritik işlevlerini koruyabilmesidir.</p><p>Örneğin öneri servisi kullanılamıyorsa ürün bilgileri yine gösterilebilir.</p><pre>public ProductPage loadProductPage(String productId) {<br>    Product product = productService.getProduct(productId);<br><br>    List&lt;Product&gt; recommendations;<br><br>    try {<br>        recommendations =<br>                recommendationService.getRecommendations(productId);<br>    } catch (RecommendationServiceException exception) {<br>        recommendations = List.of();<br>    }<br><br>    return new ProductPage(product, recommendations);<br>}</pre><p>Bu örnekte öneri servisi başarısız olduğunda boş bir öneri listesi döndürülür. Ürün bilgileri ise kullanıcıya sunulmaya devam eder.</p><p>Fallback, önbellekteki verileri veya iş kurallarına uygun alternatif bir yanıtı da kullanabilir.</p><p>Ancak fallback davranışı iş mantığıyla uyumlu olmalıdır. Ödeme başarısızlığını, isteğe bağlı ürün önerilerinin başarısızlığıyla aynı şekilde ele almak doğru değildir.</p><p>Tüm istisnaları ayrım yapmadan yakalamaktan kaçınılmalıdır. Beklenen bağımlılık hataları kontrollü biçimde ele alınırken beklenmeyen programlama hataları görünür kalmalıdır.</p><p><strong>10. Monitoring ve Observability</strong></p><p>Resilience mekanizmalarının üretim ortamında faydalı olabilmesi için izlenmeleri gerekir.</p><p>Circuit breaker gereğinden sık açılıyor olabilir. Retry politikası dış servise gereksiz trafik oluşturabilir. Bulkhead kapasitesi düşük olduğu için çok sayıda istek reddediliyor olabilir.</p><p>İzlenmesi yararlı metrikler şunlardır:</p><ul><li>İstek başarı ve hata oranları.</li><li>p95 ve p99 gecikme değerleri.</li><li>Timeout sayıları.</li><li>Retry denemeleri.</li><li>Circuit breaker durum değişiklikleri.</li><li>Bulkhead nedeniyle reddedilen çağrılar.</li><li>Rate limiter nedeniyle reddedilen istekler.</li><li>Fallback kullanım sayıları.</li></ul><p>Resilience4j, Micrometer üzerinden metrik entegrasyonu sunar. Spring Boot Actuator ise uygun yapılandırmayla bu metriklerin uygulama izleme altyapılarına aktarılmasına yardımcı olabilir.</p><p>Kaynak: <a href="https://www.baeldung.com/resilience4j-events-endpoints">Baeldung — Resilience4j Events Endpoints</a></p><p>İyi bir gözlemlenebilirlik yaklaşımı şu sorulara yanıt verebilmelidir:</p><ol><li>Hangi bağımlılık başarısız oluyor?</li><li>Hangi resilience mekanizması devreye giriyor?</li><li>Sistem hizmet hedeflerini koruyarak toparlanabiliyor mu?</li></ol><p><strong>11. Resilience Mekanizmalarını Birlikte Kullanmak</strong></p><p>Her mekanizma farklı bir hata türünü hedefler. Bunları birlikte kullanmak korumayı güçlendirebilir; ancak yapılandırmalar bilinçli biçimde tasarlanmalıdır.</p><p>Uzak servis çağrısı için örnek bir strateji şu olabilir:</p><ol><li>İşlemin tamamı için bir zaman bütçesi belirleyin.</li><li>HTTP istemcisinin timeout değerlerini yapılandırın.</li><li>Yalnızca uygun geçici hatalarda sınırlı retry uygulayın.</li><li>Sağlıksız bir bağımlılığa sürekli istek gönderilmesini önlemek için circuit breaker kullanın.</li><li>Eşzamanlı kaynak kullanımını sınırlandırmak için bulkhead değerlendirin.</li><li>Gerektiğinde rate limiter uygulayın.</li><li>İş kurallarına uygun fallback davranışı tanımlayın.</li><li>Hataları ve toparlanmayı metriklerle izleyin.</li></ol><p>Retry ile circuit breaker&#39;ın sıralaması önemlidir.</p><p>Örneğin circuit breaker her retry denemesini ayrı ayrı mı değerlendirmeli, yoksa bütün retry sürecinin sonucunu mu dikkate almalı? Bu, uygulamanın hata yönetimi politikasına bağlıdır.</p><p>Resilience4j&#39;nin anotasyon tabanlı entegrasyonunda aspect sıralaması tanımlıdır ve yapılandırılabilir. Daha hassas kontrol gerektiğinde programatik decorator API&#39;leri değerlendirilebilir.</p><p>Kaynak: <a href="https://resilience4j.readme.io/docs/getting-started">Resilience4j — Getting Started</a></p><p><strong>12. Resilience Testleri</strong></p><p>Normal koşullarda çalışan bir sistem, tek başına dayanıklı olduğunu kanıtlamaz.</p><p>Aşağıdaki senaryolar test edilmelidir:</p><ul><li>Uzak servis yavaş yanıt verdiğinde.</li><li>Bir bağımlılık tamamen erişilemez olduğunda.</li><li>İstekler art arda başarısız olduğunda.</li><li>Circuit breaker açıldığında.</li><li>Bağımlılık yeniden çalışmaya başladığında.</li><li>Bulkhead kapasitesi dolduğunda.</li><li>Rate limit aşıldığında.</li><li>Fallback doğru yanıtı ürettiğinde.</li></ul><p>Testler yalnızca hata durumunu değil, sistemin toparlanma davranışını da doğrulamalıdır.</p><p>Örneğin öneri servisi devre dışı bırakıldığında ürün sayfasının erişilebilir kalması otomatik bir testle doğrulanabilir.</p><p>Performans testleriyle gecikme, kaynak tüketimi ve yüksek yük altında retry davranışı da değerlendirilmelidir.</p><p><strong>Sonuç</strong></p><p>Resilience, güvenilir Java uygulamaları geliştirmenin temel unsurlarından biridir.</p><p>Timeout süresiz beklemeyi önler. Retry geçici hatalardan kurtulmaya yardımcı olur. Circuit breaker sağlıksız bağımlılıklara yapılan çağrıları azaltır. Bulkhead kaynak tüketimini izole eder. Rate limiter çağrı sıklığını kontrol eder. Graceful degradation ise kritik işlevlerin korunmasını sağlar.</p><p>Resilience4j, bu desenleri uygulamak için modüler bir yapı sunar ve Spring ekosistemiyle entegre çalışabilir.</p><p>Ancak yalnızca birkaç anotasyon eklemek, uygulamayı kendiliğinden dayanıklı hâle getirmez.</p><p><strong>Dayanıklı bir sistem, arızaları kontrollü biçimde yönetmek, kritik işlevleri korumak ve öngörülebilir şekilde toparlanmak üzere tasarlanır.</strong></p><p>En önemli mühendislik kararı yalnızca hangi kütüphanenin kullanılacağı değil, bağımlılıklar başarısız olduğunda uygulamanın nasıl davranacağıdır.</p><p><strong>Kaynakça</strong></p><ol><li>Baeldung — <a href="https://www.baeldung.com/spring-cloud-circuit-breaker">Spring Cloud Circuit Breaker Rehberi</a></li><li>Baeldung — <a href="https://www.baeldung.com/spring-boot-resilience4j">Spring Boot ile Resilience4j</a></li><li>Baeldung — <a href="https://www.baeldung.com/resilience4j-backoff-jitter">Exponential Backoff ve Jitter</a></li><li>Baeldung — <a href="https://www.baeldung.com/resilience4j-events-endpoints">Resilience4j Events Endpoints</a></li><li>Resilience4j — <a href="https://resilience4j.readme.io/docs/getting-started">Getting Started</a></li><li>Resilience4j — <a href="https://resilience4j.readme.io/docs/circuitbreaker">CircuitBreaker</a></li><li>Resilience4j — <a href="https://resilience4j.readme.io/docs/retry">Retry</a></li><li>Resilience4j — <a href="https://resilience4j.readme.io/docs/bulkhead">Bulkhead</a></li><li>Resilience4j — <a href="https://resilience4j.readme.io/docs/ratelimiter">RateLimiter</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19f832dd27a3" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>