DEV Community

Discussion on: 7 Deadly Sins of Angular

Collapse
 
swisscoder profile image
Steve

Thanks a lot for this interesting article, hope I don't come across unfriendly or rude :D

While I agree that it's not ideal to simply group stuff by type. I find this example structure is flawed.

  • Every Component hat its own Module? why?
  • Since one paragraph earlier lazy loading is mentioned. you have split logic into modules in 2 different ways: --app -- --admin -- -- --companies -- -- --users -- --common

In one case you have the common module, which is probably used by admin/companies/users but is outside in a different folder.
And then there are the companies and users module which are contained inside the admin modules structure but both depend on the admin module.

If you would apply the same logic in both cases you would either get:
--app
-- --common
-- -- --admin
-- -- -- --companies
-- -- -- --users
or:
--app
-- --admin
-- --companies
-- --users
-- --common

I personally think, you should heed your own sound advice:
"2. For components/pipes/directives/services used by different modules create a Shared Module"
There is no reason to have only 1 shared module that's named "shared" or "common", simply create a module, whenever you reuse logic/components/services in several (other) modules. so this module structure would be fine:
--app
-- --admin
-- --companies
-- --users
-- --common
and no, not use that Variation of yours.
"For example, if we have an AdminModule, which contains UserModule and AccountModule"
=> modules containing modules is not the correct understanding of modules I think.
Modules contain components and modules reference other modules, but modules shouldn't contain modules.

the following structure would be fine if companies and users would be components only, but not if they are modules on their own:
--admin
-- --companies
-- --users