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-ja-jp.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,9 +15,9 @@ _このドキュメントは[AngularJS in Patterns](https://github.com/mgechev/a
15
15
*[ディレクティブ](#ディレクティブ)
16
16
*[フィルタ](#フィルタ)
17
17
*[サービス](#サービス)
18
-
*[AngularJS Patterns](#angularjs-patterns)
19
-
*[Services](#services-1)
20
-
*[Singleton](#singleton)
18
+
*[AngularJSのパターン](#angularjs-patterns)
19
+
*[サービス](#services-1)
20
+
*[シングルトン](#singleton)
21
21
*[Factory Method](#factory-method)
22
22
*[Decorator](#decorator)
23
23
*[Facade](#facade)
@@ -249,32 +249,32 @@ function MyCtrl(developer) {
249
249
}
250
250
```
251
251
252
-
## AngularJS Patterns
252
+
## AngularJSのパターン
253
253
254
-
In the next a couple of sections, we are going to take a look how the traditional design and architectural patterns are composed in the AngularJS components.
In the last chapter we are going to take a look at some architectural patterns, which are frequently used in the development of Single-Page Applications with (but not limited to) AngularJS.
>The singleton pattern is a design pattern that restricts the instantiation of a class to one object. This is useful when exactly one object is needed to coordinate actions across the system. The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects.
-Takes its name and makes a lookup at a hash map, which is defined into a lexical closure (so it has a private visibility).
271
-
-If the dependency exists AngularJS pass it as parameter to the component, which requires it.
272
-
-If the dependency does not exists:
273
-
-AngularJS instantiate it by calling the factory method of its provider (i.e. `$get`). Note that instantiating the dependency may require recursive call to the same algorithm, for resolving all the dependencies required by the given dependency. This process may lead to circular dependency.
274
-
-AngularJS caches it inside the hash map mentioned above.
275
-
-AngularJS passes it as parameter to the component, which requires it.
We can take better look at the AngularJS' source code, which implements the method `getService`:
277
+
`getService` メソッドが実装されている部分のソースコードを見たほうが良いでしょう。
278
278
279
279
```JavaScript
280
280
functiongetService(serviceName) {
@@ -300,14 +300,14 @@ function getService(serviceName) {
300
300
}
301
301
```
302
302
303
-
We can think of each service as a singleton, because each service is instantiated no more than a single time. We can consider the cache as a singleton manager. There is a slight variation from the UML diagram illustrated above because instead of keeping static, private reference to the singleton inside its constructor function, we keep the reference inside the singleton manager (stated in the snippet above as `cache`).
This way the services are actually singletons but not implemented through the Singleton pattern, which provides a few advantages over the standard implementation:
For further discussion on this topic Misko Hevery's [article](http://googletesting.blogspot.com/2008/05/tott-using-dependancy-injection-to.html)in the Google Testing blog could be considered.
0 commit comments