Refactor Code >> Replace Parameter with Method

การ Refactor Code แบบ Replace Parameter with Method คือการลดพารามิเตอร์โดยการนำ method เข้ามาช่วยในการเขียนโค้ด โดยมีตัวอย่างโค้ดดังนี้ (ภาษา Ruby)  แบบยังไม่ได้ทำการ Refactor Code [code] def get_price() base_price = quantity * item_price discount_level = ” if quantity > 100 discount_level = 2 else discount_level = 1 end final_price = discounted_price(base_price, discount_level) return final_price end private def discounted_price(base_price, discount_level) if discount_level == 2 […]

Refactor Code >> Replace Parameter with Method Read More »