Architecture of autonomous applications

xiaoxiao2021-03-06  69

This page

What is FIEFDOM? Safe Gateway Architecture Mode Emissary Verified the Business Rule Depending on the XML WEB Services Based on the Business Rule WEB Service Depending on Usage Design XML Dataset Using Custom Entity Classes to map entity objects to database XML datasets Never connect to database summation

No one will be separated from the world, even for developers. Software architects, designers and developers need to communicate with each other. The application is the same. In the past, we treated the application as a Self-contained application. Both large-scale applications and small-scale PC applications can contain everything they need. They control user interfaces, business logic, and data, without having to take external programs to intervene.

But now it is no longer like this. Applications we build today usually need to integrate with existing software, and this trend is still continuing. In addition, more and more applications no longer control the user interface, the reason is: First, the user interface is designed in other places; the other is that the user interface access the application via the Internet.

Obviously, when building and designing applications, we should consider this need to integrate cross computing platforms. Fortunately, we have an architecture solution. Service-oriented architecture (SOA) sees applications as a service that can be discovered and accessed through Internet, regardless of whether the user runs on what platform and what programming language is used to create a user. In other words, the service provides services that have nothing to do with the platform and language. Web services are just one of them.

What is FIEFDOM?

The service should be a full autonomous application. But it is not a dislot island because you can make it a service for you. However, its autonomous performance is fully controlled and rejects the outside world directly or directly accesses its object. The only way to access its resource is to send a message to request you to perform a task. If it doesn't like your request or doesn't like you, it will refuse to perform the service. No one will make decisions in its name, it makes itself decision.

The Microsoft Architect Pat Helland was the first person in the autonomous application, but he is no longer the only one in the field. This is a reasonable concept, we will introduce you in this column. PAT uses the term "FIEFDOM" to describe the autonomous application, where we will use this term.

FIEFDOM Save, manage, monitor, and protect the main resources - data. FIEFDOM's data can be saved in different types of data sources, but in most cases, structured data is saved in the relational database, such as Microsoft SQL Server. FIEFDOM never allows anyone or any tool to obtain its data directly from the FIEFDOM. FIEFDOM may allow some people in the outside world to access their data, even in the name of these people, but only this FIEFDOM can access directly.

FIEFDOM does not allow external programs to lock any data. Therefore, you must consider all the data that makes FiefDom a snapshot, not actual content. For most practical purposes, the current data exists only in the FIEFDOM. You cannot expect data from FIEFDom to be current data, let alone is to receive the data. Some of the Fiefom internal transactions may change the data in their data sources before you receive the snapshot.

Most fiefdom still insists on managing their own affairs. FIEFDOM should not allow external programs to control transactions or partial transactions running within FIEFDOM. However, FIEFDom can disclose some of the transactions that are controlled and coordinated by the external side, as long as this part of the transaction is a compensation transaction. FIEFDom controls this part of the transaction, but uses it as a service provided to the client, which is the transaction coordinator.

An example of compensating a transaction is the second part of the WEB Service Affairs Specification: Business Activities (BA). Such a transaction has two different solutions. Standard solutions perform the operations specified by the transaction. The compensation scheme executes another set of operations, which is to delete the impact of completed transactions in FIEFDOM. The compensation scheme is called by the transaction coordinator of another FIEFDOM. The condition of the call compensation scheme is that FIEFDom has completed its partial transaction, but the coordinator discovered that other parts of the transaction failed. In this case, it is necessary to eliminate the influence caused by the Fiefom run and complete, even if it can't roll back. The locks added to the record have been released, while other transactions may have changed their status. The compensation scheme will eliminate these effects. Not all types of transactions are suitable for compensation. Most of the FIEFDOM do not (nor should it) participate in business that does not have a reliable compensation program.

Back to top

Security gateway

To some extent, the service-oriented nature determines that the service-oriented application is safe. Let the app provide you with any task to send a message to it, requesting a service. Execution or reject request depends on the application.

In many cases, the application allows someone to perform a specific one or a set of services. In these cases, the web service needs to be done simply delegate the job to the appropriate component, and then pass the response to the client. In other cases, the Web service may need to verify the user's identity to determine if he is authorized to execute the service. This can be a simple inspection only on the Gateway for the Active Directory or SQL database, or use security technologies (such as simulation or delegation) and role-based security checks to different levels of applications. Remember, you must always pay attention to the risk of denying service attacks, trial invasive hackers and other malicious threats.

As part of the security plan, Microsoft has released a number of security documents; the most important document is "Building Secure ASNET Applications", which is now published (Microsoft Press, 2003). You can download this document (manufactured by the Authentication, Authorization, And Secure Communication) or purchase books; it contains a lot of information about how to build deep security based on web-based applications.

Back to top

Architecture mode

Obviously, FIEFDOM is an architecture mode. Like other models, you should be able to say as a software architect. "I think we should design this application as a FIEFDOM", and the people around you should immediately understand what you are talking about. This is one of the powerful advantages of the model; they help you discuss architecture and design and use generic vocabulary in a more abstract level.

Obviously, not all FIEFDOMs are architectural in the same way. A set of services they provide affects the type types they need internal, so any FIEFDOM will use other modes to use other modes in their internal implementation. For example, most FIEFDOM will use the mode (such as using the data accessor) to access the database; use the service agent to access other services; use the data transfer object to transfer data through each layer, and use the entity manager to support the entity-level business rules.

Back to top

Emissary

Some FIEFDOM will also provide user interface (UI) for its services. Such FIEFDOM uses an Emissary mode - a web form emissary or a Windows Form Emissary. Emissary is like a sales agent or a mortgage broker. It can display reference data to the user, allowing users to select from a valid alternative, rather than typing information. Emissary also knows many of the business rules that FIEFDOM used, so it can help users ask a request in a way that is more acceptable in a FIEFDOM. Emissary can also save a session state for users. A typical example is an ASP.NET Web form, which saves the shopping cart for users during multiple calls, allowing users to add goods to existing goods existing in the shopping cart, which are kept in the shopping cart until the purchase process carry out.

However, FIEFDom does not trust Emissary, even when Emissary must be viewed as part of FIEFDom. Any requests passing through Emissary must evaluate their security, integrity, and correctness, just as careful as requested for incoming Emissary. The treatment of insurance companies in the insurance application introduced by the sales agent is this. More Emissary is more thinking for the client, not fiefom.

How should this be allocated between fiefom and its EMISSARY? In this way, FIEFDOM must handle sharing data, which means that the write operation must be serialized to protect the integrity of the data. Instead, Emissary can handle local read-only copies of reference data and each user data. Therefore, EMISSARY can ignore synchronization issues. In the non-military zone, Emissary usually processes only one client at a time, and FiefDom usually resides within the protected intranet and must always be available to all clients.

Using a web form, Emissary can extension. The expansion of FIEFDOM is quite difficult because it processes shared data, and shared data must always be available to all clients.

Therefore, if more work can be assigned to EMISSARY, the application's scalability will be significantly improved. You can achieve this through careful design. Let's take a look at Amazon.com. When you browse their sites, when you put your book and other items in your shopping cart, all work can be done by Emissary. You only need to use FIEFDom when you click the "Submit" button.

But do this, you must design the system: scratch the boundaries of Fiefdom and Emissary and use performance and extended booster (such as cache objects). In addition, the way you design the Fiefom service interface must also make the interaction between Emissary and FiEFDoms minimize.

Back to top

Verify according to business rules

Some requests are sent to FIEFDOM requests or delete data. If the request itself is not based on the security policy, it should be carefully verified according to business rules, and Fiefom should not accept such requests. This is why business rules and policy rules belong to FIEFDOM (defined by PAT Helland) and is located in the service (defined by the SOA).

Back to top

Loose coupling with the client

FIEFDOM is loosely coupled to its client. There is no connection between the client and the FIEFDOM before the client is sent to the FIEFDOM to establish a connection. FIEFDOM processes the message and transmits response to the client. The response can be the result of the request operation, or it is also a rejection of the execution service. In either case, as long as the FIEFDOM response is completed, disconnect the client and the FIEFDOM, just like HTTP messages. As HTTP, there are a variety of ways to keep connecting throughout the session, but is usually limited to a complete message cycle. Loose coupling is good for scalability. It makes any client to connect to the system and use the system resources. Loose coupling and one-time management of Microsoft Transaction Service (MTS), and then incorporated into the so-called .NET Enterprise Services for COM component services.

Back to top

XML-based web service

A concept hidden behind SOA is the location transparent, and the other is independent of computing platform and programming language. Web services are very ideal for meeting these fundamentals. Since the Web service is known to its URL, its actual location can be changed (as long as the service provider is still pointing to this location).

Since the Web service is completely independent of the underlying platform and programming language, it only requires the client to understand SOAP, XML, and the transfer protocol used. The transfer protocol is usually HTTP, but it can also be a SMTP or any standard Internet transport protocol.

Some people think that any FIEFDOM written in Microsoft .NET target language should open their data and functions through the web service. It does not need to open these web services to the outside; the only direct client types can be famished in FIEFDOM.

The inside of FIEFDOM should be constructed on the concept of loosening the FIEFDOM and its clients. FIEFDOM should use stateless service components instead of the status object collection. Its transmission and operational data should be as best as it receives data and passes to the client, that is, XML flow form. Microsoft .NET Framework helps do this because it provides a complete XML-based API to transfer data through FIEFDOM and to the client.

These APIs consist of an ADO.NET XML dataset. ADO.NET's data access feature can easily extract data from any of the database tables, and populate the XML dataset with data. You can easily pass content such as multiple components to users, or even transfers and machine boundaries. In addition, because data contained in the data set can be considered to be easily used XML document, it is very convenient to use it as an XML web service response. Finally, although the data set contains XML, the data to access or operate does not need to use XML syntax. To access properties, you can use ordinary object-oriented syntax, such as TrainerData.trainers (3) .lastname.

We sometimes hear some debate against the use of XML data sets, saying this: "We don't want to disclose the structure of the database to the client." In fact, in most cases, let the database structure affect XML data The structure of the set is very unwise. The use of independent usage should indicate the structure of the data set. You can easily define the structure of the data set, no need to have any association with the structure of the database; it is very possible to define all the data sets of the application before designing the database.

Back to top

Design XML data set according to usage

As an example, you should consider the "View the upcoming schedule" belonging to the game app, we have established the app in front of books and articles. The purpose of this use is to display a list of upcoming schedule. Data needs to include dates, tracks, cities and countries.

Figure 1 XML data set

After knowing the data required for this use case, we can design the XML dataset for it. Figure 1 shows the ideal design of this data set. We can see that this data set only contains a table. The RaceDayTable data table contains all the data required for use. In addition to the RaceDayID column, each column is displayed to the client, as shown in Figure 2. (The RaceDayID column in this data sheet is to allow the user to select a date to display, and then display the detailed game information of the day on another page.) Figure 2 Tailor details

Let's take a look at where the data comes. As shown in Figure 3 (which shows part of the database model of the application), you must create one of the required cases and only one dataset table must access four database tables.

Figure 3 four database tables

If you are interested, let's take another store procedure that can move data from four database tables to a dataset table, which uses a SQL SELECT statement, and only with the database to cross-trip, as shown in the following code:

Create Procedure GetFutureraaceDays AS

Select RacingProgramid As RacedayID, Date, TrackName AS

RaceTrackname, CityName, CountryName

From racingprograms as rp

Join RaceTracks as RT ON (rp.racetrackid = rt.racetrackid)

Join Cities As Ci On (RT.CITYID = CI.CITYID)

Join Countries as co on (ci.countrycode = co.countrycode)

Where Date> getdate ()

ORDER by racingprogramid

As can be seen from this example, the structure of the data set is completely different from the structure of the database. This is because the dataset is designed according to the needs of the singular example, and the database is designed using formal rule, which helps prevent anomalus when data is used.

Back to top

Use custom entity classes

Let us see how if the developer does not want to disclose the structure of the database to the client, how should it be designed. They can choose a status object that represents the so-called "domain model" according to a common design pattern. Of course, the domain model represents a real domain object. In our game applications, the domain model can include classes such as horse, traamers, horses and competitions.

In addition, the actual data source of domain data can also be a database. This is where most structured data storage is stored. Obviously, database models approximate representation, so it is a domain model.

This is why the physical class sets consisting primarily in the application is mainly consistent with the same domain of the same domain in the application of the custom entity class. This is why many developers underestimate the values ​​of the actual data model opposite to class models.

Ideally, the consistency between class models and related domain models should not be so close; the database should be appropriately standardized. The physical classes within the same manner typically generate a large number of actually unwanted code. This will also result in increasing code complexity and slowing operation speed.

Back to top

Map the entity object to the database

Why is the physical class within the memory tend to standardize like a database table? This is mainly due to the fact that the objects and related tables are often used in mutual mapping. Since there are few abnormalities, it is recommended to use memory-based domain models that will also recommend approximately one by one by memory-based class and database tables.

Figure 4 provides a simplified example of the problem facing the client in such a case. In addition to the keys and set classes, it is almost a replica of the database table. It goes without saying that it uses multiple SQL SELECT statements to populate these four entity objects. It is also clear that it takes more time to go four round-trip times with the database. And the benefits are only less dependent on the database.

Figure 4 Map result

It should be understood that the publication of the XML data set to the client application is not equivalent to relying on the client depending on the database. In fact, it is exactly the opposite! But you must understand the XML data set to make full use of them. When defining their XSD scheme, attention should be placed on their usage; simply do not consider the structure of the database. This is especially important in service-oriented applications. A service-oriented application opens to the client to return to the XML stream or an XML document programming interface. This is the case with a service-oriented application for public Web services. The structure of the XML document is controlled by its XSD scheme, the same as the XML dataset (they are actually an XML document).

Back to top

XML dataset never connects to the database

Some developers may not know that the XML dataset is never connected to the database. It is not able to connect to the database. To move data between XML datasets and databases, a class of agents is required to map data set tables to a relational table. ADO.NET provides such objects that have different features for different database products. It is called a data adapter, which is only used to move data between data sets and data sources. The dataset itself does not know any information of the database and the content of the SQL statement to the data set or move the data to the data source.

Then why will this be so confused? Why are so many people believe that the use of data set means depends on the database? The reason may be that the XML data set is in habits, like a replacement of the old recordset for traditional ADO, remote data object (RDO), and data access object (DAO). In all of these models, the record sets are directly connected to the data source (such as a relational database). The only exception is an ADO recordset, which can disconnect the connection with the database and then connect again.

The XML dataset is completely different from the old record set. The purpose is to retain and transmit data snapshots, completely independent of any database that may extract data from it, and ignore it.

Back to top

summary

Next time we will start to introduce a software development project, consider the architecture as FIEFDOM. If your application is to open a user interface (most applications are either this), you should consider the architecture as a set of Emissary. Emissary should try to complete your own work without fiefom, unless you have. For example, they should cache reference data and should retain the session state without with the FIEFDOM. The application of the application constructed in this manner is stronger than the application that utilizes server resources (such as shared data).

This strategy helps you design fiefom to use stateless components. This is very useful for improving scalability and simplicity. However, you should use stateless components in cases. In most applications, you should truly consider using the ADO.NET XML dataset to use it as a data transmitter. Combined with the data adapter, you can use the database perfectly. They are transparently working with the process and machine boundaries and is completely based on XML. They are designed to be data binding, which in many cases, display the preferred method of displaying data to users in a web form or Windows form.

If you want to know more about PAT Helland's Fiefdom and Emissary architectural mode, listen to the architecture network broadcast: Autonomous computing: fiefdoms and emissaries; it is worth listening.

Send you to "Design Mode" and the comments to MMPatt@microsoft.com.

STEN SUNDBLAD and PER SUNDBLAD launched SUNDBLAD & SUNDBLAD ADB-ARKITEKTUR in Sweden, the main business goal of this company is .Net development, specifically the architecture and design. They all wrote Designing for Scalability With Microsoft Windows DNA (Microsoft Press, 2000) and Design Patterns for Scalable Microsoftnet Applications (Sundblad & Sundblad, 2002). For more information on STEN and PER, you can access http://www.2xsundblad.com. You can contact them by STENS@2xsundblad.com and person@2xsundblad.com and person. Go to the original English page

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

New Post(0)