Posts

Showing posts from February, 2023

Spring Form Validation

Image
 The Need for validation is to check the user input form for  require fields Validate numbers in a range validate format (Postal code) custom business rule Java standard bean Validation API Java has a standerd Bean validaton API Defines  metadata model and API for entity validation  Not tied to either the web tier or the persistence tier Available for server-side apps and also client-side javaFx/Swigns apps. Spring version 4 and higher supports Bean Validation API The preferred method for validation when building the spring app. that means only adding annotations provided by validation API. Simply add validation JAR to our Project. Bean Validation Features: Required - to check filed is required  validate length - to check the length of the input Validate numbers -  Validate with regular expression custom validation Validation Annotation: @NotNull - Checks that the annotation value is not null. @Min - Must be a number >= value @Max - Must be a number <...

Java Collection - Array

  if we want to create 1000 variables with the same datatype we need to declare 1000  new variables and it's very difficult for programmers to deal with such types of variables. to overcome this problem Collection framework is introduced. The collection is a set of interfaces and classes to represent data structure and Algorithm.  Array :  the Array store data by indexing. the index will start from 0 Array in an indexed-based collection that contains a fixed number of homogenous data elements. We can declare an Array Student[] s = new Student[1000]; Limitation:  The array is a fixed size so once we create an Array we can not change the size of the Array. The array can hold only homogeneous data type which means Array can only contain the same data type values. the Arrays are a fixed-size index-based collection due to there being chances of memory waste. for example, if we create an Array with 1000 sizes and in programming, we only add 100 values in the array the...

Microservices design patterns

Microservices are an architectural pattern where a large application is divided into smaller, independent services that communicate with each other through APIs. Here are some common patterns used in microservices architecture API Gateway Pattern: A centralized entry point for all client requests that routes requests to the appropriate service. Service Registry Pattern: A centralized service that acts as a directory of all available services, making it easy for services to discover each other and communicate. Circuit Breaker Pattern: A mechanism that prevents a service from making requests to a failed service, improving overall system stability. Load Balancer Pattern: A component that distributes incoming requests evenly across multiple instances of a service, improving reliability and scalability. Event-Driven Pattern: A communication pattern where services communicate with each other by sending and receiving events, rather than direct request-response calls. Bulkhead Pattern: A mecha...