そのため、私はCommonJs Modulesの仕様を読み、dojoの実装とgoogleクロージャーの実装を調べてきました。コンセプトはかなりクールですが、AMDを使用したアプリケーションの緊密な結合について質問がありました。
閉鎖サイトからの例:
goog.provide('tutorial.notepad');
goog.provide('tutorial.notepad.Note');
goog.require('goog.dom');
goog.require('goog.ui.Zippy');
/**
* Iterates over a list of note data objects, creates a Note instance
* for each one, and tells the instance to build its DOM structure.
*/
tutorial.notepad.makeNotes = function(data, noteContainer) {
var notes = [];
for (var i = 0; i < data.length; i++) {
var note =
new tutorial.notepad.Note(data[i].title, data[i].content, noteContainer);
notes.push(note);
note.makeNoteDom();
}
return notes;
};
/**
* Manages the data and interface for a single note.
*/
tutorial.notepad.Note = function(title, content, noteContainer) {
this.title = title;
this.content = content;
this.parent = noteContainer;
};
/**
* Creates the DOM structure for the note and adds it to the document.
*/
tutorial.notepad.Note.prototype.makeNoteDom = function() {
// Create DOM structure to represent the note.
this.headerElement = goog.dom.createDom('div',
{'style': 'background-color:#EEE'}, this.title);
this.contentElement = goog.dom.createDom('div', null, this.content);
var newNote = goog.dom.createDom('div', null,
this.headerElement, this.contentElement);
// Add the note's DOM structure to the document.
goog.dom.appendChild(this.parent, newNote);
return new goog.ui.Zippy(this.headerElement, this.contentElement);
};
だから私の質問はここで緊密な結合が起こっているのではないですか?アプリケーションにtutorial.notepadを提供し、他のモジュールがそれを必要とし、tutorial.notepad内の機能が変更された場合、ここでは密結合の問題はありません。基本的に、モジュールをチェーン化して、そこに単独で存在できるようにして、脆弱なアーキテクチャを作成します。
誰かがこれについて評価されるアーキテクチャのコンテキストで、または疎結合のAMDアーキテクチャのアーキテクチャに関するリソースでこれについて話すことができれば、私はこれについて間違っていると考えている可能性があります。