<commit_before>---
layout: default
title: How pattern is implemented?
current_menu: mvcImplement
---

# How pattern is implemented?

In Linna Framework every Mvc component is implemented as isolated, interaction between components happens through
[Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection) or 
through [Observer Pattern](https://en.wikipedia.org/wiki/Observer_pattern).

## Why

Because every piece of Mvc pattern should do only one thing. Model manipulate data, View render it and Controller filter user input.

## Component interaction

Model is passed to View and Controller by class constructor (constructor injection).<br />
Model and View works as Observer Pattern.<br />
Controllers and Views are at same level, a Controller doesn't call a View and does not pass to it, data for render.<br />
Controller works only when is needed filter user input and manipulate data through Model<br />
View ask Model for obtain data for rendering.

This implementation require declare for all routes which is the Model, Controller and View. 

## Work Flow

![Mvc Diagram](img/mvc_diagram.png)

1. User see View output
2. User through View interacts with controller that filter passed data
3. Controller call Model for an action with User passed data (update, delete, create, etc.)
4. Model notify to View changes for output

When we must show only default data is no needed Controller job.<commit_msg>Update mvcImplement.md<commit_after>---
layout: default
title: How pattern is implemented?
current_menu: mvcImplement
---

# How pattern is implemented?

In Linna Framework every Mvc component is implemented as isolated. Interaction between components happens through
[Dependency Injection](https://en.wikipedia.org/wiki/Dependency_injection) or 
through [Observer Pattern](https://en.wikipedia.org/wiki/Observer_pattern).

## Why

Because every piece of Mvc pattern should do only one thing. Model manipulate the data, View render it and Controller filter the user input.

## Component interaction

Model is passed to View and Controller by class constructor (constructor injection).<br />
Model and View works as Observer Pattern.<br />
Controllers and Views are at the same level, a Controller doesn't call a View and does not pass to it, data for render.<br />
Controller works only when is needed filter user input and manipulate data through Model<br />
View ask Model for obtain data for rendering.

This implementation require a declaration for all routes, which is the Model, Controller and View. 

## Work Flow

![Mvc Diagram](img/mvc_diagram.png)

1. User see View output
2. User through View interacts with Controller that filter the passed data
3. Controller call Model for an action with User passed data (update, delete, create, etc.)
4. Model notify to View changes for output

When we must show only default data is no needed Controller job.
{'fraction_non_alphanumeric': 0.06241331484049931, 'fraction_numerical': 0.0027739251040221915, 'mean_word_length': 4.645792563600783, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6095807', 'n_tokens_mistral': 698, 'n_tokens_neox': 685, 'n_words': 389}