— Scott McNealy, Sun Microsystems Chairman, President and ceo



Download 40,57 Mb.
Pdf ko'rish
bet293/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   289   290   291   292   293   294   295   296   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

An instance variable 
takes cheap shots at a static variable
static vs. 
instance


numbers 
and
statics
you are here
4
309
Um, aren’t you forgetting something? 
Static variables are about as un-OO as it gets!! 
Gee why not just go take a giant backwards 
step and do some procedural programming 
while we’re at it.
You’re like a global variable, and any 
programmer worth his PDA knows that’s 
usually a Bad Thing.
Yeah you live in a class, but they don’t call 
it Class-Oriented programming. That’s just 
stupid. You’re a relic. Something to help the 
old-timers make the leap to java.
Well, OK, every once in a while sure, it makes 
sense to use a static, but let me tell you, abuse 
of static variables (and methods) is the mark 
of an immature OO programmer. A designer 
should be thinking about object state, not class 
state.
Static methods are the worst things of all, 
because it usually means the programmer is 
thinking procedurally instead of about objects 
doing things based on their unique object 
state.
Riiiiiight. Whatever you need to tell yourself...
What?
What do you mean un-OO? 
I am NOT a global variable. There’s no such 
thing. I live in a class! That’s pretty OO you 
know, a CLASS. I’m not just sitting out there 
in space somewhere; I’m a natural part of the 
state of an object; the only difference is that 
I’m shared by all instances of a class. Very 
efficient.
Alright just stop right there. THAT is 
definitely not true. Some static variables are 
absolutely crucial to a system. And even the 
ones that aren’t crucial sure are handy.
Why do you say that? And what’s wrong with 
static methods?
Sure, I know that objects should be the focus 
of an OO design, but just because there are 
some clueless programmers out there... don’t 
throw the baby out with the bytecode. There’s 
a time and place for statics, and when you 
need one, nothing else beats it.

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   289   290   291   292   293   294   295   296   ...   555




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