UNPKG

2.67 kBMarkdownView Raw
1### Beans
2
3Beans are a fancy name for **plugin**.
4
5### Organization
6
7This is still very much a work in progress, but personally, I try to stick to a few conventions which help organize my "beans". Here are some general rules I follow:
8
9- All beans are placed in a single directory. The directory name depends on what the application does.
10 - If the app serves one platform, then place the beans in `app/beans`;
11 - If the app serves multiple platforms, then place the beans in:
12 - `app/node/beans` for node.js specific beans.
13 - `app/web/beans` for web-specific beans.
14 - `app/shared/beans` for beans usable across all platforms.
15
16- Bean names should reflect any RESTful API used in the bean.
17- Beans in NPM have `bean` prepended to the name e.g: `bean.database.mongo`.
18
19
20
21### Naming Conventions
22
23
24Start off with the category of the bean first, and then the subject. A few examples:
25
26- database.mongo
27- database.redis
28- database.mysql
29
30Using `database` as the category tells that all beans share the same API. I can easily add / remove any `database` bean I want without breaking the application.
31
32
33If you have a plugin that uses many plugins, then try this naming convention:
34
35- `category`.core
36
37And for beans that make up `category.core`:
38
39- `category`.part.`subject`
40
41For example:
42
43
44- stream.core
45- stream.part.facebook
46- stream.part.twitter
47- stream.part.google
48
49
50Where all the **parts** make up `stream.core`. Remember that parts shouldn't do **anything**. They make-up core plugins. If you have a plugin that serves several plugins, split it up like so:
51
52- posting.part.facebook
53- friends.part.facebook
54
55You could also do something like:
56
57- stream.core
58- group.core
59- group.part.stream.core `part of stream.core`
60
61
62Try and follow a RESTful naming convention. For example:
63
64
65- stream.core
66- stream.part.subscription.core `listening for streamed content, and sending off to registered subscribers`
67- stream.part.subscription.email `subscription listening to stream, and sending a newsletter`
68- stream.part.subscription.facebook `subscription listening to a stream, and posting out to facebook`
69
70Note that `part` was dropped after `subscription`. I find it reduntant to use it after the first instance. We already know that `stream.part.subscription.core` is nothing without `stream.core`, so anything *after* that is also useless without the root plugin.
71
72
73
74
75
76