Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
07316e42
Commit
07316e42
authored
Jan 22, 2021
by
Fabio Pitino
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Define guidelines for naming namespaces
parent
e09c35bb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
58 additions
and
0 deletions
+58
-0
doc/development/directory_structure.md
doc/development/directory_structure.md
+58
-0
No files found.
doc/development/directory_structure.md
View file @
07316e42
...
...
@@ -34,3 +34,61 @@ module MyDomain
end
end
```
### About namespace naming
A good guideline for naming a top-level namespace (bounded context) is to use the related
feature category. For example,
`Continuous Integration`
feature category maps to
`Ci::`
namespace.
Alternatively a new class could be added to
`Projects::`
or
`Groups::`
if it's either:
-
Strictly related to one of these domains. For example
`Projects::Alias`
.
-
A new component that does not have yet a more specific domain. In this case, when
a more explicit domain does emerge we would need to move the class to a more specific
namespace.
Do not use the
[
stage or group name
](
https://about.gitlab.com/handbook/product/categories/#devops-stages
)
since a feature category could be reassigned to a different group in the future.
```
ruby
# bad
module
Create
class
Commit
end
end
# good
module
Repositories
class
Commit
end
end
```
On the other hand, a feature category may sometimes be too granular. Features tend to be
treated differently according to Product and Marketing, while they may share a lot of
domain models and behavior under the hood. In this case, having too many bounded contexts
could make them shallow and more coupled with other contexts.
Bounded contexts (or top-level namespaces) can be seen as macro-components in the overall app.
Good bounded contexts should be
[
deep
](
https://medium.com/@nakabonne/depth-of-module-f62dac3c2fdb
)
so consider having nested namespaces to further break down complex parts of the domain.
E.g.
`Ci::Config::`
.
For example, instead of having separate and granular bounded contexts like:
`ContainerScanning::`
,
`ContainerHostSecurity::`
,
`ContainerNetworkSecurity::`
, we could have:
```
ruby
module
ContainerSecurity
module
HostSecurity
end
module
NetworkSecurity
end
module
Scanning
end
end
```
If classes that are defined into a namespace have a lot in common with classes in other namespaces,
chances are that these two namespaces are part of the same bounded context.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment