Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a generic function to integrate integral_x_0^x_f y(x)dx with the following

ID: 3864609 • Letter: W

Question

Write a generic function to integrate integral_x_0^x_f y(x)dx with the following format function I = integrator (x,y, method) where x is a vector and y is a matrix whose columns y(:,j) are vectors of the same length as x and contain equally spaced data points. The output I is a row vector whose elements are the integrals of each column of y with respect to x. In other words, the j^th element of I is I(j) = integral_x_0^x_f y(:,j)dx. method is the technique used, and should either be the string 'trap' for the trapezoidal rule or 'simp' for Simpson's 1/3 rule. If the method argument is missing in the integrator function call, the default method should be set to the trapezoidal rule The integrator function should evaluate the number of intervals to integrate and should check that this number is even when Simpson's 1/3 is selected; if that's not the case, the function should stop and print an error message warning the user The integrator function should contain 2 subfunctions (local functions), one to implement the trapezoidal rule and one to implement Simpson's 1/3 rule. No loop should be used (use vector operations only). Check your subfunctions with simple problems for which you know the answer.

Explanation / Answer

Integrate applications at the business logic layer by allowing the business function in one application (the source) to be accessed by other applications (the target), as shown in Figure 1.

Figure 1. Integrating applications at the business logic layer

For an external application to integrate with the source application through Functional Integration, the following two conditions must be met:

The business function that you want must be available inside the source application's business logic.

The API of the source application must be accessible remotely.

If the desired business function is not available, you have to modify the source application to make the function available. If modifying the source application is not feasible, you should add the new function outside the source application and then communicate with the application through another form of integration, such as Data Integration or Presentation Integration. This approach has fewer side effects and is generally available for most types of applications.

Many applications only expose their business functions as a local API that is dependent on a specific programming language such as C++ or C#. In those cases, a local adapter or middleware interface has to be created that translates incoming messages from other applications into local API calls. Likewise, results from API calls are translated back into messages. In most cases, such an adapter can be generic enough to support a variety of different functions without having to be modified for each individual function that you want to make available externally.

Functional Integration is very versatile because many different operations can be performed though an API. A functional interface can retrieve data, update data entities (change an address), or perform business functions (validate a credit card). In fact, one common use of Functional Integration is to ensure data consistency between applications [Ruh01].

Functional Integration is based on the interaction between the components that are described in Table 1.

Table 1: Functional Integration Components

Components

Business logic

Responsibilities

Executes local business functions

Collaborators

Middleware interface

Components

Middleware interface

Responsibilities

- Converts incoming messages into method invocations of functions that reside in the business logic
- Converts return data back into messages that can be transported across the network

Collaborators

Business logic and remote application

Components

Remote application

Responsibilities

Consumes functions that reside in the application

Collaborators

Middleware interface

Resulting Context

After you decide to use Functional Integration, you must choose a particular kind of integration that is appropriate for your situation. Your choices are summarized by the following patterns:

Distributed Object Integration

Message-Oriented Middleware Integration

Service-Oriented Integration (through XML-based Web services)

Distributed Object Integration

Distributed Object Integration is also known as instance-based collaboration because it extends the model of object-oriented computing to distributed solutions. Objects inside one application interact with objects in another remote application in the same way that they would interact locally with another object. This implies that the interaction occurs with a specific object instance and that the client application often manages the lifetime of the object it is accessing. This type of interaction usually seems natural to application developers, but it can result in a complex and tightly-coupled interaction model between the components. This tight coupling is not a problem as long as the components are part of a single distributed application. However, it is generally not a good choice when integrating multiple stand-alone applications.

Great examples of distributed component middleware are technologies such as .NET remoting, COM+, or CORBA. For more information, see the Remote Procedure Invocation pattern [Hohpe04] or the "Distributed Systems" chapter in Enterprise Solution Patterns Using Microsoft .NET [Trowbridge03].

Message-Oriented Middleware Integration

Message-Oriented Middleware Integration connects systems by using asynchronous message queues that are based on proprietary message-oriented middleware. The connected systems then communicate by using messages that contain small packets of data. Because the communication is asynchronous and durable, there is little chance of the messages being lost during network or system failure.

To share request/response type functionality, the consuming system must create a request message and send it by way of the message queue to the system that provides the functionality. The provider then takes the message from the queue, interprets it as a request, and processes it. Upon completion, the provider creates a response message and sends it back to the functional consumer by way of the message queue. Of course, not all functionality is shared by using a request/response style collaboration, but similar principles apply. For more information, see the Messaging pattern [Hohpe04].

Service-Oriented Integration

Service-Oriented Integration connects systems by enabling them to consume and provide XML-based Web services. The interfaces to these systems are described through Web Services Definition Language (WDSL) contracts. Systems interact with each other by using SOAP messages. SOAP messages are usually conveyed through HTTP by using XML serialization.

Note: The term service is used in many different ways in the context of software engineering. It is also used in at least seven levels of scope: operating system, process, object, distributed object, proprietary message-oriented middleware, logical, and XML Web services. This guide uses the term service to mean XML Web services unless indicated otherwise.

A Service Interface [Trowbridge03] exposes functionality as a Web service, and, a Service Gateway encapsulates the logic necessary to consume services (see Figure 2).

Figure 2. Using a service gateway and service interface to connect a Web service consumer and provider

Using Service-Oriented Integration increases interoperability by using XML and XML Schema as the basis of message exchange and by using SOAP as an extensible messaging framework. XML Schema provides for a type system that is portable between disparate technical architectures. In contrast, SOAP can be bound to a number of different transport mechanisms. For more information, see Service-Oriented Integration.

Choosing Between Alternatives

There are many factors to consider when choosing the kind of Functional Integration that is best for your particular requirements. Some of these factors include:

Reliability and latency of the network between endpoints

Interfaces exposed by your current systems

Need for interoperability between disparate technical architectures

Performance

Fragility, if incompatible updates are introduced to any participant

Expertise of the technical team

Existing infrastructure

Components

Business logic

Responsibilities

Executes local business functions

Collaborators

Middleware interface

Components

Middleware interface

Responsibilities

- Converts incoming messages into method invocations of functions that reside in the business logic
- Converts return data back into messages that can be transported across the network

Collaborators

Business logic and remote application

Components

Remote application

Responsibilities

Consumes functions that reside in the application

Collaborators

Middleware interface

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote