Guava est une librairie open source créée et maintenue par les équipes de Google. Inspirée des outils internes du géant, Guava propose de nombreux mécanismes (prog fonctionnelle) pour manipuler les collections, créer des caches customisés, faciliter la gestion de la concurrence et les IOs.
De son coté, Lombok est également un projet Open Source. Lombok et Lombok-pg simplifient
sensiblement l’écriture de code classique (builders, delegates, etc.) et des nombreuses méthodes purement techniques et indispensables (getters, setters, hashCode, equals, etc.) qui polluent nos objets.
Durant cette présentation, après un rapide constat de la verbosité de nos beans, nous feront un tour d’horizon de Lombok et Guava. Nous verrons comment ils nous aident à écrire du code concis et de qualité.
Plan de la présentation :
* Milou est trop lourd (intro) ;
* Lombok (et Lombok-pg) en action ;
* Tour d’horizon de Guava
Guava est une librairie open source créée et maintenue par les équipes de Google. Inspirée des outils internes du géant, Guava propose de nombreux mécanismes (prog fonctionnelle) pour manipuler les collections, créer des caches customisés, faciliter la gestion de la concurrence et les IOs.
De son coté, Lombok est également un projet Open Source. Lombok et Lombok-pg simplifient
sensiblement l’écriture de code classique (builders, delegates, etc.) et des nombreuses méthodes purement techniques et indispensables (getters, setters, hashCode, equals, etc.) qui polluent nos objets.
Durant cette présentation, après un rapide constat de la verbosité de nos beans, nous feront un tour d’horizon de Lombok et Guava. Nous verrons comment ils nous aident à écrire du code concis et de qualité.
Plan de la présentation :
* Milou est trop lourd (intro) ;
* Lombok (et Lombok-pg) en action ;
* Tour d’horizon de Guava
Guava est une librairie open source créée et maintenue par les équipes de Google. Inspirée des outils internes du géant, Guava propose de nombreux mécanismes (prog fonctionnelle) pour manipuler les collections, créer des caches customisés, faciliter la gestion de la concurrence et les IOs.
De son coté, Lombok est également un projet Open Source. Lombok et Lombok-pg simplifient
sensiblement l’écriture de code classique (builders, delegates, etc.) et des nombreuses méthodes purement techniques et indispensables (getters, setters, hashCode, equals, etc.) qui polluent nos objets.
Durant cette présentation, après un rapide constat de la verbosité de nos beans, nous feront un tour d’horizon de Lombok et Guava. Nous verrons comment ils nous aident à écrire du code concis et de qualité.
Plan de la présentation :
* Milou est trop lourd (intro) ;
* Lombok (et Lombok-pg) en action ;
* Tour d’horizon de Guava
Guava est une librairie open source créée et maintenue par les équipes de Google. Inspirée des outils internes du géant, Guava propose de nombreux mécanismes (prog fonctionnelle) pour manipuler les collections, créer des caches customisés, faciliter la gestion de la concurrence et les IOs.
De son coté, Lombok est également un projet Open Source. Lombok et Lombok-pg simplifient
sensiblement l’écriture de code classique (builders, delegates, etc.) et des nombreuses méthodes purement techniques et indispensables (getters, setters, hashCode, equals, etc.) qui polluent nos objets.
Durant cette présentation, après un rapide constat de la verbosité de nos beans, nous feront un tour d’horizon de Lombok et Guava. Nous verrons comment ils nous aident à écrire du code concis et de qualité.
Plan de la présentation :
* Milou est trop lourd (intro) ;
* Lombok (et Lombok-pg) en action ;
* Tour d’horizon de Guava
Slides for the presentation that I made for LambdaConf 2015 in Boulder
Codebase available at http://www.slideshare.net/paulszulc/monads-asking-the-right-question
The document provides information about the speaker including their background and experience with Kotlin. Some key points:
- The speaker has 6 years of experience as an Android engineer and has created some apps.
- They are working on a Kotlin book and have been using Kotlin for 1 year.
- They organize a Kotlin user group in Bengaluru called BlrKotlin.
Functional Programming & Event Sourcing - a pair made in heavenPawel Szulc
The document discusses functional programming and event sourcing. It begins with an overview of functional programming principles like avoiding side effects and variable mutation. It then provides examples of modeling user data retrieval in a functional way using classes like Cache, UserRepo, and UserFinder. The examples demonstrate functional patterns like avoiding stateful objects and embracing immutable and recursive functions. The document argues that functional programming and event sourcing are well-aligned due to their shared emphasis on immutable data models and avoidance of shared state.
Kotlin is a statically typed programming language that runs on the Java Virtual Machine (JVM) and is fully interoperable with Java. Some key features of Kotlin include being less verbose than Java, property-based accessors, lambdas and type inference, which allow code to be more concise and readable. Kotlin aims to be practical for building large applications and introduces modern language features while also having a smooth learning curve for Java developers.
Guava est une librairie open source créée et maintenue par les équipes de Google. Inspirée des outils internes du géant, Guava propose de nombreux mécanismes (prog fonctionnelle) pour manipuler les collections, créer des caches customisés, faciliter la gestion de la concurrence et les IOs.
De son coté, Lombok est également un projet Open Source. Lombok et Lombok-pg simplifient
sensiblement l’écriture de code classique (builders, delegates, etc.) et des nombreuses méthodes purement techniques et indispensables (getters, setters, hashCode, equals, etc.) qui polluent nos objets.
Durant cette présentation, après un rapide constat de la verbosité de nos beans, nous feront un tour d’horizon de Lombok et Guava. Nous verrons comment ils nous aident à écrire du code concis et de qualité.
Plan de la présentation :
* Milou est trop lourd (intro) ;
* Lombok (et Lombok-pg) en action ;
* Tour d’horizon de Guava
Guava est une librairie open source créée et maintenue par les équipes de Google. Inspirée des outils internes du géant, Guava propose de nombreux mécanismes (prog fonctionnelle) pour manipuler les collections, créer des caches customisés, faciliter la gestion de la concurrence et les IOs.
De son coté, Lombok est également un projet Open Source. Lombok et Lombok-pg simplifient
sensiblement l’écriture de code classique (builders, delegates, etc.) et des nombreuses méthodes purement techniques et indispensables (getters, setters, hashCode, equals, etc.) qui polluent nos objets.
Durant cette présentation, après un rapide constat de la verbosité de nos beans, nous feront un tour d’horizon de Lombok et Guava. Nous verrons comment ils nous aident à écrire du code concis et de qualité.
Plan de la présentation :
* Milou est trop lourd (intro) ;
* Lombok (et Lombok-pg) en action ;
* Tour d’horizon de Guava
Guava est une librairie open source créée et maintenue par les équipes de Google. Inspirée des outils internes du géant, Guava propose de nombreux mécanismes (prog fonctionnelle) pour manipuler les collections, créer des caches customisés, faciliter la gestion de la concurrence et les IOs.
De son coté, Lombok est également un projet Open Source. Lombok et Lombok-pg simplifient
sensiblement l’écriture de code classique (builders, delegates, etc.) et des nombreuses méthodes purement techniques et indispensables (getters, setters, hashCode, equals, etc.) qui polluent nos objets.
Durant cette présentation, après un rapide constat de la verbosité de nos beans, nous feront un tour d’horizon de Lombok et Guava. Nous verrons comment ils nous aident à écrire du code concis et de qualité.
Plan de la présentation :
* Milou est trop lourd (intro) ;
* Lombok (et Lombok-pg) en action ;
* Tour d’horizon de Guava
Slides for the presentation that I made for LambdaConf 2015 in Boulder
Codebase available at http://www.slideshare.net/paulszulc/monads-asking-the-right-question
The document provides information about the speaker including their background and experience with Kotlin. Some key points:
- The speaker has 6 years of experience as an Android engineer and has created some apps.
- They are working on a Kotlin book and have been using Kotlin for 1 year.
- They organize a Kotlin user group in Bengaluru called BlrKotlin.
Functional Programming & Event Sourcing - a pair made in heavenPawel Szulc
The document discusses functional programming and event sourcing. It begins with an overview of functional programming principles like avoiding side effects and variable mutation. It then provides examples of modeling user data retrieval in a functional way using classes like Cache, UserRepo, and UserFinder. The examples demonstrate functional patterns like avoiding stateful objects and embracing immutable and recursive functions. The document argues that functional programming and event sourcing are well-aligned due to their shared emphasis on immutable data models and avoidance of shared state.
Kotlin is a statically typed programming language that runs on the Java Virtual Machine (JVM) and is fully interoperable with Java. Some key features of Kotlin include being less verbose than Java, property-based accessors, lambdas and type inference, which allow code to be more concise and readable. Kotlin aims to be practical for building large applications and introduces modern language features while also having a smooth learning curve for Java developers.
The document discusses operator overloading in Kotlin using the example of a Coin enum and Wallet class. It defines a Coin enum with values for common coins (PENNY, NICKEL, etc) that each have a cents value. A Wallet class is defined with a plusAssign operator function that allows adding Coin values to the wallet amount. Examples are shown incrementing a wallet variable by adding Coin values like QUARTER to demonstrate operator overloading.
Designing with Groovy Traits - Gr8Conf IndiaNaresha K
The document discusses using traits in Groovy to provide reusable behaviors and properties to classes without relying on inheritance. It describes how traits allow for mixing in multiple capabilities, overriding trait methods, implementing interfaces, declaring abstract methods, and having state. Traits can extend other traits and resolve conflicts using finer control. Traits also allow applying behaviors at runtime and composing common fields. Examples demonstrate composing user context, auditing objects, chaining approvals, and more.
Meetup di GDG Italia - Leonardo Pirro - Codemotion Rome 2018 Codemotion
I Google Developer Group (GDG) sono una community internazionale di appassionati delle tecnologie: sviluppatori, designer e startupper. Sono suddivisi per città, e GDG Italia è la famiglia che rappresenta tutti i gruppi presenti sul territorio locale. Mike Trizio e Carmelo Ventimiglia introdurranno i GDG, le loro attività e perchè è utile e divertente farne parte. Leonardo Pirro invece ci introdurrà Kotlin, un linguaggio di programmazione che ha avuto un crescente successo negli ultimi anni. Analizzeremo le caratteristiche principali del linguaggio e i suoi vantaggi/benefici rispetto a Java.
This document discusses prototypal inheritance in JavaScript. It explains that objects are hashes, and prototypes allow objects to inherit properties from parent objects. The document demonstrates how to define prototypes using Object.create, and shows how this allows child objects to access properties from parents in the prototype chain even if they are not directly defined on the child. It also discusses how classes are an "inconvenient fiction" in JavaScript and are simply constructor functions with methods added to the prototype.
It's happened to all of us: we ran away from some conversation or library because it kept on using those "weird" phrases. You know, like "type classes", "semigroups", "monoids", "applicatives". Yikes! They all seem so academic, so pointlessly detached from real-world problems. But then again, given how frequently we run into them in functional programming, are they REALLY irrelevant, or do they have real-world applications? This talk will go beyond giving you raw definitions of these terms, and show you real-world motivations behind the concepts. By attending, you'll be able to keep your skills relevant to an ever-changing industry, confuse your significant other ("You know, honey, a monad is just a monoid in the category of endofunctors!"), and sound extra smart on the next job interview!
This document provides an overview of the Python programming language. It includes several code examples and summaries of key Python concepts like strings, lists, tuples, dictionaries, files, regular expressions, and object-oriented programming. It also lists some common Python functions and modules for tasks like HTTP requests and database access. The document aims to introduce Python's main features and provide basic code samples to help new Python learners.
Functional programming is all the rage. It can undoubtedly produce cleaner and more expressive code, but why switch to Scala or wait for Java 8? In fact, there are many ways to dramatically improve your Java code quality by using a more functional style today. This presentation discusses how techniques such as functional programming, using fluent APIs, and other clean coding practices can make your code more concise, more readable, and much easier to maintain. But more importantly, you will learn about libraries such as LambdaJ and Google Guava that make this possible today with your existing Java code base.
This document provides an overview of text analysis with Python. It discusses common text mining tasks like entity recognition, sentiment analysis, and categorization. It promotes Python for short, concise text processing using tools like NLTK, Scipy, NumPy, and Scikit-learn. Key pre-processing steps covered include lowercasing, tokenization, handling entities, and removing stopwords. Supervised classification techniques like Naive Bayes classifiers and maximum entropy models are explained. Examples presented include a gender classifier and a system for recognizing questions in tweets.
Discovering functional treasure in idiomatic GroovyNaresha K
The document summarizes functional concepts in Groovy including functions as values, higher order functions, curried functions, function composition, pure functions, tail call optimization, memoization, and lazy evaluation. It provides examples of each concept using a sample Geek data model. The document aims to demonstrate how to write Groovy code in a more functional style by leveraging these concepts.
Android & Kotlin - The code awakens #02Omar Miatello
This document provides an overview of key Kotlin concepts compared to Java, including:
- Null safety in Kotlin prevents null reference exceptions at compile time by distinguishing nullable and non-nullable types.
- The Elvis operator (?:) provides a shorthand for checking for null values and returning a default.
- Smart casts allow the compiler to infer the type of a variable after checking its type against an if or when condition without needing an explicit cast.
- Kotlin collections APIs provide concise ways to filter, map, sort and iterate over collections compared to Java by leveraging functions like filterNotNull(), sortedBy(), map(), forEach().
The document demonstrates these Kotlin features through code examples
The document provides an overview of functional programming in Java. It discusses functional programming concepts like higher-order functions and avoiding side effects. It gives examples of functional-style code in Java for filtering lists and transforming objects. It also discusses how functional programming can be used to implement customizable business logic by passing functions as parameters and looking up functions through a dependency injection container.
Those are the slides of the presentation we made with Maurice Naftalin à Goto: Copenhagen 2019.
Functional programmers have been saying for decades that they know the way to the future. Clearly they've been wrong, since imperative languages are still far more popular. Clearly they've also been right, as the advantages of functional programming have become increasingly obvious. Is it possible to combine the two models? Scala is one language that does this, and Java too has been on a journey, which still continues, of learning from functional languages and carefully adding features from them. In this talk, we'll review what Java has learned from functional languages, what it can still learn, and how its added features compare to Scala's original ones.
The document appears to be notes from a presentation on Java 8 lambdas and functional programming concepts like mapping, filtering, and reducing collections of objects. It introduces lambda expressions as a more concise way to represent functions compared to anonymous inner classes in Java 7. Examples are provided of using lambdas with interfaces like Mapper, Predicate, and Reducer to process a List of Person objects by mapping to ages, filtering adults, and reducing to a sum. Corner cases and limitations of reduction operations are also briefly discussed.
This document introduces Kotlin, an open-source programming language developed by JetBrains. It notes that Kotlin is statically typed, interoperable with Java, and Android friendly. It provides examples of Kotlin code for basic "Hello World" programs, classes, functions, and other features. Major companies that use Kotlin, like Google, Netflix and Expedia, are listed. The document encourages learning more about Kotlin through resources on the Kotlin website.
Fun never stops. introduction to haskell programming languagePawel Szulc
The document introduces Haskell as a pure functional programming language. It discusses why functional programming matters, noting that it allows for modularity, has no concept of time, enables easy reasoning about code by just following types, and uses lazy evaluation. It also provides a brief history of Haskell, including the definition of Haskell 1.0 in 1990 and the Haskell 98 and Haskell 2010 standards. The overall document serves as an introduction to Haskell and reasons for learning the programming language.
Android & Kotlin - The code awakens #03Omar Miatello
A series of 3 events for building apps with Kotlin on Android.
Introduction to Kotlin, a modern language, developed by JetBrains (those who developed the IDE on which is based Android Studio) that compared to Java is more concise, versatile and with better error handling. The code is 100% interoperable with Java, and can be used to write native Android apps or small component.
The document discusses the evolution of functional programming features in Java and Scala over time. It notes that Scala was able to adopt features like generics, higher-order functions, and pattern matching earlier than Java due to not having backwards compatibility constraints. Java gradually added these features in pieces (generics in 2004, higher-order functions in 2014, pattern matching is upcoming) while Scala incorporated them as a whole when it launched in 2004. The document also examines some of the challenges Java faced in implementing these features due to its type erasure approach to generics and desire to maintain backwards compatibility.
A sprint thru Python's Natural Language ToolKit, presented at SFPython on 9/14/2011. Covers tokenization, part of speech tagging, chunking & NER, text classification, and training text classifiers with nltk-trainer.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms for those who already suffer from conditions like anxiety and depression.
The document discusses operator overloading in Kotlin using the example of a Coin enum and Wallet class. It defines a Coin enum with values for common coins (PENNY, NICKEL, etc) that each have a cents value. A Wallet class is defined with a plusAssign operator function that allows adding Coin values to the wallet amount. Examples are shown incrementing a wallet variable by adding Coin values like QUARTER to demonstrate operator overloading.
Designing with Groovy Traits - Gr8Conf IndiaNaresha K
The document discusses using traits in Groovy to provide reusable behaviors and properties to classes without relying on inheritance. It describes how traits allow for mixing in multiple capabilities, overriding trait methods, implementing interfaces, declaring abstract methods, and having state. Traits can extend other traits and resolve conflicts using finer control. Traits also allow applying behaviors at runtime and composing common fields. Examples demonstrate composing user context, auditing objects, chaining approvals, and more.
Meetup di GDG Italia - Leonardo Pirro - Codemotion Rome 2018 Codemotion
I Google Developer Group (GDG) sono una community internazionale di appassionati delle tecnologie: sviluppatori, designer e startupper. Sono suddivisi per città, e GDG Italia è la famiglia che rappresenta tutti i gruppi presenti sul territorio locale. Mike Trizio e Carmelo Ventimiglia introdurranno i GDG, le loro attività e perchè è utile e divertente farne parte. Leonardo Pirro invece ci introdurrà Kotlin, un linguaggio di programmazione che ha avuto un crescente successo negli ultimi anni. Analizzeremo le caratteristiche principali del linguaggio e i suoi vantaggi/benefici rispetto a Java.
This document discusses prototypal inheritance in JavaScript. It explains that objects are hashes, and prototypes allow objects to inherit properties from parent objects. The document demonstrates how to define prototypes using Object.create, and shows how this allows child objects to access properties from parents in the prototype chain even if they are not directly defined on the child. It also discusses how classes are an "inconvenient fiction" in JavaScript and are simply constructor functions with methods added to the prototype.
It's happened to all of us: we ran away from some conversation or library because it kept on using those "weird" phrases. You know, like "type classes", "semigroups", "monoids", "applicatives". Yikes! They all seem so academic, so pointlessly detached from real-world problems. But then again, given how frequently we run into them in functional programming, are they REALLY irrelevant, or do they have real-world applications? This talk will go beyond giving you raw definitions of these terms, and show you real-world motivations behind the concepts. By attending, you'll be able to keep your skills relevant to an ever-changing industry, confuse your significant other ("You know, honey, a monad is just a monoid in the category of endofunctors!"), and sound extra smart on the next job interview!
This document provides an overview of the Python programming language. It includes several code examples and summaries of key Python concepts like strings, lists, tuples, dictionaries, files, regular expressions, and object-oriented programming. It also lists some common Python functions and modules for tasks like HTTP requests and database access. The document aims to introduce Python's main features and provide basic code samples to help new Python learners.
Functional programming is all the rage. It can undoubtedly produce cleaner and more expressive code, but why switch to Scala or wait for Java 8? In fact, there are many ways to dramatically improve your Java code quality by using a more functional style today. This presentation discusses how techniques such as functional programming, using fluent APIs, and other clean coding practices can make your code more concise, more readable, and much easier to maintain. But more importantly, you will learn about libraries such as LambdaJ and Google Guava that make this possible today with your existing Java code base.
This document provides an overview of text analysis with Python. It discusses common text mining tasks like entity recognition, sentiment analysis, and categorization. It promotes Python for short, concise text processing using tools like NLTK, Scipy, NumPy, and Scikit-learn. Key pre-processing steps covered include lowercasing, tokenization, handling entities, and removing stopwords. Supervised classification techniques like Naive Bayes classifiers and maximum entropy models are explained. Examples presented include a gender classifier and a system for recognizing questions in tweets.
Discovering functional treasure in idiomatic GroovyNaresha K
The document summarizes functional concepts in Groovy including functions as values, higher order functions, curried functions, function composition, pure functions, tail call optimization, memoization, and lazy evaluation. It provides examples of each concept using a sample Geek data model. The document aims to demonstrate how to write Groovy code in a more functional style by leveraging these concepts.
Android & Kotlin - The code awakens #02Omar Miatello
This document provides an overview of key Kotlin concepts compared to Java, including:
- Null safety in Kotlin prevents null reference exceptions at compile time by distinguishing nullable and non-nullable types.
- The Elvis operator (?:) provides a shorthand for checking for null values and returning a default.
- Smart casts allow the compiler to infer the type of a variable after checking its type against an if or when condition without needing an explicit cast.
- Kotlin collections APIs provide concise ways to filter, map, sort and iterate over collections compared to Java by leveraging functions like filterNotNull(), sortedBy(), map(), forEach().
The document demonstrates these Kotlin features through code examples
The document provides an overview of functional programming in Java. It discusses functional programming concepts like higher-order functions and avoiding side effects. It gives examples of functional-style code in Java for filtering lists and transforming objects. It also discusses how functional programming can be used to implement customizable business logic by passing functions as parameters and looking up functions through a dependency injection container.
Those are the slides of the presentation we made with Maurice Naftalin à Goto: Copenhagen 2019.
Functional programmers have been saying for decades that they know the way to the future. Clearly they've been wrong, since imperative languages are still far more popular. Clearly they've also been right, as the advantages of functional programming have become increasingly obvious. Is it possible to combine the two models? Scala is one language that does this, and Java too has been on a journey, which still continues, of learning from functional languages and carefully adding features from them. In this talk, we'll review what Java has learned from functional languages, what it can still learn, and how its added features compare to Scala's original ones.
The document appears to be notes from a presentation on Java 8 lambdas and functional programming concepts like mapping, filtering, and reducing collections of objects. It introduces lambda expressions as a more concise way to represent functions compared to anonymous inner classes in Java 7. Examples are provided of using lambdas with interfaces like Mapper, Predicate, and Reducer to process a List of Person objects by mapping to ages, filtering adults, and reducing to a sum. Corner cases and limitations of reduction operations are also briefly discussed.
This document introduces Kotlin, an open-source programming language developed by JetBrains. It notes that Kotlin is statically typed, interoperable with Java, and Android friendly. It provides examples of Kotlin code for basic "Hello World" programs, classes, functions, and other features. Major companies that use Kotlin, like Google, Netflix and Expedia, are listed. The document encourages learning more about Kotlin through resources on the Kotlin website.
Fun never stops. introduction to haskell programming languagePawel Szulc
The document introduces Haskell as a pure functional programming language. It discusses why functional programming matters, noting that it allows for modularity, has no concept of time, enables easy reasoning about code by just following types, and uses lazy evaluation. It also provides a brief history of Haskell, including the definition of Haskell 1.0 in 1990 and the Haskell 98 and Haskell 2010 standards. The overall document serves as an introduction to Haskell and reasons for learning the programming language.
Android & Kotlin - The code awakens #03Omar Miatello
A series of 3 events for building apps with Kotlin on Android.
Introduction to Kotlin, a modern language, developed by JetBrains (those who developed the IDE on which is based Android Studio) that compared to Java is more concise, versatile and with better error handling. The code is 100% interoperable with Java, and can be used to write native Android apps or small component.
The document discusses the evolution of functional programming features in Java and Scala over time. It notes that Scala was able to adopt features like generics, higher-order functions, and pattern matching earlier than Java due to not having backwards compatibility constraints. Java gradually added these features in pieces (generics in 2004, higher-order functions in 2014, pattern matching is upcoming) while Scala incorporated them as a whole when it launched in 2004. The document also examines some of the challenges Java faced in implementing these features due to its type erasure approach to generics and desire to maintain backwards compatibility.
A sprint thru Python's Natural Language ToolKit, presented at SFPython on 9/14/2011. Covers tokenization, part of speech tagging, chunking & NER, text classification, and training text classifiers with nltk-trainer.
The document discusses the benefits of exercise for mental health. Regular physical activity can help reduce anxiety and depression and improve mood and cognitive functioning. Exercise causes chemical changes in the brain that may help protect against mental illness and improve symptoms for those who already suffer from conditions like anxiety and depression.
Suite à une enquête sur le terrain, nous avons fait le constat que l'information des risques de contamination par le virus du SIDA était connue. En revanche, il y a un déficit important tant sur le plan des connaissances que sur les moyens de prévention à mettre en œuvre concernant les 3 IST les plus répandues: le chlamydia, la blennorragie et l'herpès. De plus les prostituées sont originaires de pays étrangers et particulièrement des pays de l'Est,ce qui pose la question de l'accessibilité de l'information. Nous avons fait le choix de proposer un outil ciblant un apport de connaissances en 3 langues, Français, Anglais et Bulgare, et proposant le moyen de prévention: un préservatif adapté aux différentes pratiques sexuelles. 300 exemplaires de cet outil seront distribués dans le cadre d'un partenariat avec des associations.
Soirée Guava et Lombok avec Thierry LericheNormandy JUG
Guava est une librairie open source créée et maintenue par les équipes de Google. Inspirée des outils internes du géant, Guava propose de nombreux mécanismes (prog fonctionnelle) pour manipuler les collections, créer des caches customisés, faciliter la gestion de la concurrence et les IOs.
De son coté, Lombok est également un projet Open Source. Lombok et Lombok-pg simplifient sensiblement l’écriture de code classique (builders, delegates, etc.) et des nombreuses méthodes purement techniques et indispensables (getters, setters, hashCode, equals, etc.) qui polluent nos objets.
Durant cette présentation, après un rapide constat de la verbosité de nos beans, nous feront un tour
d’horizon de Lombok et Guava. Nous verrons comment ils nous aident à écrire du code concis et de
qualité.
The document discusses using Lombok and Guava annotations and utilities to simplify Java code by automatically generating boilerplate code like getters, setters, toString methods. It provides an example of how Lombok reduces a Dog class from 210 lines to just 12 lines by adding annotations, and shows how Guava provides cleaner implementations of common methods like toString and equals.
The document discusses using Lombok and Guava annotations and utilities to simplify Java code by automatically generating boilerplate code like getters, setters, toString methods. It provides an example of how Lombok reduces a Dog class from 210 lines to just 12 lines by adding annotations, and shows how Guava provides cleaner implementations of common methods like toString and equals.
This document summarizes Hamlet D'Arcy's presentation on AST transformations using tools like Lombok, Groovy, CodeNarc, and Mirah. It discusses how these tools allow manipulating abstract syntax trees to add functionality like automatic property generation, static analysis, and embedded domain-specific languages. Local AST transformations are performed without changing bytecode or requiring new semantics. Type checking can also be added through transformations. Mirah compiles to pure Java classes without additional syntax.
Introduction to the Kotlin statically typed programming language, a concise and elegant language targeting the Java Virtual Machine (JVM) and Javascript which has good support for functional programming and also object-oriented programming.
Includes examples of key features.
The document provides an overview of JavaScript for PHP developers. It discusses similarities and differences between JavaScript and PHP syntax, including variables, arrays, conditionals, loops, functions, objects, prototypes, and more. It also summarizes the built-in JavaScript API, including global functions, constructors, and properties and methods of objects like Object, Array, Function, String, Number, Math, Date, and Error.
Apache Groovy: the language and the ecosystemKostas Saidis
An overview of the Groovy language and its awesome ecosystem, advocating Groovy as the language of choice for (a) Java developers that want to dive into dynamic languages or (b) for Javascript, Ruby or Python developers that want to dive into the Java platform.
The presentation was given at the 9th FOSSCOMM (16-17 April 2016) organized by the Software Libre Sociecy of the University of Piraues.
Kotlin, a modern language for modern timesSergi Martínez
Kotlin is a programming language created by JetBrains that runs on the JVM and JavaScript. It is a modern language that aims to interoperate well with Java code and improve on Java in several ways, such as by avoiding null references and supporting features like lambdas. The document provides examples of how Kotlin code compares to Java code for tasks like defining functions and classes, handling null values, using streams and lambdas. It also includes a code sample that transforms a list of keyword strings.
This document provides an overview of JavaScript for PHP developers. It compares the syntax and core concepts between the two languages. Some of the key points covered include: variables and data types are similar, functions are objects in JavaScript, JavaScript uses prototypes instead of classes, and functions provide scope. The document also summarizes the built-in global functions and properties, common methods for objects like Array and String, and emphasizes that constructor functions are often not needed in JavaScript.
Exploring Ceylon with Gavin King - JUG BB Talk - Belrin 2014hwilming
The slide to the Java User Group Talk Exploring Ceylon from Gavin King.
Abstrakt:
Ceylon is a new programming language designed for writing large programs in teams. The language emphasizes readability, modularity, typesafety, and tooling. Ceylon programs execute on Java and JavaScript virtual machines. In this session, Gavin King will talk about the ideas behind Ceylon and demonstrate the language, its type system, its module architecture, and its IDE.
Speaker:
Gavin King leads the Ceylon project at Red Hat. He is the creator of Hibernate, a popular object/relational persistence solution for Java, and the Seam Framework, an application framework for enterprise Java. He's contributed to the Java Community Process as JBoss and then Red Hat representative for the EJB and JPA specifications and as lead of the CDI specification.
Now he works full time on Ceylon, polishing the language specification, developing the compiler frontend, and thinking about the SDK and future of the platform. He's still a fan of Java, and of other languages, especially Smalltalk, Python, and ML.
Kotlin is a statically typed programming language that runs on the JVM and JavaScript. It is fully supported by Google for Android development. Kotlin offers many features that make development easier like data classes, null safety, extensions, coroutines, and domain specific languages. These features help reduce boilerplate code and make Kotlin a powerful language that is killing it compared to other languages like Java.
The document discusses code generation on the JVM using various tools and frameworks. It provides an overview of Lombok for generating Java boilerplate code, Groovy AST transformations, CodeNarc for static analysis, and Spock, GContracts, and Groovy++ for framework-oriented code generation. It also discusses generating code at compile time using abstract syntax trees.
The document summarizes the key features of Groovy and how to get started using Groovy in Eclipse. It begins with an introduction to Groovy and its benefits compared to Java. It then walks through converting a simple "Hello World" Java program to Groovy. The remaining sections outline important Groovy features like closures and iterators, and how to install the Groovy Eclipse plugin.
1. The document discusses polyglot programming using multiple languages on the Java Virtual Machine (JVM), including Java, Groovy, Scala, and Clojure.
2. It notes that while Java has matured, other JVM languages have evolved faster with features like closures, operator overloading, and richer type systems.
3. Interoperability between JVM languages is seamless, allowing code written in different languages to easily call each other. The document promotes experimenting with multiple JVM languages for polyglot programming.
Groovy is a dynamic language for the Java Virtual Machine that builds upon Java's strengths. It allows for increased productivity by reducing boilerplate code and simplifying testing. Groovy code compiles to Java bytecode, integrates seamlessly with existing Java code, and has features like closures and iterators that make programming more concise. Groovy adopts many modern language features while keeping a low barrier to entry for Java developers.
Are you stuck in the Java world? I’ll share my story about convincing my team and the client of the benefits of Kotlin. Furthermore I’ll delve into how we migrated an existing Java Android app, with 300k active users, to Kotlin. Even if you have never seen Kotlin before, come and see how you will create better apps with this modern and elegant language. At the end of this talk you’ll be able to convince your team / client why it’s a great to use Kotlin. The power of Kotlin can be leveraged everywhere you use Java, since it compiles to JVM bytecode. So even if you’re not an Android developer, check out this session to get acquainted with Kotlin! No excuses: switch to Kotlin :)
Are you stuck in the Java world? I’ll share my story about convincing my team and the client of the benefits of Kotlin. Furthermore I’ll delve into how we migrated an existing Java Android app, with 300k active users, to Kotlin.
Even if you have never seen Kotlin before, come and see how you will create better apps with this modern and elegant language. At the end of this talk you’ll be able to convince your team / client why it’s a great to use Kotlin.
The power of Kotlin can be leveraged everywhere you use Java, since it compiles to JVM bytecode. So even if you’re not an Android developer, check out this session to get acquainted with Kotlin!
No excuses: switch to Kotlin
The document discusses the authors' initial naive expectations for using Scala and Clojure compared to their actual experience. They initially thought the languages would solve issues like boilerplate code and Java compiler problems, but found they still had to deal with interoperability, immutability, and other functional programming concepts. In the end, Clojure met more of their needs due to its emphasis on seamless interoperability, traits, and pattern matching.
Décryptez votre profil et ceux de vos interlocuteurs pour communiquer efficacement
DISC est l'acronyme de Dominant, Influent, Stable, Consciencieux
On représente les profils du modèle DISCp4 sur un disque dont les quartiers sont les quatre composantes. Le disque est divisé par deux axes.
Axe horizontal tâches-personnes
Les profils à l’ouest sont plutôt à l’aise dans la gestion des tâches tandis que ceux à l’est sont plutôt orientés vers le relationnel avec les personnes.
Axe vertical extravertis-introvertis
On retrouve au nord des personnes plutôt extraverties, qui se sentent supérieures à leur environnement et qui le maîtrisent. Au sud se situeront des personnes plutôt introverties, qui subissent leur environnement plus qu’elles ne le maîtrisent.
Chaque composante possède des caractéristiques propres et deux quartiers contigus partagent un certain nombre de ces caractéristiques.
Le profil des personnes est distribué sur les quatre composantes avec des degrés d’intensité variables. On observe généralement une ou deux composantes principales. Il est d’ailleurs assez rare qu’un profil ne soit distribué que sur une seule composante.
Le style Adapté représente votre Moi public. C'est celui que vous présentez en réponse à votre environnement.
Jung appelait cet aspect le masque. C'est celui que vous choisissez de montrer aux autres. C'est votre façon de paraître.
Le style Naturel représente votre Moi privé. Il vous indique l'aspect de votre comportement qui est le moins susceptible de varier, c'est celui que vous avez choisi inconsciemment, celui qui a le moins de chances d'être influencé par vos attentes et par celles de votre entourage.
Ce deuxième indicateur vous montre quelle est votre personne réelle. C'est celui vers lequel vous vous rabattrez automatiquement quand vous aurez du mal à maintenir votre profil adapté.
DISC is an assessment tool used to improve productivity, team work and communication. DISC stands for Dominance, Influence, Steadiness and Consciousness. The DISC profiles usually appear on a wheel whose sections are the 4 components. Each component has its own characteristics and two contiguous sections share some characteristics
DISC measures communication and behaviour styles. It is NOT an IQ test. It does NOT measure intellect, skills, mental health, values, etc. DISC profiles describe human behaviours in various situations, such as response to stress, to challenges, to crisis, to procedures, etc.
By knowing well your own profile and the ones of your audience, you can communicate in a more efficient way, both written and spoken. It helps to efficiently distribute tasks according to their types, objectives, needs, restraints, etc. It also helps to form a team by choosing the members according to the context.
The Influential likes to have good personal relationships. Usually positive and extroverted, he enjoys being with others and considers that life must be fun. Radiant and friendly, he addresses others in a convincing and democratic way
Votre chef revient d’un séminaire dédié aux outils du manager. Il est enthousiaste. Il ne parle plus que de profils en couleur ; des rouges, des jaunes, des verts ou encore des bleus. Il vous explique que ça va révolutionner la communication entre les membres de l’équipe et la rendre plus efficace. Vous voulez y croire mais ça vous semble bien mystérieux ?
Le DISC est un outil d'évaluation personnel utilisé pour améliorer la productivité, le travail d'équipe et la communication. Le DISC traite uniquement des styles de comportement et de communication. Il ne juge PAS. Il aide les gens à discuter et à comprendre leurs différences.
DISC est l'acronyme de Dominant, Influent, Stable, Conforme. La méthode DISC permet d'évaluer le profil des personnes selon ces quatre composantes.
On représente généralement les profils DISC sur un disque dont les quartiers sont les quatre composantes. Chaque composante possède ses caractéristiques propres et deux quartiers contigus partagent un certain nombre de caractéristiques. Par exemple, les profils Dominant (D) et Influent (I) correspondent généralement à des personnes extraverties.
Le profil des personnes est toujours distribué selon les quatre composantes. En général, on observe une ou deux composantes (contiguës) principales. Il est assez rare qu’un profil ne soit distribué que sur une seule composante. Les composantes diamétralement opposées sur le disque étant en opposition, il est assez rare qu’un profil soit uniformément réparti sur les quatre composantes.
Le Stable apprécie la cohérence dans sa vie et peut combattre pour une cause avec obstination. Il s'applique à être sérieux et fiable. Il ne répond pas facilement à l’ambiguïté ou à une structure impersonnelle et il peut être timide dans sa façon d’aborder les autres.
Le DISC est un outil d'évaluation personnel utilisé pour améliorer la productivité, le travail d'équipe et la communication. Le DISC traite uniquement des styles de comportement et de communication. Il ne juge PAS. Il aide les gens à discuter et à comprendre leurs différences.
DISC est l'acronyme de Dominant, Influent, Stable, Conforme. La méthode DISC permet d'évaluer le profil des personnes selon ces quatre composantes.
On représente généralement les profils DISC sur un disque dont les quartiers sont les quatre composantes. Chaque composante possède ses caractéristiques propres et deux quartiers contigus partagent un certain nombre de caractéristiques. Par exemple, les profils Dominant (D) et Influent (I) correspondent généralement à des personnes extraverties.
Le profil des personnes est toujours distribué selon les quatre composantes. En général, on observe une ou deux composantes (contiguës) principales. Il est assez rare qu’un profil ne soit distribué que sur une seule composante. Les composantes diamétralement opposées sur le disque étant en opposition, il est assez rare qu’un profil soit uniformément réparti sur les quatre composantes.
L’Influent est soucieux d’avoir de bonnes relations personnelles. Généralement positif et extraverti, il prend plaisir à la compagnie des autres et estime que la vie doit être amusante. Rayonnant et amical, il aborde les autres de façon convaincante et démocratique.
Le DISC est un outil d'évaluation personnel utilisé pour améliorer la productivité, le travail d'équipe et la communication. Le DISC traite uniquement des styles de comportement et de communication. Il ne juge PAS. Il aide les gens à discuter et à comprendre leurs différences.
DISC est l'acronyme de Dominant, Influent, Stable, Conforme. La méthode DISC permet d'évaluer le profil des personnes selon ces quatre composantes.
On représente généralement les profils DISC sur un disque dont les quartiers sont les quatre composantes. Chaque composante possède ses caractéristiques propres et deux quartiers contigus partagent un certain nombre de caractéristiques. Par exemple, les profils Dominant (D) et Influent (I) correspondent généralement à des personnes extraverties.
Le profil des personnes est toujours distribué selon les quatre composantes. En général, on observe une ou deux composantes (contiguës) principales. Il est assez rare qu’un profil ne soit distribué que sur une seule composante. Les composantes diamétralement opposées sur le disque étant en opposition, il est assez rare qu’un profil soit uniformément réparti sur les quatre composantes.
Le Dominant est bourré d’énergie, centré sur l’action et toujours en mouvement. D’un naturel plutôt positif et factuel, parfois agressif, il est extraverti, tenace et sait se concentrer sur les résultats à atteindre. Il aborde les autres de manière directe et autoritaire.
Le DISC est un outil d'évaluation personnel utilisé pour améliorer la productivité, le travail d'équipe et la communication. Le DISC traite uniquement des styles de comportement et de communication. Il ne juge PAS. Il aide les gens à discuter et à comprendre leurs différences.
DISC est l'acronyme de Dominant, Influent, Stable, Conforme. La méthode DISC permet d'évaluer le profil des personnes selon ces quatre composantes.
On représente généralement les profils DISC sur un disque dont les quartiers sont les quatre composantes. Chaque composante possède ses caractéristiques propres et deux quartiers contigus partagent un certain nombre de caractéristiques. Par exemple, les profils Dominant (D) et Influent (I) correspondent généralement à des personnes extraverties.
Le profil des personnes est toujours distribué selon les quatre composantes. En général, on observe une ou deux composantes (contiguës) principales. Il est assez rare qu’un profil ne soit distribué que sur une seule composante. Les composantes diamétralement opposées sur le disque étant en opposition, il est assez rare qu’un profil soit uniformément réparti sur les quatre composantes.
Le Consciencieux aime réfléchir avant d’agir. Il peut être perçu comme froid et indifférent. Il manifeste un fort désir de connaître et de comprendre ce qui l'entoure. Il a du mal à répondre à une pression autoritaire et préfère communiquer par écrit.
Chaque personne est unique. Chacun de nous voit le monde à sa façon. Chacun communique et se comporte d’une manière qui lui est propre. Ce constat est unanimement admis. Pourtant, nous répétons tous la même erreur de communication : nous parlons aux autres comme on aimerait qu’ils nous parlent. Cette erreur est essentielle. Il faut parler aux autres comme ils aimeraient qu’on leur parle. Une des règles d’or est qu’il faut s’adapter à son interlocuteur. Mais, pour cela, encore faut-il connaitre son profil…
DISC est un outil d'évaluation (coloré) utilisé pour améliorer la productivité, le travail d'équipe et la communication. DISC est l'acronyme de Dominant (rouge), Influent (jaune), Stable (vert) et Consciencieux (bleu). DISC mesure des styles de communication et de comportement. Ce n’est PAS un test de QI. Ça ne mesure PAS l’intelligence, les aptitudes, la santé mentale, les valeurs, etc. Les profils DISC décrivent les comportements humains dans de nombreuses situations, par exemple en réponse au stress, aux défis, aux challenges, aux crises, aux procédures, etc.
En connaissant bien son profil et celui de ses interlocuteurs, on peut communiquer de manière plus efficace, à l’écrit comme à l’oral. Cela permet de distribuer efficacement les tâches selon leurs types, les objectifs, les besoins, les contraintes, etc. Cela permet également de constituer une équipe en choisissant ses membres en fonction du contexte.
Chaque personne est unique. Chacun de nous voit le monde à sa façon. Chacun communique et se comporte d’une manière qui lui est propre. Ce constat est unanimement admis. Pourtant, nous répétons tous la même erreur de communication : nous parlons aux autres comme on aimerait qu’ils nous parlent. Cette erreur est essentielle. Il faut parler aux autres comme ils aimeraient qu’on leur parle. Une des règles d’or est qu’il faut s’adapter à son interlocuteur. Mais, pour cela, encore faut-il connaitre son profil…
DISC est un outil d'évaluation (coloré) utilisé pour améliorer la productivité, le travail d'équipe et la communication. DISC est l'acronyme de Dominant (rouge), Influent (jaune), Stable (vert) et Consciencieux (bleu). DISC mesure des styles de communication et de comportement. Ce n’est PAS un test de QI. Ça ne mesure PAS l’intelligence, les aptitudes, la santé mentale, les valeurs, etc. Les profils DISC décrivent les comportements humains dans de nombreuses situations, par exemple en réponse au stress, aux défis, aux challenges, aux crises, aux procédures, etc.
En connaissant bien son profil et celui de ses interlocuteurs, on peut communiquer de manière plus efficace, à l’écrit comme à l’oral. Cela permet de distribuer efficacement les tâches selon leurs types, les objectifs, les besoins, les contraintes, etc. Cela permet également de constituer une équipe en choisissant ses membres en fonction du contexte.
En passant à la machine à café, vous avez sans doute déjà croisé des développeurs. Vous avez sans doute constaté qu’ils ont l'air passionnés par leur métier, ce qui rend leurs discussions animées. Et vous les avez sans doute entendu prononcer des mots comme « Bubble », « Quicksort », « logarithme » ou encore « complexité », qui semblent provenir d'une autre langue. Ce sont pourtant des notions primordiales en programmation. Dans cet article, nous allons tenter de démystifier ce charabia.
Slides du cours de Génie Logiciel pour les étudiants de l'ESIEA, année 2016-17.
Le Génie Logiciel, c'est l'ensemble des activités de conception et de mise en œuvre des produits et des procédures tendant à rationaliser la production du logiciel et son suivi.
Au programme : UML, Xp, Scrum, Méthodes agiles, Java, Design Pattern, Swing, SVN, Objet, Tests, etc. et un peu de bavardages...
Guava est une librairie open source créée et maintenue par les équipes de Google. Inspirée des outils internes du géant, Guava propose de nombreux mécanismes (prog fonctionnelle) pour manipuler les collections, créer des caches customisés, faciliter la gestion de la concurrence et les IOs.
De son coté, Lombok est également un projet Open Source. Lombok et Lombok-pg simplifient
sensiblement l’écriture de code classique (builders, delegates, etc.) et des nombreuses méthodes purement techniques et indispensables (getters, setters, hashCode, equals, etc.) qui polluent nos objets.
Durant cette présentation, après un rapide constat de la verbosité de nos beans, nous feront un tour d’horizon de Lombok et Guava. Nous verrons comment ils nous aident à écrire du code concis et de qualité.
Plan de la présentation :
* Milou est trop lourd (intro) ;
* Lombok (et Lombok-pg) en action ;
* Tour d’horizon de Guava
This document discusses Google Guava and why developers like it. It covers Google Guava's factory methods for creating collections like lists, sets, and maps in a cleaner way compared to standard Java. It also discusses Guava's support for functional programming patterns using predicates, filters, and transformations. Additionally, it discusses Guava's immutable collections and how they improve defensiveness compared to standard Java.
À ce jour, le langage Java possède 53 mots réservés (dont 50 mots-clés) tels que class, for, long ou encore switch. Cet article les passe en revue, un par un, et vous propose des exemples d'utilisation simples. Pour s'y retrouver parmi ces 53 mots réservés, ils ont été triés par ordre alphabétique, mais aussi par catégorie.
Slides du cours de Génie Logiciel pour les étudiants de l'ESIEA, année 2013-2014.
Le Génie Logiciel, c'est "l'ensemble des activités de conception et de mise en œuvre des produits et des procédures tendant à rationaliser la production du logiciel et son suivi." UML, Xp, Scrum, Méthodes agiles, Java, Design Pattern, Swing, SVN, Objet, Tests, etc. et un peu de bavardages...
RPWORLD offers custom injection molding service to help customers develop products ramping up from prototypeing to end-use production. We can deliver your on-demand parts in as fast as 7 days.
International Upcycling Research Network advisory board meeting 4Kyungeun Sung
Slides used for the International Upcycling Research Network advisory board 4 (last one). The project is based at De Montfort University in Leicester, UK, and funded by the Arts and Humanities Research Council.
Best Digital Marketing Strategy Build Your Online Presence 2024.pptxpavankumarpayexelsol
This presentation provides a comprehensive guide to the best digital marketing strategies for 2024, focusing on enhancing your online presence. Key topics include understanding and targeting your audience, building a user-friendly and mobile-responsive website, leveraging the power of social media platforms, optimizing content for search engines, and using email marketing to foster direct engagement. By adopting these strategies, you can increase brand visibility, drive traffic, generate leads, and ultimately boost sales, ensuring your business thrives in the competitive digital landscape.
11. public class Dog
implements Comparable<Dog> {
...
@Override
public int compareTo(Dog other) {
int result = 0;
result = name.compareTo(other.name);
if (result != 0) {
return result;
}
...
}
Code très limite… NPE ?...
19. Java 5
birthday, fullname, name, race et sex
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (getClass() != obj.getClass()) return false;
5
Dog other = (Dog) obj;
if (birthday == null) {
if (other.birthday != null) return false;
} else if (!birthday.equals(other.birthday)) return false;
if (fullName == null) {
if (other.fullName != null) return false;
...
} else if (!race.equals(other.race)) return false;
if (sex != other.sex) return false;
return true;
}
Carrément illisible
equals ()
20. Guava
birthday, fullname, name, race et sex
public boolean equals(Object obj) {
if (!(obj instanceof Dog)) return false;
Dog other = (Dog) obj;
G
return Objects.equal(birthday, other.birthday)
&& Objects.equal(fullname, other.fullname)
&& Objects.equal(name, other.name)
&& Objects.equal(race, other.race)
&& sex == other.sex;
}
equals ()
21. Java 5
birthday, fullname, name, race et sex
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result
+ ((birthday == null) ? 0 : birthday.hashCode());
result = prime * result
+ ((fullName == null) ? 0 : fullName.hashCode());
result = prime * result
+ ((name == null) ? 0 : name.hashCode());
result = prime * result
+ ((race == null) ? 0 : race.hashCode());
result = prime * result
+ ((sex == null) ? 0 : sex.hashCode());
return result;
}
hashCode ()
5
22. Guava
birthday, fullname, name, race et sex
public int hashCode() {
return Objects.hashCode(birthday, fullName,
name, race, sex);
}
hasCode()
G
23. Java 5
name, fullname, birthday, weight, size, race et sex
public int compareTo(Dog other) {
int result = 0;
result = name.compareTo(other.name);
if (result != 0) {
return result;
}
result = fullname.compareTo(other.fullname);
if (result != 0) {
return result;
}
...
}
compareTo ()
5
31. Factory
@RequiredArgsConstructor(staticName = "of")
public class Dog {
private Integer id;
@NonNull private String name;
private String fullName;
@NonNull private SexeEnum sex;
private Date birthday;
...
Dog dog = Dog.of("Milou", MALE);
L
name, sex
32. Factory
@RequiredArgsConstructor(staticName = "of")
public class Dog {
private Integer id;
@NonNull private String name;
private String fullName;
@NonNull private SexeEnum sex;
private Date birthday;
...
Dog dog = Dog.of("Milou", MALE);
L
name, sex
private Dog(@NonNull final String name,
@NonNull final SexeEnum sex) {
if (name == null) throw new NullPointerException("name");
if (sex == null) throw new NullPointerException("sex");
this.name = name;
this.sex = sex;
}
public static Dog of(@NonNull final String name,
@NonNull final SexeEnum sex) {
return new Dog(name, sex);
}
35. Ressources
public void lireJava6(String from) {
InputStream in = null;
try {
in = new FileInputStream(from);
byte[] b = new byte[10000];
while (true) {
int r = in.read(b);
if (r == -1)
break;
...
}
} catch (Exception e) {
...
} finally {
if (in != null) {
try {
in.close();
} catch (Exception e) {
...
}
}
...
5
36. Ressources
public void lire(String from) throws IOException {
}
@Cleanup
InputStream in = new FileInputStream(from);
byte[] b = new byte[10000];
while (true) {
int r = in.read(b);
if (r == -1)
break;
...
}
L
39. Délombok
5
@Data
public class Dog {
private Integer id;
public class Dog {
private String name;
private Integer id;
private String fullName;
private String name;
private SexeEnum sex;
private String fullName;
private Date birthday;
...
private String race;
private List<String> colors;
private Boolean lof;
private Double weight;
public DogLombok() {
private Double size;
}
private List<String> colors;
@java.lang.Override
}
@java.lang.SuppressWarnings("all")
public boolean equals(final java.lang.Obje
if (o == this) return true;
if (o == null) return false;
mvn
lombok:delombok
if (o.getClass() != this.getClass()) ret
final Dog other = (Dog)o;
if (this.getId() == null ? other.getId()
...
5
@java.lang.Override
@java.lang.SuppressWarnings("all")
public int hashCode() {
final int PRIME = 31;
int result = 1;
result = result * PRIME + (this.getId()
42. Fluent
@FluentSetter
@Getter
public class Dog {
private Integer id ;
private String name ;
private String fullName ;
...
DogLombok dog = new DogLombok();
dog.name("Milou").sex(MALE);
println( dog.getName());
println( dog.getSex());
// Milou
// MALE
L
43. Builder
@Builder
@Getter
public class Dog {
private Integer id ;
private String name ;
private String fullName ;
...
Dog dog = Dog.dog().name("Milou").sex(MALE).build();
println( dog.getName());
println( dog.getSex());
// Milou
// MALE
L
44. extension
L
@ExtensionMethod({ Dog.class, MyDogExtensionClass.class })
public class DogWithExtension {
public void foo() {
Dog milou = new Dog("Milou", 12.5, ...);
boolean isTooFat = milou.isTooFat();
}
}
class MyDogExtensionClass {
public static boolean isTooFat(final Dog dog) {
double imc = dog.getWeight() / pow(dog.getSize(), 2);
return 25 < imc;
}
}
Avec paramètres FAQ 9
http://blog.developpez.com/todaystip/p11165/dev/java/extensionmethod-de-lombok-pg/
49. Java 5
< new Vs static factories >
List<Integer> primeNumbers = new ArrayList<Integer>();
Set<String> colors = new TreeSet<String>();
5
Map<String, Integer> ages = new HashMap<String, Integer>();
50. < new Vs static factories >
Java 5
5
List<Integer> primeNumbers = new ArrayList<Integer>();
Set<String> colors = new TreeSet<String>();
dur dur ?
Map<String, Integer> ages = new HashMap<String, Integer>();
Map<String, List<String>> trucs =
new HashMap<String, List<String>>();
5
Map<? extends Person, Map<String, List<String>>> trucs =
new TreeMap<? extends Person, Map<String, List<String>>>();
Map<? extends Wrapper<String, Sex, Person>, Map<String,
List<Set<Adress<String, Integer, Country>>>>> trucs = ...
51. Java 5
< new Vs static factories >
List<Integer> primeNumbers = new ArrayList<Integer>();
Set<String> colors = new TreeSet<String>();
5
7
Java 7
Map<String, Integer> ages = new HashMap<String, Integer>();
List<Integer> primeNumbers = new ArrayList<>();
Set<String> colors = new TreeSet<>();
Map<String, Integer> ages = new HashMap<>();
Qui utilise Java 7 en prod ?
52. Java 5
< new Vs static factories >
List<Integer> primeNumbers = new ArrayList<Integer>();
Set<String> colors = new TreeSet<String>();
5
7
G
Java 7
Map<String, Integer> ages = new HashMap<String, Integer>();
List<Integer> primeNumbers = new ArrayList<>();
Set<String> colors = new TreeSet<>();
Map<String, Integer> ages = new HashMap<>();
Guava
Qui utilise Java 7 en prod ?
List<Integer> primeNumbers = newArrayList();
Set<String> colors = newTreeSet();
Map<String, Integer> ages = newHashMap();
Dès maintenant !
53. Java 5
< new Vs static factories >
List<Integer> primeNumbers = new ArrayList<Integer>();
Set<String> colors = new TreeSet<String>();
5
7
G
Java 7
Map<String, Integer> ages = new HashMap<String, Integer>();
List<Integer> primeNumbers = new ArrayList<>();
Set<String> colors = new TreeSet<>();
Map<String, Integer> ages = new HashMap<>();
Guava
Qui utilise Java 7 en prod ?
List<Integer> primeNumbers = newArrayList();
Set<String> colors = newTreeSet();
Map<String, Integer> ages = newHashMap();
Lombok
Dès maintenant !
var primeNumbers = new ArrayList<Integer>();
-> primeNumbers.size();
...
L
54. List of dogs
< new Vs static factories >
List<Dog> dogs = newArrayList(
new Dog("Milou", 12.5, MALE, ...),
new Dog("Rintintin", 45.0, MALE, ...),
new Dog("Volt", 10.3, MALE, ...),
new Dog("Lassie", 45.0, FEMALE, ...),
new Dog("Pluto", 22.0, MALE, ...),
new Dog("Medor", 35.6, MALE, ...));
[Milou,
Rintintin,
Volt,
Lassie,
Pluto,
Medor]
G
57. immutable
Quand ?
mutable
On se demande souvent si une liste doit être immutable mais
c’est prendre le problème dans le mauvais sens. La plupart du
temps, ce qu’il faut vraiment se demander, c’est si la liste a
besoin d’être mutable.
60. Of
< unmodifiables Vs immutables >
ImmutableSet.of(E
ImmutableSet.of(E
ImmutableSet.of(E
ImmutableSet.of(E
ImmutableSet.of(E
ImmutableSet.of(E
e1)
e1,
e1,
e1,
e1,
e1,
E
E
E
E
E
e2)
e2,
e2,
e2,
e2,
E
E
E
E
G
e3)
e3, E e4)
e3, E e4, E e5)
e3, E e4, E e5, E e6, E...)
Of
Ne prend pas de null
ImmutableSet.of()
Vide
Map et List FAQ 4
http://blog.developpez.com/guava/p10589/collection/title-212/
61. Java 5
< Copie de défense >
public class Dog {
private String name;
...
private List<String> colors;
public Dog(String name, List<String> colors) {
this.name = name;
...
this.colors = Collections.unmodifiableList(
new ArrayList<String>(colors));
}
public List<String> getColors() {
return colors;
}
5
62. Guava
< Copie de défense >
public class Dog {
private String name;
...
private ImmutableList<String> colors;
public Dog(String name, List<String> colors) {
this.name = name;
...
this.colors = ImmutableList.copyOf(colors);
}
public ImmutableList<String> getColors() {
return colors;
}
Message clair
G
66. Guava
< Bi Map >
BiMap<String, Dog> tatouages = HashBiMap.create();
tatouages.put("ABC123", new Dog("Milou") );
tatouages.put("MBD324", new Dog("Volt") );
tatouages.put("JFT672", new Dog("Lassie") );
println( tatouages );
{ABC123=Milou,
MBD324=Volt,
JFT672=Lassie}
ABC123=Milou
MDB324=Volt
JFT672=Lassie
println( tatouages.inverse() );
Une map bijective
{Milou=ABC123,
Volt=MBD324,
Lassie=JFT672}
Il est possible de changer la valeur associée à une clé mais pas
d'avoir deux clés avec la même valeur (IllegalArgumentException).
G
67. Guava
< Multi Set >
Multiset<Integer> ages = HashMultiset.create();
ages.add(2);
ages.add(3);
ages.add(7);
ages.add(11);
ages.add(3);
ages.add(5);
println( ages );
[2, 3 x 2, 5, 7, 11]
println( ages.count(3) )
2
G
86. Super Chien
public class SuperChien implements SuperHero {
private
private
private
private
String
double
Set<String>
Set<String>
surnom ;
poids ;
couleursCostume ;
pouvoirs ;
5
...
Les héros peuvent avoir plusieurs costumes donc je
n’utilise pas un ImmutableSet. Idem pour les pouvoirs
dont la liste augmente avec l’expérience.
87. Transformation
< Transformation >
List<SuperChien> superChiens =
Lists.transform(dogs,
new Function<Dog, SuperChien>() {
@Override
public SuperChien apply(Dog dog) {
SuperChien chien = new SuperChien();
G
chien.setSurnom("Super " + dog.getName());
chien.setPoids(dog.getWeight());
chien.setCouleursCostume(newHashSet(dog.getColors()))
chien.setPouvoirs(newHashSet("Code en Java", "Vole"))
...
return chien;
}
});
[Super Milou,
Super Rintintin,
Super Volt,
Super Lassie,
Super Pluto,
Super Medor]
88. Transformation
< Transformation >
List<SuperChien> superChiens =
Lists.transform(dogs, new Function<Dog, SuperChien>() {
@Override
public SuperChien apply(Dog dog) {
SuperChien chien = new SuperChien();
...
return chien;
}
});
G
Vue (lazy)
size / isEmpty dispo
Pas pour traitements répétés FAQ 3
List<SuperChien> chiens = newArrayList(Lists.transform(...
ImmutableList<SuperChien> chiens =
ImmutableList.copyOf(Lists.transform(...
89. < Filtre >
Filtre
G
Predicate<Dog> malePredicate =
new Predicate<Dog>() {
public boolean apply(Dog dog) {
return dog.getSex() == MALE;
}
}
Iterable<Dog> maleDogs =
Iterables.filter(dogs, malePredicate);
[Milou,
Rintintin,
Volt,
Pluto,
Medor]
G
90. Filtre
< Filtre >
Predicate<Dog> malePredicate =
new Predicate<Dog>() {
public boolean apply(Dog dog) {
return dog.getSex() == MALE;
}
}
Iterable<Dog> maleDogs =
Iterables.filter(dogs, malePredicate);
[Milou,
Rintintin,
Volt,
Pluto,
Medor]
Dog firstMaleDog =
Iterables.find(dogs, malePredicate);
Milou
G
G
G
91. Filtre
< Filtre >
Predicate<Dog> malePredicate =
new Predicate<Dog>() {
public boolean apply(Dog dog) {
return dog.getSex() == MALE;
}
}
Iterable<Dog> maleDogs =
Iterables.filter(dogs, malePredicate);
[Milou,
Rintintin,
Volt,
Pluto,
Medor]
Dog firstMaleDog =
Iterables.find(dogs, malePredicate);
Milou
G
G
G
Dog firstMaleDog =
Iterables.find(femaleDogs, malePredicate, DEFAULT_DOG );
Default dog
92. Pas fluent
< Fluent or not fluent ? >
Predicate<Dog> malePredicate =
new Predicate<Dog>() {
public boolean apply(Dog dog) {
return dog.getSex() == MALE;
}};
Function<FullDog, String> nameFunction =
new Function<FullDog, String>() {
public String apply(FullDog dog) {
return dog.getName();
}};
Iterable<FullDog> maleDogs =
Iterables.filter(dogs, malePredicate);
Iterable<String> maleNames =
Iterables.transform(maleDogs, nameFunction);
G
G
G
[Milou,
Rintintin,
Volt,
Pluto,
Medor]
93. Pas fluent
< Fluent or not fluent ? >
Iterable<FullDog> maleDogs =
Iterables.filter(dogs, malePredicate);
Fluent
Iterable<String> maleNames =
Iterables.transform(maleDogs, nameFunction);
List<String> maleNames2 =
FluentIterable.from(dogs)
.filter(malePredicate)
.transform(nameFunction)
.toImmutableList();
G
G
Guava 12.0
http://blog.developpez.com/guava/p11092/annotation/fluentiterable-surmon-chien-guava/
[Milou,
Rintintin,
Volt,
Pluto,
Medor]
95. Web Service
< Memoization >
public class DogService {
@Inject
private PetShopWebService service;
public Integer getNumberDogsSoldYesterday() {
return service.checkSales( "dog" );
}
5
96. Web Service
< Memoization >
Cache manuel
public class DogService {
@Inject
private PetShopWebService service;
public Integer getNumberDogsSoldYesterday() {
return service.checkSales( "dog" );
}
private Integer nbOfDogsSold;
public Integer getNumberDogsSoldYesterday() {
if (nbOfDogsSold == null) {
nbOfDogsSold = service.checkSales( "dog" );
}
return nbOfDogsSold;
}
5
5
Double check null…
97. Guava
< Memoization >
public class DogService {
@Inject
private PetShopWebService service;
private Supplier<Integer> nbOfDogsSoldSupplier =
Suppliers.memoize(
new Supplier<Integer>() {
public Integer get() {
return service.checkSales( "dog" );
}
});
public Integer getNumberDogsSoldYesterday() {
return nbOfDogsSoldSupplier.get();
}
G
98. Guava
< Memoization >
public class DogService {
@Inject
private PetShopWebService service;
private Supplier<Integer> nbOfDogsSoldSupplier =
Suppliers.memoizeWithExpiration(
new Supplier<Integer>() {
public Integer get() {
return service.checkSales( "dog" );
}
}, 1, TimeUnit.DAYS );
public Integer getNumberDogsSoldYesterday() {
return nbOfDogsSoldSupplier.get();
}
G
99. Web Service
< Cache >
public class DogService {
@Inject
private PetShopWebService service;
private Map<String, Dog> dogMap = Maps.newHashMap();
5
public Dog getDog(String name) {
Dog dog = dogMap.get(name);
if(dog == null) {
dog = service.getAnimal( "dog", name ); // type-name
dogMap.put( name, dog );
}
return dog;
}
Quid du timeout ? Max ?
100. Guava
< Cache >
public class DogService {
@Inject
private PetShopWebService service;
G
private LoadingCache<String, Dog> dogCache =
CacheBuilder.newBuilder()
.maximumSize(2000)
.expireAfterWrite(30, TimeUnit.MINUTES)
.build(new CacheLoader<String, Dog>() {
public Dog load(String key) {
return service.getAnimal( "dog", key );
}
});
public Dog getDog(String name) {
return dogCache.get( name ); // + try-catch
}
103. Préparation
< Is in list ? >
int NB_OF_DOGS = 100000;
contains
List<Dog> dogs = newArrayList();
Random rand = new Random();
for (int i = 0; i < NB_OF_DOGS; i++) {
Dog dog = new Dog();
dog.setName("abc" + rand.nextInt(999));
...
dogs.add(dog);
}
final Dog milou = new Dog();
milou.setName("Milou");
...
boolean isInList = dogs.contains(milou);
5
5
false (14 ms)
dogs.add(milou);
boolean isInList = dogs.contains(milou);
true (14 ms)
104. Bloom filter
< Is in list ? >
Funnel<Dog> dogFunnel = new Funnel<Dog>() {
public void funnel(Dogdog, PrimitiveSink sink) {
sink.putString(dog.getName())
.putString(dog.getFullName())
.putString(dog.getRace());
}};
G
BloomFilter<Dog> bloom =
BloomFilter.create(dogFunnel, NB_OF_DOGS, 0.01);
for (int i = 0; i < NB_OF_DOGS; i++) {
...
bloom.put(dog);
boolean isInList = bloom.mightContain(milou);
false (0 ms)
bloom.put(milou);
boolean isInList = bloom.mightContain(milou);
Guava 13
true (0 ms)
http://blog.developpez.com/guava/p11149/collection/bloom-filter-de-guava-13/
105. Guava or not Guava ?
Avantages et inconvénients
106. Pro / Cons
Ne pas en abuser…
Utile
Bonnes pratiques
109. ICAUDA
http://icauda.com
http://icauda.com/articles.html
http://icauda.com/cours.html
(articles)
(slides)
Blog Guava
http://blog.developpez.com/guava
« Simplifier le code de vos beans Java à l'aide
de Commons Lang, Guava et Lombok »
http://thierry-leriche-dessirier.developpez.com/tutoriels/
java/simplifier-code-guava-lombok
(article)
113. toString
Régime : la méthode Commons ?
public String toString() {
return new ToStringBuilder(this)
.append("id", id)
.append("name", name)
.append("fullName", fullName)
...
.append("colors", colors)
.toString();
}
2
L
114. equals
Régime : la méthode Commons ?
public boolean equals(Object obj) {
if (this == obj) return true;
if (obj == null) return false;
if (!(obj instanceof Dog)) return false;
Dog other = (Dog) obj;
return new EqualsBuilder()
.append(birthday, other.birthday)
.append(fullname, other.fullname)
.append(name, other.name)
.append(race, other.race)
.append(sex, other.sex)
.isEquals();
2
}
L
115. hashCode
Régime : la méthode Commons ?
public int hashCode() {
return new HashCodeBuilder(17, 37)
.append(birthday)
.append(fullname)
.append(name)
.append(race)
.append(sex)
.toHashCode();
}
2
L
116. compareTo
Régime : la méthode Commons ?
public int compareTo(Dog other) {
return new CompareToBuilder()
.append(name, other.name)
.append(fullname, other.fullname)
.append(birthday, other.birthday)
...
.append(sex, other.sex)
.toComparison();
}
2
L
117. Transformation
Fonctionnal prog Vs boucle for : quand ?
List<SuperChien> superChiens = newArrayList(
Lists.transform(dogs, new Function<Dog, SuperChien>() {
@Override
public SuperChien apply(Dog dog) {
SuperChien chien = new SuperChien();
...
return chien;
}
}));
3
Vs
G
List<SuperChien> superChiens = newArrayList();
for(Dog dog : dogs) {
SuperChien chien = new SuperChien();
...
superChiens.add(chien);
}
G
http://code.google.com/p/guava-libraries/wiki/FunctionalExplained
118. of
Créer des Maps
public static final ImmutableMap<String, Integer>
AGES = ImmutableMap.of("Milou", 32,
"Volt", 7,
"Pluto", 37,
"Lassie", 17);
Builder
G
4
public static final ImmutableMap<String, Integer>
AGES = new ImmutableMap.Builder<String, Integer>()
.put("Milou", 32)
.put("Volt", 7)
.put("Pluto", 37)
.put("Lassie", 17)
.put("Medor", 5)
.put("Croquette", 8)
.put("Loulou", 2)
...
.build();
G
119. Java 5
Charsets
String name = "Milou";
try {
byte[] bytes = name.getBytes("UTF-8");
5
} catch (UnsupportedEncodingException e) {
throw new AssertionError(e);
}
Guava
Ca n’arrive jamais cette exception
5
String name = "Milou";
byte[] bytes = name.getBytes(Charsets.UTF_8);
G
120. Converter Spring
import org.springframework...Converter;
G
@Component("dogToChienConverter")
public class DogToChienConverter
implements Converter<List<Dog>,
List<SuperChien>> {
6
public List<SuperChien> convert(List<Dog> dogs) {
List<SuperChien> chiens = newArrayList(transform(dogs,
new Function<Dog, SuperChien>() {
public SuperChien apply(Dog dog) {
...
return chien;
}
}));
return chiens;
}
Lazy or not lazy ?
123. Extension avec valeurs
@ExtensionMethod({ Object.class, MyOtherClass.class })
public class DogWithExtension {
public void foo() {
String s1 = "toto";
s1.print();
// toto
String s2 = null;
s2.print();
// null
}
}
class MyOtherClass {
public static <T> void print(final T value) {
System.out.println(value);
}
}
9
On peut mettre autre chose qu’un "Object", par exemple un
"Arrays" , un "Dog" , etc.
L
124. Extension avec valeurs
@ExtensionMethod({ Object.class, MyOtherClass.class })
public class DogWithExtension {
public void foo() {
String s1 = "toto";
s1.print();
// toto
String s2 = null;
s2.print();
s2.print("vide");
// null
// vide
}
}
9
class MyOtherClass {
public static <T> void print(final T value) {
System.out.println(value);
}
public static void print(String value, String other) {
if (value == null || value.isEmpty()) {
System.out.println(other);
} else {
System.out.println(value);
}
L
125. < Chrono >
Guava Java 5
long start = new Date().getTime();
foo(); // traitement long (ou pas)
long end = new Date().getTime();
5
long duration = end - start; // 11 ms
Stopwatch sw = new Stopwatch();
sw.start();
foo(); // traitement long (ou pas)
sw.stop();
long duration = sw.elapsedMillis(); // 11 ms
10
G
long nano = sw.elapsedTime(NANOSECONDS); // 11179739 ns
long micro = sw.elapsedTime(MICROSECONDS); // 11179 us
long millis = sw.elapsedTime(MILLISECONDS); // 11 ms
http://blog.developpez.com/guava/p11160/base/le-stop-watch-de-guava/
127. Impl
public class Dog implements Comparable<Dog> {
private Integer id ;
private String name ;
private String fullName ;
5
...
@Override
public int compareTo(Dog dog) {
return ...;
}
12
implements List ? aie aie aie
129. Seconde liste
And, or, in…
List<Dog> dogs2 = newArrayList(
new Dog("Rintintin", 45.0, MALE, ...),
13
new Dog("Pluto", 22.0, MALE, ...),
new Dog("Lulu", 35.6, MALE, ...));
[Rintintin,
Pluto,
Lulu]
Liste 2 : dogs2
[Milou,
Rintintin,
Volt,
Lassie,
Pluto,
Medor]
Liste 1 : dogs
G
132. Java
Guava
Inférence de type
List<Integer> primeNumbers = new ArrayList<Integer>();
List<Integer> primeNumbers = newArrayList();
public static <E> ArrayList<E> newArrayList() {
return new ArrayList<E>();
}
15
http://blog.developpez.com/guava/p11334/collection/inference-de-type-avec-guava
133. Coût du bloom
final List<Dog> dogs = Lists.newArrayList();
final Funnel<Dog> dogFunnel = new Funnel<Dog>() {
@Override
public void funnel(Dog dog, PrimitiveSink sink) {
sink.putString(dog.getName())
.putString(dog.getFullName())
.putString(dog.getRace());
}
};
BloomFilter<Dog> bloom
= BloomFilter.create(dogFunnel, NB_OF_DOGS, 0.01);
final Random rand = new Random();
16
Stopwatch sw = new Stopwatch();
sw.start();
for (int i = 0; i < NB_OF_DOGS; i++) {
final DogGuava dog = new DogGuava(...);
dogs.add(dog);
}
long duration1 = sw.elapsedTime(MICROSECONDS);
138. Pas d’écrasement des getters existants
@Data
public class MicroDog {
private String name;
private Integer age;
public String getName() {
return "*" + name + "*";
}
}
18
@Test
public void testGetterExistant() {
final String name = "Milou";
final String requiredName = "*Milou*";
final MicroDog dog = new MicroDog();
dog.setName(name);
assertEquals(requiredName, dog.getName());
}