How to spread classes on папки and namespace in VS and package in Java?
That is, in other words, recommendations on the organization of the project structure.
What in general there are standard folders (Often met core, utils, support, additionals , etc ...)
And are there any standard rules / recommendations for splitting.
If not, then at least a general description of these folders / packages.

The question is for Java, and Java for android, and C #, if there are differences between them.

  • one
    for convenience if only) - iFr0z
  • one
    There are no standards, there is something to which different developers come in different ways, no one will teach you how to organize sources. - ixSci

2 answers 2

In C #, as a rule, the folder structure repeats the namespace classes that are contained in these folders. Solutions (.sln) usually contain the src folder with the code.

An example of a complex project can be found in the source code CoreFx . For smaller projects, usually only one solution is made.

    1. .NET
      VisualStudio by default offers the following option:
      • Solution consists of one or more projects.
      • The root namespase project is the same as the project name, this behavior can be changed in the project properties.
      • If the project has nested folders, then in the new class files the nested folders are added to the root namespase , with names that match the folder names.
      • There are no restrictions on the location and number of classes in the files, except for one - if the class contains the Main method, then this class must be first in the file so that it can be started, in any case, the studio insists on this, did not try to bypass this restriction I know.

    Standard project folders can be viewed by creating a project in the studio and examining the contents of the project folder, most of which are official and will not be displayed in Solution Explorer.

    Studio default behavior is just a suggested option, which is not necessary to follow. All at the discretion of the development team and code standards in the company.

    1. Java

      • From my rather superficial acquaintance with java, I managed to find out the following:
      • File and class name must match
      • One file - one class, with the exception of nested classes, of course (it is possible that it is not necessary, did not try)
      • Package (package) is actually a folder, i.e. folder structure and sets the package structure

    As for Java, I can be mistaken in some places, because I repeat, not too much worked with it, and not aware of the latest changes.

    In Java, as far as I understand, there are no standard folders as such, although you can do the same trick with VS in your IDE for Java.

    If you mean standard names for source folders, this is determined by the development team and / or company code standards.

    • Yes, I had in mind the recommendations on the name of folders / examples of standard folders and the division of classes according to them - Alexey Stepanov
    • one
      @ AlekseyStepanov, as already mentioned in the comments, there are no such recommendations, the only recommendation is that the folder structure should be understandable for all team members, therefore the team should determine these names. Well, or you yourself, if you work solo. - rdorn
    • one
      @AlekseyStepanov may be a little apart from ASP.NET and ASP.NET-MVC projects, but it is better to clarify this in the documentation or literature on these technologies and types of projects. - rdorn