Answer the question
In order to leave comments, you need to log in
How correct are the listed architectural decisions in JS?
I am creating a website , client side in HTML5/JS/CSS. Server - Java / Spring. Normally I understand server programming, but in the client part - I'm very poorly oriented.
So the questions are:
1) Is it worth using OOP in JS? If so, why is it so poorly implemented there? If not, then how can I achieve a good level of abstraction, I'm used to working with objects everywhere.
2) Should I use getters/setters for JS classes?
Consider a small piece of source code:
//Файл section.js, подключается в <head> страницы
function Section(id) {
var _id = id;
this.paste = function () {
...
}
}
//Внутри страницы
<script>
var thisSection = new Section("${section.id}");
</script>
...
<button onClick="thisSection.paste()">Вставить</button>
Answer the question
In order to leave comments, you need to log in
1) Should you use OOP in JS? If so, why is it so poorly implemented there? If not, then how can I achieve a good level of abstraction, I'm used to working with objects everywhere.
Use coffeescript there oops more familiar
2) Should I use getters/setters for JS classes?
See support
https://developer.mozilla.org/en/docs/Web/JavaScri...
The second will be better, because then it will be hard to redo the logic and you won’t hang several handlers.
3) Is it worth creating a separate file for each js class? If I have 10-15 js files connected on the page - is it good?
At the development stage, it's fine, throw the merged and minified version into production
Absolutely incorrect (you have separate templates and code on the server - on the client, it’s similar to sculpt everything in a heap)
Here's something really weird
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question