I like the concept of encapsulation. Really. I do. Hiding implementation details behind an interface is top-notch design work. I'm all for it. As long as it's done with "protected" and not "private".
The problem that I have with the private access specifier is that it discourages or prevents entirely code reuse in certain situations. Let me explain: as is often the case, I find myself coding with certain libraries or frameworks. Just as often they do not do everything exactly how I would like. Perhaps they are missing a feature, or maybe they have a small bug somewhere. No problem! They are coded with OOP principles, so if I want to add a feature, I'll just subclass it and do what I need to do, right? Wrong!
All too often the particular hook that I need to add my feature is marked private. And since it's marked private, at the discretion of the original author, I can't do what I need to do. Let me lay this out: I have access to the original source code in one form or another, I understand what the original source code is doing, I've identified exactly what I need to change, and yet I'm stuck. What are my options?
One is to change the original source code. However, this is not always possible. Take the .NET Framework for example. The framework comes in a "compiled" form, yet the source code is readable thanks to tools like Reflector. Even if I can change the source code, I don't always want to. Perhaps I want to be able to distribute my application without packaging my custom build of the library. In the case of Javascript, perhaps the library is coming from a CDN like Yahoo provides for YUI.
Another option is to use what hooks I do have available. For instance, if protected MemberA calls private MemberB, and I need to change MemberB, I can override MemberA, copying most of the code, and have it call my custom MemberC instead of the original MemberB. Sometimes this requires changing code many levels deep, and the final product is a copy/pasted mess of the original.
It seems to me that a balance could be struck between the concepts of encapsulation and the flexibility of OOP inheritance and code-reuse. This balance, I think, is called "protected". If somebody has the time and dedication to read and understand the implementation details of a class, I do not think they should be barred from subclassing and having full access to that implementation. I do not believe that it should be up to the original authors to decide what should and should not be changed; they do not have enough foresight. It is impossible to imagine every single feature that could potentially be added and create an extension point for each. Using protected means that normal users of the code still have encapsulation, and those that want or need to go the extra step have the flexibility to do so.
I don't recall a time when I ever thought to myself: "I sure am glad that member is private. That really saved me a lot of hassle." I know of numerous times when I've thought the opposite. Very dark thoughts indeed.
Monday, March 29, 2010
Subscribe to:
Post Comments (Atom)
JIANBIN0811
ReplyDeletebeats headphones
ray-ban sunglasses
cheap oakley sunglasses
louis vuitton outlet
toms outlet
ugg boots uk
longchamp handbags
longchamp outlet
coach outlet online
sac louis vuitton pas cher
ugg boots clearance
ugg boots clearance
jordan 13
abercrombie outlet
air max uk
chrome hearts eyewear
lebron james shoes
fitflops sale
rolex watches
ugg outlet store
timberland shoes
fitflops shoes
polo ralph lauren outlet
supra shoes sale
lacoste pas cher
kate spade uk
ugg uk,ugg outlet,ugg boots outlet
fitflops shoes
michael kors bags
coach outlet online
toms outlet
JIANBIN0811
ReplyDeletebeats headphones
ray-ban sunglasses
cheap oakley sunglasses
louis vuitton outlet
toms outlet
ugg boots uk
longchamp handbags
longchamp outlet
coach outlet online
sac louis vuitton pas cher
ugg boots clearance
ugg boots clearance
jordan 13
abercrombie outlet
air max uk
chrome hearts eyewear
lebron james shoes
fitflops sale
rolex watches
ugg outlet store
timberland shoes
fitflops shoes
polo ralph lauren outlet
supra shoes sale
lacoste pas cher
kate spade uk
ugg uk,ugg outlet,ugg boots outlet
fitflops shoes
michael kors bags
coach outlet online
toms outlet
Ralph Lauren Outlet
ReplyDeleteUgg Boots Sale UGGS For Women Skechers Go Walk Adidas Yeezy Boost Adidas Yeezy Adidas NMD Coach Outlet North Face Outlet Ralph Lauren Outlet Puma SneakersPolo Outlet
Under Armour Outlet Under Armour Hoodies Herve Leger MCM Belt Nike Air Max Louboutin Heels Jordan Retro 11 Converse Outlet Nike Roshe Run UGGS Outlet North Face Outlet
Adidas Originals Ray Ban Lebron James Shoes Sac Longchamp Air Max Pas Cher Chaussures Louboutin Keds Shoes Asics Shoes Coach Outlet Salomon Shoes True Religion Outlet
New Balance Outlet Skechers Outlet Nike Outlet Adidas Outlet Red Bottom Shoes New Jordans Air Max 90 Coach Factory Outlet
michael kors outlet online
ReplyDeletetrue religion
ray ban sunglasses
canada goose jackets
nike air force 1
moncler jackets
true religion outlet store
pandora uk
true religion
coach outlet
20161129caiyan
kobe shoes
ReplyDeleteugg outlet
coach factory outlet
timberland boots
buy red bottoms
louis vuitton outlet store
cheap nike air max
hollister clothing
cheap jordans
louboutin
20161129caiyan
nice blog bro obat perangsang wanita
ReplyDeleteNice artikel bro
ReplyDeleteبادر بالتواصل مع شركة تنظيف خزانات بمكة المتخصصة التي تقدمها شركة العنود حتى تتمكن من الحصول على جميع خدمات تنظيف خزانات بمكة المتكاملة التي تحتاجها لخزانات منزلك بأقل الاسعار
ReplyDeleteJual Obat Aborsi, Obat Penggugur Kandungan, Jual Obat Aborsi Tuntas, Jual Obat Aborsi Ampuh
ReplyDeleteJual Obat Aborsi, Obat Penggugur Kandungan Ampuh
uggs on sale
ReplyDeletemichael kors outlet
ugg outlet
ugg outlet
discount oakley sunglasses
ugg outlet
birkenstocks
christian louboutin
north face outlet
michael kors outlet clearance
canada goose outlet
ReplyDeletered bottoms shoes
canada goose outlet
the north face
coach outlet online
nike outlet
pandora jewelry
michael kors outlet
polo ralph lauren outlet online
canada goose
Coach Outlet Store Online Kate Spade Outlet Cheap Jordans Coach Purses Coach Outlet Kate Spade Outlet Nike Air Max Shoes Red Bottom Shoes Adidas Yeezy Boost 350 Adidas Original
ReplyDelete2018112 leilei3915
ReplyDeletemichael kors outlet
michael kors outlet
ray ban sunglasse
oakley sunglasses wholesale
coach outlet online
ugg boots
polo ralph lauren
pandora jewelry
moncler coats
coach outlet online
Great Article
ReplyDeleteAngular 5 Development Company
Angular 5 Training in CHennai Angular 5 Training in Chennai.
nike sneakers for men
ReplyDeletenike free run
tom ford sunglasses
nike air max 90
nike air max 2018
lebron soldier 11
calvin klein outlet
oakley store
louboutin shoes uk
russell westbrook shoes
This information is very useful. thank you for sharing. and I will also share information about health through the website
ReplyDeleteObat gatal Kudis/gudik
Walatra Gamat Emas Kapsul
Vitamin Untuk Kesehatan Anak
Cara Mengatasi Cacar Air
Cara Menghilangkan Kantung mata
Obat Telinga Berkerak dan Berair
kate spade outlet
ReplyDeletembt shoes outlet
pandora charms sale clearance
michael kors outlet clearance
nba jersey
pandora jewelry
ultra boosts
coach factory outlet online
coach outlet store online
christian louboutin outlet
shenyuhang20180424
Very good information, may be useful for everything;)
ReplyDeletePengobatan Atasi Penyakit Jantung (Jantung)
Pengobatan Kram Otot Sampai Tuntas
Obat Atasi Jantung Berdebar
Pengobatan Perut Sembelit
Pengobatan Mata Glaukoma
Pengobatan Radang Usus Buntu
شركة تسليك مجارى بالاحساء
ReplyDeleteThanks for the information, this is very useful. Allow me to share a health article here, which gods are beneficial to us. Thank you :)
ReplyDeleteObat Sakit Mata Belekan Alami
Obat Sariawan Alami
Obat Penghancur Batu ginjal
Cara Menghilangkan Varises
Obat Sakit perut melilit paling Ampuh
Cara Mudah Menghilangkan Keloid
Great Article
ReplyDeleteProject Centers in Chennai
Final Year Projects for CSE
Very Nice Blog Updation Keep Updating !!
ReplyDeleteCara Mengobati Penyakit Ambeien
Pengobatan Penyakit Sinusitis
Pengobatan Varises dengan Bahan Alami
Obat Radang Dinding Rahim
Obat Penyakit Miom dan Kista
Cara Mengobati Penyakit Kencing Nanah
The article is very useful, thank you for sharing. Allow me to share articles about health here, God willing, useful. thank you :)
ReplyDeleteObat Herbal Luka Gangren
Obat Usus Buntu Tanpa Operasi
Obat Mata Kabur dan Berbayang
Cara Mengobati Tremor secara Alami
The article is very interesting. And I also want to share articles about health, I'm sure this will be useful. Read and share it. Thank you very much :)
ReplyDeleteKhasiat dan manfaat QnC Jelly Gamat
Obat Benjolan Di Ketiak
Solusi Sehat Alami
Jamu Tradisional Penyubur Kandungan/Herbal Khusus Wanita
__
By reading the article material very very well and this is very useful.
ReplyDeletecara menggugurkan hamil
aktivitas penyebab keguguran
penyebab telat haid dan solusinya
tanda tanda kehamilan
kalkulator masa subur wanita
masa subur wanita
After reading and understanding this article. in my opinion this is very useful .
ReplyDeleteyeezy shoes
ReplyDeletegolden goose shoes
yeezy
yeezys
yeezy
supreme clothing
balenciaga
golden goose outlet
supreme outlet
adidas yeezy
Vé máy bay Aivivu, tham khảo
ReplyDeletegiá vé máy bay đi Mỹ khứ hồi
vé máy bay giá rẻ tết 2021
vé máy bay từ Hà nội đi San Francisco
vé máy bay đi Pháp khứ hồi
từ Việt Nam bay sang Anh mất bao lâu
thời gian bay từ Việt nam sang Los Angeles
combo đà nẵng 3 ngày 2 đêm
combo du lịch đà lạt nha trang
visa trung quốc bao nhiêu ngày
dịch vụ cách ly trọn gói
When you’re contemplating a significant move to a place like Anchorage, you might mentally “try on” your new hometown, much like stepping into a dressing room and pulling on a new outfit.
ReplyDeletetransportation service Exeter
This comment has been removed by the author.
ReplyDeletetoptan iç giyim tercih etmenizin sebebi kaliteyi ucuza satın alabilmektir. Ürünler yine orjinaldir ve size sorun yaşatmaz. Yine de bilinen tekstil markalarını tercih etmelisiniz.
ReplyDeleteDigitürk başvuru güncel adresine hoşgeldiniz. Hemen başvuru yaparsanız anında kurulum yapmaktayız.
tutku iç giyim Türkiye'nin önde gelen iç giyim markalarından birisi olmasının yanı sıra en çok satan markalardan birisidir. Ürünleri hem çok kalitelidir hem de pamuk kullanımı daha fazladır.
nbb sütyen hem kaliteli hem de uygun fiyatlı sütyenler üretmektedir. Sütyene ek olarak sütyen takımı ve jartiyer gibi ürünleri de mevcuttur. Özellikle Avrupa ve Orta Doğu'da çokça tercih edilmektedir.
yeni inci sütyen kaliteyi ucuz olarak sizlere ulaştırmaktadır. Çok çeşitli sütyen varyantları mevcuttur. iç giyime damga vuran markalardan biridir ve genellikle Avrupa'da ismi sıklıkla duyulur.
iç giyim ürünlerine her zaman dikkat etmemiz gerekmektedir. Üretimde kullanılan malzemelerin kullanım oranları, kumaşın esnekliği, çekmezlik testi gibi birçok unsuru aynı anda değerlendirerek seçim yapmalıyız.
iç giyim bayanların erkeklere göre daha dikkatli oldukları bir alandır. Erkeklere göre daha özenli ve daha seçici davranırlar. Biliyorlar ki iç giyimde kullandıkları şeyler kafalarındaki ve ruhlarındaki özellikleri dışa vururlar.
Well done! Also visit my site 온라인카지노
ReplyDeleteHard to ignore such an amazing article like this. You really amazed me with your writing talent. Thank you for sharing again.
ReplyDelete야설
Feel free to visit my blog :
야설
Nice to be visiting your blog again. it has been months for me. Well this article that i’ve been waited for so long. I need this article to complete my assignment in the college. and it has same topic with your article. Thanks. great share
ReplyDelete일본야동
Feel free to visit my blog :일본야동
I subscribed to your Feed too.
ReplyDelete일본야동
Feel free to visit my blog : 일본야동
Hi there! This article could not be written much better!
ReplyDelete야설
Feel free to visit my blog : 야설
GREAT JOB! This blog presents a very valuable information. Keep up the good work! Visit our website too. Thanks!
ReplyDelete고스톱
Took me time to read all the comments, but I really enjoyed the article. It proved to be Very helpful to me and I am sure to all the commenters here! It’s always nice when you can not only be informed, but also entertained!
ReplyDelete스포츠토토
Thanks for sharing the informative post. If you are looking the Linksys extender setup guidelines . so, we have a best technical expert for handlings your quires. for more information gets touch with us.
ReplyDelete한국야동
Nice post! This is a very nice blog that I will definitively come back to more times this year! Thanks for informative post 토토사이트
ReplyDeleteWhat a post I've been looking for! I'm very happy to finally read this post. 안전놀이터 Thank you very much. Can I refer to your post on my website? Your post touched me a lot and helped me a lot. If you have any questions, please visit my site and read what kind of posts I am posting. I am sure it will be interesting.
ReplyDeleteThe Best Casino Apps of 2020 - DrmCMD
ReplyDeleteBest casino 세종특별자치 출장마사지 apps: · 광양 출장마사지 1. 강릉 출장샵 Bovada · 2. Slots 부산광역 출장안마 Casino · 양주 출장샵 3. Vegas Slots Casino · 4. BetMGM · 5. The Atlantis · 6. Bovada.
When did you start writing articles related to ? To write a post by reinterpreting the 메이저사이트추천 I used to know is amazing. I want to talk more closely about , can you give me a message?
ReplyDelete