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 中实现类概念。在这里,我们基本上有两个选择,正如我在使用纯 JavaScript 工程前端 Web 应用程序的这一部分中所讨论的,

  1. Mozilla 在其 MDN 网站上推荐的经典的基于构造函数的类模式。新的 ECMAScript 6class构造只是这种基于构造函数的模式的语法糖。
  2. 工厂对象的形式使用预定义的Object.create方法来创建类的新实例。在 Eric Elliott 推荐的这种基于工厂的方法中,基于原型的继承机制被另一种机制所取代。Elliott 认为,基于工厂的类是 JavaScript 中基于构造函数的类的可行替代方案。

但是请注意,在 AngularJS 中,没有模型类的真正概念,但您当然可以使用自己的方法。

据说当我们使用 mongoDB 时,我们不再需要 ORM,因为输出已经是对象

这是完全错误的。总是需要一种 ORM(或者更好的对象到存储映射),例如,用于映射

  1. 对具有某种形式的参照完整性的 ID 引用的内部对象引用(表示关联),
  2. 特定存储结构的类层次结构(例如,具有可选属性的单个表或对象存储)

这种模型驱动开发不适合 AngularJS

模型驱动开发的方法可以用于任何类型的目标平台,包括 AngularJS。

于 2014-12-17T15:01:54.770 回答