Monday, December 25, 2017

What is Progressive Web App

Progressive Web App or PWA are mobile sites that offer functionalities of a native app. A user can access this site through any browser like a conventional website, but this site will store all the important information (interaction data) of the user like apps, helping you create a better experience for him the next time he returns to it.

Originally proposed by Google in 2015, PWAs have already attracted a lot of attention because of the relative ease of development and the almost instant wins for the application’s user experience.

PWA Definition by Google -  
“A Progressive Web App uses modern web capabilities to deliver an app-like user experience.” – Progressive Web Apps


Wait!!! PWA is a mobile site. Don't we have responsive sites that do the same thing.


Understanding the difference between responsive sites and progressive web apps

Responsive websites are designed to cater to audiences coming from different devices – the conventional desktop or any other type of mobile devices. The responsive sites are designed to fit into the screen that they are being accessed on.

Getting all the website elements to fit into a mobile display, requires businesses to sometimes strip a little functionality from the main site. This means you’re not truly offering a mobile first approach to your target market. While the responsive mobile site might serve the purpose up to 80%, a truly mobile centric approach is to add 100% of the functionalities progressively on the mobile site.


Why Progressive Web Apps?

Let’s understand what problems does any user face when installing a native mobile app -
  • Do I have enough space in mobile?
  • My available data is not sufficient.


The average size of apps that we install from play store/app stores would range from 30–200MB. Moreover, these app needs to updated every week!

Progressive Web Apps are within some KBs and are automatically updated.


Features of PWA - 

Progressive - By definition, a progressive web app must work on any device and enhance progressively, taking advantage of any features available on the user’s device and browser.

Discoverable - Because a progressive web app is a website, it should be discoverable in search engines.

Responsive - A progressive web app’s UI must fit the device’s form factor and screen size.

App-like - A progressive web app should look like a native app and be built on the application shell model, with minimal page refreshes.

Fresh - When new content is published and the user is connected to the Internet, that content should be made available in the app.

Safe - Because a progressive web app has a more intimate user experience and because all network requests can be intercepted through service workers, it is imperative that the app be hosted over HTTPS to prevent man-in-the-middle attacks.

Installable - Allows users to install the website as an app on their home screen without the taking user to an app store.

Some Popular Companies that Do Progressive Web Apps -


  • Ola
  • Flipkart
  • pinterest
  • Twitter
  • Alibaba
  • BookMyShow
  • MakeMyTrip
  • OLX
  • The Weather Channel
  • Forbes
  • JioCinema
  • Trivago

Friday, January 13, 2017

Difference between EXE and DLL

In .NET framework, both .EXE and .DLL are called as assemblies. EXE stands for executable, and .DLL stands for Dynamic Link Library

EXE is an executable file and can run by itself as an application, where as .DLL is usually consumed by a .EXE or by another .DLL 

We cannot run or execute .DLL directly. 

For example, In .NET, compiling a Console Application or a Windows Application generates .EXE, where as compiling a Class Library Project or an ASP.NET web application generates .DLL. 


Verbatim string literal in C#


The "@" symbol is the verbatim string literal. 

Use verbatim strings for convenience and better readability when the string text contains backslash characters, for example in file paths. 

Because verbatim strings preserve new line characters as part of the string text, they can be used to initialize multiline strings. 

Use double quotation marks to embed a quotation mark inside a verbatim string. 

The following example shows some common uses for verbatim strings:


string ImagePath = @"C:\Images\Buttons\SaveButton.jpg";
Output: C:\Images\Buttons\SaveButton.jpg



string MultiLineText = @"This is multiline
Text written to be in
three lines.";

/* Output:
This is multiline
Text written to be in
three lines.
*/

string DoubleQuotesString = @"My Name is ""Prakash.""";
Output: My Name is "Prakash."

Wednesday, November 30, 2016

Understading Stack and Heap

The stack is the memory set aside as scratch space for a thread of execution.

When a function is called, a block is reserved on the top of the stack for local variables and some bookkeeping data. When that function returns, the block becomes unused and can be used the next time a function is called.

The stack is always reserved in a LIFO order; the most recently reserved block is always the next block to be freed. This makes it really simple to keep track of the stack; freeing a block from the stack is nothing more than adjusting one pointer.

The heap is memory set aside for dynamic allocation. 

Unlike the stack, there's no enforced pattern to the allocation and deallocation of blocks from the heap; you can allocate a block at any time and free it at any time. This makes it much more complex to keep track of which parts of the heap are allocated or free at any given time; there are many custom heap allocators available to tune heap performance for different usage patterns.

Each thread gets a stack, while there's typically only one heap for the application (although it isn't uncommon to have multiple heaps for different types of allocation).



To what extent are they controlled by the OS or language runtime?
The OS allocates the stack for each system-level thread when the thread is created. Typically the OS is called by the language runtime to allocate the heap for the application.


What is their scope?
The stack is attached to a thread, so when the thread exits the stack is reclaimed. The heap is typically allocated at application startup by the runtime, and is reclaimed when the application (technically process) exits.


What determines the size of each of them?
The size of the stack is set when a thread is created. The size of the heap is set on application startup, but can grow as space is needed (the allocator requests more memory from the operating system).


What makes one faster?
The stack is faster because the access pattern makes it trivial to allocate and deallocate memory from it (a pointer/integer is simply incremented or decremented), while the heap has much more complex bookkeeping involved in an allocation or free. Also, each byte in the stack tends to be reused very frequently which means it tends to be mapped to the processor's cache, making it very fast.


Understanding Generics in C#

Generics allow you to delay the specification of the data type of programming elements in a class or a method, until it is actually used in the program. In other words, generics allow you to write a class or method that can work with any data type.

When the compiler encounters a constructor for the class or a function call for the method, it generates code to handle the specific data type.

Generics is a technique that enriches your programs in the following ways:

  • It helps you to maximize code reuse, type safety, and performance.
  • You can create generic collection classes. The .NET Framework class library contains several new generic collection classes in the System.Collections.Genericnamespace. You may use these generic collection classes instead of the collection classes in the System.Collections namespace.
  • You can create your own generic interfaces, classes, methods, events, and delegates.
  • You may create generic classes constrained to enable access to methods on particular data types.
  • You may get information on the types used in a generic data type at run-time by means of reflection.


Simple example on Generics -

// Declare the generic class.
public class GenericList<T>
{
    void Add(T input) 
   {
      //Do something here
   }
}

class TestGenericList
{
    private class ExampleClass 
   { }
   
    static void Main()
    {
        // Declare a list of type int.
        GenericList<int> list1 = new GenericList<int>();

        // Declare a list of type string.
        GenericList<string> list2 = new GenericList<string>();

        // Declare a list of type ExampleClass.
        GenericList<ExampleClass> list3 = new GenericList<ExampleClass>();
    }

}