Wednesday, 6 November 2013

Why UML is not fit for MDSD ?

Quote by James Rumbaugh

Document Actions
Masterminds of Programming features exclusive interviews with the creators of several historic and highly influential programming languages. This quote from James Rumbaugh debunks some cliché about UML and code generation.
Federico and Shane: "What do you think of using UML to generate implementation code?"
James: "I think that it's a terrible idea. I know that I disagree with many other UML experts, but there is no magic about UML. If you can generate code from a model, then it is programming language. And UML is not a well-designed programming language.
The most important reason is that it lacks a well-defined point of view, partly by intent and partly because of the tyranny of the OMG standardization process that tries to provide everything to everybody. It doesn't have a well-defined underlying set of assumptions about memory, storage, concurrency, or almost anything else. How can you program in such a language?
The fact is that UML and other modelling language are not meant to be executable. The point of models is that they are imprecise and ambiguous. This drove many theoreticians crazy so they tried to make UML "precise", but models are imprecise for a reason: we leave out things that have a small effect so we can concentrate on the things that have big or global effects. That's how it works in physics models: you model the big effect (such as the gravitation from the sun) and then you treat the smaller effects as perturbation to the basic model (such as the effects of the planets on each other). If you tried to solve the entire set of equations directly in full detail, you couldn't do anything.
I think a lot of the recent work on UML has been misguided. It never was meant to be a programming language. Use it to get the strategy right and write the final program in a suitable programming language.
Unfortunately I don't know any really good programming languages. They all have a lot of flaws that encourage mistakes. The whole C family (C, C++, Java, etc.) is sorely lacking (the syntax is almost unparsable), but we are stuck with them whether we like it or not. A lot of new faddish languages demonstrate the ignorance of any serious language theory on the part of their developers. On the other hand, many of the more academic languages are too elegant for their own good and disdain important features, such as the need for multiple teams to work separately on the same system."
—James Rumbaugh in Masterminds of Programming

Saturday, 23 June 2012

What is Domain Specific Language or DSL ?


What is Domain Specific Language or DSL?
In his book, Martin Fowler defines the DSLs as follows.
 “A computer programming language of limited expressiveness focused on a particular domain.” (Fowler, 2010)
“The basic idea of a domain specific language (DSL) is a computer language that’s targeted to a particular kind of problem, rather than a general purpose language that’s aimed at any kind of software problem.” (Fowler, 2010)
Summing up the above two quotes, a DSL can be define as follows
“A computer programming language of limited expressiveness that are specialized and focused to specify a particular aspect of a software system at a much higher level of abstraction than the general purpose programming language. It is capable of capturing the abstractions related to that particular aspect of the software system under development.”
In the literature, this particular aspect of the software system is also referred by the terms “viewpoint” or the “domain”. So in this context of DSLs, the viewpoint or the domain can be defined as follows
Domain or Viewpoint is the related set of concerns that represent the particular aspect of a whole software system under development that is important from the software development perspective. We can define the two types of domain or viewpoint for a software system, the horizontal and vertical domain (Maier, et al., 200X) (MDA Guide)
Horizontal Domain describes the technical aspects related to the software system like the architectural view, persistency view, user interface view, user interface look and feel view and user interface interaction view. (?)
Vertical Domain describes the functional aspects related to the software system like the insurance policy domain, banking domain, air traffic control domain, air flight reservation domain, medical domain, mobile software domain are the examples of few. (?)
DSLs do not live in isolation but they are integrated. As a DSL fulfils only a narrow purpose and specify a particular aspect of a software system. But the real world software has multiple aspects associated with it and all such aspects are overlapping and tightly integrated to each other. So a DSL in isolation is worthless. In order to specify all aspects of the software system we must have multiple integrated set of DSLs. (Fowler, 2010)
DSLs are not needed to be turing-complete languages like the GPLs. As the scope of these languages is much narrowed to specialized domain of a software system, therefore their capabilities are also limited as compared to the GPLs like Java and C#. A DSL is not needed to be a turing complete language like the GPLs having all kind of controls structures like conditional structures, looping structures. Also these languages are not necessarily to have the capability to create new abstraction styles. The narrowed capabilities are enough to fully specify the particular aspect of the software system. As these languages are more tilted toward the specialized domain, therefore they are expected to have more user-friendly syntax as compared to the GPLs. Due to this feature the programs or models specified in such languages are more expressive, more focused, more fluent and more readable as compared to the GPLs programs or models. (Fowler, 2010)
Examples of the DSLs include CSS, XML configuration files , regular expressions, make, rake, ant, SQL, HQL, many bits of Rails, expectations in JMock, graphviz's dot language, FIT, strut's configuration file.  (Fowler, 2010)

What is Language Oriented Programming


In his book, Martin Fowler defines the LOP as follows.
“The general style of software development which operates about the idea of building software around a set of domain specific languages” (Fowler, 2010)
“Language oriented programming is about describing the system through multiple DSLs.” (Fowler, 2010)
As discussed, a DSL is used to specify a particular aspect of the software system. But a real software system has multiple overlapping aspects associated with it. That’s why this is a new software development paradigm suggests the use of multiple integrated set of DSLs to fully describing a software system. In contrast to the GPLs, the DSLs specify the different aspects of the software system at much higher level of abstraction. Thus the resultant software specifications are very much easier to code for the programmers and very much easy to understand by the domain experts. This minimizes the communication gap between programmers and domain experts and helps resolve worst bottleneck that some of the main reasons behind the software failure. This style of development promises the order of magnitude improvement in software quality and productivity. Traditionally we have been doing LOP in the bits and pieces to get stuff done in the form of Unix little languages, lisp macros, active data models, adaptive object models, XML configuration files and GUI builders. (Fowler, 2010)

Friday, 22 June 2012

What is Domain in Domain Specific Language (DSL)

Various talks about Model Driven Software Development (MDSD)  and Domain Specific Languages (DSL) discuss the "Domain" witout elaborating their definition of domain. Domain is an overloaded terms that means different to different people. The following paragraph will try to elaborate this terms in the context of MDSD and DSL.


Horizontal domains are actually the solution space and the horizontal domains based efforts to raise the level of abstraction results in the horizontal abstractions. These abstractions do not deal with accidental complexity as they have nothing to do with the reusability of the conceptual structures. These abstractions ease the software development and make the expression of the design very much easy and deals only with accidental complexity. These technical abstractions can be well reused among the different technical domains. Their examples include (web applications, software architecture, deployment architecture, data persistency, concurrency, scalability and user interface).

Vertical domains are actually the problem space and the vertical domains based efforts to raise the level of abstraction results in the vertical abstractions. These abstractions deal with the essential complexity as they promote the reusability of the conceptual structures among the different software applications of that domain and also at the same time they make the expression of the design very much easy. But it is only the reusability of the conceptual structures that makes it relevant to deal with the essential complexity. Horizontal abstractions are prerequisite to the vertical abstractions and these vertical abstractions are built on the top of the horizontal abstractions. Therefore both kind of abstractions are important from the LOP perspective. 


Model Driven Software Development vs. Hand Crafted code

Many talks about the Model Driven Software Development (MDSD) portray it as the replacement of traditional hand crafted way of Software Development. By generating simple toy samples they try to convince that this is new style of software development. This idea seem OK on the paper but all practical experiences with the MDSD in the real life projects tell it is not true.

One way think MDSD is that it is a great assistance our hand crafted style of software development.

One may divide a software product under development in to two parts
1. One part of software that is repetitive and recurring
2. One part of software that is innovative and yield the real value of the software.

We can leverage the MDSD to deal with the first part. We specify that part of the software higher level of abstractions using Domain Specific Language (DSLs) and generated the repetitive stuff by code generation. This saves the developers time from doing the rote and menial tasks.

We should use manual style of software development to code the innovative part of the software. Fred Brooks refers this part of the software as the "Conceptual Constructs of the Software" that cause the Essential Complexity. MDSD leverage the abstraction and automation and yield more Developer's time and stamina to do deal with the Essential Complexity of software.

What is Model Transformation


Model transformations
Model transformation is the process in which the models or programs written in the source language are translated to the models or programs of the target language. Both input and output models or programs confirm to their respective language definition. That target language may be another modeling language or the programming language.
Why we need model transformation?
While developing software using the modern programming languages we write the software specifications in the form of programs. While doing so we are specifying software at much higher level of abstraction that is close to the human understanding. But the computer understands the programs in the form of 0s and 1s. Compilers translate these higher level software specifications to the low level instructions that are directly understandable and executable by the computers. In the same way when we are specifying software in the form of models, we are specifying it at further higher level of abstraction than the modern programming languages. We need to translate these models too into the intermediate models to the code of programming languages like Java or C# so that it could be further translated to the machine code.