Out of curiosity: What is the guideline on naming ...
# java-to-kotlin-refactoring
p
Out of curiosity: What is the guideline on naming files either starting with upper or lowercase? I just saw it in Duncan's videos and couldn't find a reference to it in the book.
j
I haven't seen guidelines on it, but I tend to see Camel case for when the file name matches the main class declared in the file, and lowercase when there is no main thing in the file, but rather a collection of related elements of somewhat equal importance. That might not be the proper way at all of course, just a tendency I have seen in a couple projects
Oh wait I didn't realize we were in the channel for the specific book, my bad
d
All welcome!
I like to play with words, so I like to call collections of functions with ‘ing’ names. logging, reading, writing, updating
p
I'd like to crosspost from #random because it's a question that's haunting me the last several days: https://kotlinlang.slack.com/archives/C09222272/p1648202455946919?thread_ts=1648202455.946919&cid=C09222272
Overall I'm constantly thinking about how to make the codebase as easy to navigate as possible. Searching for a class is usually the option I use, but with top level functions I usually fall back to 'search for file', which requires me to know how the file containing the function was called. I see that e.g.
updating
is sufficient for our beloved service for Gilded Rose Inc., but gets harder when the codebase gets bigger (because gilded rose now competes with Amazon..)
d
I guess as the codebase gets bigger we will rely on packages to distinguish between updating Items or Customers or Stores. With some careful tiny typing we might find a function by parameter type, and extension functions are really nicely discoverable. In the end though most codebases end up with some duplication, and reuse that only occurs because someone looks at some code and realises that something they saw last Tuesday could be used here. That's ok IMO, these are human systems after all.
c
Searching for a class is usually the option I use, but with top level functions I usually fall back to ‘search for file’, which requires me to know how the file containing the function was called.
maybe idea’s go to class should also find top level fields and functions.
👍 1
p
That would make my life way easier..
c
p
Wow, great! Will for sure upvote it. One small thing: “in kotlin projects Go to class should also find top level classes and fields.” I think you meant functions there 🙂
👍 1
d
Upvoted. IntelliJ is certainly showing its Java roots in many areas at the moment. And yet I currently can’t actually extract Method when that it what I want to do - it only seems to extract top-level functions in Kotlin these days
p
‘extract method’ never works in the way I want it to be..
c
my favorite java refactoring is also still missing: https://youtrack.jetbrains.com/issue/KTIJ-10606
j
Why don't you guys use Go to symbol, if what you want is not a class? I would be pretty puzzled if Go to class gave me things that are not classes
c
go to symbol just finds way too much
for me “go to top level symbol” would be perfect
👍 1
if you think it would be confusing to you or other people als put it into the ticket. i just created it to see what other users think