Post on 18-Dec-2014
description
Copyright © 2014 TIS Inc. All rights reserved.
Scalable Generator: Using Scala in SIer Business
2014.9.6
Yugo Maede !TIS Inc.
Copyright © 2014 TIS Inc. All rights reserved. 2
My profile
• TIS株式会社 戦略技術センター!•社内エンジニアリング基盤の構築!• Scalaの活用検証!•甲賀忍者
Work in Strategic technology center of TIS Inc.!have built in-house application framework and tools!Evaluating Scala!Koka-Ninja!Twitter : @yugolf
自己紹介
Copyright © 2014 TIS Inc. All rights reserved. 3
My articles
-‐ ITPro “Is it easy to switch the build tool from Maven to Gradle?”!-‐ @IT “Your dream will definitely come true. What is Web Components?”!-‐ CodeZine “Introduction to Play Framework”
執筆記事紹介
• ITPro 「ビルドツールの移行性 MavenからGradleへの乗り換えは容易か」!• @IT 「あなたの知らない超絶便利なWebを叶える仕様Web Componentsとは」!• CodeZine 「ScalaのWebアプリケーションフレームワーク「Play Framework」入門」
TIS技術ブログ Tech-‐Sketch
http://tech-‐sketch.jp/
Copyright © 2014 TIS Inc. All rights reserved. 4
Agenda
Background!A barriers of using Scala!Introduce code generator!Demonstration!Summary •背景!
•Scala採用の壁!•コードジェネレータの紹介!•デモ!•まとめ
アジェンダ
Copyright © 2014 TIS Inc. All rights reserved. 5
Background : About TIS
-‐ TIS is System Integrator Entrusted development on various scale!!
-‐ Our cover fields!The enterprise like bank, insurance, credit card, manufacturing and so on
• SIer 大・中・小 受託開発!•主な対象分野 金融・カード・産業!!
TISについて
Copyright © 2014 TIS Inc. All rights reserved. 6
Background : Our activities in the past
To improve the efficiency of development -‐ In-‐house application framework (for development by Java)!-‐ Code generator!-‐ Development tools and guide (for test, CI etc)!-‐ Training for developer in my company!
-‐ about framework, Jenkins, Maven, JUnit etc
•生産性の向上を目指して •社内向けアプリケーション開発基盤 (=Java)!•コードジェネレータ!•開発効率化ツール/ガイド(テスト効率化・CI etc)!•社内教育!
•フレームワーク・Jenkins・Maven・JUnit etc
これまでの取り組み
Copyright © 2014 TIS Inc. All rights reserved. 7
More Improvement
It’s difficult to improve the efficiency only by framework, generator, and some tools.
focus on improving of programing itself! Java ▶︎ Scala
Generator
Java
CI
Test Tool
Framework
LibrariesLibrariesLibraries Scala
フレームワーク・ジェネレータ・その他周辺ツールの整備だけでは困難! プログラミングそのものの効率化へ
更なる改革
Copyright © 2014 TIS Inc. All rights reserved. 8
The barrie of using Scala
-‐ A shortage of tools and libraries for developing enterprise applications -‐ Stability-‐oriented customers and developers!-‐ Difficult to learn and teach Scala!!
-‐ Can we really improve the efficiency of development by Scala?
•エンタープライズ向けのライブラリやツールの不足 •安定志向の開発現場や顧客!•習得や教育の難しさ!!!本当にScalaで開発が効率化出来るのか?
Scalaを採用する壁
Copyright © 2014 TIS Inc. All rights reserved. 9
How does development change by switching to
-‐ The number of codes decrease compared to Java. -‐ If we master Scala, productivity must increase. -‐ Can't completely say that it has rapid effect, but it has high potential. -‐ After all, Does it depends on personal ability? !
-‐ Yes. I’d like to make the following;
excellent developers can show their ability.
• Scalaの簡潔性によりJavaに比べコード量が激減する。
• Scalaの習熟度があがれば生産性が上がる。
•決して、即効性は高いとは言えないが大きな伸びしろを秘めている。 •結局プログラマの能力次第?
• Yes。能力の高いプログラマが力を発揮できる世界を作りたい。
Scalaで何が変わる?
Copyright © 2014 TIS Inc. All rights reserved.
Is that true? The number of steps will decrease.
全体のコード量が減ったとしても、実装量が減らないと意味がない。
Java
Seasar2
Xenlon
auto
Fram
ework
Application
Scala
Play2
hand made
hand made
hand made
Fram
ework
Application
the previous development using Scala/Play2
If the total amount of source codes decreased, but we need to decrease the programing part except framework.
10
hand made
本当に実装コードは減る?
Copyright © 2014 TIS Inc. All rights reserved.
auto
How shall we solve?
We should automate programing which is able to be automated.! -> need a Code Generator
自動化出来るところは自動化する。 ▶ コードジェネレータ11
解決するには?
Java
Seasar2
Xenlon
auto
Fram
ework
Application
the previous development
hand made
Scala
Play2
add-‐on
hand made
Fram
ework
Application
using Scala/Play2
Copyright © 2014 TIS Inc. All rights reserved. 12
Automation by the code generator
-‐ Automate simple works, and programers focus on essential business logics. -‐ The automation isn't 100%, it's important to develop business logic by hand
-‐ automate -‐ The structure of code does not depend on programing language. -‐ The code depends on a framework.
-‐ not automate -‐ Business logic
•機械的に実装出来る部分は自動化し、プログラマーは本質的な ビジネスロジックの実装に注力
• 100%自動生成ではなく、ビジネスロジックをScalaで実装する事に価値
<自動化>
•実装言語によって構造が変わらない部分(シンプルにならない) •フレームワークによって記述が異なる部分(FWの壁)
<非自動化>
•ビジネスロジック
コードジェネレータによる自動化
Copyright © 2014 TIS Inc. All rights reserved. 13
Generator features
-‐ Based on Play Framework and Slick (Typesafe products). -‐ Source codes are generated from DB schema.
-‐ Import Application structures into the Repository in the generating process. -‐ Allow you to edit the application structures in the repository. -‐ Don't have to install, because provided by "Typesafe Activator".
• Play Framework / Slick対応のTypesafeプロダクト準拠
• DBスキーマ情報からソースコードをジェネレート
•アプリケーション構造をリポジトリ登録 •アプリケーション構造をリポジトリに格納し編集可能 • Typesafe Activator のテンプレートで提供するため環境構築不要
ジェネレータの特徴
Copyright © 2014 TIS Inc. All rights reserved. 14
For Play Framework and Slick
• Scala開発企業であるTypesafeが開発/サポートしているため安心
•定番フレームワークに!? • Slickコードジェネレータを活用し、そのポリシーを踏襲
-‐ We can trust and use them, because they are developed by Typesafe who develop Scala.
-‐ De facto standard(!?) -‐ It uses Slick code generator and follow its policy.
Play Framework と Slick
Copyright © 2014 TIS Inc. All rights reserved.
Generating flow when using the code generator
1. When execute Scaffold, it imports information for generating an application into design repository, and generate source codes.
(2) generate source code! from database
Database Schema
Design Repository
Route
Controller
View
Model
Form
Dao
(1) create design repository
(3) generate source code! from repository
(4) edit repository
(5) regenerate
Web Application
2. Edit design repository and re-‐generate source code.
15
ジェネレート生成のフロー
Copyright © 2014 TIS Inc. All rights reserved. 16
Design Repository
The table structure and relations
Screens ! Screen ID Screen Type
Screen Entities ! Screen ID Entity Name
Screen Items ! Screen ID Item No Domain Code Search Condition Component Type
Domains ! Domain Code
Validations ! Domain Code Validation Code Validation Attribute Validation Value
-‐ Create -‐ Search -‐ Update
-‐ = -‐ != -‐ > -‐ < -‐ contains …etc
-‐ text -‐ select -‐ checkbox -‐ radio …etc
-‐ text -‐ bigDecimal -‐ number …etc
1*
1*
10..1
1*
設計リポジトリ
Copyright © 2014 TIS Inc. All rights reserved. 17
Edit design repository
設計リポジトリを編集することで、Scaffoldから実用的なアプリケーションへ進化させる。
Scalable Generator
The codes are improved into a practical application by editing design repository.
設計リポジトリの変更
Copyright © 2014 TIS Inc. All rights reserved. 18
Generated codes
When you edit design repository, generated source codes change .
case class EventSearchData( @(== @field) eventId: Option[String], @(contains @field) eventNm: Option[String], …)
val eventCreateForm = Form( mapping( “eventId” -‐> nonEmptyText(maxLength=10), “eventNm” -‐> optional(text(maxLength=100), …)…
@helper.inputText(eventSearchForm(“eventId”)) @helper.select(eventSearchForm(“place”), …)
change into partial match by changing Search condition.
change into required by checking required.
change into select list by changing Component
生成されたコード
Copyright © 2014 TIS Inc. All rights reserved. 19
Don’t have to install
$ activator new <application name> skalholt
Library
Skalholt Template
Skalholt code generator
-‐ You don't have to install, because it's provided as one of the template of Typesafe Activator.
-‐ When you execute a command, can build blank project.
Typesafe Activatorのテンプレートの1つとして提供するため環境構築不要
コマンド一つでブランクプロジェクトが出来上がる。
環境構築不要
Copyright © 2014 TIS Inc. All rights reserved. 20
Demonstration
Required:Typesafe Activator is installed
https://typesafe.com/platform/getstarted
!1. activator new 2. h2-browser 3. activator run 4. skalholt-ui 5. generate 6. modify repository 7. regenerate
!!! ▶︎ http://localhost:9000/ ▶︎ http://localhost:9001/ ▶︎ check the application ! ▶︎ check the application
デモ
Copyright © 2014 TIS Inc. All rights reserved. 21
What problem is solved by the generator?
•エンタープライズ向けのライブラリやツールの不足 ▶ ジェネレータにより実装するコード量の削減 •安定志向の開発現場や顧客 ▶ ジェネレータによる品質の底上げ!•習得や教育の難しさ! ▶ ジェネレートされたコードをベースとした実装による障壁の軽減
-‐ A shortage of tools and libraries for develop enterprise applications -‐ >The number of codes to be written by programers is decreased by the code generator.
-‐ Stability-‐oriented customers and developers -‐ >Improve the basic quality by the code generator!
-‐ Difficult to learn and educate Scala!-‐ >the barrier is minimized by programing based on generated codes.
何が解決されたのか?
Copyright © 2014 TIS Inc. All rights reserved. 22
The biggest barrie? Find/Train an engineer of Scala.
-‐ Learning materials are already prepared now. -‐ If you feel a barrier for using Scala, would you start from Play? -‐ If you feel a barrier for using Play, would you start from Skalholt? !
-‐ I'd like you to use Skalholt not only for improving the efficiency of development but also for learning Scala.
•勉強する環境は整っている。
•Scalaに障壁を感じている人はPlayから始めて見ませんか?
•Playに障壁を感じている人はSkalholtから始めて見ませんか?
!• 開発を効率化するだけでなく、Scalaを習得するためのツールとして活用して欲しい。
Copyright © 2014 TIS Inc. All rights reserved. 23
What I have done as a Java engineer.
-‐ Converted sample application on a Java based framework into Scala application.
-‐ Converted some of the features of the framework to be use by Scala. -‐ Evaluated Scala on real project. -‐ Held a study session for our company. -‐ Took Typesafe training. -‐ Took a course of Odersky on Coursera.
“Functional Programing Principles in Scala”
• Java製FW上のサンプルアプリをPlay2+Scalaにコンバート
• Java製FWの持つ機能をScalaから使えるように
•実プロジェクトで検証 •社内向けの勉強会開催 • Typesafeのトレーニング受講
• Coursera受講 : Functional Programing Principles in Scala
Javaエンジニアの私がやったこと
Copyright © 2014 TIS Inc. All rights reserved. 24
How to use Skalholt.
• OSSとして公開しました!
GitHub Pagesをご覧下さい。
!•自分向けのコードをジェネレートするにはGitHubから
Skalholtは使えるの?
-‐ Have released it Please look at GitHub Pages
http://tech-‐sketch.github.io/skalholt/ !-‐ If you want to generate customized code, please get source code from GitHub
THANK YOU