I am currently refactoring a multi-pages JavaScript application using Design Patterns. So far I found a pattern for most of the code, but I'm always wondering where to put the object initialization. Here are two examples:
1 - Systematic initialization
// Considering I'm using jQuery with a tooltip extension
$('.toolip-link').tooltip();
Nowadays, all those kind of code line are in a super explicit "scripts.js" where we initialize modals, tooltips, accordions...
2 - Conditional initialization
var $searchForm = $('#search-form');
if ($subuForm.length) {
// some form elements initialization
// ...
}
To which Design Patterns those two snippets belongs?
Thanks in advance for your help.
Aucun commentaire:
Enregistrer un commentaire