Monday, February 28, 2022

How to use Context and useReducer for state management in React app? Example Tutorial

Introduction
A React component is made up of props and state. The state can be local or global. Usually, the local state is handled within the component using the setState method in class components and hooks in the functional components. But as the application grows, the state is usually required to be shared among multiple components. The global state is managed using third-party libraries such as Redux

Redux works perfectly but setting up redux is complicated and working with it is more complicated. So for moderate global state management, we can use Context API or the useReducer hook. But, there is one more way for managing the global state and that is by using the Context API and useReducer together.

Friday, February 25, 2022

What is "render props" in React.js? Example Tutorial

Props in React are properties that are passed from a parent component to a child component. Basically, props are plain JavaScript objects. Unlike the state, which is managed within the component, props are received as input from another component. As mentioned, props are JavaScript objects. But props are not limited to this only. There is another way of using props and it is known as “render props”. In this article, we will discuss what “render props” are and how to use this technique in React with the help of examples.

Sunday, February 13, 2022

Top 20 Hibernate Interview Questions with Answers for Java Programmers

Hibernate is one of the most popular persistent frameworks in the Java world. Hibernate offers an object to relational (ORM) solution which frees Java developers from writing tedious, hard to read, and cluttered JDBC code converting SQL columns into Object properties. Apart from freeing Java developers from writing JDBC and database interaction code, Hibernate also offers the out-of-box solution on caching, proxying, and lazy loading which drastically improves the performance of your Java Web application. 

Saturday, February 12, 2022

How to Parse JSON in Java Object using Jackson - Example Tutorial

Hello guys, if you are wondering how to parse JSON in Java then don't worry, there are many options. In the last article, I have shown you 3 ways to parse JSON in Java in this example, You will learn how to parse a  JSON String to Java and how to convert Java Object to JSON format using Jackson. JSON stands for JavaScript Object notation is a subset of JavaScript object syntax, which allows all JavaScript clients to process it without using any external library. Because of its compact size, compared to XML and platform independence nature makes JSON a favorite format for transferring data via HTTP. 

Friday, February 11, 2022

How to use useReducer in React.js and JavaScript? Example Tutorial

Introduction

Before the React hooks were introduced, it was not possible to use state in functional components. The React hooks transformed stateless functional components into stateful components in which state and lifecycle methods like functionality could be used. 


The useState hook is the primary hook for declaring the state in a functional component. Using it, a state variable can be declared and initialized along with a function to manipulate it. But sometimes state gets complex and the useState hook is not efficient to handle it.


So React provides another hook for complex state management in functional components. This hook is called useReducer. In this article, we will discuss what useReducer hook is and how to use it. 

Wednesday, February 9, 2022

Difference between save(), saveOrUpdate() and persist() in Hibernate Session

The Session interface in Hibernate provides a couple of methods to move an object from a new or transient state to a persistent state like save(), saveOrUpdate(), and persist() is used to store an object into the database, but there are some significant differences between them. The Session.save() method does an INSERT to store the object into the database and it also returns the identifier generated by the database. On the other hand, saveOrUpdate() can be used to reattach a detached object in Hibernate Session i.e. it can do INSERT or UPDATE depending upon whether an object exists in the database or not. 

Monday, February 7, 2022

7 Examples of HttpURLConnection in Java - Sending GET and POST Request [Tutorial]

If you want to learn how to send GET and POST requests from the Java program then you have come to the right place. Earlier, I have shared free Java Courses for beginners, and today, I am going to show you how to use HttpURLConnection class in Java to send HTTP requests to the server.  The HttpURLConnection is an important class in the java.net package which allows you to send an HTTP request from a Java program. By using this class you can send any kind of HTTP request like GET, POST, PUT, DELETE, HEAD, etc to the server and call REST APIs. 

Saturday, February 5, 2022

15 Technical Core Java Interview Questions Answers for Experienced Developers

When the experience of a Java Programmer grows in the years e.g. when it goes from beginner years ( 2 to 4) to more experience or sort of senior level ( 5 to 7 years), Core Java Interview Questions also change a bit. Of course, basics like data structure, algorithms, and object-oriented programming remains the same, but types of questions will become more advanced and their answers will definitely need to be more detailed and accurate. I often receive queries about core Java questions asked to a senior developer with 5 to 6-year experience, or, sometimes, I am going for an interview of a senior Java developer, what kind of questions I should expect.