DEV Community

Cover image for Java Concepts #1 (Java8, Mircro-services, String)
a gorde
a gorde

Posted on

Java Concepts #1 (Java8, Mircro-services, String)

About me

In my previous company, I worked on multiple phases of product lifecycle. I worked on database migration from DB2 to Oracle for a banking client, then contributed to building a microservices-based service manager integrated with RabbitMQ, and also handled maintenance and bug fixes for legacy JSP applications.


Java 8

It felt like a big leap forward. Java 1.8 was stacked and released for improved code readability, reduced boilerplate, and enhanced performance.

some of the features was

  • Streams API a game changer for clean, realizable code and whole boilerplate reduction.
  • Lambda expression are basically short, inline way of writing functions.
  • Default and Static Methods in Interfaces aka Functional Interfaces to support Lambda expression.

Where I've used it? I've benefited from lambdas when working with collection like filtering a list of transactions in one line instead of writing loops.

and yes some additional changes were;

  • New Date and Time API
  • Method References
  • Optional Class

Microservice architecture

micro - small & service - logic
consider small logics are together combining to make one application. Suppose this as building a factory where every function working separately and support each others work inside, for example packing department as one microservice and Quality Control department as a another together they are can we called as factory or an application.

how do you handle inter-service communication ?

classic question but you need to understand what does it takes, Inter-service comms can be handled in two main ways; Asynchronous and Synchronous

Strings

Remember as immutable: String is immutable, means onces an object is created, its value cannot be changed. Any modification creates a new object in memory.

String str = "Hello readers"
String str = new String("hello");

Before Java 7 String was stored in the PermGen space.
PermGen (Permanent Generation) is a special heap space separated from the main heap memory.

Reasons being:

  • PermGen had a fixed size
  • Poor tuning and management
  • Not Designed for GC's
  • Memory fragmentation

While the entire PermGen was removed completely in java 8 and replaced with MetaSpace for better scalability, performance, and easier management.

While String begin immutable, StringBuilder and StringBuffer are mutable, means their content can be modified without creating a new object.

Top comments (0)