SlideShare a Scribd company logo
Evolving with Java - How to
Remain Effective
Naresha K
@naresha_k

https://blog.nareshak.com/
About me
Developer, Architect &
Tech Excellence Coach
Founder & Organiser
Bangalore Groovy User
Group
Business
Time to Market |
Speed of Delivery
Economy
public static void main(String[] args) {
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 6);
List<Integer> result = numbers.stream()
.map(ParallelStreams::computeHeavyArithmetic)
.collect(Collectors.toList());
System.out.println(result);
}
public static void main(String[] args) {
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 6);
List<Integer> result = numbers.parallelStream()
.map(ParallelStreams::computeHeavyArithmetic)
.collect(Collectors.toList());
System.out.println(result);
}
public static void main(String[] args) {
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 6);
List<Integer> result = numbers.stream()
.map(ParallelStreams::computeHeavyArithmetic)
.collect(Collectors.toList());
System.out.println(result);
}
public static void main(String[] args) {
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 6);
List<Integer> result = numbers.parallelStream()
.map(ParallelStreams::computeHeavyArithmetic)
.collect(Collectors.toList());
System.out.println(result);
}
private static Logger LOGGER = LoggerFactory
.getLogger(MyClass.class);
All
models are wrong,
but some are useful.
https://en.wikipedia.org/wiki/All_models_are_wrong
George Box
Pain!
Suffering
Pain!
I have not experienced
the pain, yet.
public static String concatWithPlus(String[] values) {
String result = "";
for (int i = 0; i < values.length; i++) {
result += values[i];
}
return result;
}
public static String concatWithStringBuffer(String[] values) {
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < values.length; i++) {
buffer.append(values[i]);
}
return buffer.toString();
}
Java
1.4
Java 5
Maintainability?
‘+’ vs StringBuffer
API Contract
Concatenation
Thread Safety
Level of Abstraction
Concatenation
Favour
higher level of
abstraction
Premature
optimisation is the
root of all evil
~ Donald Knuth
Rule 1: Don’t
Rule 2: Don’t, yet
Rule 3: Profile before optimising
http://wiki.c2.com/?RulesOfOptimization
YAGNI
Make it work
Make it better
Make it work
Make it Right
Make it Fast
http://wiki.c2.com/?MakeItWorkMakeItRightMakeItFast
Java 11
Red Green
Refactor
TDD
/**
* This method returns orders of customer
* @param customer Customer whose orders to be fetched
* @return List containing Order objects of the
* specified Customer
*/
public List getOrdersOfCustomer(Customer customer);
public List<Order>
getOrdersOfCustomer(Customer customer);
public List<OrderSummary> getOrdersOfCustomer(Customer
customer);
Self Documenting Code
public static void main(String[] args) {
List numbers = Arrays.asList(1, 2, 3, 4, 5);
Iterator iterator = numbers.iterator();
while (iterator.hasNext()) {
Number number =
(Number) iterator.next();
System.out.println(number);
}
}
Java
1.4
public static void main(String[] args) {
List numbers = Arrays.asList(1, 2, 3, 4, 5);
Iterator iterator = numbers.iterator();
while (iterator.hasNext()) {
Number number =
(Number) iterator.next();
System.out.println(number);
}
}
Java
1.4
List<Number> numbers =
Arrays.asList(1, 2, 3, 4, 5);
for(Number number : numbers) {
System.out.println(number);
}
Java 5
Syntactic Sugar
Minimise
Moving Parts
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 6);
int sumOfSquaresOfEvenNumbers = 0;
for (Integer number : numbers) {
if(number % 2 == 0) {
sumOfSquaresOfEvenNumbers += number * number;
}
}
System.out.println(sumOfSquaresOfEvenNumbers);
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 6);
int sumOfSquaresOfEvenNumbers = 0;
for (Integer number : numbers) {
if(number % 2 == 0) {
sumOfSquaresOfEvenNumbers += number * number;
}
}
System.out.println(sumOfSquaresOfEvenNumbers);
Predicate<Integer> isEven = (number) -> number % 2 == 0;
Function<Integer, Integer> square = (number) -> number *
number;
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 6);
Integer sum = numbers.stream()
.filter(isEven)
.map(square)
.collect(Collectors.
summingInt(Integer::intValue));
System.out.println(sum);
Java 8
Favour
Declarative Code
Learn Multiple
Paradigms
Predicate<Integer> isEven = (number) -> number % 2 == 0;
Function<Integer, Integer> square = (number) ->
number * number;
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 6);
Integer result = numbers.stream()
.filter(isEven)
.map(square)
.findFirst().orElse(-1);
System.out.println(result);
Java 8
Predicate<Integer> isEven = (number) -> number % 2 == 0;
Function<Integer, Integer> square = (number) ->
number * number;
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 6);
Integer result = numbers.stream()
.filter(isEven)
.map(square)
.findFirst().orElse(-1);
System.out.println(result);
List<Integer> numbers = List.of(1, 2, 3, 4, 5, 6);
int suqareOfFirstEvenNumber = -1;
for (Integer number : numbers) {
if(number % 2 == 0) {
suqareOfFirstEvenNumber += number * number;
break;
}
}
System.out.println(suqareOfFirstEvenNumber);
Java 8
What you see
is not what
you get
Lazy Evaluation
Understand one level
below the abstraction
you deal with
Introspector.java
Food pizza = new Pizza();
Person friend = new Person(“Raj");
friend.getMouth().setFood(pizza);
Food pizza = new Pizza();
Person friend = new Person(“Raj");
friend.getMouth().setFood(pizza);
Person friend = new Person(“Raj");
Edible food = new Pizza();
friend.offer(food);
Encapsulation
Use checked exceptions
Judiciously
55
Most people talk about Java the language,
and this may sound odd coming from me,
but I could hardly care less. At the core of
the Java ecosystem is the JVM.
- James Gosling,
Creator of the Java Programming Language(2011, TheServerSide)
http://zeroturnaround.com/rebellabs/the-adventurous-developers-guide-to-jvm-languages-java-scala-groovy-fantom-clojure-ceylon-kotlin-xtend/
https://www.tiobe.com/tiobe-index/
https://www.tiobe.com/tiobe-index/
package com.nareshak.demo
data class Person(val firstName: String,
val lastName: String)
package com.nareshak.demo;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class Person {
private String firstName;
private String lastName;
}
package com.nareshak.demo;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class Person {
private String firstName;
private String lastName;
}
package com.nareshak.demo;
import lombok.Data;
@Data
public class Person {
private String firstName;
private String lastName;
}
Learn Multiple
Languages
INHERITANCE
68
default methods???
Use features
Judiciously
Strive for Simplicity
Go beyond Familiarity
Evolution is the TRUE
nature of code
Thank You

More Related Content

What's hot

関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)
riue
 

What's hot (20)

Collections Framework Begineers guide 2
Collections Framework Begineers guide 2Collections Framework Begineers guide 2
Collections Framework Begineers guide 2
 
Julia meetup bangalore
Julia meetup bangaloreJulia meetup bangalore
Julia meetup bangalore
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
 
関数潮流(Function Tendency)
関数潮流(Function Tendency)関数潮流(Function Tendency)
関数潮流(Function Tendency)
 
JDI 2.0. Not only UI testing
JDI 2.0. Not only UI testingJDI 2.0. Not only UI testing
JDI 2.0. Not only UI testing
 
Asegúr@IT IV - Remote File Downloading
Asegúr@IT IV - Remote File DownloadingAsegúr@IT IV - Remote File Downloading
Asegúr@IT IV - Remote File Downloading
 
(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net(1) c sharp introduction_basics_dot_net
(1) c sharp introduction_basics_dot_net
 
Lucene
LuceneLucene
Lucene
 
Hash set (java platform se 8 )
Hash set (java platform se 8 )Hash set (java platform se 8 )
Hash set (java platform se 8 )
 
Практическое применения Akka Streams
Практическое применения Akka StreamsПрактическое применения Akka Streams
Практическое применения Akka Streams
 
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
«Практическое применение Akka Streams» — Алексей Романчук, 2ГИС
 
Programs
ProgramsPrograms
Programs
 
Collection Core Concept
Collection Core ConceptCollection Core Concept
Collection Core Concept
 
Typescript barcelona
Typescript barcelonaTypescript barcelona
Typescript barcelona
 
The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181The Ring programming language version 1.5.2 book - Part 7 of 181
The Ring programming language version 1.5.2 book - Part 7 of 181
 
5 Rmi Print
5  Rmi Print5  Rmi Print
5 Rmi Print
 
Fp java8
Fp java8Fp java8
Fp java8
 
SparkSQLの構文解析
SparkSQLの構文解析SparkSQLの構文解析
SparkSQLの構文解析
 
Tips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET ApplicationTips and Tricks of Developing .NET Application
Tips and Tricks of Developing .NET Application
 
Mcs011 solved assignment by divya singh
Mcs011 solved assignment by divya singhMcs011 solved assignment by divya singh
Mcs011 solved assignment by divya singh
 

Similar to Evolving with Java - How to Remain Effective

Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#
Mark Needham
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdf
rajeshjangid1865
 
Problem 1 Show the comparison of runtime of linear search and binar.pdf
Problem 1 Show the comparison of runtime of linear search and binar.pdfProblem 1 Show the comparison of runtime of linear search and binar.pdf
Problem 1 Show the comparison of runtime of linear search and binar.pdf
ebrahimbadushata00
 
SeaJUG March 2004 - Groovy
SeaJUG March 2004 - GroovySeaJUG March 2004 - Groovy
SeaJUG March 2004 - Groovy
Ted Leung
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
HCMUTE
 

Similar to Evolving with Java - How to Remain Effective (20)

Evolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and EffectiveEvolving with Java - How to remain Relevant and Effective
Evolving with Java - How to remain Relevant and Effective
 
object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lectures
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
 
Java 8 Lambda Expressions
Java 8 Lambda ExpressionsJava 8 Lambda Expressions
Java 8 Lambda Expressions
 
Java arrays
Java    arraysJava    arrays
Java arrays
 
Java 5 and 6 New Features
Java 5 and 6 New FeaturesJava 5 and 6 New Features
Java 5 and 6 New Features
 
Arrays
ArraysArrays
Arrays
 
Functional Programming
Functional ProgrammingFunctional Programming
Functional Programming
 
Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#Mixing functional and object oriented approaches to programming in C#
Mixing functional and object oriented approaches to programming in C#
 
Mixing Functional and Object Oriented Approaches to Programming in C#
Mixing Functional and Object Oriented Approaches to Programming in C#Mixing Functional and Object Oriented Approaches to Programming in C#
Mixing Functional and Object Oriented Approaches to Programming in C#
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdf
 
Problem 1 Show the comparison of runtime of linear search and binar.pdf
Problem 1 Show the comparison of runtime of linear search and binar.pdfProblem 1 Show the comparison of runtime of linear search and binar.pdf
Problem 1 Show the comparison of runtime of linear search and binar.pdf
 
Alternate JVM Languages
Alternate JVM LanguagesAlternate JVM Languages
Alternate JVM Languages
 
Basic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time APIBasic java, java collection Framework and Date Time API
Basic java, java collection Framework and Date Time API
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Ruby
 
Functional techniques in Ruby
Functional techniques in RubyFunctional techniques in Ruby
Functional techniques in Ruby
 
SeaJUG March 2004 - Groovy
SeaJUG March 2004 - GroovySeaJUG March 2004 - Groovy
SeaJUG March 2004 - Groovy
 
Computer java programs
Computer java programsComputer java programs
Computer java programs
 
6_Array.pptx
6_Array.pptx6_Array.pptx
6_Array.pptx
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 

More from Naresha K

More from Naresha K (20)

The Groovy Way of Testing with Spock
The Groovy Way of Testing with SpockThe Groovy Way of Testing with Spock
The Groovy Way of Testing with Spock
 
Take Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainersTake Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainers
 
Implementing Resilience with Micronaut
Implementing Resilience with MicronautImplementing Resilience with Micronaut
Implementing Resilience with Micronaut
 
Take Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainersTake Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainers
 
Favouring Composition - The Groovy Way
Favouring Composition - The Groovy WayFavouring Composition - The Groovy Way
Favouring Composition - The Groovy Way
 
Effective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good PracticesEffective Java with Groovy - How Language Influences Adoption of Good Practices
Effective Java with Groovy - How Language Influences Adoption of Good Practices
 
What's in Groovy for Functional Programming
What's in Groovy for Functional ProgrammingWhat's in Groovy for Functional Programming
What's in Groovy for Functional Programming
 
Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...
Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...
Effective Java with Groovy & Kotlin - How Languages Influence Adoption of Goo...
 
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
Effective Java with Groovy & Kotlin How Languages Influence Adoption of Good ...
 
Implementing Cloud-Native Architectural Patterns with Micronaut
Implementing Cloud-Native Architectural Patterns with MicronautImplementing Cloud-Native Architectural Patterns with Micronaut
Implementing Cloud-Native Architectural Patterns with Micronaut
 
Groovy - Why and Where?
Groovy  - Why and Where?Groovy  - Why and Where?
Groovy - Why and Where?
 
Leveraging Micronaut on AWS Lambda
Leveraging Micronaut on AWS LambdaLeveraging Micronaut on AWS Lambda
Leveraging Micronaut on AWS Lambda
 
Groovy Refactoring Patterns
Groovy Refactoring PatternsGroovy Refactoring Patterns
Groovy Refactoring Patterns
 
Implementing Cloud-native Architectural Patterns with Micronaut
Implementing Cloud-native Architectural Patterns with MicronautImplementing Cloud-native Architectural Patterns with Micronaut
Implementing Cloud-native Architectural Patterns with Micronaut
 
Effective Java with Groovy
Effective Java with GroovyEffective Java with Groovy
Effective Java with Groovy
 
Effective Java with Groovy - How Language can Influence Good Practices
Effective Java with Groovy - How Language can Influence Good PracticesEffective Java with Groovy - How Language can Influence Good Practices
Effective Java with Groovy - How Language can Influence Good Practices
 
Beyond Lambdas & Streams - Functional Fluency in Java
Beyond Lambdas & Streams - Functional Fluency in JavaBeyond Lambdas & Streams - Functional Fluency in Java
Beyond Lambdas & Streams - Functional Fluency in Java
 
GORM - The polyglot data access toolkit
GORM - The polyglot data access toolkitGORM - The polyglot data access toolkit
GORM - The polyglot data access toolkit
 
Rethinking HTTP Apps using Ratpack
Rethinking HTTP Apps using RatpackRethinking HTTP Apps using Ratpack
Rethinking HTTP Apps using Ratpack
 
Design Patterns from 10K feet
Design Patterns from 10K feetDesign Patterns from 10K feet
Design Patterns from 10K feet
 

Recently uploaded

JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
Max Lee
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
mbmh111980
 

Recently uploaded (20)

JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)JustNaik Solution Deck (stage bus sector)
JustNaik Solution Deck (stage bus sector)
 
How to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabberHow to install and activate eGrabber JobGrabber
How to install and activate eGrabber JobGrabber
 
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
KLARNA -  Language Models and Knowledge Graphs: A Systems ApproachKLARNA -  Language Models and Knowledge Graphs: A Systems Approach
KLARNA - Language Models and Knowledge Graphs: A Systems Approach
 
5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand5 Reasons Driving Warehouse Management Systems Demand
5 Reasons Driving Warehouse Management Systems Demand
 
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
Paketo Buildpacks : la meilleure façon de construire des images OCI? DevopsDa...
 
A Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data MigrationA Guideline to Zendesk to Re:amaze Data Migration
A Guideline to Zendesk to Re:amaze Data Migration
 
Advanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should KnowAdvanced Flow Concepts Every Developer Should Know
Advanced Flow Concepts Every Developer Should Know
 
Benefits of Employee Monitoring Software
Benefits of  Employee Monitoring SoftwareBenefits of  Employee Monitoring Software
Benefits of Employee Monitoring Software
 
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdfMastering Windows 7 A Comprehensive Guide for Power Users .pdf
Mastering Windows 7 A Comprehensive Guide for Power Users .pdf
 
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdfA Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
A Comprehensive Appium Guide for Hybrid App Automation Testing.pdf
 
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
How Does XfilesPro Ensure Security While Sharing Documents in Salesforce?
 
Studiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting softwareStudiovity film pre-production and screenwriting software
Studiovity film pre-production and screenwriting software
 
INGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by DesignINGKA DIGITAL: Linked Metadata by Design
INGKA DIGITAL: Linked Metadata by Design
 
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with StrimziStrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
StrimziCon 2024 - Transition to Apache Kafka on Kubernetes with Strimzi
 
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAGAI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
AI/ML Infra Meetup | Reducing Prefill for LLM Serving in RAG
 
Using IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New ZealandUsing IESVE for Room Loads Analysis - Australia & New Zealand
Using IESVE for Room Loads Analysis - Australia & New Zealand
 
Agnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in KrakówAgnieszka Andrzejewska - BIM School Course in Kraków
Agnieszka Andrzejewska - BIM School Course in Kraków
 
A Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data MigrationA Guideline to Gorgias to to Re:amaze Data Migration
A Guideline to Gorgias to to Re:amaze Data Migration
 
Breaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdfBreaking the Code : A Guide to WhatsApp Business API.pdf
Breaking the Code : A Guide to WhatsApp Business API.pdf
 
Crafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM IntegrationCrafting the Perfect Measurement Sheet with PLM Integration
Crafting the Perfect Measurement Sheet with PLM Integration
 

Evolving with Java - How to Remain Effective