Several Issues regarding the usage of UML in SPA Angular

638 views Asked by At

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 = '';
}
1

There are 1 answers

1
Gerd Wagner On BEST ANSWER

Is UML only appropriate for ECMAScript 6 Harmony?

No, UML (class diagrams and sequence/activity diagrams), can always be used for making IT-independent conceptual (information and process) models as well as platform-independent (information and process) design models. This is independent of any programming language. So these models can (and should) be used, no matter if you are using Java, C# or JavaScript for your implementation.

It's another question which code patterns can be used for implementing a class concept in JavaScript. Here, we basically have two choices, as discussed in this section of my book Engineering Frontend Web Apps with Plain JavaScript,

  1. The classical constructor-based class pattern recommended by Mozilla on their MDN website. The new ECMAScript 6 class construct is just syntactic sugar for this constructor-based pattern.
  2. In the form of a factory object that uses the predefined Object.create method for creating new instances of a class. In this factory-based approach, which has been recommended by Eric Elliott, the prototype-based inheritance mechanism is replaced by another mechanism. Elliott argues that factory-based classes are a viable alternative to constructor-based classes in JavaScript.

Notice, however, that in AngularJS, there is no real concept of a model class, but you can certainly use your own approach.

It is said that when we use mongoDB we are no longer need ORM anymore because the output is already object

This is plain wrong. A kind of ORM (or maybe better object-to-storage mapping) is always needed, e.g., for mapping

  1. internal object references (representing associations) to ID references with some form of referential integrity,
  2. class hierarchies to certain storage structures (e.g. a single table or object store with optional attributes)

Is this kind of Model Driven Development not appropriate for AngularJS

The approach of Model-Driven Development can be used for any kind of target platform, including AngularJS.