MVC ARCHITECTURE AND PROCESSES IN ELIXIR

M

The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each of these components are built to handle specific development aspects of an application.

Model:

  • Representation of domain data
  • Business Logic
  • Persistence Mechanism

Controller:

  • Intermediary between model and view
  • It maps user actions(Model actions)
  • Select the view and provide information to itself

View

  • User Interface
  • Interaction elements

Importance of MVC

  • Organization
  • Reusing code
  • The views and application behavior should reflect the manipulation of the data immediately
  • It allows different user interface standards or port it to other environments where the application code should not be affected

Control Flow of the MVC

  • The user performs an action on the interface
  • The controller takes the input event
  • The controller notifies the user action to the model which may involve a change of state of the model
  • It generates a new view, the view takes the data model
  • The user interface waits for another user interaction, which starts a new cycle.

Processes

Understanding the difference between Synchronous and Asynchronous

In most high-level programming languages, your program starts from top to bottom. it starts by executing the first line of source code and each line of code executed sequentially thereafter.

In synchronous processes/programs, your program is executed line by line one at a time, each time a function is called, the entire program waits until that function returns before moving on to the next line of code.

While in

Asynchronous processes/programs, the entire process does not pause or wait for the return of a function executed before it. In asynchronous, you are essentially saying “I know this function call is going to take a great deal of time, but my program doesn’t want to wait around while it executes”

Concurrency in elixir and erlang is based upon the actor model. Actors are single threaded processes which can send and receive messages amongst themselves. Their memory is completely isolated, which makes having to worry about “shared state” a non-issue.

Putting it simple, a process in Elixir is the actor. It can communicate with another actor by sending a message to a specific PID (Process ID). The recipient can receive a message by checking a message by checking its mailbox for new messages.

 

 

About the author

Ayo Ajanaku

Add comment

By Ayo Ajanaku

Recent Posts

Categories

Get in touch

We are here, Just reach out

08052549414, 08113215559
[email protected]