Skip to content

Commit 6c480ea

Browse files
committed
Improvements in Singleton
1 parent d7a4c7f commit 6c480ea

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,14 @@
3131

3232
## Abstract
3333

34-
One of the best ways to learn something new is to see how the things you already know fits in it.
35-
The goal of this paper is to show the patterns used in the AngularJS framework and any application build with this framework.
34+
One of the best ways to learn something new is to see how the things you already know are used in it.
35+
This paper describes how different software design and architectural patterns are applied in AngularJS or any AngularJS single-page application.
3636

3737
## Introduction
3838

39-
The document begins with brief overview of the AngularJS framework. The overview explains the main AngularJS components - directives, filters, controllers, services, scope. Next sections describe the different design patterns used in the framework and how you can take advantage of concepts we are already familiar with.
39+
The document begins with brief overview of the AngularJS framework. The overview explains the main AngularJS components - directives, filters, controllers, services, scope. The second section lists and describes different design and architectural patterns, which are implemented inside the framework.
40+
41+
The last section contains a few architectural patterns, which are commonly used inside most of the single-page applications build with AngularJS.
4042

4143
## AngularJS overview
4244

@@ -248,7 +250,7 @@ When given dependency is required by any component, AngularJS resolves it using
248250
- Takes its name and makes a lookup at a hash map, which is defined into a lexical closure (so it has a private visibility).
249251
- If the dependency exists AngularJS pass it as parameter to the component, which requires it.
250252
- If the dependency does not exists:
251-
- 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.
253+
- 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 all dependencies required by the dependency. This process may lead to circular dependency.
252254
- AngularJS caches it inside a hash map.
253255
- AngularJS passes it as parameter to the component, which requires it.
254256

@@ -278,7 +280,7 @@ function getService(serviceName) {
278280
}
279281
```
280282

281-
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 itself, we keep the reference inside the singleton manager (called `cache`).
283+
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`).
282284

283285
### Factory Method
284286

0 commit comments

Comments
 (0)