Why does UE4 use separate 'Classes', 'Private', 'Public' folders? Pros/cons?

Hey guys,

As the title suggests, I’m just curious about UE4’s source structure. Is there a particular reason as to why the files are split out like this, with headers and source files separate to each other (folder-wise). Additionally, what makes the classes in ‘Private’ actually private? Just trying to get a handle on the current structure and the reasons behind it.

Thanks.

2 Likes

Hi ,

Classes and Private are not special names, you can use any structure that you want. The only name that is actually still special is the Public folder, which is added as an include path if another module depends on your module. The Classes folder used to be special (the only place that UObjects could be declared) but that limitation is no longer in place, and the folder is effectively deprecated for any new samples or modules that we build.

You can structure your module however you want. For leaf modules like a game there is little benefit to a public/private split, but for library modules it helps to clearly mark the public and private portions of the module and indicate which parts are interface versus implementation.

Cheers,
Michael Noland

6 Likes

I’m a little confused…Is the Classes folder really deprecated?
Current documentation says: Classes folder : For UCLASS, USTRUCT etc. so for types that are reflected.
Public folder: Says… “Most Plugin Modules will not export public APIs in header files via the Public source folder”
[INDENT=2]So, from current documentation it sounds as if public is deprecated. There are a number of further caveats as to what is useful to put in public folder.[/INDENT]
The documentation is from here: Plugins in Unreal Engine | Unreal Engine 5.2 Documentation in the “Code in Plugins” section. At time of writing the documentation was for ue4.19

1 Like

It’s really deprecated. I’m guessing the documentation hasn’t kept up.

2 Likes