Elements Of The Mvvm Pattern

Print   

02 Nov 2017

Disclaimer:
This essay has been written and submitted by students and is not an example of our work. Please click this link to view samples of our professional work witten by our professional essay writers. Any opinions, findings, conclusions or recommendations expressed in this material are those of the authors and do not necessarily reflect the views of EssayCompany.

For each of the underlined items above describe and explain the item (or a closely related set of items working together) using diagrams appropriately—this may include two or more items featuring in the same diagram to show their relationship(s). Each of your item explanations should refer to a relevant operating system and/or software sub-system and/or software library as appropriate.

A Process is known by its execution environment which is an active program entry that has context and a state. It is also a share resources defined by computer system such as memory registers and others (Barrett, 2005).

A thread in operating system is a fundamental unit of CPU exploitation, consisting of a program counter, a stack, and a set of registers and a thread ID. When multiple threads are running concurrently on the computer, this is known as multithreading alike multitasking principally, an operating system with multitasking capabilities will allow programs or processes to run apparently at the same time. On the other side a single program with multithreading capabilities will consent to entity sub-processes or threads to run ostensibly at the same time (Massa, 2002).

Memory management is the behaviour of a computer operating system responsible for maintaining computers primary memory. It maintains the track status of each memory location whether allocated or free. If there is required to send data through the kernel such as a message of a known size with or without a header or a flag to notify an event for processing .Memory management maintains this process. Some process such as scheduler or task manager generates some information by signal and lets another process to take note or uses it through the kernel functions for the PCs.This mechanism is known as Inter-process communication (Menaker & Guttigoli, 2000).

Middleware is software that enables services to connect individual or different software applications together. It allows multiple processes running at one or more machines to interact in a network (Hofmeister, 2000).

Software framework libraries are an abstraction in which software providing generic functionality can be selectively changed by additional user-written code, thus providing application-specific software. An application domain is the CLR correspondent of an operation system's process. An application domain is used to segregate applications from one another. This is the same way an operating system process works. The division is required so that applications do not affect one another (Gschwind & Mascolo, 2005).

The Application specific Library is a multipurpose auxiliary library that provides various functions related to the development and use of applications (Silbertchaz, n.d.).

(b)[5 marks]

Differentiate between a paradigm, a design pattern and an architectural pattern giving two examples of each and justifying why each of your six examples fits into the category you have selected for it.

Answer:

We differentiate paradigm, design patterns and architectural patterns in term of their characteristics and performance. Paradigms are specific to programming language where design patterns solve reoccurring problems in software construction. On other hand, architectural patterns are just a fundamental structural organization for software systems (Buschmann et al., 2007).

Moving to prototype, we can characterize it as instruction that repeats. Now the description of design pattern is building something that repeats in mind or capturing design ideas as a pattern of given problems. Design Pattern supply solution that can be used every time from the core solution. However, sometime accomplishment may fluctuate and the reason behind that is we have the core solution and not the precise solution. We have discussed example of database normalization. Normalization is patterns which have Core solution to database design .However; the level of normalization required for exact solution depends on context and requirement (Oquendo, 1973).

An architectural pattern communicates an image of a system. It is known as the pattern that solves and outlines some essensial cohesive elements of software architecture. Different architecture may execute the same pattern and share the related characteristics. For example the layered architecture is a call and return method because it state an overall style to interact to those method. As it is strictly described and generally obtainable, it is a pattern (Buschmann et al., 2007).

(c)[5 marks]

Describe and explain the Pipes and Filters Architectural Pattern with particular reference to its use in the UNIX command shell (or similar) context. You should use examples to explain the advantages when pipes are used effectively and point out the problems that can occur when they are not used appropriately.

Answer:

Pipes and filters consist of a chain of processes, arranged in such a way that the output of

Each element of the chain is the input of the next. They are also known as pipelines. As all pipes and filters are active on, as they accept data, on it in the case of filters, and send it to the next step (Buschmann, 1996).

The uses of this pattern are:

A filter is a small and specialized program in UNIX- like operating systems that transforms plain text data in some meaningful way. . The flexibility of UNIX pipes made the operating system a platform for the binary reuse of filter programs and for application integration.CMS pipeline is the system utility of IBM mainframes to support pipes and filters architectures. It provides a reuse and integration platform in the same way as UNIX (Buschmann, 1996).

The advantages of using pipes and filter architectural pattern are:

It enforces sequential processing.

It is easy to wrap it in an atomic transaction.

Reuse of filter components.

Efficiency by parallel processing.

The problems that can occur in pipes and filter architectural pattern are:

If processing stage require to distribute a great amount of global data, using pipes and filter is either inefficient or could not provide the full benefits of this pattern (Buschmann, 1996).

(d)[5 marks]

Describe, using text and diagrams, and discuss how pipes can be implemented effectively (i) between two processes on the same computer, and (ii) between two processes on two different computers connected by a network. You should take into consideration in each case whether synchronization is required and, if it is, describe and explain a suitable mechanism.

Answer:

wikipedia.org.png

Figure: Pipeline of three programs

A pipeline of all those three programs operate on a text terminal reference to computer memory, a pipe is a temporary section of computer memory capable of linking two or more computer processors, increasing the overall efficiency of the computer.

The pipelines can be implemented effectively between two processes on the same computer by initiation of all rudiments at the same time as processes. In other common models, elements are implemented lightweight threads or as co-routines to reduce the OS overhead often concerned with processes (Buschmann, 1996).

The pipelines can be implemented effectively between two processes on two different computers connected by a network is given below: All processes of a pipeline begin at the same time, with their streams joined appropriately, and operated together by the scheduler with all other processes running on the machine (Buschmann, 1996).

Question 2 [20 marks]

(a)[5 marks]

Describe and draw diagrams for each of the following patterns and explain why they are related to the Broker pattern:

Forwarder-Receiver

Proxy

Client-Dispatcher-Server

Mediator

Cite the sources you referred to in formulating your answers.

Answer:

Forwarder Receiver

This pattern is used in communicating between peers. Each peer communicates with the other with the help of forwarder and receiver. The forwarder acts as a client and allows a communicating peer to forward message to it. The receiver acts as a server and waits for the peer to read a message (Oquendo, 1973).wwwgliffycom.png

Figure: Forwarder Receiver

Proxy

Proxy object acts as the agent between the client and the target object.

The classes and or object participating in this pattern are (Oquendo, 1973) .

Proxy maintains an orientation that lets the proxy way in to the real subject.

Further responsibilities depend on the kind of proxy. Remote proxies are responsible for encoding a request and its arguments and for sending, the encoded request to the real subject is a different address space.

Virtual proxies may cache additional information about the real subject.

Protection proxies checks that the caller has the access permissions required to perform a request

Subject

If defines the common interface for Real Subject and Proxy.

Real Subject

It defines the real object that the proxy represents real

real Subject

Request ()

Client

Subject

+request ()

real subject

+ request ()

Proxy

+ request ()

real subject

Fig: Proxy

Client Dispatcher Server

In this pattern, the server registers itself with the dispatcher. After a while, a client asks the dispatcher for a communication channel to a specified server. As the dispatcher is responsible for establishing the communication channel between a client and a server, it establishes a communication link to the server. If it cannot initiate the

Communication, it sends the client an error message (Oquendo, 1973).

cdsDynamics.gif

Figure: Client Dispatcher Server

The client uses the communication channel to send a request directly to the server. After recognizing the incoming request, the server executes the appropriate service. After the service execution is completed, the server sends the result back to the client.

Mediator

Mediator defines an object that encapsulates how a set of object interacts. Mediator component helps to communicate between two objects that reduce those dependencies between communicating objects. The mediator component helps in communicating between two objects (Frank Buschmann, n.d.).

mediator_implementation_-_uml_class_diagram.gif

Figure: Mediator

(b)[5 marks]

Describe and explain how the Broker pattern could be applied to peer-to-peer networking and what advantages would thereby accrue. Discuss why multiple Brokers might be preferable. Draw relevant diagrams and cite the sources you referred to in formulating your answers.

Answer

Peer to peer networking allows sharing files, printers and other resources across all of the devices. Broker pattern allows in coordinating communication.

The advantage of broker pattern includes the following:

Isolation: extrication all the communication-related code into its own layer to isolates it from the

application.

Simplicity: Encapsulating complex communication logic into a detach layer breaks down the problem space.

Flexibility: Encapsulating functions in a layer allow swapping this layer with a different implementation.

The advantages of using multiple brokers are:

Work seamlessly with different providers on behalf of customers. It includes taking care of system provisioning, monitoring, billing, etc.

No longer locked in with a particular service provider.

Maximize performance/price ratio of cloud services by shuffling workloads among the providers.

fig-0.png

Figure: Peer to peer networking

(c)[10 marks]

Consider application processes that cooperate at the level of objects via published interfaces (for example COM, DCOM, CORBA). A process calls a method of an interface implemented in a second process. The method has parameters including complex data structure values and reference parameters but is a procedure with no return value. The two processes are on different computers.

Describe and explain in detail, with appropriate diagrams, how DCOM enables the calling process so that it is able to (I) determine whether an object of the specified class exists and can be instantiated on the target computer, (ii) cause an object of the said class to be instantiated on the target computer and gain access to the desired interface, and (iii) make a successful call to the method taking into account the types of parameters described above.

Answer:

DCOM is a proprietary Microsoft Windows expertise that enables software mechanism to communicate directly over a network. Components on a server and a client need to be configured

and must keep up a correspondence with each other to facilitate the DCOM network communication (Frank Buschmann, n.d.). 

DCOM does not transparently provide load balancing.

DCOM_Architecture (1).gif

Figure: DCOM

To access the dcom object:

Var type = Type.GetTypeFromCLSID (new Guid (CLSID), Environment.MachineName, true);

Vac COM Object = Activator.CreateInstance (type);

Var return Value = COMObject.GetType ().Invoke Member (method Name, flags, null, COMObject, args, argModifiers, null, null);

(Anon., 2010)

Question 3 [20 marks]

(a)[7 marks]

Software Architecture ‘principles’ are intended to ‘improve’ the software we create. What does this mean in real-world terms? How do we measure such ‘improvement’? What are the ‘quality factors’ we must consider? What are the costs we must be concerned with? What failures are we trying to avoid?

Describe and explain the factors that contribute to the creation of high quality software by answering the questions above. Cite the sources you referred to in formulating your answers.

Answer:

The improvement can be measured through its reliability, efficiency, flexibility etc which does matter in this real-world term.

The quality factors we must consider are:

Reliability

Integrity

Usability

Flexibility

Maintainability

Testability

Portability

Reusability

Interoperability

Efficiency

Correctness

The cost factors we must consider is time spend in development and parts of development phase, as including human and other resources (Oquendo, 1973).

The factors that contributes to the creation of high quality software are listed below

Good communication skills: if there is good communication between a project leader and other participants then people will get easy to work with. So, a project leader should have good communication skills which include patience, tactful, good writing clear English speaking etc.

No bad politics: if political process takes place in project then people became frustrated and leave the project. Therefore, to maintain a good policy in project is the most important.

Good Social engineering skills: To contribute for the project, project leader can use some genuine words like saying thank you or congratulating people for their contribution etc. it helps in using program more fun and less frustrating.

Hype

The project will be succeeded only if a project receives a lot of negative hype.

Good Software management

The sources from which good advices can be taken for good software management should be used.

Bad testers

A lot of feedbacks can be obtained if there are beta testers for code.

Automated tests

Writing automated tests before writing the actual code and accumulating such tests is a good practice, which aims in maintaining high quality.

Having modular, well written code

The faster development will take if a projects code is modular

A good name

Finally, a project should have good name which also helps in software quality.

The failures we are trying to avoid are:

Lack of preparation

The reason that a project fails is poor planning. So, there should be good planning.

Business Misfit If a technology doesn’t fit with the business needs, the project has the potential to be a waste of money.

Unilateral decision making

When IT fails to involve business leaders while planning new initiatives that affect business operations, the technology department risks a business misfit. Putting everyone at the same table ensures that nobody makes a short sighted unilateral decision.

Inflexibility

Inflexibility is a project killer. Businesses that can move quickly to adjust to the market’s changing needs are able to put themselves in a position of growth.

Scope creep

It is the opposite problem of inflexibility, where IT and business managers are so "flexible" that they bloat the project costs with a million bells and whistles added once the project gets underway (Buschmann, 1996).

(b)[7 marks]

In the context of object-oriented design SOLID brings together a set of principles that can contribute positively to the creation of software systems.

Describe and explain, in your own words, inventing your own examples and citing your sources, (i) what positive contributions are to be expected, and (ii) what each principle is and why each principal is useful.

Answer:

The following aims to explain the five SOLID principles.

Single Responsibility Principle (SRP)

It states that every class should only have are reason to change making sure that a class has a single responsibility makes it per default also easier to see what it does and how you can

Lengthen or improve it. In little it means that like things should be collectively and nothing more.

Open/Closed Principle

It says that a class should be open for extension but closed for adaptation.

Linked Substitution Principle

Derived Classes must be substitutable for their base classed. It means that method/class preconditions cannot be strengthened, past conditions cannot be weakened, all exceptions thrown must equally identical, and method signatures should be completely compatible.

Interface-Segregation Principle

Make fine grained interfaces that are client specific.

Dependency Inversion

Principle Depend on abstractions, not on concretions. In real world, it means when we have to introduce class dependencies, we should be as broad as

Possible in what we expect.

(Anon., 2009)

(c) [6 marks]

Using Visual Studio 2012 and C# create a well-documented console application that demonstrates clearly the following three forms of Dependency Injection (sometimes referred to as Inversion of Control): (i) interface injection, (ii) setter injection, and (iii) constructor injection.

Answer:

The following program is console application that demonstrates clearly the three forms of Dependency injection developed in Visual Studio 2012 and C#.

Using System;

Using Const=DependencyInjection.Constructor;

using Prop=DependencyInjection.Property;

Using Inter = DependencyInjection.Interface;

Namespace Dependency Injection

{

class Program

{

static void Main(string[] args)

{

IFareCalculator constFemaleFareCalculator = new FemaleFare();

//Contructor Dependency Injection

//Dependent Calculator passed through constructor

Const.Calculator constCalculator = new Const.Calculator(constFemaleFareCalculator);

constCalculator.Rate = 2.0;

Console.WriteLine("Constructor Injection : {0}", constCalculator.CalculatedRate);

IFareCalculator propDisableFareCalculator = new DisableFare();

Prop.Calculator propCalculator = new Prop.Calculator();

//Property Dependency Injection

//Dependent Calculator set on the Calculator property of PropertyInjectionCalculator

propCalculator.RateFareCalculator = propDisableFareCalculator;

propCalculator.Rate = 4.0;

Console.WriteLine("Property Injection : {0}",propCalculator.CalculatedRate);

IFareCalculator interStudentFareCalculator = new StudentFare();

Inter.Calculator interCalculator=new Inter.Calculator();

//Interface Dependency Injection

//Dependent Calculator set on the Interface through method SetRateCalculator method

interCalculator.SetRateCalculator(interStudentFareCalculator);

interCalculator.Rate = 2.0;

Console.WriteLine("Interface Injection : {0}", interCalculator.CalculatedRate);

Console.ReadKey();

}

}

}

Question 4 [40 marks]

(a)[10 marks]

Draw a diagram of an interactive application that implements the Model View Controller (MVC) pattern. The application can display two views of the application’s data (but only one view at a time). Label the Model, View(s) and Controller elements in your diagram. Show (and label appropriately) the interactions between the Model, View(s) and Controller elements as well as where the application’s data is received, manipulated and returned to an associated data store.

Describe and explain, with reference to your MVC diagram, the role of each of the three elements and the interactions between the elements, the data store, the user interface and the user.

Answer:

MVC architecture is very comparable to a client/server model, apart from that all the components are bundled into one application. The design patterns are valuable, but their benefit is not only in creating re-usable, easy to understand code - but, more importantly in helping the way that programmer think about programs. Traditional MVC did not anticipate its use on the web. With the donation of UI happening in the browser and the controller on a remote server, MVC on the web is also multi- tier architecture. MVC is just not alarmed where it happens. But the most substantial thing is that whatever the platform is, its model is already designed as per for platform independency. It depend upon a users what they call upon and to the controller to response their respective call. The most important part here is the nature and functionality of controller. All characteristics to execute depend upon a controller as what view to push toward users' call. Elaborating more design can be totally different but the logic inside the particular design is same for PC and Smart phones. As to understand, design are made for compatibility for different platforms but the logic or code inside the design are global in nature or its same for PC and Smart phones. As the diagram below describes well on this topic:

Figure: MVC architecture images.jpg

Therefore, MVC is best suited for these types of applications. As per design it’s more effective from each point of view in MVC pattern but yes, someone can argue the design as a big head but to make it compatible it’s really essential to follow the MVC pattern by designing more than one model (Hall, 2010).

(b)[8 marks]

Present and discuss the rationale of the MVC pattern in the context of an application that must work well on both smart phones and desktop computer systems where the application data store is only accessible over the Internet. Set out, with justification, why MVC is best suited to this type of application and the problem sit is designed to avoid.

Answer:

To use the Model-View Controller MVC paradigm effectively we must point to the division of labour within the MVC triad. And they are of it has got three parts of the triad communicate with each

Other and with other active views and controllers; the distribution of a single mouse, keyboard and display screen among several applications demands communication and cooperation. To construct the best use of the MVC the presented subclasses of View and Controller which provide ready-made starting points for your applications (Hall, 2010).

As MVC has following benefits:

Separation of concerns:

It allows the re-use of the business logic across applications separating all components in three parts.

Developer specialization and focus:

The developer of User Interface will be able to completely focus on the User Interface screens and developer of Model will be able to completely focus exclusively on the business logic executions, transformation, updating without relying the feel and look .It has nothing to with business logic.

As per all the benefits discuss above MVC is best suited to develop such applications which would be displays in different platform as like in PC or Smart phone (Silbertchaz, n.d.).

(c) [12 marks]

Draw a diagram of an interactive application that implements the Model View View-Model (MVVM) pattern. The application can display several views of the application’s data simultaneously. Label the Model, View(s) and View-Model elements in your diagram. Show (and label appropriately) the interactions between the Model, View(s) and View-Model elements as well as where the application’s data is received, manipulated and returned to an associated data store.

Describe and explain, with reference to your MVVM diagram, the role of each of the three elements and the interactions between the elements, the data store, the user interface and the user.

Answer:

Model view view Model (MVVM) is an architectural pattern used in software engineering. The MVVM pattern was conceived to support WPF and silver light. MVVM is a design pattern for building user interfaces (Haldar & Aravind, 2009).

mvvmarch.jpg

Figure: Model view view Model (MVVM)

Elements of the MVVM pattern include:

Model: it represents objects and operations of business domain. It doesn’t contain any information about the users interface.

View: it is element of user interface (UI) that represents the state of the view model. It display information from the view model, send commands to the view model and when the state of the view model changes, it update.

View Model: It is a pure-code representation of the data and operation as a UI. It is not the UI itself. Although it is not he persisted data model, it holds the unsaved data which the user is working.

View model is a model of the view. It acts as an intermediate class between model and view as they references the model and calls method as the model to retrieve domain objects, which are typically exposed to the view.

MVVM consists of a view that gets all the user input and forwards it to the view model, by using commands. The view actively pulls the data from the view model by using data bindings. The model does not know about the view model (Hall, 2010).

(d)[10 marks]

Explain (using an appropriate example and code snippets) why the MVVM application pattern is favoured for applications built using Microsoft Windows Presentation Foundation (WPF). Your explanation should include the relevance of XAML and data binding in this context. Cite the sources you referred to in formulating your answers.

Answer:

Model view view Model (MVVM) is an architectural pattern used in software engineering. The MVVM pattern was conceived to support WPF and silver light. MVVM is a design pattern for building user interfaces.

Elements of the MVVM pattern include:

Model: it represents objects and operations of business domain. It doesn’t contain any information about the users interface.

View: it is element of user interface (UI) that represents the state of the view model. It display information from the view model, send commands to the view model and when the state of the view model changes, it update.

View Model: It is a pure-code representation of the data and operation as a UI. It is not the UI itself. Although it is not he persisted data model, it holds the unsaved data which the user is working.

View model is a model of the view. It acts as an intermediate class between the view and the model as it references the model and calls method as the model to retrieve domain objects, which are typically exposed to the view (Hall, 2010).

MVVM consists of a view that gets all the user input and forwards it to the view model, by using commands. The view actively pulls the data from the view model by using data bindings. The model does not know about the view model (Frank Buschmann, n.d.).

MVVM pattern was possible because of new concepts that came into being as part of the WPF (and later Silver light).

WPF Bindings - Each binding joins two properties (possibly from two different objects) so that if one of them changes, the other changes too.

WPF Data Templates, change non-visual data (View Model) into its visual representation (View).

WPF Commands provide to pass the events from the Views to the View Models.

All of the WPF Commands, WPF Bindings, provide interactive functionality for communications between the View and the View Model. Another method such as C# events can be used to trigger a change within a View when something takes place within its View Model (Hall, 2010).



rev

Our Service Portfolio

jb

Want To Place An Order Quickly?

Then shoot us a message on Whatsapp, WeChat or Gmail. We are available 24/7 to assist you.

whatsapp

Do not panic, you are at the right place

jb

Visit Our essay writting help page to get all the details and guidence on availing our assiatance service.

Get 20% Discount, Now
£19 £14/ Per Page
14 days delivery time

Our writting assistance service is undoubtedly one of the most affordable writting assistance services and we have highly qualified professionls to help you with your work. So what are you waiting for, click below to order now.

Get An Instant Quote

ORDER TODAY!

Our experts are ready to assist you, call us to get a free quote or order now to get succeed in your academics writing.

Get a Free Quote Order Now