Posts

Showing posts from July, 2020

Java 10 Time Based Release Versioning

Java 10 has introduced time based release versioning. In this article, I will be explaining this feature in detail. Before Java 10 Before Java 10, Java did not have a time based release. Instead, Java release was driven by features. So, if there was some delay in developing the features, the Java release also would be delayed. Java 10 time based release versioning gets rid of this issue by guaranteeing a Java release every 6 months. There are two main aspects to time based release versioning as follows: Feature Release Feature releases occur every 6 months.  All those features that are ready will be part of the release. The features that are not ready will be part of the next release. Support for these releases last only for 6 months, that is until the next release. The current version of Java is Java 14. It was released in March 2020 and it is a feature release. Long Term Release (LTS) Long term releases occur once in every three years. Support for such release would be for 3 years. J

Python Dictionary

In my  earlier article, I had covered Python Tuples.  In this article, I will be covering Python dictionary.   What is a Python dictionary? A Python dictionary stores a List of key-value pairs. Creating a Python dictionary You can create a dictionary by specifying key-value pairs in curly brackets separated by commas. The following code demonstrates this: employeeDict = {'name':'John Doe','salary':5000.00,'department':'HR'} This code creates a dictionary employeeDict with some key value pairs. The key and value need to be separated by a colon symbol(:) Accessing values in a Python dictionary You can access a value from a dictionary by specifying the key in square brackets. The following code demonstrates this: employeeDict = {'name':'John Doe','salary':5000.00,'department':'HR'}print(employeeDict['name']) Updating a Python dictionary You can update the value for an existing key, add a new key-valu

ToIntFunction in Java 8 With Code Sample

Functional interfaces and lambda expressions are one of the major features in Java 8. Java provides a lot of in-built functioal interfaces in the java.util.function package. One of these is the ToIntFunction. In this blog post, I will be explaining how thisfunctional interface works. To know more about functional interfaces, you can refer to this  blog post. Edit What is ToIntFunction ToIntFunction is an in-built functional interface in the java.util.Function package. It accepts an argument of any data type but returns a result of type int . It is a primitive specialization of the Function interface that always returns a result of int type. So IntFunction<T> is similar to Function<T,Integer> It has an applyAsInt  method. It then applies the logic in this method on the argument passed in to produce the int result. ToIntFunction Sample Code The following code snippet demonstrates this interface: ToIntFunction<String> strLengthProducer = str -> str.length()

Spring Bean Scopes Explained With Code Samples

Image
The Spring Framework allows defining scopes for a Spring Bean. Spring Bean scopes define the lifetime of a Spring bean. In this article, we will take a look at bean scopes. What is Spring Bean Scope? A Spring Bean scope specifies the lifetime of a Spring bean. So it specifies when the bean will be created and how long it will exist in the system. Edit What are the different bean scopes? Spring supports the following bean scopes:   Singleton This is the default bean scope. As per this scope, only one instance of a bean is created. Each time the bean is requested, the same instance is returned. Prototype As per this scope, a new instance of a bean is created each time the bean is requested. Request This bean scope is valid only for a web application. As per this bean scope, a new instance of the bean is created for each HTTP request. The bean stays alive until the HTTP request completes.  If you use this bean scope for a standalone application, your code will result in an err