Wednesday, March 17, 2021

Angular Interview Questions with Answers

Below is video covering 25 most important Angular Interview Questions and Answers do refer the same: -

C# Interview Questions and Answers

Below is video covering 30 most important C# Interview Questions and Answers do refer the same: -

ASP.NET MVC Interview Questions with answers

Below is video covering 25 most important ASP.NET MVC Interview Questions and Answers do refer the same: -

Tuesday, November 20, 2018

Concurrency VS Parallelism.

Actual Parallelism VS feel of Parallelism

Why a feel of parallelism and why not actual?

Concurrency is about design, parallelism is about hardware’s


Further readings

Actual Parallelism VS feel of Parallelism

Technical vocabulary in IT industry are sometimes very confusing and “Concurrency” and “Parallelism” is one of them. Many developers think “Concurrency and parallelism means executing at the same time” which is right 50% but with one big difference:-

  • Concurrency gives you a feel of parallelism and parallelism as the name implies is actual parallelism.

Feel of parallelism means you execute multiple tasks on the same core and the core switches context between tasks and serves them. You can also term this has time slicing / over lapping time period because your single core is just dedicating some time to one task and then some time to other.

Actual parallelism means you execute multiple task on multiple cores parallely.

Note: - “Concurrency is a broader term and Parallelism is subset of it”.

Mapping to the real world the left image depicts parallelism the right image depicts concurrency.

Why a feel of parallelism and why not actual?

In order to achieve actual parallelism we need dedicated cores, separate memory and so on.

Let’s say we want to show a progress bar for some task completed. Now we really do not want to have separate cores allocated to display the progress.

We do not want PERFORMANCE here we want that physiologically the end user feels both tasks are happening simultaneously.

We want to just beat the human eye capability of 100 FPS and give an illusion of parallelism without stressing our computer resources. But let’s say we want to process big excel files with million records then yes we would love to have actual parallelism to achieve performance.

Concurrency is about design, parallelism is about hardware’s

In order to achieve concurrency we need to compose our application logic independently. For instance let’s say you want to process employee data where you want to increment the salary by x% and bonus by x%.

So you can decompose the application in to logical units by following different designs:-

Design 1

  • Divide data in to 50% size each.
  • Process each 50% as separate unit.

Design 2

  • Process bonus calculation as separate unit.
  • Process salary calculation as separate unit.

Design 3

  • Divide data in to 50% size each.
  • For every 50% data process bonus calculation separately and salary calculation separately.

There can be many such designs and combination. So when you say your application is supporting concurrency your application should be composed in to small independent units.

Now you take these units and run on one core (Concurrency) or you run on multiple cores (Parallelism). So concurrency is about design while on parallelism we talk more from hardware perspective, 2 core, 3 cores and so on.

If you try to run every concurrent code as parallel you have resource starvation unnecessarily. So ask yourself do you want an illusion (concurrent) or do you performance (parallel).


Concurrency Parallelism
Basic definition Executing multiple task on same core using overlapping or time slicing. Executing multiple tasks on different core.
Goal Feeling of parallelism without stressing out resources. Actual parallelism for performance.
Perspective Software design: - Composition of independently executing computations in a co-operative fashion. Hardware: - Executing computation parallel.
Resource utilization Light Heavy
  • Parallelism is a subset of concurrency.
  • Concurrency enables parallelism.
  • Concurrency is more about software design while parallelism is more about hardware’s.
  • Concurrency gives an illusion of parallelism while parallelism is about performance.
  • Concurrency just needs one core while parallelism needs at least 2 cores.

Further readings

Concurrency is not parallelism by Rob pike

Nice discussion on concurrency and parallelism

Monday, June 11, 2018

bin vs obj folders in C#.

When we compile C# programs you would see 2 folders “bin” and “obj”. In this article we will try to understand the difference and importance of these folders.

Both these folders have compiled IL code, but the question comes is why not just one folder and why two folders?.

We have two folders because the compilation process goes through two steps compiling and linking. See the below diagram.

  • In compiling phase every code file is compiled in to individual compiled units. So if you have two code files two independent compiled codes will be generated.
  • In linking phase all these compiled code files are linked and compiled in to single unit assembly which can be a DLL or EXE.

If you compare both the folders ( see below image) you will find more files in “obj” folder as compared to “bin” folder. We have more files in “obj” folder because it creates seperate compiled code files for each source code file.

So the next question which comes to our mind why do we need compiling in two phase, why not just do it one go. By doing the two phase compiling we achieve incremental or conditional compiling.

When we work with big projects we will have lot of code files and we would like to only compile those code files which have changed. In the “obj” folder we have entry of each code file compilation. So we can know from the same which files exactly have changed , thus making compiling fast.

In summary in “obj” folder have compiled files for each source code file and in “bin” folder we have a single unit which links all individually compiled code files.

Below is 10 minutes youtube video which demonstrates how these both folders look like and how incremental compilation happens.

Friday, November 3, 2017

What is the best project folder structure for Angular projects?

There no straight answer to this as every project is different, developers are of different mindset and architecture have their own though process.

But whatever it is you will end up with some kind of nearby folder structure for angular as shown below:-

  • You will need two root folders one for the server code and the other for client code. The client code folder sometimes is also named as “app”.
  • If you have a big project then inside in the client folder you can create sub folder which represent modules of your project. Normally developers divide project in modules for better management so these subfolders represent those modules.
  • In this those module folder you can have separate folder for component, model, module and routing.
  • A common folder is also needed where in you can push your common utilities like common pipes, filters, http components, injectables and so on.
  • Server folder will have its own folder structure depending on whether you are doing ASP.NET or JSP or PHP. In this discussion we will restrict only to client side angular folder structure.

This question was raised in our Mumbai angular training of 86th batch