Probably most of use read book "Effective Java" by Joshua Blooch. But what "effective" programming really means? We will go through some real-life problems and talk about possible, effective solutions.
5. Whoami
•Software Architect in the Dynatrace,
•Worked as Software Developer and Team Lead,
•10+ years of experience with Java – Enterprise
Application mostly,
•Main area of interest: optimization and application
performance
8. What this workshop is about?
•Showing examples on good, better and the best
solutions to some common design problems,
•Signaling some commons programming anti-
patterns you should avoid,
•Having fun solving simple Java programming puzzles
9. What this workshop is not about?
•Learning programming from scratch,
•Learning Java from the beginning,
•Solving all possible Java problems
17. The moral
• There are many ways of implementing the same algorithm/functionality,
• There are reusable patterns that you should use (on every possible level:
implementation, integration, deployment etc.
19. Specification
• Given the lists of strings as an input, method groupBy in the Example1 class
should return map with all strings that occurred in the input list as key and
number of string occurrences as value,
Example:
For a given input list {„John”, „Aaron”, „John” „Adam”, „Adele”} method
should return following map { {„John”, 2}, {„Aaron”, 1}, {„Adam”, 1},
{„Adele”, 1}}
• Method should throw IllegalArgumentException if elements list is null,
• Method should return empty map if elements list is empty.
24. Moral
• Functional programming is more about coding convenience,
• You should not mix imperative and functional programming
styles,
• Developer must be familiar with how streams work and behave
(e.g. parallel stream execution),
• Must be used with caution (see: 10 Subtle Mistakes When Using
the Streams API)
26. What you should know about generics?
•Compile time type check rather than runtime check,
•Generic types are invariant (compare with covariant
arrays)
•List<Integer> is not subtype of List<Number>,
•Can be confusing when implementing API contract,
•Use wildcards with caution.
30. Specification
• Implement union method in the Exercise2 class, so that it returns set being
an union of two sets passed as an argument,
• Change it’s definition so that the following line of code compiles
• Method should throw IllegalArgumentException if any set passed as an
argument is null,
• Remember that producer – super, consumer – extends…
Set<Number> result = Excercise2.union(new HashSet<Integer>(), new HashSet<Number>());