[Erlang crisis] (2.1) project structure, erlang2.1

Source: Internet
Author: User

[Erlang crisis] (2.1) project structure, erlang2.1

Original article, reprinted with the source: Server non-amateur researchSunface by http://blog.csdn.net/erlib



Project Structure

The structures of OTP applications and of OTP releases are different. an OTP application can be expected to have one top-level supervisor (if any) and possibly a bunch of dependencies that sit below it. an OTP release will usually be composed of multiple OTP applications, which may or may not depend on each other. this will lead to two major ways to lay out applications.

The   OTP applications and OTP release project structures are different. An OTP application can be seen as a top-level monitoring tree (if any ), and there may be a lot of dependencies (a bunch of dependencies) below ). an OTP release is usually a combination of multiple OTP applications. These applications may have dependencies or none. This forms two main ways to deploy applicaitons.



OTP Applications

For OTP applications, the proper structure is pretty much the same as what was explained in 1.2:

For OTP applicaitons, the appropriate structure is basically the same as described in 1.2:
----------------------------------------------------------------------------------

1doc/
2deps/
3ebin/
4src/
5test/
6LICENSE.txt
7README.md
8rebar.config

----------------------------------------------------------------------------------
What's new in this one isDeps/Directory, which is fairly useful to have, but that will be generated automatically by rebar 2 if necessary.
That's because there is no canonical package management in Erlang. People instead adopted rebar, which fetches dependencies locally, on a per-project basis.

Folder added by ghost:Deps/A very useful folder. If necessary, this folder can be automatically generated through rebar.
This is because there is no standard package management in Erlang ). The current practice is to use rebar to obtain dependencies for each project locally.

This is fine and removes a truckload of conflicts, but means that each project you have may have to download its own set of dependencies.
This is accomplished with rebar by adding a few config lines to rebar. config:

This can solve a lot of conflicts, but it also means that you have to download your own dependent projects to create a project.
The following describes how to configure a rebar by adding some configuration items in rebar. config:
----------------------------------------------------------------------------------
1{deps,
2[{application_name, "1.0.*",
3{git, "git://github.com/user/myapp.git", {branch,"master"}}},
4{application_name, "2.0.1",
5{git, "git://github.com/user/hisapp.git", {tag,"2.0.1"}}},
6{application_name, "",
7{git, "https://bitbucket.org/user/herapp.git", "7cd0aef4cd65"}},
8{application_name, "my regex",
9{hg, "https://bitbucket.org/user/theirapp.hg" {branch, "stable"}}}]}.
----------------------------------------------------------------------------------

Feel free to install rebar globally on your system, or keep a local copy if you require a specific version to build your system. applications are fetched directly from a git (or hg, or svn) source, recursively. they can then be compiled, and specific compile options can be added with the {erl_opts, List }. option in the config file 3.
Within these directories, you can do your regular development of an OTP application.

Applications recursively obtain the source code from git (or hg, or svn. they can be compiled and compiled using specific options {erl_opts, List. this option is also defined in the config file 3.
You can develop functions for your OTP application in these folders.

To compile them, call rebar get-deps compile, which will download all dependencies, and then build them and your app at once.
When making your application public to the world, distribute it without the dependencies. it's quite possible that other developers 'applications depend on the same applications yours do, and it's no use shipping them all multiple times.

To compile dependencies, you can use rebar get-deps to download and compile dependencies and build dependencies and your own apps immediately.
When you open source your application, you must remove its dependencies. Because the application of other developers is likely to depend on the same application as you, there is no need to reload them multiple times.

The build system in place (in this case, rebar) shocould be able to figure out duplicated entries and fetch everything necessary only once.

Rebar should be able to identify repeated dependencies and the repeated items will be loaded only once.

[2] A lot of people package rebar directly in their application. This was initially done to help people who had never used rebar before use libraries and projects in a boostrapped manner.
[3] More details by calling rebar help compile.

[NOTE 2]: Many people integrate rebar into their own applicaiton. This was initially designed to help people who never use rebar quickly master this tool. You can freely Install rebar in the system, you can also save a specific version locally to build your system.
[NOTE 3]: You can enter rebar help to view more help information.



OTP Releases

For releases, the structure shocould be a bit different 4. Releases are collections of applications, and their structures shocould reflect that.

For Releases, the structure of the release changes a little. Releases is a collection of applicaitons, and their structure should also reflect these.

Instead of having a top-level app, applications shoshould be nested one level deeper and divided into two categories: apps and deps. the apps directory contains your applications 'source code (say, internal business code), and the deps directory contains independently managed dependency applications.

Embedded applications should be nested and divided into apps and deps, instead of top-down app structures. The apps folder contains your own applicaitons source files (internal business code ), the deps folder includes independent application management.
---------------------------------------------------------------------------------
1apps/
2doc/
3deps/
4LICENSE.txt
5README.md
6rebar.config
---------------------------------------------------------------------------------

This structure lends itself to generating releases. Tools such as ool and Reltool have been covered before 5, and can allow the user plenty of power. An easier tool that recently appeared is relx 6.
A relx configuration file for the directory structure above wowould look like:

The release structure helps to automatically generate releases. Tools such as Systool and Reltool were previously supported and used very well. Relatively easy to use, there is also a simple work recently launched: relx6.
The configuration file format of   relx is as follows:
----------------------------------------------------------------------------------
1{paths, ["apps", "deps"]}.
2{include_erts, false}. % will use currently installed Erlang
3{default_release, demo, "1.0.0"}.
4
5{release, {demo, "1.0.0"},
6[members,
7feedstore,
8...
9recon]}.
----------------------------------------------------------------------------------

Calling./Relx(If the executable is in the current directory) will build a release, to be found in the _ rel/directory.

You can call./Relx(Called in the current folder) to create a release, you can find this release in the _ rel/folder.

If you really like using rebar, you can build a release as part of the project's compilation by using a rebar hook in rebar. config:

If you prefer to use rebar to create a release, you may use the rebar hook in rebar. config to create a release as part of project compilation.
----------------------------------------------------------------------------------
1{post_hooks,[{compile, "./relx"}]}.
----------------------------------------------------------------------------------

And every time rebar compile will be called, the release will be generated.

Each time you run rebar compile, a new release is created.

[4] I say shocould because assumerlang developers put their final system under a single top-level application (in src) and a bunch of follower ones as dependencies (in deps ), which is less than ideal for distribution purposes and conflicts with assumptions on directory structures made by OTP.
People who do that tend to build from source on the production servers and run custom commands to boot their applications.
[5] http://learnyousomeerlang.com/release-is-the-word
[6] https://github.com/erlware/relx/wiki

[NOTE 4]: I should say it is because a large number of Erlang developers put the final system in src to form a single application (a single top-level application ), instead of using dependencies in deps, this does not perfectly resolve conflicts caused by the OTP file structure. developers do this because they want to build products from the source code and use custom commands to drive their applications.
[Note 5]: http://learnyousomeerlang.com/release-is-the-word
[NOTE 6]: https://github.com/erlware/relx/wiki.pdf.





Project Structure decomposition ??

1. Concept of WBS Decomposition
WBS (Work Breakdown Structure) is used to effectively plan and control construction projects. It is composed of a group of deliverables of project products/facilities. It is displayed as a hierarchical tree structure that defines the scope of work of the entire project. Based on the needs of project management, different levels of decomposition can be implemented to plan and manage the time, cost, and quality of project products/facilities. With the deepening of the decomposition layer, the more detailed the products/facilities of the defined project are, the more specific the project is. The bottom layer of the WBS decomposition structure is a product/facility that cannot be further subdivided, also known as a work package, it forms a cost information database. If it needs to be further decomposed, its decomposition principle will be changed to the activity sequence or construction process for completing the work package.
2. Main decomposition principles of WBS
During WBS decomposition, the project products/facilities obtained by the decomposition should be:
1) definable-it can describe its work content or objectives and is easily understood by all participants of the project;
2) manageable: A person can be assigned a member, department, or organization to clarify the responsibilities of the person, department, or organization;
3) evaluable-you can estimate the time required, resources, and fees;
4) Measurable-plans the start time and end time and milestones;
5) Independent-the product/facility of each project has the least interface or dependency, providing a clear working interface;
6) Professional: meets the classification requirements of professional qualifications;
7) Complete: the sum of the products/facilities of all projects at the next level of each level constitutes the scope of work of its project products/facilities, all project products/facilities constitute the scope of work of a complete project;
8) applicable-when the scope of work of the Project changes, the corresponding project products/facilities can be flexibly and conveniently increased/reduced.
In addition, if repeated occurrence frequency is high, it should be listed separately if the above conditions are met.

Example: Three-Level decomposition of the Whole Process Management of Housing and Construction Projects

1. project planning and decision-making
1.1 Project Planning
1.1.1 Regional Development Plan
1.1.2 Department (industry) Development Plan
1.1.3 Planning Evaluation
1.2 select a project
1.2.1 Project Investment Opportunity Research
1.2.2 project proposal
1.2.3 Auxiliary research (Special Study)
1.3 project decision-making
1.3.1 Feasibility Study
1.3.2 project evaluation and decision-making
2. project preparation stage
2.1 Engineering Design
2.1.1 solution design
2.1.2 Preliminary Design
2.1.3 Technical Design
2.1.4 construction drawing design
2.2 Project Bidding
2.2.1 design (Scheme) bidding or competition
2.2.2 supervision bidding
2.2.3 construction bidding
2.2.4 tendering for main materials and equipment
3. Project implementation stage
3.1 project implementation
3.1.1 construction preparation
3.1.2 Construction
3.1.3 Supervision
3.1.4 procurement of main materials and equipment
4. stage of project completion acceptance and summary evaluation
4.1 project acceptance and handover
4.1.1 completion acceptance
4.1.2 operation and training
4.1.3 Quality Warranty

The project structure of the school should be divided into four layers.

At half past one, it will be difficult to give you an accurate answer. Generally, the layer-3 structure is detailed enough. The layer-4 structure is certainly better,
Here is just an example of a simple outline. It only takes more time to investigate and design the decomposition structure for the "school" project, or ask a professional with relevant work experience. I am a little embarrassed...
Example:

Project Breakdown Structure of xxx project
1. Project Phase
1.1 project deliverable 1
1.1.1 Work Package
1.1.2 Work Package B
1.1.3 Work Package c
...
1.2 project deliverable 2
1.2.1 Work Package d
1.2.2 Work Package e
1.2.3 Work Package f
...
1.3 project deliverable 3
1.3.1 Work Package g
1.3.2 Work Package h
1.3.3 Work Package I
...
2. Project Phase B
2.1 Project deliverables 4
2.1.1 Work Package j
2.1.2 Work Package k
2.1.3 Work Package l
...
2.2 Project deliverables 5
2.2.1 Work Package m
2.2.2 Work Package n
2.2.3 work package o
...
2.3 project deliverables 6
2.3.1 Work Package p
2.3.2 Work Package q
2.3.3 Work Package r
...
3. Project Phase C
3.1 project deliverables 7
3.1.1 Work Package s
3.1.2 Work Package t
3.1.3 Work Package u
...
3.2 project deliverables 8
3.2.1 Work Package v
3.2.2 Work Package w
3.2.3 work package x
...
3.3 project deliverables 9
3.3.1 Work Package y
3.3.2 Work Package z
3.3.3 Work Package $
...

And so on ....

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.