# Architecting
---
#### What is Separation of Concerns(SoP)?
Separation of concerns is the idea that each module or layer in an application should only be responsible for one thing and should not contain code that deals with other things.
Separating concerns reduces code complexity by breaking a large application down into many smaller units of **encapsulated** functionality.
---
***Example***
Your HTML should only contain information about your content, and all of your styling decisions should be made in your CSS.
---
#### How is it related to Front/Back-end Development?
In software engineering, the terms front end and back end refer to the SoP
```
between the presentation layer 'front end'
and the data access layer 'back end'
```
The backend usually consists of three parts: a server, an application, and a database.
---

---
#### What kind of tasks are normally handled in the back end?
1. Writing APIs
2. Storing, retrieving, and organizing data (for example, blog posts or flight-prices)
3. Database transformation
4. Security
5. Backup
---
### Which are more usually handled in the front end?
Everything related to markup, style, accessibility, cross-browser, cross-platform and cross-device functionality.
---
### Client vs. Server
---
### Front-end Validation and Templating
Pros:
- Better user experience.
- Instant feedback.
- Reduces the load on the server.
Cons:
- Can easily be bypassed by "expert" users.
---
### Back-end Validation and Templating
Pros:
- Done for security.
- Protects from script injections.
- Allows to see whether you already have this data in your database.
---
### Alternative back-end technologies
---
*Other back-end languages*: PHP, Phyton, Ruby
Node.js is a JavaScript runtime environment.
Java is a language, but also an ecosystem with its own libraries, plugins, APIs, and a runtime environment.
Java can be run on any platform, Node has modules that are tied to the specific operating system
---
The quality of Java libraries is considered to be higher
Java is faster when it comes to running CPU-intensive applications (streaming)
Node is the first tool to use JS in the backend, code can be migrated
Node.js takes about 33% fewer lines of code than Java
---
### Javascript Runtime Enviroment
When you visit a website you do so within a web browser like Chrome, Firefox, Edge, or Safari.
Each browser has a JS Runtime Environment.
In the environment are Web API’s that a developer can access to build a program.
Also in the runtime environment is a Javascript Engine that parses the code. Each browser has its own version of a JS engine.
Chrome uses what it calls its V8 JS Engine.
---
### Differences between JS in Node and in the Browser
You can use the modern ES6 JavaScript that your Node version supports
Some browsers cannot deal with ES6, so you will need to use an older version of JS
You can use Babel (a JS complier) to transform your code to be ES5-compatible before shipping it to the browser
We use require() in Node and *import* in the browser
{"metaMigratedAt":"2023-06-14T22:59:17.700Z","metaMigratedFrom":"Content","title":"Architecting","breaks":true,"contributors":"[{\"id\":\"c812783e-2740-47d0-8981-33bca2701792\",\"add\":3850,\"del\":2345},{\"id\":\"30d420a4-4f55-4e03-805c-e5f852312214\",\"add\":2089,\"del\":479}]"}