Skip to content

Commit

Permalink
feat(pattern): module pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
dribble-njr committed Sep 19, 2024
1 parent 1aecf0b commit 6268b16
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/.vuepress/sidebar/reading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ export default [
'03-flyweight-pattern',
'04-mediator-pattern',
'05-middleware-pattern',
'06-mixin-pattern'
'06-mixin-pattern',
'07-module-pattern'
]
}
]
Expand Down
1 change: 1 addition & 0 deletions docs/frontend/engineering/basic/001-modularization.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: 模块化
date: 2022-08-10
icon: box
category:
- 工程化
tag:
Expand Down
18 changes: 18 additions & 0 deletions docs/reading/patterns/vanilla/07-module-pattern.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
title: 模块模式
date: 2024-09-19
icon: box
author: patterns
category:
- reading
tag:
- design pattern
- vanilla
- module-pattern
---

随着应用程序和代码库的增长,保持代码的可维护性和分离性变得越来越重要。模块模式可以将代码分割成更小的、可重复使用的片段。

除了可以将代码分割成更小的、可重复使用的片段外,模块还可以将文件中的某些值保持私有。默认情况下,模块中的声明会被作用域(封装)到该模块。如果我们没有明确导出某个值,那么该值在该模块之外就不可用。这就降低了代码库其他部分声明的值发生名称冲突的风险,因为这些值在全局范围内不可用。

更详细的内容可以见 [模块化](../../../frontend/engineering/basic/001-modularization.md)

0 comments on commit 6268b16

Please sign in to comment.