General file folders

We can keep the file structure of the template as it is; it is already providing a nicely organized hierarchy. The only folder you want to add is Workers on the same level as Controllers, so you should add it to Sources/App/. In this folder, we may put classes that act as Workers for us. In the Workers section, later on, you will learn in detail why we need such a folder.

Additionally, create another Helpers folder in Sources/App/. This folder is for extensions and functions that are not tied to our own classes but are either generic (global) or extended classes from other frameworks.

You can leave the remaining folders and files as they are. We will stick to a few guidelines, though, to keep things consistent:

  • Filenames should be capitalized.
  • There should be one class or struct per file.
  • The class, function, or struct name should be the filename.
  • Extension files use the + sign to label the original class. For example, the Application+ImageRequest.swift file would extend the Application class with functions related to image requests.

Go ahead and make any non-capitalized filenames capitalized (except for main.swift; the compiler requires this to be spelled in lowercase). Swift is not strict with the folders or filenames, but it will make it a lot easier to pick this project up later or have someone else work with it.

During active development, it is entirely human to break some of these rules. Just make sure that you clean them up before committing them to a repository.

Now that you have set up the folders, let's set up our dependencies.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.207.44