Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Vavrのすすめ
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
kawagoo
October 27, 2024
700
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Vavrのすすめ
kawagoo
October 27, 2024
More Decks by kawagoo
See All by kawagoo
docker-compose.yml から Helm Chartに 変換してくれるツール Katenary を試してみた
eterny13
0
670
ECS の IPv6 がムズカシイ
eterny13
0
2.8k
固定回線にNAT64/DNS64を導入して
eterny13
0
280
Featured
See All Featured
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Joys of Absence: A Defence of Solitary Play
codingconduct
1
420
WENDY [Excerpt]
tessaabrams
11
39k
Large-scale JavaScript Application Architecture
addyosmani
515
110k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
2.9k
The World Runs on Bad Software
bkeepers
PRO
72
12k
For a Future-Friendly Web
brad_frost
183
10k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
180
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
260
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
340
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
Transcript
1 @Copyright BIGLOBE inc. 2024. All rights reserved Vavrのすすめ ビッグローブ株式会社
川口永一郎
2 @Copyright BIGLOBE inc. 2024. All rights reserved Vavrとは? •
Javaの関数型プログラミングライブラリ ◦ https://vavr.io/ ◦ https://github.com/vavr-io/vavr ◦ JAVAをひっくり返すとVAVr • Java標準にないイミュータブルなデータ構造を利用できる • 所属しているチームでJavaを使用する際はマストで採用
3 @Copyright BIGLOBE inc. 2024. All rights reserved Vavrが用意しているデータ構造(一部) •
Tuple ◦ いくつかの値(異なる型でも良い)の組を保持する型 • Functions ◦ Function0〜Function8 といった標準にはない3引数以上のものが ある • Values ◦ 1つの型の値を0個以上持つようなオブジェクトを抽象化した インターフェース ▪ Option • ある型の値を持つか持たないかどちらかを表現できる ▪ Try • 例外を戻り値のように扱うことができる ▪ Either • 2つの型のうちどちらか一方だけを持つ型 • 2つの型は Left, Right と呼ばれ、成功時の値とエラー値を保持できる
4 @Copyright BIGLOBE inc. 2024. All rights reserved 例 files
= sftp.getFiles("test.csv"); // sftpでファイル取得 if (files.isEmpty()) { throw new RuntimeException("No file found"); } String csvContent; try { csvContent = CSVParser.parse(files.get(0)); // ファイルをCSVにパース } catch (IOException e) { throw new RuntimeException("CSV parse failed", e); } return new XXXReader(csvContent);
5 @Copyright BIGLOBE inc. 2024. All rights reserved 例 files
= sftp.getFiles("test.csv"); if (files.isEmpty()) { throw new RuntimeException("No file found"); } String csvContent; try { csvContent = CSVParser.parse(files.get(0)); } catch (IOException e) { throw new RuntimeException("CSV parse failed", e); } return new XXXReader(csvContent); return Try.of(() -> sftp.getFiles("test.csv") ) .filter( f -> !f.isEmpty(), f -> new RuntimeException("No file found") ) .mapTry( f -> CSVParser.parse(f.get(0)) ) .recoverWith( IOException.class, e -> Try.failure( new RuntimeException("CSV parse failed", e)) ) .map(XXXReader::new) .get();
6 @Copyright BIGLOBE inc. 2024. All rights reserved ちゃんとメンテされてるん? •
2021年7月に0.10.4がリリースされて以来、アップデートがなかったが、 今月0.10.5にアップデート ◦ 新しい maintainer に変わったとのこと
7 @Copyright BIGLOBE inc. 2024. All rights reserved Javaで関数型プログラミングやりたい人は 使ってみてください!