Last active
December 16, 2015 12:39
-
-
Save suin/5436300 to your computer and use it in GitHub Desktop.
Scalaで図書館ドメインモデルを軽く組んでみた。クラス図は「誤解しがちなモデリングの技:第7回:モデルの意味的な誤り(I) | 豆蔵ソフト工学ラボ( http://labo.mamezou.com/special/sp_002/sp_002_007.html)」を参考にした。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Date | |
// entity | |
class 書誌 ( | |
ISBN:ISBN, | |
書誌名:String, | |
出版社:String, | |
発売日:Date | |
) { | |
def ISBN():ISBN = ISBN | |
def 書誌名():String = 書誌名 | |
def 出版社():String = 出版社 | |
def 発売日():Date = 発売日 | |
} | |
// value object | |
class ISBN (ISBN:String) { | |
def ISBN():String = ISBN | |
} | |
// entity | |
class 蔵書 ( | |
蔵書ID:蔵書ID, | |
ISBN:ISBN, | |
登録日:Date, | |
貸出状況:貸出状況 | |
) { | |
def 蔵書ID():蔵書ID = 蔵書ID | |
def ISBN():ISBN = ISBN | |
def 登録日():Date = 登録日 | |
} | |
// value object | |
class 蔵書ID (id:Long) { | |
def id():Long = id | |
} | |
// value object | |
class 貸出状況 (貸出状況:Symbol) { | |
} | |
// ✄ - - - - - - - - - - - - - - - - - - - - - - - - | |
val Scalaの本 = new 書誌( | |
ISBN = new ISBN("ISBN978-8443-3084-4"), | |
書誌名 = "Scalaスケーラブルプログラミング第二版", | |
出版社 = "Impress Japan", | |
発売日 = new Date() | |
) | |
val 蔵書1冊目 = new 蔵書( | |
蔵書ID = new 蔵書ID(100), | |
ISBN = Scalaの本.ISBN, | |
登録日 = new Date(), | |
new 貸出状況('貸出可) | |
) | |
val 蔵書2冊目 = new 蔵書( | |
蔵書ID = new 蔵書ID(101), | |
ISBN = Scalaの本.ISBN, | |
登録日 = new Date(), | |
new 貸出状況('貸出中) | |
) | |
println("書誌ISBN: " + Scalaの本.ISBN.ISBN) | |
println("書誌名: " + Scalaの本.書誌名) | |
println("出版社: " + Scalaの本.出版社) | |
println("発売日: " + Scalaの本.発売日) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment