|
| 1 | +# Functional Programming with Java |
| 2 | + |
| 3 | +## Learn Functional Programming with Java using a Hands-on Step by Step Approach |
| 4 | + |
| 5 | +Are you ready to learn about Functional Programming and take the next step in your programming career? |
| 6 | + |
| 7 | +Do you want to join 300,000+ learners having Amazing Learning Experiences with in28Minutes? |
| 8 | + |
| 9 | +Look No Further! |
| 10 | + |
| 11 | +#### Required Tools |
| 12 | +- Java 9+ |
| 13 | +- Eclipse - Oxygen+ - (Embedded Maven From Eclipse) |
| 14 | + |
| 15 | +#### Installing Guides |
| 16 | +- [Playlist - Installing Java, Eclipse & Embedded Maven](https://www.youtube.com/playlist?list=PLBBog2r6uMCSmMVTW_QmDLyASBvovyAO3) |
| 17 | + |
| 18 | +#### Troubleshooting Installations |
| 19 | +- Eclipse and Embedded Maven |
| 20 | + - Troubleshooting Guide - https://github.com/in28minutes/in28minutes-initiatives/tree/master/The-in28Minutes-TroubleshootingGuide-And-FAQ#tip--troubleshooting-embedded-maven-in-eclipse |
| 21 | + - PDF - https://github.com/in28minutes/SpringIn28Minutes/blob/master/InstallationGuide-JavaEclipseAndMaven_v2.pdf |
| 22 | + - GIT Repository For Installation - https://github.com/in28minutes/getting-started-in-5-steps |
| 23 | + |
| 24 | +## Course Overview |
| 25 | + |
| 26 | +******* Course Overview ******* |
| 27 | + |
| 28 | +Architectures are moving towards Microservices and Cloud. Docker makes it easy to containerize your applications and make them cloud ready. |
| 29 | + |
| 30 | +Docker is the No 1 Tool to Containerize your Java Spring Boot Applications. Learning Docker would help you streamline your deployment processes and experiment easily with new frameworks and tools. |
| 31 | + |
| 32 | +In this handson course, we will containerize - create docker images and create containers - for a variety of Spring Boot Applications: |
| 33 | +- REST APIs - Hello World and Todo - Jar |
| 34 | +- Todo Web Application War |
| 35 | +- Full Stack Application with React and Spring Boot |
| 36 | +- CCS and CES Microservices |
| 37 | +- Eureka Naming Server and Zuul API Gateway |
| 38 | + |
| 39 | +This course would be a perfect first step as an introduction to Docker. |
| 40 | + |
| 41 | +You will be using containerizing a variety of projects created with React (Frontend Framework), Spring Boot (REST API Framework), Spring (Dependency Management), Spring Security (Authentication and Authorization - Basic and JWT), BootStrap (Styling Pages), Maven (dependencies management), Node (npm), Visual Studio Code (TypeScript IDE), Eclipse (Java IDE) and Tomcat Embedded Web Server. We will help you set up each one of these. |
| 42 | + |
| 43 | +## What you'll learn |
| 44 | +- You will Learn the Fundamentals of Docker from Zero, no previous experience required |
| 45 | +- You will learn the important Docker Concepts - Registry, Repository, Tag, Image, Container and Volumes |
| 46 | +- You will learn the important Docker commands |
| 47 | +- You will understand the Docker Architecture |
| 48 | +- You will create Docker images for 8 Java Spring Boot Projects |
| 49 | +- You will learn to use Dockerfile to Automate Building of your Docker Image |
| 50 | +- You will learn to use various maven plugins - Dockerfile Spotify Plugin, JIB Plugin and Fabric8 Docker Maven Plugin - to create Docker images |
| 51 | +- You will learn to create best practices with creating Docker Images - Improve Caching of Docker Images and create Multi Stage Docker Builds. |
| 52 | +- You will Containerize Java Spring Boot Todo Web Application talking with MySQL |
| 53 | +- You will Containerize Java Spring Boot React Full Stack Application with Docker |
| 54 | +- You will Containerize CCS, CES Microservices, Eureka Naming Server and Zuul API Gateway with Docker and Run them using Docker Compose |
| 55 | +- You will learn to run MySQL, RabbitMQ and Zipkin as Docker Containers |
| 56 | +- You will learn the basics of Docker Networking - HOST, BRIDGE and NONE |
| 57 | +- You will learn to use Docker Compose to Manage Your Containers |
| 58 | +- You will learn the basics of Microservices |
| 59 | +- You will Join 250,000 Learners having AMAZING LEARNING Experiences with in28Minutes |
| 60 | + |
| 61 | +## Requirements |
| 62 | +- You have an attitude to learn while having fun :) |
| 63 | +- You have some programming experience with Java, Spring and Spring Boot |
| 64 | +- You DO NOT need to have any experience with Docker |
| 65 | +- We will help you install Eclipse, Visual Studio Code, Git client, Docker Desktop and Node JS (for npm) |
| 66 | + |
| 67 | +## Who is this course for |
| 68 | +- You are a Java Spring Boot developer getting started with the Cloud |
| 69 | +- You want to containerize your Java applications with Docker |
| 70 | +- You are a Java Developer and You are curious about Docker |
| 71 | +- You want to learn to containerize a Java Spring Boot full stack application with Docker |
| 72 | +- You want to learn to play with Docker and Spring Boot Microservices - Service Registry, Distributed Tracing and Zuul API Gateway |
| 73 | + |
| 74 | +## Step By Step Details |
| 75 | + |
| 76 | +### Introduction to the Course |
| 77 | +- 00 Step 01 - Deploy Spring Boot Applications to Docker - Course Overview |
| 78 | +- 00 Step 02 - Deploy Spring Boot Applications to Docker - Getting Started |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | +```sh |
| 83 | +for file in *; do mv "${file}" "${file//-/ }"; done |
| 84 | +for file in *; do mv "${file}" "${file// / - }"; done |
| 85 | +for file in *; do mv "${file}" "${file//01 Step/Step}"; done |
| 86 | +``` |
| 87 | + |
| 88 | + |
| 89 | +### Commands Executed during the course |
| 90 | + |
| 91 | +``` |
| 92 | +System.out.println("Ranga") |
| 93 | +List<Integer> numbers = List.of(12, 9, 13, 4, 6, 2, 4, 12, 15); |
| 94 | +numbers.stream().reduce(0, (x,y)->x+y) |
| 95 | +numbers.stream().reduce(0, (x,y)->x) |
| 96 | +numbers.stream().reduce(0, (x,y)->y) |
| 97 | +numbers.stream().reduce(0, (x,y)-> x>y ? x:y) |
| 98 | +numbers.stream().reduce(Integer.MIN_VALUE, (x,y)-> x>y ? x:y) |
| 99 | +numbers.stream().reduce(Integer.MIN_VALUE, (x,y)-> x>y ? y:x) |
| 100 | +numbers.stream().reduce(Integer.MAX_VALUE, (x,y)-> x>y ? y:x) |
| 101 | +numbers |
| 102 | +numbers |
| 103 | +numbers.stream().reduce(0, (x,y) -> x*x + y*y) |
| 104 | +numbers.stream().map(x -> x*x).reduce(0, Integer::sum) |
| 105 | +numbers.stream().map(x -> x*x*x).reduce(0, Integer::sum) |
| 106 | +numbers.stream().filter(x -> x%2==1).reduce(0, Integer::sum) |
| 107 | +numbers.stream().filter(x -> x%2==0).reduce(0, Integer::sum) |
| 108 | +numbers.stream().distinct().forEach(System.out::println) |
| 109 | +numbers |
| 110 | +numbers.stream().sorted().forEach(System.out::println) |
| 111 | +numbers.stream().distinct().sorted().forEach(System.out::println) |
| 112 | +List<String> courses = List.of("Spring", "Spring Boot", "API" , "Microservices","AWS", "PCF","Azure", "Docker", "Kubernetes"); |
| 113 | +courses |
| 114 | +courses.stream().sorted().forEach(System.out::println) |
| 115 | +courses |
| 116 | +courses.stream().sorted().forEach(System.out::println) |
| 117 | +courses.stream().sorted(Comparator.naturalOrder()).forEach(System.out::println) |
| 118 | +courses.stream().sorted(Comparator.reverseOrder()).forEach(System.out::println) |
| 119 | +courses.stream().sorted(Comparator.comparing(str -> str.length())).forEach(System.out::println) |
| 120 | +numbers |
| 121 | +courses |
| 122 | +courses.stream().map(x -> x.length()).collect(Collectors.toList()) |
| 123 | +numbers.stream().map(x -> x*x).collect(Collectors.toList()) |
| 124 | +Supplier<String> supplier = () -> {return "Ranga";}; |
| 125 | +Consumer<String> consumer = (str) -> { System.out.println(str);System.out.println(str);}; |
| 126 | +
|
| 127 | +
|
| 128 | +numbers.stream() |
| 129 | +List<Integer> numbers = List.of(12, 9, 13, 4, 6, 2, 4, 12, 15); |
| 130 | +numbers.stream() |
| 131 | +Stream.of(12, 9, 13, 4, 6, 2, 4, 12, 15).count() |
| 132 | +Stream.of(12, 9, 13, 4, 6, 2, 4, 12, 15).reduce(0, Integer::sum) |
| 133 | +Stream.of(12, 9, 13, 4, 6, 2, 4, 12, 15) |
| 134 | +int[] numberArray = {12, 9, 13, 4, 6, 2, 4, 12, 15}; |
| 135 | +Arrays.stream(numberArray) |
| 136 | +Arrays.stream(numberArray).sum() |
| 137 | +Arrays.stream(numberArray).average() |
| 138 | +Arrays.stream(numberArray).min() |
| 139 | +Arrays.stream(numberArray).max() |
| 140 | +IntStream.range(1,10) |
| 141 | +IntStream.range(1,10).sum() |
| 142 | +IntStream.rangeClosed(1,10).sum() |
| 143 | +IntStream.iterate(1, e -> e + 2).limit(10).sum() |
| 144 | +IntStream.iterate(1, e -> e + 2).limit(10).peek(System.out::println).sum() |
| 145 | +IntStream.iterate(2, e -> e + 2).limit(10).peek(System.out::println).sum() |
| 146 | +IntStream.iterate(2, e -> e * 2).limit(10).peek(System.out::println).sum() |
| 147 | +IntStream.iterate(2, e -> e * 2).limit(10).boxed().collect(Collectors.toList()) |
| 148 | +Integer.MAX_VALUE |
| 149 | +Long.MAX_VALUE |
| 150 | +IntStream.rangeClosed(1,50).reduce(1, (x,y)->x*y) |
| 151 | +LongStream.rangeClosed(1,50).reduce(1, (x,y)->x*y) |
| 152 | +LongStream.rangeClosed(1,50).reduce(1L, (x,y)->x*y) |
| 153 | +LongStream.rangeClosed(1,10).reduce(1, (x,y)->x*y) |
| 154 | +LongStream.rangeClosed(1,20).reduce(1, (x,y)->x*y) |
| 155 | +LongStream.rangeClosed(1,40).reduce(1, (x,y)->x*y) |
| 156 | +LongStream.rangeClosed(1,50).mapToObj(BigInteger::valueOf).reduce(BigInteger.ONE, BigInteger::multiply) |
| 157 | +
|
| 158 | +courses.stream().collect(Collectors.joining(" ")) |
| 159 | +courses.stream().collect(Collectors.joining(",")) |
| 160 | +"Spring".split("") |
| 161 | +courses.stream().map(course -> course.split("")).collect(Collectors.toList()) |
| 162 | +courses.stream().map(course -> course.split("")) |
| 163 | +courses.stream().map(course -> course.split("")).flatMap(Arrays::stream).collect(Collectors.toList()) |
| 164 | +courses.stream().map(course -> course.split("")).flatMap(Arrays::stream).distinct().collect(Collectors.toList()) |
| 165 | +List<String> courses = List.of("Spring", "Spring Boot", "API" , "Microservices","AWS", "PCF","Azure", "Docker", "Kubernetes"); |
| 166 | +List<String> courses2 = List.of("Spring", "Spring Boot", "API" , "Microservices","AWS", "PCF","Azure", "Docker", "Kubernetes"); |
| 167 | +courses.stream().flatMap(course -> courses2.stream().map(course2 -> List.of(course,course2))).collect(Collectors.toList()) |
| 168 | +courses.stream().flatMap(course -> courses2.stream().map(course2 -> List.of(course,course2))).filter(list -> list.get(0).equals(list.get(1))).collect(Collectors.toList()) |
| 169 | +courses.stream().flatMap(course -> courses2.stream().map(course2 -> List.of(course,course2))).filter(list -> !list.get(0).equals(list.get(1))).collect(Collectors.toList()) |
| 170 | +courses.stream().flatMap(course -> courses2.stream().filter(course2 -> course2.length()==course.length()).map(course2 -> List.of(course,course2))).filter(list -> !list.get(0).equals(list.get(1))).collect(Collectors.toList()) |
| 171 | +courses.stream().filter(courses -> courses.length()>11).map(String::toUpperCase).findFirst() |
| 172 | +courses.stream().peek(System.out::println).filter(courses -> courses.length()>11).map(String::toUpperCase).peek(System.out::println).findFirst() |
| 173 | +courses.stream().peek(System.out::println).filter(courses -> courses.length()>11).map(String::toUpperCase).peek(System.out::println) |
| 174 | +$4.findFirst() |
| 175 | +List<String> courses = List.of("Spring", "Spring Boot", "API" , "Microservices","AWS", "PCF","Azure", "Docker", "Kubernetes"); |
| 176 | +courses.replaceAll( str -> str.toUpperCase()) |
| 177 | +List<String> modifyableCourses = new ArrayList(courses); |
| 178 | +modifyableCourses.replaceAll(str -> str.toUpperCase()) |
| 179 | +modifyableCourses |
| 180 | +modifyableCourses.removeIf(course -> course.length()<6) |
| 181 | +modifyableCourses |
| 182 | +
|
| 183 | +``` |
| 184 | + |
| 185 | +## Next Steps |
| 186 | + |
| 187 | +## Todo |
| 188 | +- Course Promotion Emails/Posts |
| 189 | + - 2 Emails on Udemy |
| 190 | + - 2 Emails to Email List |
| 191 | +- Create YouTube Course Preview Video |
| 192 | + - Add YouTube Course Preview Video as End Video for all videos |
| 193 | + - Make it the YouTube Default Video |
| 194 | +- Release atleast 20 small videos - one a day on Youtube |
| 195 | +- Do atleast 3 Youtube live sessions |
| 196 | +- After a Month |
| 197 | + - UFB and Packt |
| 198 | + |
| 199 | + |
| 200 | + |
| 201 | +### Later |
| 202 | + |
| 203 | +- collect(ArrayList::new, ArrayList::add, ArrayList::addAll) |
| 204 | +- partitioningBy |
| 205 | + |
| 206 | +Behavior Parameterization |
| 207 | +-> Tracing Performance of methods -> Pass function to track as a parameter |
| 208 | +-> Externalize Sort Behavior as a parameter |
| 209 | + |
| 210 | +Function Composition |
| 211 | +- Function<String, Integer> lengthBis = unNullify.andThen(length); |
| 212 | +- Function<String, Integer> lengthBis = length.compose(unNullify); |
| 213 | +Consumer.andThen |
| 214 | +- Predicate<String> startsWithJAndLengthIs7 = startsWithJ.and(lengthIs7); |
| 215 | +- Predicate<String> lengthIs9orError = lengthIs9.or(equalsError); |
| 216 | + |
| 217 | +Design Patterns |
| 218 | +- Decorator Pattern |
| 219 | +- Template Method - Execute Around Pattern |
| 220 | +- Strategy Pattern - Even/Odd/Prime |
| 221 | + |
| 222 | +Play based on Position: |
| 223 | +- IntStream.range(0, input.size()).filter(pos -> input.get(pos).length() > pos).mapToObj(pos -> input.get(pos)).collect(Collectors.toList()); |
| 224 | + |
| 225 | +Lambda Expressions in Unit Tests => assertThrows |
| 226 | + |
| 227 | +Currying f(x,y) = (g(x))(y) |
| 228 | +- int function(BiFunction<Integer,Integer,Integer> func, Integer value1, Integer value2) { return func.apply(value1,value2); } |
| 229 | +- function((x,y) -> x + y, 2, 3) |
| 230 | +- BiFunction<Integer, Integer, Integer> curry(BiFunction<Integer,Integer,Integer> func) { return (x,y) -> func.apply(x,y); } |
| 231 | +- BiFunction<Integer, Integer, Integer> add = curry( (x,y) -> x+y) |
| 232 | +add.apply(1,2) |
| 233 | + |
| 234 | +Map Operations |
| 235 | +- keys.forEach(key -> map.compute(key, (k, v) -> v == null ? k : v.toUpperCase())); |
| 236 | +- map.computeIfAbsent,Present,merge,putIfAbsent, computeIfPresent |
| 237 | + |
0 commit comments