Hi everyone! I've recently decided that I want to rewrite my currently static portfolio website/blog as a dynamically served website with a server (mainly with the purpose of adding additional functionality). I love Kotlin and when looking into using it for the server I came across ktor and exposed which I think I would work well together. However, most of the server-side code I've written has been in Ruby under the Rails framework, which is super opinionated and pushes for a predefined structure that I certainly followed. Now I've started working with ktor and exposed and I'm a bit at a loss for how to organize my code. Have any of you figured out a way to organize your classes, functions, files, etc. that's scaled well?
t
tipsy
01/24/2019, 6:49 PM
most people recommend package by feature, so if you have
blogposts
on your website, you'd do
Copy code
blogpost
BlogPost // data class
BlogPostController // business logic
BlogPostDao // database access
tipsy
01/24/2019, 6:50 PM
then make one package per feature your website has
m
mp
01/24/2019, 7:27 PM
It doesn’t matter too much because it’s pretty easy to change later because there’s so much better tooling in Kotlin than in Ruby… rearrange stuff to your heart’s content and the IDE / compiler will make sure you get it right. 🙂
t
Tomer
01/24/2019, 7:27 PM
Okay thanks! I'll try that
j
Jeremy
01/24/2019, 9:43 PM
You can still develop spaghetti in any language incl. Kotlin 🙂