Use Builders... Cautiously - Effective Java, Item 2
The builder pattern is a powerful tool to ease the instantiation of complex classes. Whether constructor parameters are too numerous, there are too many of the same type, or whether many are optional - with a builder you can make your life easier. Although, I posit, often you can make your life even easier by directly tackling the class' or constructor's complexity.
In this video I show an example of how to simplify a class to make a builder obsolete, but also how to build more powerful builders that add more value than just simplifying constructor calls.
Table of contents:
00:00 Mixed feelings
02:42 Builders explained
03:55 └ A better solution to Josh's example
06:20 └ An even better solution to Josh's example
08:26 Random details (threading, style, other languages)
10:50 Builders as DSL
13:43 More powerful builders
15:31 Inheriting builders and recursive generics
20:14 Refactor towards builder
22:56 Summary
Repository with examples: https://github.com/CodeFX-org/effective-java
JavaZone in Oslo: https://2018.javazone.no/
My opinion on Optional: https://blog.codefx.org/techniques/intention-revealing-code-java-8-optional/
Map.of et al: https://blog.codefx.org/java/java-9-tutorial/#Collection-Factories
Named & default parameters in Kotlin: http://www.deadcoderising.com/kotlin-how-to-use-default-parameters-in-functions-and-constructors/
Automaton: https://brilliant.org/wiki/finite-state-machines/
Partial application: https://en.wikipedia.org/wiki/Partial_application
Self types with generics: https://www.sitepoint.com/self-types-with-javas-generics/
Nicolai:
* home: http://codefx.org
* online Java courses: http://courses.codefx.org
* on Twitter: https://twitter.com/nipafx
Affiliate links for Effective Java, Third Edition:
* InformIT (the publisher): http://tiny.cc/effective-java-3rd
* Amazon USA: https://amzn.to/2QI0D0S
* Amazon Germany: https://amzn.to/2OvsWOu
Что делает видео по-настоящему запоминающимся? Наверное, та самая атмосфера, которая заставляет забыть о времени. Когда вы заходите на RUVIDEO, чтобы посмотреть онлайн «Use Builders... Cautiously - Effective Java, Item 2», вы рассчитываете на нечто большее, чем просто загрузку плеера. И мы это понимаем. Контент такого уровня заслуживает того, чтобы его смотрели в HD 1080, без дрожания картинки и бесконечного буферизации.
Честно говоря, Rutube сегодня — это кладезь уникальных находок, которые часто теряются в общем шуме. Мы же вытаскиваем на поверхность самое интересное. Будь то динамичный экшн, глубокий разбор темы от любимого автора или просто уютное видео для настроения — всё это доступно здесь бесплатно и без лишних формальностей. Никаких «заполните анкету, чтобы продолжить». Только вы, ваш экран и качественный поток.
Если вас зацепило это видео, не забудьте взглянуть на похожие материалы в блоке справа. Мы откалибровали наши алгоритмы так, чтобы они подбирали контент не просто «по тегам», а по настроению и смыслу. Ведь в конечном итоге, онлайн-кинотеатр — это не склад файлов, а место, где каждый вечер можно найти свою историю. Приятного вам отдыха на RUVIDEO!
Видео взято из открытых источников Rutube. Если вы правообладатель, обратитесь к первоисточнику.