Category: Notes

Posted on: July 8, 2022 Posted by: rahulgite Comments: 3,414

Getting started with Android Development

Download Android Studio Stable Release: https://developer.android.com/studio Once it is downloaded and installed open SDK Manager Installed the below packages for any recent android version from the SDK platform tab (NOTE: Click on show package details to expand inner packages) Below are Tools for SDK Tools We are ready with the environment for android development.

Loading

Posted on: March 29, 2022 Posted by: rahulgite Comments: 3,318

Kotlin

GitHub – https://github.com/rahulgite/Kotlin Why a New JVM Language? Wordy and full of boilerplate Requires tedious getters and setters Difficult to avoid null pointer exceptions Lacks many modern programming features Why Kotlin? 100% compatible with Java. Eliminates most null pointer exceptions. The syntax is clean and easy to read. Modern features like smart casting. The easiest way to get a taste of Kotlin on https://play.kotlinlang.org/ Create Kotlin Project in Intellij New Project Select Gradle with below framework options Select Java Select Kotlin JVM Next Enter Project Name and Finish. The project will get built and you…

Loading

Posted on: January 28, 2022 Posted by: rahulgite Comments: 329

Angular Best Practices

Angular Best Practices Use ES6 features like let, const, arrow function Use trackby along with ngFor Use lazy loading Use index.ts file for shorter import use datatype, Avoid ‘any’ type Create own Data type using Interface Avoid memory leak by unsubscribing the observable also we can use Rxjs operator  like takeUntil() Should use Async pipe Avoid logics in the template Use Environment variable for multiple server or API call configurations Use module structure Focus on small and reusable components Declaring a variable with ‘const’ if the value is not changing Use smart and dumb Components strategies Using…

Loading

Posted on: January 28, 2022 Posted by: rahulgite Comments: 6

AWS – Basics

AWS – Amazon Web Services #AWS Amazon Web Services (AWS) is the world’s most comprehensive and broadly adopted cloud platform, offering over 200 fully-featured services from data centers globally Its Global cloud platform Infrastructure as service: provide servers, we don’t need to backup and power supply of servers. Platform as a service: We can get Java, ruby, PHP.etc., so you don’t need to manage binaries. Software as a service: We can get email sending capabilities like SES(Simple Email Service), SQS(Simple Queue Service), and lots of storage options like EBS(Elastic block store), S3 Simple storage service.…

Loading

Posted on: December 24, 2021 Posted by: rahulgite Comments: 12

Unit Testing with Spring Boot

Create a new controller and hello service import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; @RestController public class HelloController { @GetMapping(“/hello”) public String helloWorld(){ return “Hello World”; } } JUnit 4 Code @RunWith(SpringRunner.class) @WebMvcTest(HelloWorldController.class) JUnit 5 Code @WebMvcTest(HelloWorldController.class)   Testing Simple Hello Controller import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; import org.springframework.test.web.servlet.RequestBuilder; import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; import static org.junit.jupiter.api.Assertions.*; @WebMvcTest(HelloController.class) class HelloControllerTest { @Autowired private MockMvc mockMvc; @Test void helloWorld() throws Exception { // request GET /hello and application/json RequestBuilder requestBuilder = MockMvcRequestBuilders.get(“/hello”) .accept(MediaType.APPLICATION_JSON); MvcResult result=mockMvc.perform(requestBuilder).andReturn(); //verify controller assertEquals(“Hello World”,result.getResponse().getContentAsString()); } } Controller with status and…

Loading

Posted on: December 23, 2021 Posted by: rahulgite Comments: 11

Mockito

Class to test Junit package com.unittest.unittesting.business; import com.unittest.unittesting.data.DataService; public class BusinessImpl { private DataService service; public DataService getService() { return service; } public void setService(DataService service) { this.service = service; } public int calculateSum(int data[]){ int sum=0; for(int i:data){ sum+=i; } return sum; } public int calculateSumByService(){ int data[]=service.retriveData(); int sum=0; for(int i:data){ sum+=i; } return sum; } } Basic Junit Test package com.unittest.unittesting.business; import com.unittest.unittesting.data.DataService; import org.junit.jupiter.api.Test; import static org.junit.jupiter.api.Assertions.*; class BusinessImplTest { @Test void calculateSum() { BusinessImpl business=new BusinessImpl(); int actualResult=business.calculateSum(new int[] {1,2,3}); int expectedResult= 6; assertEquals(expectedResult,actualResult); } @Test void calculateSum_empty() { BusinessImpl…

Loading

Posted on: November 17, 2021 Posted by: rahulgite Comments: 1,180

GRPC Microservices Project Setup

Create Maven Project Add below dependencies in pom.xml ( Note: please change project name as per your project) <?xml version=”1.0″ encoding=”UTF-8″?> <project xmlns=”http://maven.apache.org/POM/4.0.0″ xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd”> <modelVersion>4.0.0</modelVersion> <groupId>org.example</groupId> <artifactId>shopping-services</artifactId> <version>1.0-SNAPSHOT</version> <properties> <maven.compiler.source>8</maven.compiler.source> <maven.compiler.target>8</maven.compiler.target> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <grpc.version>1.42.0</grpc.version> <protobuf.version>3.19.1</protobuf.version> <protoc.version>3.15.1</protoc.version> </properties> <dependencies> <!– https://mvnrepository.com/artifact/org.projectlombok/lombok –> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> <version>1.18.22</version> <scope>provided</scope> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-netty-shaded</artifactId> <version>${grpc.version}</version> <scope>runtime</scope> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-protobuf</artifactId> <version>${grpc.version}</version> </dependency> <dependency> <groupId>io.grpc</groupId> <artifactId>grpc-stub</artifactId> <version>${grpc.version}</version> </dependency> <dependency> <groupId>com.google.protobuf</groupId> <artifactId>protobuf-java-util</artifactId> <version>${protobuf.version}</version> </dependency> <dependency> <groupId>org.apache.tomcat</groupId> <artifactId>annotations-api</artifactId> <version>6.0.53</version> <scope>provided</scope> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.13.2</version> <scope>test</scope> </dependency> <dependency> <groupId>com.h2database</groupId> <artifactId>h2</artifactId> <version>1.4.200</version> </dependency> </dependencies> <build> <extensions> <extension> <groupId>kr.motd.maven</groupId> <artifactId>os-maven-plugin</artifactId> <version>1.6.2</version> </extension> </extensions>…

Loading

Posted on: November 16, 2021 Posted by: rahulgite Comments: 11

GRPC – Remote Procedure Call (RPC)

Inter-service communication Modern software applications no longer reside in a monolith today.  This big block of code, which is the monolith, is divided into smaller units, which are independent and autonomous.  They can be efficiently maintained and they are highly scalable.  the messages can be passed within services in a synchronous or an asynchronous fashion. Asynchronous message passing is when you place messages in logical queues so that the services can pick them up in the background and carry on with their further processing.   Inter-service communication has evolved Remote Procedural Call.  In this, the client invokes a procedure on the server…

Loading

Posted on: November 15, 2021 Posted by: rahulgite Comments: 11

Pagination in Angular Material and Prime NG

Pagination in Angular Material and Prime NG against 20k records Prime NG Angular Material 34 ms Loading 1650 ms Scripting 57 ms Rendering 2 ms Painting 320 ms System 13 ms Loading 168883 ms Scripting 103 ms Rendering 7 ms Painting 446 ms System Prime NG works very well with pagination, no matter the number of records available for pagination. Angular Material takes the same amount of time as it would take for rendering 20k records. So page loading time increases as the number of records available for pagination. Best Not good. Need to check more if this is…

Loading

Posted on: November 11, 2021 Posted by: rahulgite Comments: 17

PrimeNG vs Angular Material

More Angular Notes Angular Docs PrimeNG Vs Angular Material  PrimeNG Angular Material Reference Introduction PrimeNG is a UI component library that is created by Primark Informatics. Primark Informatics is a vendor with a lot of expertise and experience in developing open-source UI solutions. It is like a sibling to the PrimeFaces UI component library. The Widgets contained within the library are open-source, therefore are free to use under the MIT license. This library not only provides multiple free themes, but also a plethora of premium themes available with a lot more UI variations available for a…

Loading