0

While we are waiting for the next upcoming version of javascript, that is ECMAScript 6 codename Harmony, we are enforced to use object-based/functional-based javascript. Currently there are no class construct, interface, inheritance, means for information hiding, and so on. But I won't argue about its usefulness, I just wondering about the usage of UML constructs in complete Single Page Application framework such as AngularJS.

  1. Is UML only appropriate for ECMAScript 6 Harmony?

  2. It is said that when we use mongoDB we are no longer need ORM anymore because the output is already object, then now Oracle has provided HTTP Plugin that enable MySQL to provide RESTful CRUD API and has JSON as its output. The question is, when I creates Class Diagram, I can convert it to JPA entity class, than is it still useful when I use Restangular-->MySQL or just nice to have?

  3. In Doug Rosenberg & Matt Stephens' book Use Case Driven Object Modeling with UML, they use one boundary lifeline for each page and entity lifeline for each domain model that are involved within his sequence diagram, so when I use Angular-UI's UI-Router, then what is it count to be boundary lifeline? is it each state? then I guess the control lifeline is my angular's registered controller, and entity lifeline for my javascript object that I pass to each Restangular's post/put/delete method, aren't they?

  4. I think Restangular is a kind of Data Access Object, isn't it?

  5. Is this kind of Model Driven Development not appropriate for AngularJS at all, if so then what it is that appropriate?

code example for accesing mysql directly from restangular:

Restangular.setDefaultHeaders({'Authorization':'Basic '+btoa("basic_auth_user:basic_auth_passwd")});
RestangularProvider.setBaseUrl('http://localhost:8080/crud/mydatabase/');

myModule.controller('salesmanController',
function($scope, Restangular){
var salesmanDAO = Restangular.all('salesmanTable');
$scope.allSalesman = salesmanDAO.getList().$object;


$scope.insertSalesman = function(){
    var newSalesman = {firstName: $scope.newSalesman.firstName, lastName: $scope.newSalesman.lastName, city: $scope.newnewSalesman.city};
    salesmanDAO.post(newSalesman)
    .then(
        function(newObject){
            $scope.allSalesman = salesmanDAO.getList().$object;
        },
        function error(reason){
            console.log("the reason: ", reason)
        }
    );
    $scope.newSalesman.firstName = '';
    $scope.newSalesman.lastName = '';
    $scope.newSalesman.city = '';
}
4

1 に答える 1

0

UML は ECMAScript 6 Harmony にのみ適していますか?

いいえ、UML (クラス図とシーケンス/アクティビティ図) は、IT に依存しない概念 (情報とプロセス) モデルと、プラットフォームに依存しない (情報とプロセス) 設計モデルを作成するために常に使用できます。これは、どのプログラミング言語にも依存しません。したがって、実装に Java、C#、または JavaScript を使用しているかどうかに関係なく、これらのモデルを使用できます (使用する必要があります)。

JavaScript でクラスの概念を実装するためにどのコード パターンを使用できるかは、別の問題です。ここでは、私の著書Engineering Frontend Web Apps with Plain JavaScriptのこのセクションで説明したように、基本的に 2 つの選択肢があります。

  1. Mozilla が MDN Web サイトで推奨している従来のコンストラクター ベースのクラス パターン。新しい ECMAScript 6classコンストラクトは、このコンストラクター ベースのパターンのシンタックス シュガーにすぎません。
  2. クラスの新しいインスタンスを作成するために定義済みのメソッドを使用するファクトリオブジェクトの形式。Object.createEric Elliott によって推奨されているこのファクトリ ベースのアプローチでは、プロトタイプ ベースの継承メカニズムが別のメカニズムに置き換えられます。Elliott は、ファクトリ ベースのクラスは、JavaScript のコンストラクタ ベースのクラスに代わる実行可能な代替手段であると主張しています。

ただし、AngularJS にはモデル クラスの実際の概念はありませんが、独自のアプローチを使用できることに注意してください。

mongoDB を使用すると、出力が既にオブジェクトになっているため、ORM はもう必要ないと言われています。

これは明らかに間違っています。一種の ORM (またはおそらくより優れたオブジェクトからストレージへのマッピング) が常に必要です。たとえば、マッピング用です。

  1. 内部オブジェクト参照 (関連付けを表す) から ID 参照への何らかの形式の参照整合性、
  2. 特定のストレージ構造へのクラス階層 (たとえば、オプションの属性を持つ単一のテーブルまたはオブジェクト ストア)

この種のモデル駆動型開発は AngularJS には適していませんか?

モデル駆動型開発のアプローチは、AngularJS を含むあらゆる種類のターゲット プラットフォームに使用できます。

于 2014-12-17T15:01:54.770 に答える