Skip to content

Commit 914f79e

Browse files
committed
added images for above the fold. and some typo corrections
1 parent 193953d commit 914f79e

File tree

1 file changed

+28
-12
lines changed

1 file changed

+28
-12
lines changed

README.md

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,8 @@ Many of my styles have been from the many pair programming sessions [Ward Bell](
335335
}
336336
```
337337
338+
![Controller Using "Above the Fold"](https://raw.githubusercontent.com/johnpapa/angularjs-styleguide/master/assets/above-the-fold-1.png)
339+
338340
- Note: If the function is a 1 liner it consider keeping it right up top, as long as readability is not affected.
339341
340342
```javascript
@@ -558,6 +560,8 @@ Many of my styles have been from the many pair programming sessions [Ward Bell](
558560
559561
- This way bindings are mirrored across the host object, primitive values cannot update alone using the revealing module pattern
560562
563+
![Factories Using "Above the Fold"](https://raw.githubusercontent.com/johnpapa/angularjs-styleguide/master/assets/above-the-fold-2.png)
564+
561565
**[Back to top](#table-of-contents)**
562566
563567
## Directives
@@ -804,7 +808,6 @@ Many of my styles have been from the many pair programming sessions [Ward Bell](
804808
angular.module('app').controller('Dashboard', d);function d(a, b) { }
805809
```
806810
807-
808811
- **Manually Identify Dependencies**: Use $inject to manually identify your dependencies for AngularJS components.
809812
810813
*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](
10241027
* the file name
10251028
* the registered asset name with Angular
10261029
1027-
10281030
*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.
10291031
10301032
*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](
12301232
12311233
*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.
12321234
1233-
12341235
**[Back to top](#table-of-contents)**
12351236
12361237
## Application Structure
@@ -1291,6 +1292,8 @@ Many of my styles have been from the many pair programming sessions [Ward Bell](
12911292
session-detail.controller.js
12921293
```
12931294
1295+
![Sample App Structure](https://raw.githubusercontent.com/johnpapa/angularjs-styleguide/master/assets/modularity-2.png)
1296+
12941297
- 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.
12951298
12961299
```javascript
@@ -1337,28 +1340,41 @@ Many of my styles have been from the many pair programming sessions [Ward Bell](
13371340
13381341
- **Many Small, Self Contained Modules**: Create small modules that enapsulate one responsibility.
13391342
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.
13411344
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.
13431346
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.
13451348
13461349
- **Keep the App Module Thin**: Only put logic for pulling together the app in the application module. Leave features in their own modules.
13471350
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.
13491352
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).
13511354
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.
13531356
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.
13551358
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.
13571360
13581361
- **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.
13591362
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+
![Modularity and Dependencies](https://raw.githubusercontent.com/johnpapa/angularjs-styleguide/master/assets/modularity-1.png)
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.
13611376
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.
13621378
13631379
**[Back to top](#table-of-contents)**
13641380

0 commit comments

Comments
 (0)