Sponsored by:
Sponsored by:
Samil Vargas
Payment System Developer at @Wirecard
Sponsored by:
What we are going to see ?
Sponsored by:
Functional programming is the process of building software by composing pure functions, avoiding shared state, mutable data, and side-effects. Functional programming is declarative rather than imperative, and application state flows through pure functions. Contrast with object oriented programming, where application state is usually shared and colocated with methods in objects.
Sponsored by:
Functional programming is a programming paradigm, meaning that it is a way of thinking about software construction based on some fundamental, defining principles (listed above).
Sponsored by:
Sponsored by:
Imperative: In which programmer instruct the machine how to change its state.
Declarative: in which programmer merely declares properties of the desired properties.
Sponsored by:
Sponsored by:
Sponsored by:
Task: Make a Java function that return whether a number is prime or not
Sponsored by:
Descriptive Way
public static boolean isPrime(int number) {
return number > 1 &&
IntStream.range(2, (int)Math.sqrt(number))
.noneMatch(index -> number % index == 0);
}
Sponsored by:
Sponsored by:
Imperative Way
public static boolean isPrime(int number) {
for (int i = 2; i * i <= number; i++) {
if (number % i == 0) {
return false;
}
}
return number > 1;
}
Sponsored by:
Sponsored by:
Text
Clarifications
Sponsored by:
A lot of people in Java-land are trying to mix traditional imperative Java code and functional-ish code, with varying degrees of success. Java is not a functional language, it is fundamentally an Object Oriented language that allows us to adopt some functional concepts in so far as we enforce their correct implementation through developer discipline. Unlike in Haskell, Idris, Ocaml (and even Scala) the compiler alone won’t save us.
Sponsored by:
Pros and Cons
Sponsored by:
Functional Programming Pros
Some of the issues that are solved by using functional programming instead of OOP are the followings:
Sponsored by:
Object-Oriented Programming Pros
Some of the issues that are solved by using object-oriented programming instead of FP are the followings:
Sponsored by:
Sponsored by: