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.
Is UML only appropriate for ECMAScript 6 Harmony?
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?
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?
I think Restangular is a kind of Data Access Object, isn't it?
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 = '';
}
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,
class
construct is just syntactic sugar for this constructor-based pattern.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.
This is plain wrong. A kind of ORM (or maybe better object-to-storage mapping) is always needed, e.g., for mapping
The approach of Model-Driven Development can be used for any kind of target platform, including AngularJS.