You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+28-12Lines changed: 28 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -335,6 +335,8 @@ Many of my styles have been from the many pair programming sessions [Ward Bell](
335
335
}
336
336
```
337
337
338
+

339
+
338
340
- Note: If the function is a 1 liner it consider keeping it right up top, as long as readability is not affected.
339
341
340
342
```javascript
@@ -558,6 +560,8 @@ Many of my styles have been from the many pair programming sessions [Ward Bell](
558
560
559
561
- This way bindings are mirrored across the host object, primitive values cannot update alone using the revealing module pattern
560
562
563
+

564
+
561
565
**[Back to top](#table-of-contents)**
562
566
563
567
## Directives
@@ -804,7 +808,6 @@ Many of my styles have been from the many pair programming sessions [Ward Bell](
804
808
angular.module('app').controller('Dashboard', d);functiond(a, b) { }
805
809
```
806
810
807
-
808
811
- **Manually Identify Dependencies**: Use $inject to manually identify your dependencies for AngularJS components.
809
812
810
813
*Why?*: This technique mirrors the technique used by [`ng-annotate`](https://github.com/olov/ng-annotate), which I recommend for automating the creation of minification safe dependencies. If `ng-annotate` detects injection has already been made, it will not duplicate it.
@@ -1024,7 +1027,6 @@ Many of my styles have been from the many pair programming sessions [Ward Bell](
1024
1027
* the file name
1025
1028
* the registered asset name with Angular
1026
1029
1027
-
1028
1030
*Why?*: Naming conventions help provide a consistent way to find content at a glance. Consistency within the project is vital. Consistency with a team is important. Consistency across a company provides tremendous efficiency.
1029
1031
1030
1032
*Why?*: The naming conventions should simply help the findability and communication of code.
@@ -1230,7 +1232,6 @@ Many of my styles have been from the many pair programming sessions [Ward Bell](
1230
1232
1231
1233
*Why?*: Being DRY is important, but not crucial if it sacrifices the others in LIFT, which is why I call it T-DRY. I don’t want to type session-view.html for a view because, well, it’s obviously a view. If it is not obvious or by convention, then I name it.
1232
1234
1233
-
1234
1235
**[Back to top](#table-of-contents)**
1235
1236
1236
1237
## Application Structure
@@ -1291,6 +1292,8 @@ Many of my styles have been from the many pair programming sessions [Ward Bell](
- Note: Structuring using folders-by-type is another common option. It requires moving to multiple folders when working on a feature. This could get unwieldy quickly as the app grows to 5, 10 or 25+ views and controllers (and other features), which makes it more difficult than folder-by-feature to locate files.
1295
1298
1296
1299
```javascript
@@ -1337,28 +1340,41 @@ Many of my styles have been from the many pair programming sessions [Ward Bell](
1337
1340
1338
1341
- **Many Small, Self Contained Modules**: Create small modules that enapsulate one responsibility.
1339
1342
1340
-
*Why?*: Modular applications make it easy to plug and go as they allow the development teams to build vertical slices of the applications and roll out incrementally. This means we can plug in new features as we develop them.
1343
+
- *Why?*: Modular applications make it easy to plug and go as they allow the development teams to build vertical slices of the applications and roll out incrementally. This means we can plug in new features as we develop them.
1341
1344
1342
-
- **Create an App Module**: Create a application root module whose role is pull together all of the modules and features of your application. Name this for your application.
1345
+
- **Create an App Module**: Create an application root module whose role is pull together all of the modules and features of your application. Name this for your application.
1343
1346
1344
-
*Why?*: AngularJS encourages modularity and separation patterns. Creating an application root module whose role is to tie your other modules together provides a very straightforward way to add or remove modules from your application.
1347
+
- *Why?*: AngularJS encourages modularity and separation patterns. Creating an application root module whose role is to tie your other modules together provides a very straightforward way to add or remove modules from your application.
1345
1348
1346
1349
- **Keep the App Module Thin**: Only put logic for pulling together the app in the application module. Leave features in their own modules.
1347
1350
1348
-
*Why?*: Adding additional roles to the application root to get remote data, display views, or other logic not related to pulling the app together muddies the app module and make both sets of features harder to reuse or turn off.
1351
+
- *Why?*: Adding additional roles to the application root to get remote data, display views, or other logic not related to pulling the app together muddies the app module and make both sets of features harder to reuse or turn off.
1349
1352
1350
-
- **Feature Areas are Modules**: Create modules that represent feature areas, such as layout, resuable and shared services, dashboards, and app specific features (e.g. customers, admin, sales).
1353
+
- **Feature Areas are Modules**: Create modules that represent feature areas, such as layout, reusable and shared services, dashboards, and app specific features (e.g. customers, admin, sales).
1351
1354
1352
-
*Why?*: Self contained modules can be added to the application will little no no friction.
1355
+
- *Why?*: Self contained modules can be added to the application will little or no friction.
1353
1356
1354
-
*Why?*: Sprints or iterations can focus on feature areas and turn them on at the end of the sprint or iteration.
1357
+
- *Why?*: Sprints or iterations can focus on feature areas and turn them on at the end of the sprint or iteration.
1355
1358
1356
-
*Why?*: Separating feature areas into modules makes it easier to test the modules in isolation and reuse code.
1359
+
- *Why?*: Separating feature areas into modules makes it easier to test the modules in isolation and reuse code.
1357
1360
1358
1361
- **Reusable Blocks are Modules**: Create modules that represent reusable application blocks for common services such as exception handling, logging, diagnostics, security, and local data stashing.
1359
1362
1360
-
*Why?*: These types of features are needed in many applications, so by keeping them separated in their own modules they can be application generic and be reused across applications.
1363
+
- *Why?*: These types of features are needed in many applications, so by keeping them separated in their own modules they can be application generic and be reused across applications.
1364
+
1365
+
- **Module Dependencies**: The application root module depends on the app specific feature modules, the feature modules have no direct dependencies, the cross-application modules depend on all generic modules.
1366
+
1367
+

1368
+
1369
+
- *Why?*: The main app module contains a quickly identifiable manifest of the application's features.
1370
+
1371
+
- *Why?*: Cross application features become easier to share. The features generally all rely on the same cross application modules, which are consolidated in a single module (`app.core` in the image).
1372
+
1373
+
- *Why?*: Intra-App features such as shared data services become easy to locate and share from within `app.core` (choose your favorite name for this module).
1374
+
1375
+
- Note: This is a strategy for consistency. There are many good options here. Choose one that is consistent, follows AngularJS's dependency rules, and is easy to maintain and scale.
1361
1376
1377
+
>> My structures vary slightly between projects but they all follow these guidelines for structure and modularity. The implementation may vary depending on the features and the team. In other words, don't get hung up on an exact like-for-like structure but do justify your structure using consistency, maintainability, and efficiency in mind.
0 commit comments