Refactorizacion

7 views
Skip to first unread message

miguel agustin cardamone

unread,
Oct 9, 2019, 8:20:59 AM10/9/19
to Aida/Web Smalltalk Web Framework
Hola

tengo estos dos metodos de clase 

priceBeforeTax
| com p p2 |
com := self isBestSeller
ifTrue: [ price / 50 ]
ifFalse: [ price / 100 ].
p := self isBestSeller
ifTrue: [ price * 1.1 ]
ifFalse: [ price ].
p2 := p + com.
^ p2

-----------------------------------------------------------

price
| com p p2 p3 |
self isBestSeller
ifTrue: [ p := price * 1.1.
com := price / 50 ]
ifFalse: [ p := price.
com := price / 100 ].
p2 := p + (p * 21 / 100).
p3 := p2 + com.
^ p3

como se ve hay codigo repetido quiero si pueden me ayuden a refactorizar estos dos metodos 

gracias 

Reply all
Reply to author
Forward
0 new messages