Julien Ponge
This talk introduces part of the Java SE 7 novelties. The fork/join framework aims at making parallel programming simpler, while Project Coin brings a set of subtle yet useful changes to the Java programming language.
http://soft-shake.ch/2011/conference/sessions/java/2011/09/06/java7.html
Conf soat tests_unitaires_Mockito_jUnit_170113SOAT
Vous subissez les régressions à chaque livraison ? Vous ne voyez pas l’intérêt des tests unitaires car ils ne servent qu’à tester des additions ? Si c’est le cas, suivez David dans la quête du Test Driven Development. Nous rencontrerons pléthore d'ennemies contre lesquels nous aurons à combattre : bugs, complexité, code statique, couplage fort. Ils essaieront de nous barrer la route, mais heureusement, nous pourrons compter sur nos alliés jUnit, Mockito, refactoring et injection/dépendance
~10min dive to Python Asynchronous IO
HTML version (recommended): https://dl.dropboxusercontent.com/u/1565687/speak/Python3%20AsyncIO%20Horizon/index.html
Entrepreneurship and Commerce in IT - 14 - Web Marketing CommunicationsSachintha Gunasena
This series in about the Entrepreneurial and E-Commerce opportunities and how to harness the power of Information Technology to improve or revolutionize business.
This session discusses about web marketing communications.
Conf soat tests_unitaires_Mockito_jUnit_170113SOAT
Vous subissez les régressions à chaque livraison ? Vous ne voyez pas l’intérêt des tests unitaires car ils ne servent qu’à tester des additions ? Si c’est le cas, suivez David dans la quête du Test Driven Development. Nous rencontrerons pléthore d'ennemies contre lesquels nous aurons à combattre : bugs, complexité, code statique, couplage fort. Ils essaieront de nous barrer la route, mais heureusement, nous pourrons compter sur nos alliés jUnit, Mockito, refactoring et injection/dépendance
~10min dive to Python Asynchronous IO
HTML version (recommended): https://dl.dropboxusercontent.com/u/1565687/speak/Python3%20AsyncIO%20Horizon/index.html
Entrepreneurship and Commerce in IT - 14 - Web Marketing CommunicationsSachintha Gunasena
This series in about the Entrepreneurial and E-Commerce opportunities and how to harness the power of Information Technology to improve or revolutionize business.
This session discusses about web marketing communications.
This session discusses about the basic building blocks of Concurrent Programming in Java, which include:
high-level concurrency objects, lock objects, executors, executor interfaces, thread pools, fork/join, concurrent collections, atomic variables, concurrent random numbers.
The fork/join framework, which is based on the ForkJoinPool class, is an implementation of the Executor interface. It is designed to efficiently run a large number of tasks using a pool of worker threads. A work-stealing technique is used to keep all the worker threads busy, to take full advantage of multiple processors
Concurrency Programming in Java - 01 - Introduction to Concurrency ProgrammingSachintha Gunasena
This session discusses a basic high-level introduction to concurrency programming with Java which include:
programming basics, OOP concepts, concurrency, concurrent programming, parallel computing, concurrent vs parallel, why concurrency, real world example, terms, Moore's Law, Amdahl's Law, types of parallel computation, MIMD Variants, shared memory model, distributed memory model, client server model, scoop mechanism, scoop preview - a sequential program, in a concurrent setting - using scoop, programming then & now, sequential programming, concurrent programming,
While most bugs reveal their cause within their stack trace, Java’s OutOfMemoryError is less talkative and therefore regarded as being difficult to debug by a majority of developers. With the right techniques and tools, memory leaks in Java programs can however be tackled like any other programming error. This talks discusses how a JVM stores data, categorizes different types of memory leaks that can occur in a Java program and presents techniques for fixing such errors. Furthermore, we will have a closer look at lambda expressions and their considerable potential of introducing memory leaks when they are used incautiously.
An introduction on testing Node.js code.
Covers frontend (UI) testing, backend unit tests and code coverage.
Also mentions how to use a Makefile to run frontend and backend tests at the same time.
Java Programming Must implement a storage manager that main.pdfadinathassociates
Java Programming: Must implement a storage manager that maintains a series of data objects in
each data file. This assignment provides you with a set of incomplete classes (, see SlottedPage,
FileManager, and BufferedFileManager which contain methods currently throwing an
UnsupportedOperationException). You will need to write code for these classes. Your code will be
graded by running a set of unit tests and then examining your code (see SlottedPageTest and
FileManagerTest which use JUnit1, as well as BufferedFileManagerTest which produces output
messages). Note that passing unit tests does NOT necessarily guarantee that your
implementation is correct and efficient. Please make sure that your code will not cause any
problem in other cases not covered by the unit tests. Below are the files and make sure there are
no errors and show the output as well.
BufferedFileManager.java
package mypack;
import java.io.IOException;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
public class BufferedFileManager extends FileManager {
private int bufferSize;
private Map<Integer, SlottedPage> buffer;
public BufferedFileManager(int bufferSize) {
this.bufferSize = bufferSize;
buffer = new LinkedHashMap<Integer, SlottedPage>(bufferSize);
}
@Override
public void put(int fileID, Long location, Object o) throws IOException, InvalidLocationException {
if (buffer.containsKey(first(location))) {
SlottedPage p = buffer.get(first(location));
p.put(second(location), o);
buffer.put(first(location), p);
} else {
if (buffer.size() == bufferSize) {
// Evict the least recently used page
buffer.remove(buffer.keySet().iterator().next());
}
SlottedPage p = page(fileID, first(location));
p.put(second(location), o);
updated(p, fileID);
buffer.put(first(location), p);
}
}
@Override
public Object get(int fileID, Long location) throws IOException, InvalidLocationException {
if (buffer.containsKey(first(location))) {
return buffer.get(first(location)).get(second(location));
}
SlottedPage p = page(fileID, first(location));
if (buffer.size() == bufferSize) {
// Evict the least recently used page
buffer.remove(buffer.keySet().iterator().next());
}
buffer.put(first(location), p);
return p.get(second(location));
}
@Override
public Object remove(int fileID, Long location) throws IOException, InvalidLocationException {
if (buffer.containsKey(first(location))) {
SlottedPage p = buffer.get(first(location));
Object o = p.remove(second(location));
buffer.put(first(location), p);
return o;
}
SlottedPage p = page(fileID, first(location));
Object o = p.remove(second(location));
updated(p, fileID);
if (buffer.size() == bufferSize) {
// Evict the least recently used page
buffer.remove(buffer.keySet().iterator().next());
}
buffer.put(first(location), p);
return o;
}
@Override
public Iterator<Object> iterator(int fileID) throws IOException {
SlottedPage[] pages = pages(fileID);
return new BufferedPageIterator(pages, buffer);
}
}
BufferedPageIterator.java
package mypack;.
soft-shake.ch - Windows Phone 7 „Mango“ – what’s new for Developers?soft-shake.ch
Sascha Corti
Just a year after Windows Phone 7 was released to the market, Microsoft is updating the already widely popular platform to a new release called “Mango”, which adds a lot of highly anticipated features, especially for developers.
This session will introduce you to what’s new in the Mango platform for you as a developer. Many samples will show you the latest additions including background agents, the new on-device database, how to make your application run in the background and how to create augmented-reality applications or create multiple live tiles per application, that can be easily updated from within the running app.
http://soft-shake.ch/2011/conference/sessions/microsoft/2011/09/06/windows-phone-7-mango.html
Sascha Corti
With Internet Explorer 9, Microsoft has entered the league of HTML 5 browsers and with its active participation in the W3C working groups, the company proves its engagements towards the new and emerging standards. Developers however are often left wondering where the boundaries are drawn between HTML5 web site, plug-in based rich internet application and smart client or “app”.
This session intends to answer this question and uses many examples to show you some of the most important enhancements introduced by HTML5, CSS3, SVG, DOM, WOFF and ECMA script. You will learn now the standards are still evolving and how Microsoft is contributing.
http://soft-shake.ch/2011/conference/sessions/microsoft/2011/09/06/introduction-to-html5.html
soft-shake.ch - Domotique et robotique avec le micro Framework .NETsoft-shake.ch
Jean-Claude Armici and Philippe Schutz
Le micro Framework .NET offre un environnement de développement et d’exécution complet et innovant. Il offre une programmation de haut niveau, par exemple en C#, permettant de gérer toutes les possibilités offertes par diverses carte électroniques modernes et performantes.
Cette présentation a pour but de faire connaître le micro Framework .NET, son architecture et ses fonctionnalités, au travers d’exemples et de démonstrations dans les domaines de la domotique et de la robotique. La programmation, dans un environnement standard, ainsi que le matériel utilisé, très abordable à tous les points de vue, devraient permettre à chacun de s’initier sans peine à l’utilisation de l’informatique embarquée.
http://soft-shake.ch/2011/conference/sessions/microsoft/2011/09/06/domotique-et-robotique-avec-le-micro-framework-NET.html
Christophe Grand
Une introduction à Clojure qui met l’accent sur la programmation par valeurs.
Sans elle, pas de programmes plus simples à “faire tenir dans sa tête”, pas de gestion saine des états et encore moins de programmation concurrente !
http://soft-shake.ch/2011/conference/sessions/java/2011/09/06/clojure.html
soft-shake.ch - JBoss AS 7, la révolutionsoft-shake.ch
Alexis Hassler
JBoss AS 7 est sorti pendant l’été 2011. Cette version est une véritable révolution pour tous les utilisateurs JBoss : temps de démarrage et de déploiement record, techniques d’administration renouvelées, configuration simplifiée et plus expressive,…
Dans cette présentation, j’explique ces nouveautés et je les montre avec des vrais morceaux de ligne de commande.
http://soft-shake.ch/2011/conference/sessions/java/2011/09/13/jboss.html
soft-shake.ch - Tests d'intégration JavaEE avec Arquilliansoft-shake.ch
Alexis Hassler
Avec les EJB 3, on a beaucoup mis en avant leur caractère POJO qui facilite la mise en oeuvre de tests unitaires ainsi que le conteneur autonome pour des tests d’intégration. On a vite constaté que ces possiblités étaient limitée et qu’ils manquait un outil dans cet ensemble.
Les équipes de JBoss nous proposent Arquillian. Cet outil est capable de piloter les serveurs d’applications, d’y déployer des archives et de tester toute sorte de composant JavaEE dans leur jus, avec un effort minimal.
Cette session est très pratique, elle montre comment utiliser Arquillian pour les tests d’intégration CDI, EJB, JPA, sur JBoss, Glassfish et Tomcat.
http://soft-shake.ch/2011/conference/sessions/java/2011/09/06/arquillian.html
soft-shake.ch - Un zeste d’Erlang dans le shaker!soft-shake.ch
Dominic Williams & Fabrice Nourisson
Les technologies logicielles se multiplient. Il faut savoir combiner les forces de plusieurs langages et outils. Erlang est la seule technologie conçue spécifiquement pour tirer parti très simplement des architectures multi-coeur et en cluster. Cette présentation vous invite à ajouter cet ingrédient à votre cocktail.
Sommaire:
- Aperçu du langage.
- Démo de code, en TDD et en binôme, avec du refactoring et de la mise à jour de code à chaud.
- Points forts, points faibles, domaines et contextes adaptés.
- Ecosystème (références, produits).
- Cas d’étude: chat online de Facebook.
http://soft-shake.ch/2011/conference/sessions/incubator/2011/09/13/un-zeste-d-erlang-dans-le-shaker.html
soft-shake.ch - Déploiement continu sur le cloud avec SlipStreamsoft-shake.ch
Marc-Elian Begin
Le passage en production de toute application nécessite de franchir une série d’étapes - p. ex. construction, testes unitaires, déploiement en environnement de certification, testes fonctionnels, déploiement en production, maintenance, mise-à-jour). Ces étapes sont souvent, à l’heure actuelle, manuelles et donc prônes à l’erreur.
De plus, dans un contexte agile, ou les équipes de développement sont amenées à ‘releaser’ souvent, ce besoin de passer en production crée en goulot d’étranglement important et peut être la source de stresses et frictions importantes.
Avec l’avènement du cloud, de la virtualisation et des services en ligne (SaaS), une nouvelle génération de produits et services permet d’automatiser considérablement la chaine de production logiciel, permettant de déployer en continue et à la demande, des systèmes multi-tiers, pour créer des environnements de développement et testes proches de la production et ce en quelques minutes.
Cette session propose un workshop, ou les participants pourront ‘apprendre en faisant’, ou la théorie et la pratique s’alternera pour permettre aux participants de créer et déployer une application sur un environnement de cloud, par petites étapes et de la tester.
Cette session utilisera SlipStream, une application développée par SixSq et un cloud basé sur StratusLab, une solution open source européenne de cloud IaaS.
Venez participer avec ou sans laptop !!
http://soft-shake.ch/2011/conference/sessions/incubator/2011/09/12/deploiement-continu-sur-le-cloud-avec-slipstream.html
Mathilde Lemée & Romain Maton
La théorie, c’est bien, la pratique … aussi !
Venez nous rejoindre pour découvrir les profondeurs de Node.js !
Nous nous servirons d’un exemple pratique pour vous permettre d’avoir une premiere experience complete autour de Node.js et de vous permettre de vous forger un avis sur ce serveur Javascript qui fait parler de lui !
http://soft-shake.ch/2011/conference/sessions/incubator/2011/09/01/hands-on-nodejs.html
soft-shake.ch - De Hermes RUP à Hermes Scrumsoft-shake.ch
Alexandre Cuva
Retour d’expérience à l’Administration Cantonale sur la mise en place de Scrum dans une équipe de maintenance évolutive avec des procédures de gestion de projet Hermes RUP et des stratégies de test TMap.
Nous allons couvrir les différentes étapes de l’évolution de l’équipe SCRUM dans un monde standard. Les problèmes rencontrés et les solutions que nous avons trouvées.
“YES WE CAN !!!”
http://soft-shake.ch/2011/en/conference/sessions.html?key=hermes
soft-shake.ch - Stewardship et motivationsoft-shake.ch
Thierry Cros
L’auto-organisation est à la base des pratiques agiles.
Nous verrons lors de cet atelier les pratiques agiles qui vous permettent de véritablement vous auto-organiser.
Nous reviendrons aux bases de l’agilité : responsabilité et hédonisme.
http://soft-shake.ch/2011/en/conference/sessions.html?key=stewardship
soft-shake.ch - Agile qu'es aco : scrum xp leansoft-shake.ch
Thierry Cros
Aujourd’hui l’agilité est “mainstream”. Comment s’y retrouver parmi les innombrables présentations, retours d’expérience qui se réclament de l’agilité ?
Cette présentation vous propose un bref panorama de l’agilité, depuis ses débuts historiques jusqu’aux évolutions actuelles. Vous allez donc acquérir les informations qui vous permettront de vous forger viotre propre opinion et discerner ainsi ce qui est véritablement agile.
http://soft-shake.ch/2011/conference/sessions/agility/2011/09/23/agilte-kesaco.html
soft-shake.ch - Documentation et agilitésoft-shake.ch
Jean-François Jagodzinski
<br /><br />
La documentation est une question récurrente des organisations qui découvrent le mode de fonctionnement agile pour les projets.
<br /><br />
Les bases du manifeste Agile “un logiciel opérationnel plutôt qu’une documentation exhaustive” ainsi que le fait de privilégier l’accueil du changement perturbent la logique actuelle dont les fondations reposent avant tout sur la documentation.
Le but de cette présentation est de répondre aux interrogations que suscite la logique Agile. La documentation ne disparaît pas, c’est son rôle qui change. Sa forme, son contenu, son mode de production s’en trouvent affectés. En modifiant son point d’observation les choses deviennent plus claires.
http://soft-shake.ch/2011/conference/sessions/agility/2011/09/12/Documentation-et-ailite.html
soft-shake.ch - Agilité = discipline et rigueur ?soft-shake.ch
Christian Lapointe
L’Agilité. Liberté pour les uns, chaos pour les autres. La liberté de choisir comment on veut travailler vient avec la responsabilité de livrer ce que nous promettons. La réussite d’un projet Agile demande de la discipline et de la rigeur. Cela vous semble t’il aller à l’encontre de la définition que vous avez de l’Agilité?
Nous allons jeter un coup d’œil sur certaines perceptions que les gens ont de l’Agilité. Celles où ont entends :
“Oui mais en Agile, vous ne faites pas de doc”
“Nous, on n’a pas de spec car nous sommes agiles”
“On livre une première version tout de suite même si elle est buggé. C’est pas grave, en Agile on itère”
soft-shake.ch - Transition agile & Accompagnement au changementsoft-shake.ch
Romain Couturier
Des pressions externes grandissantes poussent les entreprises à changer leurs organisations pour s’adapter et développer la réactivité. Les SI, eux aussi sont impactés. L’agilité devient une alternative pertinente pour accélérer la mise en œuvre de produits et sécuriser les développements.
Premier challenge : définir l’organisation agile adaptée au contexte de votre entreprise.
Mais au-delà, la réelle complexité réside dans l’implication des hommes à tous les échelons. L’évolution des habitudes de travail doit être couplée à l’évolution des habitudes de conception des solutions informatiques. Je vous propose un premier cadre de réflexion sur la transition organisationnelle nécessaire au déploiement de l’agilité.
http://soft-shake.ch/2011/conference/sessions/agility/2011/08/31/transition-agile-et-accompagnement-au-changement.html
soft-shake.ch - Agilité et Testing: de l'intérêt d'une démarche structuréesoft-shake.ch
Julien Behr
Comment réconcilier l’approche des tests structurés et les démarches Agile.
http://soft-shake.ch/2011/en/conference/sessions.html?key=agiliteettesting
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
As AI technology is pushing into IT I was wondering myself, as an “infrastructure container kubernetes guy”, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefit’s both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
10. class Sum implements Callable<Long> {
private final long from;
private final long to;
Sum(long from, long to) {
this.from = from;
this.to = to;
}
public Long call() {
long acc = 0;
for (long i = from; i <= to; i++) {
acc = acc + i;
}
return acc;
}
}
11. ExecutorService executor = Executors.newFixedThreadPool(2);
List<Future<Long>> results = executor.invokeAll(asList(
new Sum(0, 10),
new Sum(100, 1000),
new Sum(10000, 1000000)
));
for (Future<Long> result : results) {
System.out.println(result.get());
}
12. 1.0 Threads made easy
1.1
1.2
1.3
1.4
5 Concurrency made easier
6
7 Parallelism made easier
13. Sum of an array
n1 n2 n3 n4 n5 n6 n7 n8 n9 ... ... ... ...
sum1 sum2 sum3
sum1 + sum2 sum3 + (...)
total sum
18. 16
Folder word
counting task
10
5
1
Document word Document word Folder word
counting task counting task counting task
3 2
fork()
Document word Document word
n join() counting task counting task
21. No I/O
No synchronization / locks
Decompose in simple recursive tasks
Do not decompose below a threshold
Take advantage of multicores with no pain
You have more F/J candidate algorithms than
you think!
23. private void writeSomeData() throws IOException {
DataOutputStream out = new DataOutputStream(new FileOutputStream("data"));
out.writeInt(666);
out.writeUTF("Hello");
out.close();
}
24. private void writeSomeData() throws IOException {
DataOutputStream out = new DataOutputStream(new FileOutputStream("data"));
out.writeInt(666);
out.writeUTF("Hello");
out.close();
}
what if...
25. private void writeSomeData() throws IOException {
DataOutputStream out = null;
try {
out = new DataOutputStream(new FileOutputStream("data"));
out.writeInt(666);
out.writeUTF("Hello");
} finally {
if (out != null) {
out.close();
}
}
}
26. private void writeSomeData() throws IOException {
DataOutputStream out = null;
try {
out = new DataOutputStream(new FileOutputStream("data"));
out.writeInt(666);
out.writeUTF("Hello");
} finally {
if (out != null) {
out.close();
}
}
}
...this is still far from correct!
27. try (
FileOutputStream out = new FileOutputStream("output");
FileInputStream in1 = new FileInputStream(“input1”);
FileInputStream in2 = new FileInputStream(“input2”)
) {
// Do something useful with those 3 streams!
// out, in1 and in2 will be closed in any case
out.write(in1.read());
out.write(in2.read());
}
28. public class AutoClose implements AutoCloseable {
@Override
public void close() {
System.out.println(">>> close()");
throw new RuntimeException("Exception in close()");
}
public void work() throws MyException {
System.out.println(">>> work()");
throw new MyException("Exception in work()");
}
}
30. AutoClose autoClose = new AutoClose();
try {
autoClose.work();
} finally {
autoClose.close();
}
>>> work()
>>> close()
java.lang.RuntimeException: Exception in close()
at AutoClose.close(AutoClose.java:6)
at AutoClose.runWithMasking(AutoClose.java:19)
at AutoClose.main(AutoClose.java:52)
31. AutoClose autoClose = new AutoClose();
try {
autoClose.work();
} finally {
autoClose.close();
}
MyException
m asked by Run
>>> work() time Exception
>>> close()
java.lang.RuntimeException: Exception in close()
at AutoClose.close(AutoClose.java:6)
at AutoClose.runWithMasking(AutoClose.java:19)
at AutoClose.main(AutoClose.java:52)
39. try (AutoClose autoClose = new AutoClose()) {
autoClose.work();
}
>>> work()
>>> close()
MyException: Exception in work()
at AutoClose.work(AutoClose.java:11)
at AutoClose.main(AutoClose.java:16)
Suppressed: java.lang.RuntimeException: Exception in close()
at AutoClose.close(AutoClose.java:6)
at AutoClose.main(AutoClose.java:17)
40. public void compress(String input, String output)
throws IOException {
try(
FileInputStream fin = new FileInputStream(input);
FileOutputStream fout = new FileOutputStream(output);
GZIPOutputStream out = new GZIPOutputStream(fout)
) {
byte[] buffer = new byte[4096];
int nread = 0;
while ((nread = fin.read(buffer)) != -1) {
out.write(buffer, 0, nread);
}
}
}
42. Not just syntactic sugar
Clutter-free, correct code
close():
- be more specific than java.lang.Exception
- no exception if it can’t fail
- no exception that shall not be suppressed
(e.g., java.lang.InterruptedException)
51. class SomeClass<T extends Serializable & CharSequence> { }
Non-denotable type
SomeClass<?> foo = new SomeClass<String>();
SomeClass<?> fooInner = new SomeClass<String>() { };
SomeClass<?> bar = new SomeClass<>();
SomeClass<?> bar = new SomeClass<>() { };
52. class SomeClass<T extends Serializable & CharSequence> { }
Non-denotable type
SomeClass<?> foo = new SomeClass<String>();
SomeClass<?> fooInner = new SomeClass<String>() { };
SomeClass<?> bar = new SomeClass<>();
SomeClass<?> bar = new SomeClass<>() { };
No denotable type
to generate a class
73. // 123 in decimal, octal, hexadecimal and binary
byte decimal = 123;
byte octal = 0_173;
byte hexadecimal = 0x7b;
byte binary = 0b0111_1011;
// Other values
double doubleValue = 1.111_222_444F;
long longValue = 1_234_567_898L;
long longHexa = 0x1234_3b3b_0123_cdefL;
74. public static boolean isTrue(String str) {
switch(str.trim().toUpperCase()) {
case "OK":
case "YES":
case "TRUE":
return true;
case "KO":
case "NO":
case "FALSE":
return false;
default:
throw new IllegalArgumentException("Not a valid true/false string.");
}
}
75. public static boolean isTrue(String s) {
String str = s.trim().toUpperCase();
int jump = -1;
switch(str.hashCode()) {
case 2404:
if (str.equals("KO")) {
jump = 3; Bucket
}
break;
(...)
switch(jump) {
(...)
case 3:
case 4:
case 5:
return false;
default: Real code
throw new IllegalArgumentException(
"Not a valid true/false string.");
}
}
76. Oracle Technology Network (more soon...)
Fork and Join: Java Can Excel at
Painless Parallel Programming Too!
http://goo.gl/tostz
Better Resource Management with
Java SE 7: Beyond Syntactic Sugar
http://goo.gl/7ybgr