Internal Study Session Report: Hands-On Experience Setting Up a Vue 3 Development Environment with Cursor

We recently held an in-house workshop titled “Hands-On Experience: Setting Up a Vue 3 Development Environment with Cursor.” Here’s a look at how it went.

The purpose of this study session was to provide hands-on experience in setting up a Vue 3 development environment using the AI editor “Cursor.”
We were pleased to see a large turnout, including many non-engineers as well as engineers, making for a very lively event.

Note that we are setting up the environment based on a technical blog.

Study Session Agenda

  • An Overview of Vue 3
  • Setting Up the Development Environment
  • Creating a Vue 3 Project
  • Startup Demo

① Overview of Vue 3

First, I explained the position of Vue 3.

Vue is a framework specialized for the “V” (View) component of the MVC model, and its primary role is to control the display of screens and the behavior in response to user interactions.

  • Vue: Display, Interact, Switch
  • Server-side: Protect, Decide, Remember

I explained the distinction between front-end and back-end roles using this comparison.
By emphasizing that “Vue is strictly responsible for the user interface,” the content became easier for beginners to understand.

② Setting up the development environment

Next, I explained the overall picture of the tools required for development.

  • Node.js: A platform for running JavaScript
  • Vue 3 + Vue Router: How Screens Are Built
  • Cursor: A development editor with AI capabilities

After that, we actually carried out the following installation procedures.

  • Installing Node.js
  • Installing Cursor
  • Installing Recommended Plugins for Cursor

There were many instances where participants supported one another, making it a practical learning experience.

③ Creating a Vue 3 Project

Once the environment is set up, use the following command to create a Vue 3 project.

npm create vue@latest

During this step, some participants encountered an issue where the npm command was not recognized.
When errors occurred, the team members supported one another, and we were able to successfully complete the project.

④ Startup Demo

Finally, I started the development server using the following command and verified the screen display.

npm run dev

The local server has started up, and I have confirmed that the Vue welcome screen is displaying correctly in the browser.

For those with extra time, we also had them try implementing Element Plus, a UI library.
By combining Vue with UI components, I believe they were able to get a sense of what screen development is like.

In this study session,

  • Understanding the Role of Vue 3
  • Setting Up a Development Environment Using Cursor
  • Creating and Running a Vue Project

We have completed all of the above steps.

We plan to continue hosting development workshops focused on Cursor.
Stay tuned for our next article!

社内勉強会レポート:CursorでVue3開発環境構築体験

今回は社内勉強会「CursorでVue3開発環境構築体験」を開催しました。その様子をご紹介します。

本勉強会では、AIエディタ「Cursor」を活用しながら、Vue3の開発環境構築を実際に体験することを目的に実施しました。
エンジニアだけでなく、非エンジニアの方にも多くご参加いただき、非常に活気のある会となりました。

なお、環境構築は技術者ブログをベースに進めています。

勉強会の流れ

  • Vue3の概要
  • 開発環境の構築
  • Vue3プロジェクト作成
  • 起動デモ

① Vue3の概要

まずはVue3の立ち位置について解説しました。

VueはMVCモデルにおける「V(View)」に特化したフレームワークであり、
画面表示やユーザー操作に対する動きの制御を主な役割とします。

  • Vue:見せる・触る・切り替える
  • サーバー側:守る・判断する・覚える

という対比で、フロントエンドとサーバーサイドの役割の境界線を説明しました。
「Vueはあくまで画面担当」という点を強調することで、初学者にも理解しやすい内容となりました。

② 開発環境の構築

続いて、開発に必要なツールの全体像を説明しました。

  • Node.js:JavaScriptを実行するための基盤
  • Vue3 + Vue Router:画面を構築する仕組み
  • Cursor:AI機能を備えた開発エディタ

その後、実際に以下のインストール作業を実施しました。

  • Node.js のインストール
  • Cursor のインストール
  • Cursorの推奨プラグイン導入

参加者同士でサポートし合いながら進める場面も多く、実践的な学びの場となりました。

③ Vue3プロジェクト作成

環境が整った後は、以下のコマンドでVue3プロジェクトを作成します。

npm create vue@latest

この工程では、一部の参加者で npm コマンドが認識されない事象が発生しました。
エラーが発生した時には、メンバー同士でフォローしあい、無事にプロジェクト作成まで進めることができました。

④ 起動デモ

最後に、以下のコマンドで開発サーバを起動し、画面表示を確認しました。

npm run dev

ローカルサーバが立ち上がり、ブラウザにVueの初期画面が無事表示されることを確認できました。

さらに時間に余裕のある方には、UIライブラリであるElement Plusの導入にも挑戦してもらいました。
VueとUIコンポーネントを組み合わせることで、画面開発のイメージを体験できたと思います。

今回の勉強会では、

  • Vue3の役割理解
  • Cursorを使った開発環境構築
  • Vueプロジェクト作成と起動体験

までを一通り実施しました。

今後もCursorをテーマにした開発勉強会を継続して開催していく予定です。
次回の記事もぜひお楽しみに!

Engineer Blog: Sending Emails in OutSystems

In this engineer blog, I introduce the topics I study and work on in my daily learning.

Today’s Topic: Sending Emails in OutSystems

In OutSystems, you can send emails from screens or batch processes by using your own mail server.
In this post, I’ll walk through how to configure the environment and how to create a test screen.

Preparation: What You Need to Have Ready in Advance

OutSystems alone cannot send emails.
You need to prepare an email server in advance and make note of the following information:
#1.SMTP server
#2.SMTP port number
#3.Username (email address)
#4.Password
Depending on the type of mail server, there may also be options such as ‘restrictions on sending from overseas.’
If such a setting exists, be sure to turn it off.
Otherwise, you may encounter errors like ‘Sender address rejected: Incorrect country code US,’ which can prevent email delivery even when your configuration is correct.

Step 1: Environment Setup

First, enter the mail server information that OutSystems will use from Service Center. In Service Studio, click the gear icon shown below to access Service Center.

After logging in, open the email server settings by selecting Administration > Email

Enter the following information as shown below:
・SMTP Server: Preparation #1
・SMTP Port: Preparation #2
・Username: Preparation #3
・Password: Preparation #4
・Default Sender Email: Preparation #3
・Redirect Emails To Test List: Optional
 *This option redirects emails to the Test List Addresses even if the logic specifies a different recipient.
  Enable this for testing purposes.
・Test List Addresses: Optional
 *Specify the email address to which messages will be redirected.

After entering all the information, click the Save and Apply Settings to the Factory button to apply the configuration.
 *Note: Simply clicking ‘Save’ does not activate the email settings.
  Also, the Password field will appear blank after saving, but as long as the configuration is correct, emails will still be sent without any issues.

Step 2: Creating the Logic

This time, we will create a simple test screen and the logic for sending emails, as shown below.

① Test Screen: Enter the recipient, subject, and message body, then click the SendMail button to send an email based on the entered values.
② Email Body Screen: The value received through the InBody input parameter is displayed directly as the email body.
③ Client Action: This action is triggered when the SendMail button is clicked. It calls the server action responsible for sending the email.
④ Server Action: This action is called from the Client Action. It sends the email according to the layout created in step ②

Testing the Functionality

Once the 1‑Click Publish completes successfully, open the screen and try running it.

Example Input: To verify the redirect behavior, enter an email address in the top recipient field that is different from the one configured in Test List Addresses.
The email that was actually received at the address specified in Test List Addresses.

The top section shows the value of the Default Sender Email.
You can also see that the recipient field contains the address entered on the screen (which is different from the one specified in Test List Addresses), confirming that the redirect feature is working as expected.

Email sending logs in Service Center.

From Monitoring > Email, you can check the subject, sender/recipient email addresses, email size, and status.
In particular, the status may show Sent (success), Pending (waiting), or Error (failed). When an error occurs, you can click the Detail link to view the error information, which helps identify the cause.

Conclusion

With the above steps, you are now able to send emails from OutSystems.
However, one important point to keep in mind is that the actual email‑sending mechanism ultimately depends on the mail server.
Be sure to review the mail server settings carefully to ensure they meet your requirements—for example, limits on the number of emails that can be sent per hour, or restrictions on sending or receiving emails from specific addresses.

Stay tuned for the next developer blog…

技術者ブログ:(Outsystems)メールを送信する

技術者ブログとして日ごろ取り組んでいる学習内容を紹介します。

今回のテーマ:(Outsystems)メールを送信する

Outsystemsでは、各自で用意したメール送信サーバを用いることで、画面・バッチよりメールを送信することが出来ます。
今回は、環境設定と、テスト用画面の作成方法について紹介します。

準備:予め用意しておくもの

Outsystems単独ではメールを送信することはできません。
予め、メール送信サーバを調達し、以下の情報をメモしておきましょう:
#1.送信サーバ(SMTP)
#2.送信サーバのポート番号
#3.ユーザー名(メールアドレス)
#4.パスワード
また、メール送信サーバの種類にもよりますが、気を付けるべき点として「海外からの送信制限」のようなオプションがある場合、Offにしておきましょう。
“Sender address rejected: Incorrect country code US”のようなエラーが発生し、設定が正しいのにメールが送信できない場合があります。

手順1:環境設定

まず、ServiceCenterより、Outsystemsが使用するメール送信サーバの情報を入力します。
ServiceStudioより、下記歯車アイコンを押下し、ServiceCenterへアクセスしてください。

ログイン後、メニューよりAdministration>Emailとリンクを押下することで、メール送信サーバの設定画面が開きます。

それぞれ、次のように入力します:
・SMTP Server:準備#1
・SMTP Port:準備#2
・Username:準備#3
・Password:準備#4
・Default Sender Email:準備#3
・Redirect Emails To Test List:任意
 ※ロジックで宛先を指定しても、後述するTest List Addressesへメールをリダイレクトする機能です。
  動作確認のため、有効化しておきます。
・Test List Addresses:任意
 ※リダイレクト先のメールアドレスを設定します。

一通り入力し終えたら、Save and Apply Settings to the Factoryボタンを押下し、入力した設定値を反映しましょう。
 ※Saveするだけではメール設定は有効になりません。
  また、Save後Password欄は空欄になりますが、正しく設定できていればメールは送信できますので問題ありません。

手順2:ロジック作成

今回は、下記のようなシンプルなテスト画面、およびメール送信機能のロジックを作成します。

①テスト画面:宛先、件名、本文を入力し、SendMailボタンを押下することで入力値に基づきメールが送信される。
②メール本文画面。引数InBodyで受け取った値をそのままメール本文に表示する。
③ClientAction:SendMailボタン押下時に呼ばれる。メール送信用サーバアクションを呼び出す。
④ServerAction:ClientActionから呼び出される。②で作成したレイアウトに従い、メールを送信する。

動作確認

1-click publishが正常終了したら、画面を開いて動かしてみましょう。

入力例:リダイレクト動作確認のため、最上段の宛先メールアドレスには、Test List Addressesで設定したものと異なるメールアドレスを入力する。
実際にTest List Addressesに記載のメールアドレスにて受信したメール。

最上段にはDefault Sender Emailの値が記載されています。
また、宛先欄には画面で入力した宛先(≠Test List Addressesに記載のメールアドレス)が記載されており、リダイレクトが期待通りに機能していることが読み取れます。

ServiceCenterにおけるメール送信ログ。

Monitoring>Emailより、件名・送信元/先メールアドレス・メール容量・ステ―タスが確認できます。
特に、ステータスはSent(送信完了)・Pending(待機中)の他にError(送信失敗)になる場合があり、この時表示されるDetailリンクからエラー内容を確認できるため、原因の特定に役立てることができます。

まとめ

以上の手順にて、Outsystemsよりメールを送信することができるようになりました。
ただし、一つ気を付けておかなければならないのは「あくまでメール送信の仕組み自体はメール送信サーバに依存している」ことです。
時間当たりの送信可能メール数や、特定のメールアドレスから/へのメール送受信を許可しない設定など、要件に合わせたカスタマイズが送信サーバ側の設定をよく確認しましょう。

それでは、次回の技術者ブログをお楽しみに…。

Employee Introduction

Thank you for reading!
I’m Fuku, the writer for this article. (This is my third appearance.)

I’d like to share why I joined Dandelions and my impressions since joining.

Reason for joining the company

I have worked in the IT industry for approximately 12 years.
I have primarily been responsible for system maintenance, continuing to perform operations and improvements to ensure systems run stably.

Maintenance work is a crucial job and plays an essential role in supporting the system.
By quickly identifying the cause when failures occur, I gained the ability to understand the entire system.
Improving the system based on user requests made me realize the importance of communication with users, providing valuable experience.

On the other hand, as I continued working for a long time, I also began to feel frustrated by the lack of opportunities to engage with new technologies.

It was around the time I began to wonder, “Is it really okay to stay like this?” and “I want to challenge myself with something new.”

At that time, I heard that the current CEO and President was launching Dandelions.
When I heard that, I felt it would be a chance to take on new challenges, grow technically, and be involved in building the company. I decided to join, thinking, “Let’s make a fresh start and give it a shot.”

My thoughts since joining the company

Before I knew it, eight years had passed since I joined the company.
When I first joined, we started as a small team of founding members. I clearly remember working in an atmosphere where everyone was close, tackling new technologies together while building the company from the ground up.

From there, our team gradually grew, and today we’ve welcomed young employees and members from other countries, making our team incredibly diverse. Working alongside members of different ages, backgrounds, and cultures is truly fascinating—it exposes me to new perspectives and ways of thinking, providing valuable inspiration every day.

Moving forward, I aim to leverage the experience I’ve cultivated to date while also focusing on creating an environment where members can collaborate more easily and providing greater support.
As the company continues to grow, I want to contribute to building a better organization by supporting the entire team so they can perform at their best.

That concludes this blog post.
We hope you’ll look forward to our next blog post.

社員紹介

閲覧いただきまして、ありがとうございます!
今回の記事担当となりました「フク」です。(3回目の登場になります)

ダンデライオンズに入社した理由と入社してからの感想についてお話ししたいと思います。

入社のきっかけ

私はこれまで、IT業界で約12年間仕事をしてきました。
主にシステムの保守業務を担当し、システムが安定して動くように運用・改善を行う仕事を続けてきました。

保守業務はとても重要な仕事であり、システムを支える大切な役割です。
障害が起きたときに迅速に原因を特定することでシステム全体を理解する力が身についてきて、利用者の要望に合わせて改善を行うことからユーザーとのコミュニケーションの重要を感じる貴重な経験となりました。

一方で、長く続けていく中で「新しい技術に触れる機会が少ない」という悩みも感じるようになっていました。

「このままで良いのだろうか」「もっと新しいことに挑戦したい」といった思いを持つようになっていたころでした。

そんな時、現在の代表・社長がダンデライオンズを立ち上げるという話を聞きました。
その話を聞いた時に、新しいことに挑戦できそう・技術的にも成長できそう・会社づくりにも関われそうと感じ、「心機一転チャレンジしてみよう」と思い、入社を決意しました。

入社してからの感想

入社してから気がつけば、8年が経ちました。
入社した当初は、創業メンバーとして少人数のチームでスタートしました。一人ひとりの距離も近く、新しい技術に取り組みながらみんなで会社を作っていくという雰囲気の中で仕事をしていたことをよく覚えています。

そこから少しずつ仲間が増えていき、現在では若手社員や外国籍メンバーも加わり、チームのバリエーションもとても豊かになりました。年齢やバックグラウンド、文化の違うメンバーと一緒に働くことで、新しい視点や考え方に触れることができるのはとても面白く、日々良い刺激をもらっています。

これからは、自分自身がこれまで培ってきた経験を活かしながら、メンバー同士がより協力しやすい環境づくりやサポートにも力を入れていきたいと考えています。
会社がさらに成長していく中で、チーム全体が力を発揮できるよう支えながら、より良い組織づくりに貢献していきたいと思っています。

今回の紹介ブログは以上となります。
次回のブログもお楽しみにしていただければと思います。

Recreation: “Let’s Try Myanmar Cuisine”

Hello everyone! I’m “Pudding🍮” from Team 1.
At Dandelions, we regularly hold recreational events to foster camaraderie among employees. This time, Team 1 hosted an outing to a Myanmar restaurant near Fushimi Station!

Some of you might be wondering, “Why Myanmar cuisine?” Actually, Team 1 has a member from Myanmar, and this project started from the idea that “Since we have this chance, let’s make it a recreation where we can experience a culture outside of Japan!”

Hesitation during the planning stage

Actually, Myanmar cuisine wasn’t the only option from the start. Since the event was held in winter, close to Christmas, ideas like a gift exchange were also proposed.
We tried taking a survey within Team 1, but opinions just wouldn’t come together…
Therefore, we’ve decided to conduct a company-wide survey!

The result was…

  • Myanmar cuisine: 58.3%
  • Gift Exchange: 41.7%

The opinions were evenly split until the very end, making for a fascinating outcome.
In the end, it was decided by a narrow margin: Myanmar cuisine!

Off to the store!

I made a reservation at a recommended Myanmar restaurant, and the day finally arrived. To begin with, I was shocked to learn there are only about three restaurants serving Myanmar cuisine around Nagoya Station…!
Upon entering the shop, the first thing I noticed was the exotic aroma.
Perhaps it was spices. A unique scent, unlike anything I’d smelled much in Japan, filled the air.

My thoughts after actually trying it

The dishes we were served this time included a wide variety, such as Mon Hinga (a traditional Myanmar breakfast dish featuring rice noodles in a soup made with catfish or other fish), Che Oo Sittar (a stir-fried noodle dish with pork and quail eggs), and Wetta Daw Taw (a street stall staple where pork and offal are skewered and simmered in a soy sauce-based broth).

Honestly, I expected the food to have a stronger flavor profile, but when I actually tried it, the seasoning was very easy to eat, even for Japanese people.
However, there are quite a few spicy dishes, so those who aren’t fond of spicy food might want to be a bit cautious.
Even if you think while eating, “This is just the right amount of spice and delicious,” sometimes the heat creeps up on you afterward, and you can’t stop sweating.

Every dish was something rarely found in Japan, allowing us to fully enjoy Myanmar’s culinary culture.

Recreation begins!!

Of course, we didn’t just enjoy the recommended dishes; this time we also split into three groups for a little activity.
The idea was to each rank “dishes that people from Myanmar find delicious” and “dishes that Japanese people find delicious,” then compare them!
When we actually tasted them side-by-side, differences in taste perception and preferences became apparent. Comments like “Wait, this is number one!?” and “This one might actually be more Japanese-friendly than expected” naturally sparked conversation.
Furthermore, deciding the rankings by sharing opinions within each group sparked lively conversation even among members who don’t usually talk much, making it a very exciting time.
Not just about work,

・Food preferences
・Talk about hometowns
・Cultural differences
One of the major benefits of this event was the relaxed atmosphere unique to recreational activities, which allowed us to interact freely.

Summary

This recreational event allowed us to deepen camaraderie among employees while experiencing a different culture through Myanmar cuisine.
The recreation focused on “experiencing an unfamiliar culture” proved to be more enjoyable and educational than we had imagined.

That’s all for this time.
Thank you for reading this far.
Stay tuned for next time!

レクリエーション「ミャンマー料理を食べてみよう」

皆さんこんにちは!チーム1所属「プリン🍮」です。
ダンデライオンズでは、社員同士の親睦を深めるために定期的にレクリエーションを開催しています。今回はチーム1主催で、伏見駅近くのミャンマー料理店へ行ってきました!

「なんでミャンマー料理?」と思った方もいるかもしれません。実はチーム1にはミャンマー出身のメンバーが在籍しており、「せっかくなら日本以外の文化を体験できるレクリエーションにしたい!」という思いから、今回の企画がスタートしました。

企画段階での迷い

実は最初からミャンマー料理一択だったわけではありません。開催時期が冬で、ちょうどクリスマスも近かったため、プレゼント交換会などの案も出ていました。
チーム1内でアンケートを取ってみたものの、なかなか意見がまとまらず……。
そこで、会社全体でアンケートを実施することに!

その結果は……

・ミャンマー料理:58.3%
・プレゼント交換会:41.7%

途中まできれいに意見が割れていて、とても面白い結果になりました。
最終的には僅差で「ミャンマー料理」に決定しました!

いざ、お店へ

おすすめのミャンマー料理屋さんを予約して、いざ当日。そもそもミャンマー料理を扱っているお店自体が、名古屋駅周辺では3件ほどしかないらしく、それを聞いてびっくり…!
お店に入ると、まず感じたのは異国感あふれる香り。
スパイスでしょうか。日本ではあまり嗅いだことのない、独特な香りが漂っていました。

実際に食べてみた感想

今回いただいた料理は、ミャンマーの伝統的な朝食料理であるモンヒンガー(米粉麺にナマズなどの魚を使ったスープ麺)をはじめ、豚肉やウズラの卵を具材にした和え麺料理のチェーオー・シーチャッ、豚肉や内臓を串に刺し、醤油風のスープで煮込んだ屋台定番料理ウェッタードウットウなど、種類も豊富でした。

正直、もっと癖の強い料理を想像していましたが、実際に食べてみると日本人でもとても食べやすい味付けでした。
ただし、辛い料理も多めなので、辛いものが苦手な方は少し注意が必要かもしれません。
食べているときは「ちょうどいい辛さで美味しいな」と思っていても、あとからじわじわと辛さを感じて、汗が止まらなくなることもありました。

どの料理も日本ではなかなか味わえないものばかりで、
ミャンマーの食文化を存分に楽しむことができました。

レクリエーションスタート!!

もちろんおすすめの料理を楽しむだけでなく、今回は3つのグループに分かれてちょっとした企画も行いました。
内容は、「ミャンマー出身の方が“おいしい”と感じる料理」と「日本人が“おいしい”と感じる料理」をそれぞれランキング形式で選び、比べてみよう!というもの。
実際に食べ比べてみると、味の感じ方や好みの違いが見えてきて、「え、これが1位!?」「こっちは意外と日本人向けかも」など、自然と会話が広がりました。
また、グループ内で意見を出し合いながらランキングを決めることで、普段あまり話す機会のないメンバー同士でも会話が弾み、とても盛り上がる時間となりました。
仕事の話だけでなく、
・食の好み
・出身地の話
・文化の違い
など、レクリエーションならではのリラックスした雰囲気で交流できたのも、今回の大きな収穫でした。

まとめ

今回のレクリエーションでは、ミャンマー料理を通して異文化に触れながら、社員同士の親睦を深めることができました。
「知らない文化を体験してみる」というレクリエーションも、想像以上に楽しく、学びの多い時間でした。

今回は以上になります。
ここまで読んでくださり、ありがとうございました。
次回もお楽しみに!

Engineering blog – 5 Useful Java Features in Modern Java

Java has evolved significantly over the past decade. While many developers still associate Java with verbose syntax and heavy boilerplate, modern Java versions (Java 8 and beyond) introduced powerful features that make development cleaner, safer, and more expressive.

In this article, we’ll explore five useful Java features that every developer should know and start using today.

1. Lambda Expressions

Lambda expressions allow you to write concise, functional-style code. They eliminate the need for anonymous classes and make your code easier to read.

Before Java 8:

Runnable r = new Runnable() {
    public void run() {
        System.out.println("Hello World");
    }
};

With Lambda:

Runnable r = () -> System.out.println("Hello World");

Why It’s Useful:

  • Reduces boilerplate code
  • Improves readability
  • Encourages functional programming

Lambda expressions are widely used with Streams, collections, and event handling.


2. Stream API

The Stream API allows you to process collections in a declarative and functional style.

Example:

List<String> names = List.of("Alice", "Bob", "Andrew");

names.stream()
     .filter(name -> name.startsWith("A"))
     .map(String::toUpperCase)
     .forEach(System.out::println);

Benefits:

  • Clear and expressive data processing
  • Supports parallel execution
  • Encourages immutability

Streams make complex data transformations readable and maintainable.


3. Optional Class

Optional helps avoid NullPointerException by explicitly representing a value that may or may not exist.

Example:

Optional<String> username = Optional.ofNullable(getUsername());

username.ifPresent(System.out::println);

Why It Matters:

  • Encourages null-safe coding
  • Makes APIs clearer
  • Reduces runtime errors

Instead of returning null, methods can return Optional<T> to express uncertainty.


4. Records (Java 16+)

Records provide a concise way to create immutable data classes.

Example:

public record User(String name, int age) {}

The compiler automatically generates:

  • Constructor
  • Getters
  • equals() and hashCode()
  • toString()

Advantages:

  • Less boilerplate
  • Immutable by default
  • Ideal for DTOs

Records are perfect for modeling simple data carriers.


5. Switch Expressions

Modern Java allows switch to return values and use arrow syntax.

Example:

String dayType = switch (day) {
    case "Sat", "Sun" -> "Weekend";
    default -> "Weekday";
};

Why It’s Better:

  • More concise syntax
  • No need for break
  • Fewer bugs

Switch expressions improve readability and reduce accidental fall-through errors.


Modern Java focuses on: Cleaner syntax, Safer code and Better developer experience.

If you’re still using older Java patterns, upgrading your style to include these features can dramatically improve your productivity and code quality.

Stay tuned for our next article!

技術ブログ – モダンJavaの便利な機能5選

Javaはこの10年で大きく進化しました。多くの開発者はいまだに、冗長な構文や大量のボイラープレートコードを連想するかもしれませんが、モダンJava(Java 8以降)では、よりクリーンで安全、そして表現力の高い開発を可能にする強力な機能が導入されています。

この記事では、すべての開発者が知っておくべき5つの便利なJava機能を紹介します。

1. ラムダ式(Lambda Expressions)

ラムダ式を使うことで、簡潔な関数型スタイルのコードを書くことができます。無名クラスを使う必要がなくなり、コードの可読性が向上します。

Java 8以前:

Runnable r = new Runnable() {
    public void run() {
        System.out.println("Hello World");
    }
};

ラムダ式を使うと:

Runnable r = () -> System.out.println("Hello World");

メリット:

  • ボイラープレートコードの削減
  • 可読性の向上
  • 関数型プログラミングの促進

ラムダ式は、Stream APIやコレクション操作、イベント処理などで広く利用されています。


 

2. Stream API

Stream APIを使用すると、コレクションを宣言的かつ関数型スタイルで処理できます。

例:

List<String> names = List.of("Alice", "Bob", "Andrew");

names.stream()
     .filter(name -> name.startsWith("A"))
     .map(String::toUpperCase)
     .forEach(System.out::println);

メリット:

  • 明確で表現力の高いデータ処理
  • 並列実行に対応
  • イミュータブルな設計を促進

Streamを使うことで、複雑なデータ変換も読みやすく保守しやすいコードになります。


 

3. Optionalクラス

Optionalは、値が存在するかどうかを明示的に表現することで、NullPointerExceptionを回避するのに役立ちます。

例:

Optional<String> username = Optional.ofNullable(getUsername());

username.ifPresent(System.out::println);

重要なポイント:

  • null安全なコーディングを促進
  • APIの意図が明確になる
  • 実行時エラーの削減

メソッドがnullを返す代わりに、Optional<T>を返すことで、値が存在しない可能性を明確に表現できます。


 

4. Records(Java 16以降)

Recordは、不変なデータクラスを簡潔に作成するための機能です。

例:

public record User(String name, int age) {}

コンパイラが自動的に生成するもの:

  • コンストラクタ
  • Getterメソッド
  • equals()hashCode()
  • toString()

メリット:

  • ボイラープレートの削減
  • デフォルトでイミュータブル
  • DTOに最適

Recordは、シンプルなデータ保持用クラスのモデリングに最適です。


 

5. Switch式(Switch Expressions)

モダンJavaでは、switchが値を返せるようになり、アロー構文(->)も使用できます。

例:

String dayType = switch (day) {
    case "Sat", "Sun" -> "Weekend";
    default -> "Weekday";
};

優れている点:

  • より簡潔な構文
  • breakが不要
  • バグの減少

Switch式は可読性を向上させ、意図しないフォールスルー(fall-through)によるエラーを防ぎます。


 

モダンJavaが目指しているのは、よりクリーンな構文、より安全なコード、そして優れた開発者体験です。

もしまだ古いJavaの書き方を使っているなら、これらの機能を取り入れることで、生産性とコード品質を大きく向上させることができます。

次回の記事もお楽しみに!