owned this note changed 8 months ago
Linked with GitHub

『自己的源碼自己寫』- 從停車場計費器看測試與架構設計 - Kuma Syu

歡迎來到 https://hackmd.io/@coscup/2024 共筆

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

點擊本頁上方的 開始用 Markdown 一起寫筆記!
手機版請點選上方 按鈕展開議程列表。

請從這裡開始

你就是不寫測試才會沒時間:Kuma 的單元測試實戰 Java篇(iThome鐵人賽系列書)

https://www.tenlong.com.tw/products/9786263332645?list_name=r-zh_tw

今日主題

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

我們關心的維度有哪些

  • 誰停的,停多久
  • 單日/多天
  • 基本費率/當日上限
  • 平日/假日
  • 怎麼描述?
  • 怎麼切?
  • 怎麼分?怎麼算?
  • 怎麼定義?
  • 放哪裡?怎麼存取?
  • 誰來切?
  • 誰來算?
  • 誰來定義?

你有沒有可能寫成這樣?

Image Not Showing Possible Reasons
  • The image was uploaded to a note which you don't have access to
  • The note which the image was originally uploaded to has been deleted
Learn More →

怎麼辦?

SOLID

TDD + Refactoring

(看 code)

物件導向-用商業邏輯包物件
把責任拆到不同物件裡面(價目表/…/假日或平日)

取資料 把資料丟給資料

在這個過程寫測試很重要,這樣你才知道有沒有沒改壞

進階題(optinal)

Q:如果我要把這套系統賣給不同的停車場?
應該要做什麼事情?

A:加不同的價目表

Q & A

Q1

發問:想在公司實踐 TDD,測試案例要怎麼來?
Kuma:不是程式問題而是需求方問題,最近 DDD 很紅(笑)
很多問題我們想都沒有過,所以案例是「溝通來的」,我們要去請教,所以敏捷開發常說我們不是流程跟工具,我們追求是跟使用者直接溝通,取得共識。

Q2

發問:我是職場上的小螺絲釘工程師,跟客戶間會有老闆跟PM,溝通上會隔很多層,開發上都會直接對 PM,剛提到要去溝通需求。
Kuma:change a company(會眾大笑)
「導入」敏捷,「導入」TDD「導入」聽起來很駭人,其實就是把自己的事情先做好,再去改變別人。
如果這個公司環境允許你跟需求方溝通,不允許就去找代理人溝通,如果代理人可以回答,那很好。不然就準備去刷 leetcode (XD)

推薦書:Naming Things

講者補充:為什麼數字改了測試沒壞?

YouTube

Select a repo