Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

ponchoprojects
umbrellaprojects
elixir
dependencies

What are poncho projects in Elixir?

Tehreem Arshad

What is Elixir?

Elixir is a dynamic, functional programming language. It is successful in making applications across a wide range of industries. The Elixir system is primarily focused on maintainable applications. This happens by using dependencies.

Dependencies types

Dependencies can be of two kinds:

  1. External dependencies: These are the dependencies that are not tied to only one project. These can be used while working on different projects, where tasks are dependent on each other.

  2. Internal dependencies: These are the dependencies that are tied to only one project. They cannot be used outside the project.

These dependencies play an important role in umbrella and poncho projects. Mix handles dependencies that support umbrella and poncho projects.

Note: Mix handles both dependencies. It lists down the dependencies and their current status. It also supports gits and path dependencies.

Poncho projects

A poncho project can be defined as a connection of already existing directory to new directories made inside, whereas the code will be outside the library and will have its own separate library directory. It further helps to reduce coupling.

Umbrella projects got replaced by poncho projects due to their remarkable flexibilities.

Note: Mix supports umbrella projects and it is common to run different applications together in a single repository.

How does the poncho project work?

It is popular to make nerves-based projects. Nerves-based projects require us to have control over the order of configuration applications. This demands a permanent solution to be in the databases, and here poncho projects help us the most.

Creating a new project

Let’s assume we have a mastery application, and we have to make a new poncho project there. It will have the following steps:

cd mastery

mix new mastery_persistence

We create a complete mix project with a full application.ex file that defines our supervision structure. Notice the application entry in /mastery_persistence/mix.exs:

def application do 
    [
      extra_applications: [:logger],
      mod: {MasteryPersistence.Application, []} 
    ]
  end
Application entry

Poncho projects hierarchy

  • We create a dependency from within mastery dependency.
  • The code will be outside the library and will have its own separate directory.
  • At a time of separation from the directory level, mixed dependencies can be changed and can be moved to different repositories.
Poncho project hierarchy

Why are poncho projects more convenient?

When it comes to configurations, poncho projects are more explicit. It has one set with all the config files. It is also easy to develop independently in poncho as compared to umbrella. It is more helpful in loosely coupled projects. Hence, it is advisable to use poncho for nerves-based projects.

RELATED TAGS

ponchoprojects
umbrellaprojects
elixir
dependencies

CONTRIBUTOR

Tehreem Arshad
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring