3 ms·
Honest question that I haven't taken the time to figure out. Do I still have to have only 1 file per class/interface in Java 8?
by kasey_junk 13y ago
Honest question that I haven't taken the time to figure out. Do I still have to have only 1 file per class/interface in Java 8?
- ryanobjc 13y agoyou've never had to only have 1 class per file. You can only have 1 public class per file however. You can also nest classes in other classes for quick little data types you need locally. So the notion that every single last tiny class has it's own file hasn't ever been true (even if thats the coding style in a lot of code).
- kasey_junk 13y agoBut if I have an interface and a couple of implementations I'm back to multiple files right?
- mason55 13y agoNot in scala, no.
- mason55 13y agoNo, in fact you frequently have more when you start using case classes. Plus you frequently have the companion object that goes with your class that acts as a singleton.
- kasey_junk 13y agoI understand the limitations of Scala with regard to class/trait/objects etc. What I'm asking is if it is still an issue in Java 8? I'm shocked every time I drop back into java land that people haven't revolted against this terrible requirement.
- edwinnathaniel 13y agoWhy is this an issue or a big deal? Really.
- kasey_junk 13y agoBecause it adds friction between separating implementation and interface. That is one of those things I want to be as seamless as possible. Is it a big deal in the case of 1 interface and 1 class? No not really. But in the case of thousands of them it becomes an issue. It's actually one of the biggest things I notice when I come back to java land.
- edwinnathaniel 13y agoI think with modern Java libraries (and testing libraries as well), the days of 1:1 interface=>classes are almost gone. I rarely do that any more these days so hopefully it'll become non-issue in the future for you.
- mason55 13y agoOh, yes, in Java it's still one class per file