https://kotlinlang.org logo
Title
a

Andrew Gazelka

04/23/2019, 2:30 PM
no package protected makes me so frustrated... no real purpose of having unit tests in same package as what I am testing... to do unit tests practically would need each thing I am testing to be in a seperate module
☝️ 4
1
💯 4
m

Marko Mitic

04/23/2019, 2:38 PM
Does visibility of classes impacts functionality of your code or tests?
d

Dias

04/23/2019, 2:39 PM
Is there any real need to have package private access? If you someone has access to the source code they can always change a modifier anyway whenever they need to. If you are writing a library, it doesn't matter, because you have module level protection
j

jw

04/23/2019, 2:45 PM
It's useful in mixed codebases
a

Andrew Gazelka

04/23/2019, 3:00 PM
@Marko Mitic it is nice for autocompletion and making sure I am referencing the right things I want to test
I am unit testing LeetCode-style code so I want each problem "modularized"
but at the same time making each problem a separate module is WAY too heavy weight
this is why package protected is very nice
j

jw

04/23/2019, 3:05 PM
Even as far as encapsulation goes, module to class is a big jump to make
4
a

Andrew Gazelka

04/23/2019, 3:08 PM
@jw so what do you mean by it being "a big jump"? are you recommending me to use modules?
j

jw

04/23/2019, 3:10 PM
No. I'm advocating for package visibility
👍 2
m

Marko Mitic

04/23/2019, 3:12 PM
Let's implement it guys, how hard can it be?
j

jw

04/23/2019, 3:14 PM
It's not omitted because it's hard. We need to provide a compelling reason for it to exist.
👍 2
a

Andrew Gazelka

04/23/2019, 3:52 PM
to do this the "right" way with modules will take me about an hour to convert lol https://github.com/andrewgazelka/ProjectEuler/tree/style-modularize
g

ghedeon

04/23/2019, 3:55 PM
give it some love: https://youtrack.jetbrains.com/issue/KT-29227 I was a bit emotional by that time, should have provide a less wordy description. My wild guess is they didn't think it through, the simplification went too far, also swift influence. Iirc, Dart has an interesting approach on this matter.
👍 1
a

Andrew Gazelka

04/23/2019, 4:10 PM
@ghedeon link to Dart's approach? I don't know what to search for
g

ghedeon

04/23/2019, 4:57 PM
It's not exactly the state of the art but
part/part of
in conjunction with underscore in Dart helps to group tightly coupled files. That being said, they plan to deprecate it in favor of a similar
friend
semantics. At least they got library visibility right: you expose explicitly your files and everything under
lib/src
is private to the library so you don't have to write tons of
internal
boilerplate. https://www.dartlang.org/guides/libraries/create-library-packages