Modeling language from UML to C # code

xiaoxiao2021-03-06  41

From UML modeling language to C # code [translation] vczhgame 2004-02-01

An article in this site is published! Chen Yushan is a member of the team's oldest member. This year, the second grade of the high school, the second grade, the elliptic snailhouse, the rabbit, the rhyme, the rhyme, the murder, the murder,   馐   胪 胪 胪 胪   胪 胪 煳 煳 煳 煳 煳 煳 煳Oh, 雍 蟮 谝 谝   澹 澹  窈   贑 贑 贑 贑 给 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文 文I hope everyone gives special encouragement and support! Here team members wish Vczhgame classmates to learn progress and admitted to the ideal university. In this article, I will tell you some of the way UML into C # code in this article. First, I will tell a case related to UML. Now, we put the focus on how to turn the UML to C # code, and do not describe how to make a UML chart. That's why everyone will see the UML chart at the analysis design phase at the beginning. The case description has a company to improve their information system. The first step is to analyze the training procedures for employees and automate some tasks.

When a worker applies for training to the trainer, a training program begins. The trainer will decide whether to agree to the employee training application. If the trainer agrees with the employee training application, the trainer will find a suitable training program in the training program currently responsible. Once the employee determines the training project she has to accept, the trainer will register with the faculty. If the training stops in the middle of the employee, it must notify the trainee in the shortest time in order to log out registration. After the training, the employee must submit a self-assessment and a registration form to the trainer. The trainer checks before submitting the form to Huiji Service. Note: UML IN PRACTICE, P.ROQUES, WILEY, 2004 provide case main ways. We will use the UML chart below to explain:

Class Diagram

Class maps are used to define the code framework to be said to be a declaration of the entire class. At the beginning, we can approximately say:

A UML class chart will become a C # class UML class diagram attribute will become a variable class diagram of an instance of the C # class. The method of operation will become a C # class method. You will notice that the Navigable role is implemented as an instance variable, just like attributes, But it is not a simple type, but a user-defined type. This suggests a class creation. I will give a simple illustration for these methods.

Figure A A frame code for an order class

Interact

The interaction diagram illustrates the operation procedure of the class method, especially the calling order of some ways to interconnect some methods. The next illustration illustrates the relationship between the message serial number and the C # method implementation code.

Figure B EnregistremPrunteur (Register Borrower) Method

After these examples, I will give some specific practical examples. From the UML class map to the C # framework code, you will see Figure C, pay attention to the "training application" class

Figure C training application class internal relationship

The previous method has already lived enough to convert this chart into a C # framework code. The only thing we have to remember is that we must add an import statement to ensure that you can establish contacts with classes in other packages (whether user-defined packages or standard base libraries). The equivalent C # framework code is in Figure D.

Figure D: Training application class C # framework code

If we want to add read and write operations for an attribute, according to the package of the package, we must naturally add an attribute to the class, just like the following code:

Public int propdatevalidite {get {return Datevalidite;} // This is the "read" operation set {datevalidite = value;} // this is "Write" operation} Now let's take a look at the picture E, pay attention to "Training" class.

Figure E: The relationship between classes and between them

Compared with the previous example, some additional problems: • Summary of the relationship between elements • Multiple: Theme (Topic) << 1.. * >> and session << 0 .. * >> {ORDERED} The front method is no longer available. We have seen how to use the multiple of << 1 >> (or << 0..1 >>) to implement Navigable, however, how to convert contact to <* >>? There is a fairly simple principle: to replace << * >> multiplex by replacing a reference to a single object with a type having a specific attribute (such as an object reference collection). It is difficult to properly select the set type provided by the .NET Framework. Although it is easy to create manager arrays with C #, this is unnecessary for a correct solution. In general, people prefer a collection type like C # from ArrayList or HashTable. • If you want to remember the order between objects, and if you want to use an integer index to get an object, choose ArrayList; • If you want to get an object with any keyword, you use HashTable or sortedlist. Here are some solutions to various needs:

Figure F: UML Contact C # convert

For the Formation class, we will use: • A ArrayList to implement organizations for the session • A HashTable to implement organizations for the THEME rather than using a simple array. We use the name of the outline as a qualified word through the above instructions, we can write this code:

Figure G: C # frame code for the Formation class

Conclusion The UML chart into code is a must-specific sensitive job. So, for some languages, the conversion codes may have some conflicts between the UML chart. The code generation tool automatically performs the conversion of UML and code, but it also provides some different options to the object editor (such as ArrayList and Hashtable).

转载请注明原文地址:https://www.9cbs.com/read-52782.html

New Post(0)