What is the difference between MVP and MVC? : C#

This article will present clear and succinct difference between two architecture presentation patterns i.e. MVP and MVC. Many developers are confused around what is the difference between these patterns.

Here are the key differences between the patterns:

MVP Pattern

  • View is more loosely coupled to the model. The presenter is responsible for binding the model to the view.
  • Easier to unit test because interaction with the view is through an interface
  • Usually view to presenter map one to one. Complex views may have multi presenters.

Continue reading

Advertisements

Why use AsQueryable() instead of List()? : C#

While using data access with the Entity Framework and LINQ, we always return List(), while some of developer prefer AsQueryable().

When we use AsQueryable, it just create a query, which is instruction to get a list. We can make further changes to the query later such as adding new Where clause that sent to the database level.

Returning IQueryable<T> has the advantage, that the execution is postponed until we start enumerating the result and we can compose the query with other queries and still get server side execution.

Continue reading

Local Storage vs Cookies

To reduce load times on our websites, we always cache some item in cookies and local storage. In this article some of differences between “Local Storage vs Cookies” is described.

Both Cookies and local storage serve difference purposes.

Choosing from these two

Cookies are primarily for reading server-side, local storage can only be read client-side.

So choosing from these two location to store data for our app, one question comes that, who needs this data : the client or the server?

If it’s our client (like JavaScript), then we can store all data in local storage.

If it’s our server need data, local storage isn’t so useful because we have to forward the data with each request by somehow (with Ajax or hidden form fields or something).

Diffrence

LocalStorage stays on the client, while cookies are sent with the HTTP header.

Continue reading