|
Mapping UML design to java
|
"Mapping UML design to Java" is like to map Unified modeling language diagrams to Java to construct Java code from UML designs (diagrams).UML designs(diagrams) are constructed for the under-developing system or application (like a game application in Java ) using different tools like Umbrello UML Modeller in Unix systems . UML diagram for any software application becomes a complex as application design increases ,so to avoid this complex structure of UML diagram , UML diagram is divided into subparts according to the design concerns ( different modules in the application) . For each module of design separate UML diagram is constructed , thus we will get a set of UML diagrams for that particular system or application . All these diagram finally collected to get desired system or application and this complex diagram can used to generate actual Java code for that software system or application .To generate actual code from this UML diagram mapping is necessary .So to generate code from UML model (diagrams) design will be useful and worthy for developer's . The mapping of UML design to Java , code generated from this design can be reused, such designs gives maximum type safety,also support for generalization and also for association. Introduction : For efficient design & management of the complex software systems , modeling languages, which represent design graphically, are widely used nowadays. Such modeling languages are used in various kinds of design such as to provide a description of the implementation of the system, modeling the architecture of the system E.g.: UML(Unified Modeling Language). The balance between design & implementation code becomes more apparent and easy when model represents the design of specific implementation. But when model of a system is designed independent of the implementation, it provides more flexible description of the system’s architecture while validating a specific implementation & its design model is harder. Objectives *Separate design from implementation *Separate behavior from representation *Maximum type safety *Support for designing with concerns *Support for Generalizations (Supporting multiple Inheritance) *Support for associations *Behavioral access for associations & attributes *Unified set of Idioms for accessing/navigating the model *Promote code reuse System is designed as follows</br> System designer partitions system into different parts upon design relation . The concern designer works on the particular task, their operations, and relationships ,attribute to other kinds of entities. The attributes, associations, and operations of each entity characterize how that entity can be used by the designers and implementers of other entities in the same concern and of other concerns . Object designer coeds other attributes , relationship and also operation which are in that entity relation.The behavior implementer specifies other parts like algorithms for particular design Separate Design from Implementation : System or application developed by designer may under goes various changes as per customer needs. So to minimize the work of developer the code generated from a design should use specific programming style to separate design elements from each designer. Separate Behavior from Representation : We also try to minimize the effect representation of data decisions made with respect to association and storages of attribute. Also when data representation is changed code that represents behavior of object shouldn't be changed. Maximize Type-Safety : There should be strong type checking for detecting errors in the development process and we should confirm that code which is generated by this retains type information to help compiler for type checking. If we loss of information of attributes type which may result in error-prone code and also a lot of time of the developer to write type casting of each of these. So we achieve this in mapping and avoid designer to do it explicitly. Support for Designing with Concerns : Divide and conquer is the best strategy to design overall system where we divide complete UML design into separate diagrams which makes easy understanding. The designer then work on each separate UML design diagram and model it ,elaborates in large scale. In last a skeleton of all these separated diagrams are conquered to get total design. From all this diagram we should get our specific design of that system. Support for Generalizations : Generalization in object oriented language is called as Inheritance i.e more general concept should be collected in one class and that can be used by other classes to get behavior of that particular implementation . So our goal is to have generalization concept to design of a system by mapping. support for association : Association is a relationship between instance of classes . We will use this to give support for following capabilities and our mapping should go in smoother way. #Directionality and roles - can be traversed in both direction forward and back-word also. #Multiplicity- each end of association there must be annotation of multiplicity. #Association classes-Association gives more general concept between instances of classes rather than linking them. #Stereotypes-defines simply difference between semantics association. Behavioral Access for Associations and Attributes : Code written for object should provide methods to get access to the association and attributes of that object without need of implementers to write code in data representation of that attributes . By specifying methods to this association and attribute for manipulating will be helpful. An easy way to do it is having get and set methods of that object. And this should go in automatic way. Unified Set of Idioms for Accessing/Navigating the Model : Generated code should have a support for accessing different parts of model. i.e if some attribute in c language some name that should be followed in other language like java, etc so that a designer will not get any conflicts. Promote Code Reuse : In the design we may be implementing code which is required in many times and also in many software application then we should collect and provide it to all implementor's so that all can use it without wasting time on again and again implementing it . We should must have support for this in mapping. Methods For Mapping UML Designs To Object-oriented Code In the below section we going to describe how to map the UML design to Java Object Oriented code.</br> UML Class Diagrams The classes which are marked with the stereotype entity ,UML construct that with attributes, association, operation, relationship. There might exist high-level class designs which are specific for implemented system. So classes which are not a part of stereotype entity considered as implementation-specific designs . We will be using term “entity” for the UML class with stereotype entity.</br> Entities Each entity for a design can be mapped into an interface and a pair of implementing classes . Suppose such an entity , 'A' ,we then generate an interface named A from that design ans also classes named AAbst(abstract) and Ainst(instantiable). The Interface generated by above method contains different operations for that particular entity in Uml model and also operations for modifying and accessing it's different attributes, associations. Ainst class extends Aabst class which can be instantiated and implementations of various operation for A can be defined over here. Aabst class is an abstract class which contains the implementations of basic operations. : We cant's modify the code generated of this interface A along with Aabst class which are generated from the entity of system design. Also code written by the behavior implementer is hidden in Ainst class , doesn't need to be again generated in different model changes which are not related with the previous one . Access to all attributes of an entity is done through getAtrr() and setAttr() methods,which gives us separate behaviors from representation. Also we must maintain the type-safety to do this all auxiliary operations use type of attribute provided in UML design. Ex. From the above fig. The entity college member is generalization of student entity. By mapping this will construct studentAbst,studentInstand studebt interface. The student interface consist of getname() setname() and study methods. The getname() and setname() are present in studentAbst class. Definition of study method is present in studentInst. Association Mapping method we are going to propose over here uses same rules which were we proposed to map attributes i.e we are going to do separate the semantics from the implementation and representation. To do this we defining a new abstraction named as "cursor". Example: Consider the example given in the side diagram here diagram shows interface generated from the student entity and cursor corresponding to "belongsTO" relationship. There are two named roles which are accessible from relation student, interface contains auxiliary methods for getting information about cursors of those roles. Also we can see that StudentBelongsToCursor interface and associated implementation. The information of StudentBelongsToCursor it's operation are included into student interface.Also when we invoke an instance of student ,we will get a cursor giving access to the collection of belongsTo links from that instance ,also a cursor has methods for removing and adding links . Cursor always refers to the instance at the other end of link.
|
|
|