4. (Alternative Implementation of the DVM Problem) The solution of the DVM system in this chapter was

Question:

4. (Alternative Implementation of the DVM Problem)

The solution of the DVM system in this chapter was based on C++ templates and PBD. This may not be the most suitable approach in all situations. More importantly, developers may feel more comfortable with class hierarchies and subtype polymorphism

(which many C++ legacy systems use). For this reason, implement DVM using class hierarchies and virtual member functions. To this end, we have implemented DVM in C#

using interfaces and generics and the code is almost in the form that we wish to see in C++. The interfaces (these will be pure abstract classes in C++) and SUD interface are:

// Define the interfaces/contracts public interface ISource

{

string message();

}

public interface IAuth

{

int amount();

void increment(int amount);

void decrement(int amount);
}
public interface IResource {
void displayProducts();
Tuple getProduct(string product);
void updateProduct(string product, int quantity);
}
public interface ISink {
void notify(string prod, bool status);
}
public interface IMIS {
void notify();
}
// ** end of interfaces // Notation: G{Sys} == Generic system, not instantiated public class DVM
where GSource : ISource where GAuth : IAuth where GResource : IResource where GSink : ISink where GMIS : IMIS {
private ISource iso_;
private IAuth ia_;
private IResource ir_;
private ISink isi_;
private IMIS im_;
// More }
Answer the following questions:

a) Implement DVM in C++ using C# as baseline requirements. Emulate C# interfaces using C++ pure abstract base classes. Test the program and check that the output is the same as before.

b) Compare all solutions in terms of efficiency, maintainability, extendibility and replaceability of components at run-time. The answers will help you decide which option is most suitable in a given context.

c) Consider the option of using C++ universal function wrappers and the Boost C++ signals2 library as a means to allow the SUD to communicate with the external world.
What are the advantages and disadvantages when compared to the other solutions?

Consider issues such as shared/non-shared state, event-driven programming, maintainability and whether data is pushed or pulled.

d) Discuss the feasibility of implementing the SUD using variadic template parameters.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: