Clean Code


private String stringValue



Download 3,58 Mb.
Pdf ko'rish
bet206/384
Sana05.04.2022
Hajmi3,58 Mb.
#530298
1   ...   202   203   204   205   206   207   208   209   ...   384
Bog'liq
Clean Code

private String stringValue;
public void setBoolean(boolean value) {
booleanValue = value;
}
public boolean getBoolean() {
return booleanValue;
}
public void setString(String s) {
stringValue = s;
}
public String getString() {
return stringValue == null ? "" : stringValue;
}
}
Again, these changes were made one at a time and in such a way that the tests kept
running, if not passing. When a test broke, I made sure to get it passing again before con-
tinuing with the next change. 
By now you should be able to see my intent. Once I get all the current marshalling
behavior into the 
ArgumentMarshaler
base class, I’m going to start pushing that behavior
down into the derivatives. This will allow me to keep everything running while I gradually
change the shape of this program.
The obvious next step was to move the 
int
argument functionality into the
ArgumentMarshaler
. Again, there weren’t any surprises.
private Map, ArgumentMarshaler
> intArgs = 
new HashMap, ArgumentMarshaler
>();
...


216
Chapter 14: Successive Refinement
private void parseIntegerSchemaElement(char elementId) {
intArgs.put(elementId, 
new IntegerArgumentMarshaler()
);
}
...
private void setIntArg(char argChar) throws ArgsException {
currentArgument++;
String parameter = null;
try {
parameter = args[currentArgument];
intArgs
.get
(argChar)
.setInteger
(Integer.parseInt(parameter));
} catch (ArrayIndexOutOfBoundsException e) {
valid = false;
errorArgumentId = argChar;
errorCode = ErrorCode.MISSING_INTEGER;
throw new ArgsException();
} catch (NumberFormatException e) {
valid = false;
errorArgumentId = argChar;
errorParameter = parameter;
errorCode = ErrorCode.INVALID_INTEGER;
throw new ArgsException();
}
}
...
public int getInt(char arg) {

Download 3,58 Mb.

Do'stlaringiz bilan baham:
1   ...   202   203   204   205   206   207   208   209   ...   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