Live data from Hacker News

Wikileaks To Leak 5000 Open Source Java Projects

steve-yegge.blogspot.com

21–30 of 140 posts

Re: Wikileaks To Leak 5000 Open Source Java Projects

#21
post #13

I sympathize, yet encapsulation is appropriate for some projects. Not all users of a library want to frequently update to their own code. Forbidding encapsulation and deprecation would increase this cost. Also, it's comforting to be able to refactor the guts of a class without harming users.

Encapsulation is completely orthogonal to access modifiers.

Re: Wikileaks To Leak 5000 Open Source Java Projects

#22

Does Java have something similar to .Net's reflection?

I'm not sure how .NET's reflection works, but it does have reflection, where you can say stuff like "tell me all of String's methods" and for each of those you can find out public vs private vs protected, final vs not, etc.

See http://download-llnw.oracle.com/javase/1.3/docs/api/java/lan...

Re: Wikileaks To Leak 5000 Open Source Java Projects

#23

"If I buy you a house and put the title in your name, but I mark some of the doors 'Employees Only', then you're not allowed to open those doors, even though it's your house. Because it's really my house, even though I gave it to you to live in." Love it!

Yeah, it's fine for our software but not their music

Re: Wikileaks To Leak 5000 Open Source Java Projects

#25
post #11

In a global header long time ago, a friend of mine (and big "C" lover) did this to his best buddy once (a C++ and especially boost lover): #define class struct #define private public #define protected public

continued "fun" (read dangerous) redefines:

  #define true false
  #define false true

  #define true 0
  #define false !true

  #define if while
  #define continue break
:)

Re: Wikileaks To Leak 5000 Open Source Java Projects

#26
post #11

In a global header long time ago, a friend of mine (and big "C" lover) did this to his best buddy once (a C++ and especially boost lover): #define class struct #define private public #define protected public

This gets even more fun in languages which allow unicode names. Did you know there are dozens of identical-looking ways to spell "true"?

Re: Wikileaks To Leak 5000 Open Source Java Projects

#27
post #21
post #13

I sympathize, yet encapsulation is appropriate for some projects. Not all users of a library want to frequently update to their own code. Forbidding encapsulation and deprecation would increase this cost. Also, it's comforting to be able to refactor the guts of a class without harming users.

Encapsulation is completely orthogonal to access modifiers.

Your view differs from some of the OO language designers. For example, Stroustrup defines encapsulation as "the enforcement of abstraction by mechanisms that prevent access to implementation details of an object or a group of objects except through a well-defined interface. C++ enforces encapsulation of private and proteced members of a class..."

http://www2.research.att.com/~bs/glossary.html#Gencapsulatio...

Since this idea is not obvious, would someone mind explaining?

Re: Wikileaks To Leak 5000 Open Source Java Projects

#29
post #18
post #13

I sympathize, yet encapsulation is appropriate for some projects. Not all users of a library want to frequently update to their own code. Forbidding encapsulation and deprecation would increase this cost. Also, it's comforting to be able to refactor the guts of a class without harming users.

The issue is less about encapsulation and more about language-enforced encapsulation. Encapsulation is good, but encapsulation that's enforced by the language is debatable.

If the language isn't enforcing the encapsulation, how is it encapsulated?

For me, encapsulation comes down to "What I hide, I can change. What I expose, other types may couple to in an inappropriate way."

Re: Wikileaks To Leak 5000 Open Source Java Projects

#30
post #27
post #21

Earlier quoted context omitted.

Encapsulation is completely orthogonal to access modifiers.

Your view differs from some of the OO language designers. For example, Stroustrup defines encapsulation as "the enforcement of abstraction by mechanisms that prevent access to implementation details of an object or a group of objects except through a well-defined interface. C++ enforces encapsulation of private and proteced members of a class..." http://www2.research.att.com/~bs/glossary.html#Gencapsulatio... Since t…

> Your view differs from some of the OO language designers.

Oh come on, that's not true at all. C++ just happens to use access modifiers to provide its brand of encapsulation. However, languages without the `private` reserve word can still provide encapsulation -- they're not the same thing.

What if Java had no notion of private? It would be very difficult to provide data hiding (not that they're hidden anyway, but that's beside the point), so instead you would be forced to put little flags on your names and warnings in your documentation delineating the parts that people shouldn't touch. If they did then that's their fault no?

Post reply on HN