Category: fullstackdevelopment

  • The best way to use Optional in Java

    Null pointer exceptions. They have often been a headache to java developers. Your application breaks out of nowhere and throws null pointer exceptions. You rub your forehead then and add that null check you missed out. Java wanted to solve this problem. And they introduced the Optional keyword. They described it as a “Container” that…

  • How to create a custom annotation in Spring Boot?

    How to create a custom annotation in Spring Boot?

    Annotation is a powerful feature in Java. You can plug in some logic by just adding a word ! Consider this annotation in Spring Data: @Transactional Add this to a method where you are performing a sequence of database operations and they suddenly turn transactional. If any of the database operation fails all the other…

  • How to automate java bean to bean mapping in Spring Boot using MapStruct?

    Let’s say you are developing an application which fetches data from the database. Let’s say you are using hibernate to do the object relational data mapping. So the data you fetch from database are mapped into Java entity objects . And then you extract data from this entity object into another java bean object (DTO/data…

  • How to enable CORS (Cross Origin Resource Sharing) for specific domains in Spring Boot?

    For security reasons, browsers don’t allow javascript code to call APIs deployed in domains other than the current domain in which the javascript code is deployed. So if your javascript code is in a.com you cannot call an API deployed in b.com. So if you have deployed an API developed in Spring Boot in b.com…

  • How do javascript functions differ from Java functions?

    How do you avoid repeated coding in a programming language? By using functions. You write the piece of code with the logic you want to execute inside a function and then call it wherever you want. Javascript functions achieve the same but differ a bit from languages like Java. Here are the features in javascript…

  • How do numbers differ in Javascript and Java?

    Numbers are a basic data type. You can’t have a programming language without them. Yet how these numbers are treated can vary slightly between different languages. Brendan Eich , when he created Javascript was hugely influenced by Java. In face he was asked to create a Java language for the browser by Netscape and ended…

  • How does HTTPS work?

    One of the most basic knowledge required for web developers is to know how https protocol works (also called SSL/TLS). How does it secure your websites compared to http? Let’s first see why http is not secure. Assume you are in a public wifi network. You are using the wifi to connect to the internet.…

  • How the binary logical operators ‘&&’ and ‘||’ differ in Javascript from Java

    The binary logical operators && and || are used to determine whether an expression is true or false. && means the expression on both the side of the operator should be true. Example: Even if one of the expressions is false the final expression evaluates to false || means any of the two expressions should…

  • undefined vs null in javascript

    If you are from the background of a programming language like Java , you might feel that the way to represent a “no value” is through the value “null”. But Javascript has two ways to denote a “no value”. One is “undefined” Another is “null” “undefined” represents “no value” whereas “null” represents “no object” to…

  • How to find execution time in javascript?

    Let’s say you want to find out the time the code you wrote took to run. There is an easy way in javascript to do it. Just use console.time() and console.timeEnd() methods. Here is an example: In the above code I am using a variable totalTime to give a label (against which the total execution…