Java for Fucking Idiots: Learn the Basics of Java Programming Without any experience!



Download 3,91 Mb.
Pdf ko'rish
bet64/70
Sana02.04.2022
Hajmi3,91 Mb.
#524999
1   ...   60   61   62   63   64   65   66   67   ...   70
Bog'liq
Java for Fucking Idiots

class
StatusScreen {
private
Order
order
;
private
Networker
networker
;
public void
showOrderStatus() {
String currentStatus =
networker
.getOrderStatus(
order
.getId());
updateProgressBar(currentStatus);
}
private void
updateProgressBar(String status) {
//update order progress bar

}


}
private is saying that no other class knows how to update the progress bar
on the screen. Only the StatusScreen can call this method. It’s invisible to
the rest of them. Consider private properties and methods to be what is
“abstracted away” from the classes that would interact with it.
public is saying that any other class can call this method. It’s possible we’d
have another part of the user interface that wants to tell this screen to show
the order status. And luckily for us, it would appear that Networker’s
getOrderStatus
method is public, since we’re able to use it.
And that’s correct; this is what Networker might look like:
public class
Networker {
public
String getOrderStatus(String id) {
establishNetworkConnection();
makeRequest();
processResult();
return
getStatusFromResult();
}
private void
establishNetworkConnection() {}
private void
makeRequest(String id) {}
private void
processResult() {}
private
String getStatusFromResult() {}
}
We get to call the public method 
getOrderStatus
from our user interface
class. And we have no idea that all this complicated networking shit is
happening under the hood.
This is the beauty of encapsulation; we’re forcing abstraction. Other classes
can’t fuck up our shit if they aren’t even allowed access to it.

Download 3,91 Mb.

Do'stlaringiz bilan baham:
1   ...   60   61   62   63   64   65   66   67   ...   70




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