If/Else Cumleleri Icin Rule Tasarim Kalibi

Bugun, projemizde kullandigimiz Rule tasarim kalibi (Rule Design Pattern) anlatacagim. Bu yontemi zaman baskisi yuzunden ekibe kabul ettirmek zor oldu ama ortaya cikan sonuctan memnun kaldik. Umarim sizin de isinize yarar. Problem Spring Boot ile yazilan backend uygulamamizda farkli musteri tipleri icin farkli kurallarin uygulandigi bir fonksiyon vardi. Musteri tiplerine gore onyuze farkli bildirim mesajlarini […]

Factory Method Pattern for Spring Hateoas Links

Problem Description You have a single class in your application where you create Hateoas Links for different API versions (e.g.: V1 and V2). The class grows quickly with time as you add a lot of logic for those versions. You want to refactor the existing class so that it is easier to be modified for […]

Testing HTTP Methods using Mockito framework

In this post, you will learn how to create HTTP methods in Spring Boot and test them using the Mockito framework. If you are not familiar with unit testing, see my post on Medium. For those who are impatient, you can find the source code on GitHub. HTTP Verbs Overview The most-commonly-used HTTP verbs are […]

Java SE 8/11 Programmer II Exam Series: Concurrency (Part 1)

Introduction This post is currently in progress… In this post, we will look at the exam objective; create worker threads using Runnable, Callable, and use an ExecutorService to concurrently execute tasks. Note that this is also a part of the Java SE 11 Programmer II Certification. Runnable Interface Runnable interface Usages of Runnable interface Creating a […]

Java SE 8/11 Programmer II Exam Series: Exception Handling and Assertions

Introduction In this post, we will look at the following exam objectives. Note that this is also a part of the Java SE 11 Programmer II Certification. Use the try-with-resources construct Create and use custom exception classes Test invariants by using assertions Use the try-with-resources construct The new try-with-resources statement automatically closes all resources opened […]

Java SE 8/11 Programmer II Exam Series: Internationalization and Localization

Introduction In this post, we will look at how to add internationalization and localization to the Java application. We will learn how to pick a locale, create and use properties files in different languages, and to format the numbers. Note that the localization is also a part of the Java SE 11 Programmer II Certification. […]

Java SE 8/11 Programmer II Exam Series: Advanced Stream Pipeline Concepts

Introduction In this section, we will cover advanced stream pipeline concepts in Java 8. We will analyze chaining Optionals, predefined collectors, and learn how to use groupingBy, partitioningBy, and mapping methods. Chaining Optionals Chaining optionals help eliminate the nested if-statements for Optional variables. The function below prints the virus name if it contains Covid-19 without […]

Java SE 8/11 Programmer II Exam Series: Primitive Streams

Introduction In this post, we will cover creating primitive streams, using Optional types with primitives, and summarizing statistics in a single pass. Primitive Streams There are three types of primitive streams: IntStream (int, short, byte, and char), LongStream (long), and DoubleStream (double and float). Creating Primitive Streams Creating primitive streams is the same as a […]

Java SE 8/11 Programmer II Exam Series: Streams

Introduction In this post, we will cover the streams in Java 8. We will discover the three parts of the pipeline: source, terminal, and intermediate operations. What is a stream pipeline? Stream operations are divided into intermediate and terminal operations and are combined to form stream pipelines. A stream pipeline consists of a source; followed by zero or more intermediate […]

Java SE 8/11 Programmer II Exam Series: Built-in Functional Interfaces

Introduction Functional interfaces are the basics of functional programming in Java 8. If you master the six basic interfaces, you can derive the rest and understand the streams. In this section, we will cover the common functional interfaces in java.util.function package: Supplier, Consumer, Predicate, Function, UnaryOperator, and BinaryOperator. Class Hierarchy The diagram shows the class […]