Design from another perspective: Schema-based Global Business Data Definition

Source: Internet
Author: User
Design from another perspective: Global Business data definition based on schema.

In a traditional large project, after a business model is created, data definitions are repeatedly divided into the following parts during the implementation phase:

1. Database

2. Data Layer entity or DTO

3. Transmission objects at the service layer

4. Data at the presentation layer

5. user input

6. Reports and other applications...

Each layer above defines its own data format and verification method, which is repetitive and meaningless.

In addition, the data validation and significance may not reflect the original requirements due to the influence of the definition capability of each link.

So who is the Terminator? Schema!

Schema is the younger generation of DTD, but it is more powerful and flexible. We know that schema is generally only used to define XML and verify XML.

However, schema also provides extended space, that is, annotation. It can be defined under annotation.

Document, document is the annotation of schema. Appinfo is mounted under annotation. From the name,

This is for the ApplicationProgramSpace for providing information. From the schema definition, appinfo can store various XML data without restriction.

This is my example:




customer
customers who place orders
customers who place orders


.....
..... // here is the definition of type


you can see that when defining a customer, we can add meta information to it to inform the program, the data name, tip, and help.
if necessary, you can even define a help link, a data source for the secondary input, and a control name for the secondary selection.
these meta information undoubtedly provide valuable information for debugging, interfaces, UIS, reports, and other scenarios, making it possible to automatically generate images.

So what are the benefits of a global schema definition?

1. From the preceding scenarios, use schema to generateCodeIt's easy. These codes are self-described and verified. It is important that the numbers and texts transmitted between layers are no longer meaningless and they are active.

2. schema supports references between schemas, and type redefinition or extension. It is very easy to reuse or reorganize existing definitions, and annotation can be inherited.

3. schema is language-independent. What does it mean? The schema definition can be implemented in different languages.

4. The rule engine is the business layer, and schema-based screen generation is the user interface. With the XML database, the storage problem is also solved.

Two years ago, I had a semi-successful attempt. I first defined the global business data schema and then generated the database schema,

Of course, the database schema references the business schema because the business schema is the source.

Next, because it is a B/S project, I have defined the request schema and response schema of the image.

The remaining tasks with These schemas are simple: the SQL database creation script is generated based on the database schema.

According to the request schema and response schema, the front-end staff made an XSL for converting XML into a webpage.

Response schema is used to verify the XML output of the business layer. Both schemas generate sample data for independent debugging by front-end personnel and background personnel.

Because of Schema reference, the design is fast and accurate, and even many descriptions are directly written into the schema annotatiion.

However, there were also some unsatisfactory points. For example, we defined the conversion rules from Schema to bean and handwritten bean code.

It also took some time for developers to learn XSLT and understand schema.

Today's developers are very happy, and there are many options for various Schema-based tools.

In the long run, directly storing XML and using the rule engine, dynamic user Images Based on schema will be the development direction. The code almost disappears.

Summary:

1. Schema-based global data definitions ensure global consistency of data definitions.

2. provides a benchmark for code generation. generative code greatly reduces development and change costs.

3. Schema-based dynamic generation is the highest ideal.

References:

Schema spec

Xmlbeans

. Net schema document

Jaxme

@ Todo:

Dynamic echo/swing/SWT screen generation.

Schema appinfo Writing Tool.

Other code conversion tools

Posted on steeven read (83) Comments (0) EDIT favorites

Http://www.cnblogs.com/steeven/archive/2004/11/17/64605.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.