3 ms·
Yup! It seems we're not disagreeing entirely. My complaint is that it's fine if you want to use "gov.nasa.arc.spife" as a unique disambiguator for your package
by makmanalp 12y ago
Yup! It seems we're not disagreeing entirely. My complaint is that it's fine if you want to use "gov.nasa.arc.spife" as a unique disambiguator for your package / modules, but you shouldn't have to encode that in the path, just some metadata in a file somewhere would have done the same job. The nestedness is superfluous. The logical hierarchy here need not also be a physical one, that's basically what I'm getting at. Fair point about java-specific IDEs hacking around that.
edit: even clearer example: https://github.com/nasa/OpenSPIFe/tree/master/gov.nasa.arc.spife.core.plan.editor.timeline https://github.com/nasa/OpenSPIFe/tree/master/gov.nasa.arc.s...
All this code is ALREADY in a folder named gov.nasa.arc.spife.core.plan.editor.timeline so why even bother creating the src/gov/nasa/arc/spife/core/plan/editor/timeline structure within that?
- bitemix 12y ago1) The containing folder you're referring to is not part of the compiled artifact. 2) If you're feeling particularly adventurous, you could probably write a ClassLoader which knows how to resolve the full class identifier (including package) to its actual class, which needn't be in that directory structure, but at that point you're fighting 19 years of Java history. 3) Scala mitigates the crazy folder hierarchies by letting you structure the source more naturally (needn't be a 1:1 between package and folder structure, and even have multiple classes per file), and ensures the resulting class files are structured the way the JVM's default ClassLoader wants them. That said, many folks end up adopting the Java source style for consistency, especially in teams where they have to maintain legacy Java code anyhow.
- jvilk 12y ago> you shouldn't have to encode that in the path, just some metadata in a file somewhere would have done the same job There are two problems with this approach, from how I see it. 1) Now there is an extra build step: Produce the metadata that associates class names with files. 2) This mechanism also adds an extra level of indirection when the ClassLoader needs to resolve a class. By using a file system, you can edit a single Java file in a project with many classes, and recompile only that single file to test your changes. > All this code is ALREADY in a folder named gov.nasa.arc.spife.core.plan.editor.timeline That's NASA's choice for organizing code into modules. Each of these look like individual libraries, and that's the full name of the package that the library supplies. Sounds practical, especially since they have the source code of other non-NASA libraries checked in (e.g. rhino). They could have merged the source trees of the individual components, but that becomes cumbersome as some of the third party components are under different licenses, and it's likely that each of these packages are built and packaged into separate JAR files. That folder name won't be in the final JAR file, which will only have the hierarchy past the src folder. Note that the JVM has a robust mechanism for custom classloaders, so you could actually implement your metadata idea if you wanted to. What will happen at runtime is that the JVM will invoke your custom classloader with the full class name (e.g. java.lang.String), and then you have to give it the Class object associated with it (which you can construct dynamically, produce from a byte array loaded from somewhere, or request from the JVM's file-based classloader).