supportDocs

Package and class organization is crucial in full stack development, it will save you time because you won’t be hunting around for a random class, and it will be an expectation once you hit the job market! Everyone kind of struggles with this in the beginning, but hopefully this helps you a little bit.

*Some of the stuff the mention in the videos, like “DAO” I try to cover below. *In the second video he talks about Maven and Spring, both of which you will learn about in full stack. He also talks about microservices

  1. Package Naming:

    • Packages are like folders that help organize related classes together.
    • Package names are written in lowercase and use dots to separate words.
    • The main package name often starts with your company’s website name in reverse order (com.coderscampus).
    • For example, if your company’s website is “example.com”, the main package could be “com.coderscampus”.
    • You can create subpackages to further organize classes based on what they do.
  2. Organizing Classes into Packages:

    • Controller Classes:

      • These classes handle user requests and manage the flow of data.
      • They are usually placed in a package named “controller” or “web”.
      • Examples: “UserController”, “ProductController”
    • Service Classes:

      • These classes contain the business logic and perform tasks related to the application’s functionality.
      • They are usually placed in a package named “service”.
      • Examples: “UserService”, “ProductService”
      • AKA do your work in these classes.
    • Repository or DAO Classes:

      • These classes interact with the database to store and retrieve data.
      • They are usually placed in a package named “repository” or “dao”.
      • Examples: “UserRepository”, “ProductDAO”
    • Model or Domain(POJO/DTO) Classes:

      • These classes represent the main objects or entities in your application.
      • They are usually placed in a package named “model” or “domain”.
      • Examples: “User”, “Product”, “Order”
    • Configuration Classes:

      • These classes handle the configuration and setup of your application.
      • They are usually placed in a package named “config” or “configuration”.
      • Examples: “DatabaseConfig”, “SecurityConfig”
    • Utility Classes:

      • These classes provide helpful functions that can be used throughout your application.
      • They are usually placed in a package named “util” or “helper”.
      • Examples: “DateUtils”, “StringHelper”
  3. Naming Classes:

    • Class names should start with an uppercase letter and use uppercase for the first letter of each word (PascalCase).
    • The class name should clearly describe what the class does or represents.
    • Common words can be added at the end of the class name to show what type of class it is, like “Controller”, “Service”, “Repository”, etc.

These conventions help keep your Java code organized and make it easier for other developers to understand and work with your code.

Remember, the main idea is to group related classes together in packages based on what they do and give them clear and meaningful names. This makes your code more organized and easier to maintain.