Kebetulan gw lagi into DSL, dan ini exactly one of the side topics...

Good API design adalah
customer.!isAdaKreditMacet()

Tapi kalo lu bikin DSL, lu mesti sadar bahwa things that apply to good API
development practice gak selalu apply ke business communication.
Dalam DSL, ini lebih make sense:
customer.isTidakAdaKreditMacet()

Same thing dengan if-else syntax.
Sebagai programmer, lu cenderung ngerasa ini lebih make sense:
if (customer.is_favorable and customer.total_spending > 500) or
    (customer.is_not_favorable and customer.total_spending > 1000)
then
    apply free_sms_bonus.for(2.months)

Tapi buat most non-developers, in this particular scenario (rule
configuration buat customer's bonus), kalimat ini jauh lebih masuk akal:
apply free_sms_bonus.for(2.months) if
    (customer.is_favorable and customer.total_spending > 500) or
    (customer.is_not_favorable and customer.total_spending > 1000)

Jadi, short answer... buat general API, nomer 1 is better. Kalo tujuannya
buat DSL, maka nomer 2 is better.

2010/4/20 andika.wibawanto <andika.wibawa...@yahoo.com>

>
>
> Dear all,
>
> Saya ada method seperti ini, Mana yang lebih mudah dibaca ?
>
> 1. if (isTidakAdaKreditMacet()) hapusBlacklistNasabah();
>
> 2. if (!isAdaKreditMacet()) hapusBlacklistNasabah();
>
> Thanks,
> Andika
>
>  
>

Kirim email ke