Clean Code


Iterator currentArgument)



Download 3,58 Mb.
Pdf ko'rish
bet222/384
Sana05.04.2022
Hajmi3,58 Mb.
#530298
1   ...   218   219   220   221   222   223   224   225   ...   384
Bog'liq
Clean Code

Iterator currentArgument) 
throws ArgsException {
try {
m.set("true");
catch (ArgsException e) {
}
}
Didn’t we just put that exception processing in? Putting things in so you can take
them out again is pretty common in refactoring. The smallness of the steps and the need to
keep the tests running means that you move things around a lot. Refactoring is a lot like
solving a Rubik’s cube. There are lots of little steps required to achieve a large goal. Each
step enables the next.
Why did we pass that 
iterator
when
setBooleanArg
certainly doesn’t need it? Because
setIntArg
and
setStringArg
will! And because I want to deploy all three of these functions
through an abstract method in 
ArgumentMarshaller
, I need to pass it to 
setBooleanArg
.


234
Chapter 14: Successive Refinement
So now 
setBooleanArg
is useless. If there were a 
set
function in 
ArgumentMarshaler
, we
could call it directly. So it’s time to make that function! The first step is to add the new
abstract method to 
ArgumentMarshaler
.
private abstract class ArgumentMarshaler {
public abstract void set(Iterator currentArgument) 
throws ArgsException;
public abstract void set(String s) throws ArgsException;
public abstract Object get();
}
Of course this breaks all the derivatives. So let’s implement the new method in each.
private class BooleanArgumentMarshaler extends ArgumentMarshaler {
private boolean booleanValue = false;
public void set(Iterator currentArgument) throws ArgsException {
booleanValue = true;
}
public void set(String s) {

Download 3,58 Mb.

Do'stlaringiz bilan baham:
1   ...   218   219   220   221   222   223   224   225   ...   384




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish