官术网_书友最值得收藏!

Managing projects

On the left side of the IDE window, you can see the directory structure of the project. The IDE knows the different types of files and shows them in a way that is meaningful from the programming point of view. For example, it does not display Main.java as a filename. Instead, it displays Main and an icon that signals that Main is a class. It can also be an interface still in a file named Main.java but, in that case, the icon will show that this is an interface. This is again done by the IDE continuously scanning and compiling the code.

The files are structured into subdirectories when we develop a Java code. These subdirectories follow the packaging structure of the code. Many times, in Java, we use compound and long package names, and displaying it as a deep and nested directory structure will not be so easy to handle.

Packages are used to group the source files. The source files for classes that are related in some way should go into one package. We will discuss the notion of packages and how to use them in the next chapter

The IDE is capable of showing the package structure instead of the nested directories for those directories of the project that contain source files.

When you move a class or an interface from one package to another, it happens in a similar way as renaming or other refactoring. All references to the class or interface in the source files get renamed to the new package. If a file contains an import statement referring to the class, the name of the class in the statement is corrected. To move a class, you can open the package and use the good old drag and drop.

Package hierarchy is not the only hierarchy displayed in the IDE. The classes are in packages but, at the same time, there is an inheritance hierarchy. Classes may implement interfaces and can extend other classes. The Java IDEs help us by showing type hierarchies where you can navigate across a graphical interface along the inheritance relations.

There is another hierarchy that IDEs can show to help us with development: method call hierarchy. After analyzing the code, the IDE can show us the graph displaying the relations between the methods: which method calls which other methods. Sometimes, this call graph is also important in showing the dependencies of methods on each other.

主站蜘蛛池模板: 自治县| 东阿县| 益阳市| 米脂县| 恩施市| 杭锦后旗| 岢岚县| 石渠县| 洛宁县| 忻州市| 揭西县| 图们市| 合水县| 咸宁市| 丰台区| 长治市| 安康市| 青阳县| 达拉特旗| 平利县| 乌兰察布市| 灵丘县| 乌拉特中旗| 贵阳市| 唐山市| 邮箱| 阜阳市| 舞钢市| 咸丰县| 江永县| 宝山区| 陆丰市| 屏东县| 蒙城县| 仲巴县| 阿拉尔市| 大冶市| 成安县| 光泽县| 赣州市| 韶山市|