7.7

Code style

To follow the proper coding style for this class, you should have Eclipse insert spaces for indentation instead of tabs. This ensures that the code looks the same in every editor, regardless of the tab width settings. To do so, follow these instructions:

Style of code is important for its readability and uniformity. Most companies impose a code style that makes all the code created by numerous developers have the same formatting. In this course we will use a styling convention from Google and employ IntelliJ to enforce this style on our code. All the assignments in this course will have a part of their grade determined by style, so it is important that you enforce this style for all source code!

  1. Download the style file intellij-java-google-style.xml.

  2. Follow the tutorial video for IntelliJ from 20:43 to 28:12. A summary:
    • For Intellij IDEA, download intellij-java-google-style.xml and save it in the config/codestyles/ subdirectory of your IntelliJ configuration folder.

    • Restart IntelliJ.

    • From IntelliJ, go to File > Other Settings > Default Settings..., then in the dialog that pops up, go to Editor / Code Style, and select it in the Scheme dropdown, where it should have appeared as an option. If you’ve already created a project, then you’ll additionally need to set this as the project style, using File > Settings.