Tuesday, September 20, 2016

Interview Question Series - Abstraction and Encapsulation

Abstraction means in object oriented design that , a class should and only include the required functions or methods. like if there is a class of Customer, it should not include any order related details. and it should have only required properties or methods of customer which is going to use in implementation of that class.

Abstraction means to show only the necessary details to the client of the object

another similar keyword is "Abstract Class"
Abstract class in OOD is like interface but can not create objects , it has only required methods/functions which can be used in derived / implemented class.
like a vehicle class can not create object but another derived class of this like CAR can create object or Hyundai, Maruti etc.

Encapsulation is used to hide its members from outside class or interface, this can be done with access modifiers, like public ,private, internal, protected and protected internal. also with proper implementation of get and set properties.

for example, in employee class the calculation of age is not required outside the class, so that method can be created as private and properties of get and set can be defined for date of birth and only get can be defined for Age. there is object have only age get option, there is no set for age property and no calculation method both are hidden inside the class based on encapsulation concept.

details of access modifiers
  • Public: Access to all code in the program
  • Private: Access to only members of the same class
  • Protected: Access to members of same class and its derived classes
  • Internal: Access to current assembly
  • Protected Internal: Access to current assembly and types derived from containing class.

Interview Question Series - Service oriented architecture

Service oriented architecture (SOA) is based on distributed computing where the consumer of service need not to worry about provider's implementation.
in other words, it has loose coupling, where consumer sends a request to provider and provider gives the response. this communication happens based on some rules and XML.

these rules are defined in SOAP/ REST implementation.

here in SOA , our provider can be written in JAVA/ Dotnet, and consumer can also be in different language.  not all code should be in same language.

it is recommended that implementations of SOA should use open standards to realize interoperability.

Change UUID for Virtual box's VDI File

vdi uuid rename command

VBoxManage  internalcommands sethduuid c:\rsoni\VirtualMachines\Win2012R2\Win2012R2.vdi

Thursday, May 19, 2016

Interview Question Series - Architecture Concerns

Interview Question Series - REST vs SOAP

Difference between SOAP (Simple Object Access Protocol) and REST (Representational State Transfer)

      SOAP is standard communication protocol (with some set of rules) and its XML based message exchange. SOAP can use http and SMTP both. In SOAP, the WSDL (web service description language) contain the description for set of rules defined for messages,  binding and operations. for complex Service /application program SOAP is useful and better.

      REST  is based on pure Http, doesn't contain any additional messaging layer, resources can be access from unique URI. It works with standard http operations (methods/Verbs) GET,PUT,DELETE,POST and HEAD. for simple CRUD (create,retrieve, update and Delete) operations the REST is better.

Interview Question Series - Tier vs Layer

  • Layer is a logical separation, how to organize the code. E.g.: presentation (view), controller, models, repository, data access, and Tier is a physical separation, where the code / process runs. E.g.: client, application server, database server;
  • Layers mainly help in architecture principal of Maintainability, to deploy separate code at separate server, in Tier helps in performance where we can improve app performance if we have more then 1 server, like app server and DB Server.
  • Layers are like, presentation layer (or UI), business logic layer and Database Layer, and Tire is like 2 tire , with app server and DB server.

Friday, May 6, 2016

Java language support for .net

If you love C# and Visual studio, and you have some work in java, want to use Visual studio for JAVA language support ? Microsoft already provided one extension for java language in visual studio

here is the link

Monday, April 25, 2016

SHA512 Hash in C#

Computing SHA 512 is easy for dotnet developers. in your application add System.Security.Cryptography, and then use below method for encryption of string which can be plain text.

APISecretKey is privateKey for encryption, which can be empty as well.
EncryptionType parameter shows which type of return value is needed, either in hex format or base64 string.

MSDN reference  is HERE 

Friday, April 22, 2016

How to calculate BMI in HTML and Javascript

as per the formula, we can calculate the bmi with height and weight, if you are creating a simple html page then here is the code to use.


 function calculateBMI() {
            var age = parseInt(document.getElementById("txtage").value);
            if (isNaN(age) || age <= 0) {
                alert("Provide valid Age");
            var weigth = parseInt(document.getElementById("txtweigth").value);
            if (isNaN(weigth) || weigth <= 0) {
                alert("Provide valid weight");
            var height = parseInt(document.getElementById("txtheight").value);
            if (isNaN(height) || height <= 0) {
                alert("Provide valid height");
            var heightPercentage = 1;
            if (height > 10)
                heightPercentage = height / 100;

            var BMI = weigth / (heightPercentage * heightPercentage);
            BMI = BMI.toFixed(2);
            document.getElementById("lblBMI").innerText = "Your BMI is  " + BMI;
            if (BMI > 25)
                document.getElementById("lblBMI").className = "redBMI";
            else if (BMI > 18.5)
                document.getElementById("lblBMI").className = "greenBMI";
                document.getElementById("lblBMI").className = "yellowBMI";
CSS Style 

<style type="text/css">
        .greenBMI {
            color: green;
            font-weight: bold;

        .redBMI {
            color: red;
            font-weight: bold;

        .yellowBMI {
            font-weight: bold;


 Enter the Age : <input id="txtage" type="number" name="age" min="5" max="99" maxlength="2" required />
    <br />
    <br />
    Enter weigth  : <input id="txtweigth" type="number" name="weigth" min="5" max="200" maxlength="5" /> in Kg
    <br />
    <br />
    Enter height :  <input id="txtheight" type="number" name="height" min="5" max="200" maxlength="5" /> in cm
    <br />
    <br />
    <input type="button" onclick="calculateBMI()" value="Calculate BMI">
    <br />
    <span id="lblBMI"></span>

Thursday, April 21, 2016

WCF REST Service Error "Request Entity too large"

Recently I had this issue in my WCF service, this service was for file upload and download.

in uploading the file, WCF was throwing an error of Request entity too large. later after some searching on net, I have found to change the web.config for webhttpBinding, like below.


maxBufferSize="2147483647" transferMode="Streamed">

which worked fine for me.