https://www.gravatar.com/avatar/306d401b2a8c0efe0996fec60e0c90aa?s=240&d=mp

My coding journey

Disclaimer: it's just for fun

Introduction to TLS, jks and keystores

Let’s face it: certifiates, key management, ssl/tls has never been any fun for any Java developer. That’s why I was also avoided this topic for as long as possible. And the time came to finally gather all I know , or rather: what I don’t know, just for reference.

Model ISO - OSI

What is ISO OSI model

ISO OSI = International Organization for Standardization Open Systems Interconnection

ISO OSI model is conceptual framework:

  • used to standardize and understand how different networking protocols and functions interact within a networks
  • consists of seven layers, each with a specific role and set of functions

Layers

Physical Layer (Layer 1):

  • the lowest layer
  • deals with the physical aspects of data transmission.
  • defines the physical medium, such as cables, electrical voltages, or optical signals, and how data is transmitted over them.
  • example: Ethernet cables, fiber optic connections, and wireless communication signals.
  • responsible for framing data for transmission and detecting and correcting errors in the data
  • manages access to the physical medium
  • resolves issues related to the physical addressing of devices on a local network.
  • examples: Ethernet and Wi-Fi

Network Layer (Layer 3):

  • focuses on routing and forwarding data between different networks or subnets.
  • uses logical addressing (such as IP addresses) to determine the best path for data to travel from source to destination
  • examples: routers operate at this layer

Transport Layer (Layer 4):

  • manages end-to-end communication and data segmentation into smaller packets.
  • provides error detection, flow control, and data integrity, ensuring that data is reliably and accurately delivered
  • examples: Protocols like TCP (Transmission Control Protocol) and UDP (User Datagram Protocol)

Session Layer (Layer 5):

  • establishes, maintains, and terminates connections between two devices or applications
  • manages session synchronization and ensures that data is delivered in the correct order
  • examples: NetBIOS and RPC (Remote Procedure Call)

Presentation Layer (Layer 6):

  • responsible for data translation, encryption, and compression.
  • ensures that data is in a format that both the sender and receiver can understand.
  • can handle data compression and encryption as needed.

Application Layer (Layer 7):

  • the topmost layer, the closest to end-users and applications
  • provides network services directly to end-users and applications (usually through language or libraryAPI) and is where most user-facing software interacts with the network
  • Common application layer protocols include HTTP (for web browsing), SMTP (for email), and FTP (for file transfer)

How to avoid switch statement in Spring Boot

In this guest post Norbert Tusiński writes on how to execute different type of behavior in situations where the type of behavior is determined by the value of some `Enum` variable. Immediate intuition is to use switch statement, however Norbert shows other possible solutions in the context of Spring Boot framework.

If not ThreadLocal then what? ScopedValue!

What is a ScopedValue?

ScopedValue is a value that can be seen and used in methods, but hasn’t been passed to them as a parameter. Untill recently this was possible in Java language by means of ThreadLocal variables. Let’s look at ThreadLocals for a moment to refresh our knowledge and let’s see what new features are being introduced by newer replacements, that is: ScopedValues.

What is the ThreadLocal variable?

ThreadLocal variables are typically declared as private global variables (static fields) and ensure that the value we read from them (using the get() method) is the same value that was previously stored in them (using the set() method) within the same thread (or the one returned by calling the protected initialValue() method that returns the initial value of the ThreadLocal variable).

What's new in Java 21?

Java 21

This is a real thing! Java 21 feels almost as a different programming language! Changes planned to be released in Sptember 2023 (in just a month!) can be roghly grouped into two categories:

Language and library changes

Here are the most important and - in my opinion - the most interesting changes that await us in Java 21. They are not revolutionary, but they make writing code - and, what is even more important, reading it - much easier.

Other changes

These are low-level changes, important for library creators (vector API, FFI, cryptography), or related to "code clean-up." They are probably less interesting for the typical programmer, although it's worth taking a look at the descriptions in JEPs to have a general idea of what they are about.

Piece by piece

Sequenced collections

We will have new interfaces which would be able to correctly model the encounter order. The API we have so far (let me say this: all Collection API) is a bit chaotic: taking first or last element from different collections has different API:

Java 21 - how to install early_access version

I want to try Java 21!

Its easy!

You can easily try out the new features in Java 21 that I wrote about in the previous post. You don’t need to install anything. Just follow these steps:

  • Download and unzip the archive.
  • Set the JAVA_HOME variable to point to it.
  • Add the /bin subdirectory to your PATH variable.

Let’s do it step by step

Here’s how to do it in Ubuntu Linux:

Virtual Threads in Javia 21

A bit of history

Java has allowed concurrent programming since version 1.0 through the use of the Thread class.

This capability was introduced in 1996 (I celebrated my 18th birthday that year!), but it quickly became evident that it wasn’t straightforward. Larger and more complex applications required better tools to handle threads.

The standard Java library lacked essential constructs for modeling certain concurrent programming patterns, and the code was often hard to read and prone to errors.

Extracting data from Excell

Excell files circulate in the veins of large companies. Ther are times when you want to extract some data and you have to use Java language for this purpose. Let’s see how to quickly extract data from .xls or .xlsx files using Apache POI library.

The library

Maven coordinates of the library(ies) can be found here: https://mvnrepository.com/artifact/org.apache.poi. Note that there are two types of excel spreadsheet formats and apache-poi project has two of its most important libraries to handle these data:

Chat GPT

I registered in ChatGPT web page today. Here are my prompts and its responses. I’m not very creative, as you can see. Perhaps I don’t have enough faith in its capabilities to expect more than from a better search engine.

Images in today’s blog post are generated using http://bing.com/images/create

Generate blog post

Generate blogpost about chat gpt written by a programmer about capabibities and risks related with AI usage when programming.