Wednesday, 2 December 2015

Design Pattern Overview

Design Pattern Overview

Many people teach design patterns as a fundamental step to Object Oriented Programming.
In this post we are going to discussing ideas design pattern more details step by step
with my fellow code junkies.

Now question what actually design patterns represent in software development?
Design patterns represent the best practices used by experienced object-oriented software developers.Design patterns are solutions to general problems that software developers faced during software development.

Design Patterns have two main usages in software development. This are the common platform for developers and best practices.



In this article post discussion will be covering...

1)What they are?
2)Where they came form?
3)Why they matter?

Software professionals may be familiar with the term "Design Patterns," but many have no idea of where they come from and what they truly are.Consequently, some do not see the value and benefits design patterns bring to the software development process.

What Design Patterns are?


  1. General and reusable solutions or template to common problems in software design
  2. Not a finished solution
  3. A template or recipe for solving certain problems
  4. With names to identify them


Patterns deal with:


  1. Application and system design
  2. Abstractions on top of code
  3. Relactionships between classes or other collaborators
  4. Problems that have already been solved


Patterns are not concerned with:


  • Algorithms
  • Specific implementations or classes...


Design Patterns History:
 Design Patterns: Elements of Reusable Object-Oriented Software in 1994 by Gang of Four: Eric Gamma,Richard Helm, Ralph Johnson, and John Vlissides.
This book is considered to be the "coming out" of design patterns to the software community.
In 1998, the Gang Of Four were awarded Dr Dobbs Journal 1998 Excellence in Programming Award.


Design Patterns Structure:

Term Descrition
Pattern Name     Describes the essence of the pattern in a short
Intent Describes what the pattern does
Also Known As    List any synonyms for the pattern
Motivation Provides an example of a problem and how the pattern solves that problem
Applicability                Lists the situations where the pattern is applicable
Structure                     Set of diagrams of the classes and objects that depict the pattern
Collaborations Describes how the participants collaborate to carry out their responsibilities


Design Patterns Benefits
Design patterns have two major benefits. First one, they provide you with a way to solve issues related to software development using a proven solution.
Second one, design patterns make communication between designers more efficient.

Difference between Co-related Sub-Query and Sub-query

Difference between Co-related Sub-Query and Sub-query

Below example is not Co-related Sub-Query. It is Derived Table / Inline-View since i.e, a Sub-query within FROM Clause.

A Corelated Sub-query should refer its parent(main Query) Table in it. For example See find the Nth max salary by Co-related Sub-query:


Technical difference between Normal Sub-query and Co-related sub-query are:

1. Looping: Co-related sub-query loop under main-query; whereas nested not; therefore co-related sub-query executes on each iteration of main query. Whereas in case of Nested-query; subquery executes first then outer query executes next. Hence, the maximum no. of executes are NXM for correlated subquery and N+M for subquery.

2. Dependency(Inner to Outer vs Outer to Inner): In the case of co-related subquery, inner query depends on outer query for processing whereas in normal sub-query, Outer query depends on inner query.

3.Performance: Using Co-related sub-query performance decreases, since, it performs NXM iterations instead of N+M iterations. ¨ Co-related Sub-query Execution.

What is a CLR?


What Is CLR?

Full form of CLR is Common Language Runtime and it forms the heart of the .NET framework.
All Languages have runtime and it is the responsibility of the runtime to take care of the code
execution of the program. For example, VC++ has MSCRT40.DLL, VB6 has MSVBVM60.DLL,
and Java has Java Virtual Machine etc. Similarly, .NET has CLR. Following are the
responsibilities of CLR
• Garbage Collection: - CLR automatically manages memory thus eliminating
memory leaks. When objects are not referred, GC automatically releases those
memories thus providing efficient memory management.
• Code Access Security: - CAS grants rights to program depending on the security
configuration of the machine. Example the program has rights to edit or create a
new file but the security configuration of machine does not allow the program to
delete a file. CAS will take care that the code runs under the environment of
machines security configuration.
• Code Verification: - This ensures proper code execution and type safety while the
code runs. It prevents the source code to perform illegal operation such as accessing
invalid memory locations etc.
• IL (Intermediate language)-to-native translators and optimizer’s:- CLR uses
JIT, compiles the IL code to machine code, and then executes. CLR also determines
depending on platform what is optimized way of running the IL code.

How IIS Process ASP.NET Request

How IIS Process ASP.NET Request

Introduction

When request come from client to the server a lot of operation is performed before sending response to the client. This is all about how IIS Process the request.  Here I am not going to describe the Page Life Cycle and there events, this article is all about the operation of IIS Level.  Before we start with the actual details, let’s start from the beginning so that each and everyone understand it’s details easily.  Please provide your valuable feedback and suggestion to improve this article.

What is Web Server ?

When we run our ASP.NET Web Application from visual studio IDE, VS Integrated ASP.NET Engine is responsible to execute all kind of asp.net requests and responses.  The process name is“WebDev.WebServer.Exe” which actually takw care of all request and response of an web application which is running from Visual Studio IDE.
Now, the name “Web Server” comes into picture when we want to host the application on a centralized location and wanted to access from many locations. Web server is responsible for handle all the requests that are coming from clients, process them and provide the responses.

What is IIS ?

IIS (Internet Information Server) is one of the most powerful web servers from Microsoft that is used to host your ASP.NET Web application. IIS has it’s own ASP.NET Process Engine  to handle the ASP.NET request. So, when a request comes from client to server, IIS takes that request and  process it and send response back to clients.

Request Processing :

Hope, till now it’s clear to you that what is Web server and IIS is and what is the use of them. Now let’s have a look how they do things internally. Before we move ahead, you have to know about two main concepts
1.    Worker Process
2.   Application Pool
Worker Process:  Worker Process (w3wp.exe) runs the ASP.Net application in IIS. This process is responsible to manage all the request and response that are coming from client system.  All the ASP.Net functionality runs under the scope of worker process.  When a request comes to the server from a client worker process is responsible to generate the request and response. In a single word we can say worker process is the heart of ASP.NET Web Application which runs on IIS.
Application Pool: Application pool is the container of worker process.  Application pools is used to separate sets of IIS worker processes that share the same configuration.  Application pools enables a better security, reliability, and availability for any web application.  The worker process serves as the process boundary that separates each application pool so that when one worker process or application is having an issue or recycles, other applications or worker processes are not affected. This makes sure that a particular web application doesn’t not impact other web application as they they are configured into different application pools.
Application Pool with multiple worker process is called “Web Garden”.
Now, I have covered all the basic stuff like Web server, Application Pool, Worker process. Now let’s have look how IIS process the request when a new request comes up from client.
If we look into the IIS 6.0 Architecture, we can divided them into Two Layer
1.    Kernel Mode
2.    User Mode
Now, Kernel mode is introduced with IIS 6.0, which contains the HTTP.SYS.  So whenever a request comes from Client to Server, it will hit HTTP.SYS First.
Now, HTTP.SYS is Responsible for pass the request to particular Application pool. Now here is one questionHow HTTP.SYS comes to know where to send the request?  This is not a random pickup. Whenever we creates a new Application Pool, the ID of the Application Pool is being generated and it’s registered with the HTTP.SYS. So whenever HTTP.SYS Received the request from any web application, it checks for the Application Pool and based on the application pool it send the request.
So, this was the first steps of IIS Request Processing.
Till now, Client Requested for some information and request came to the Kernel level of IIS means at HTTP.SYS. HTTP.SYS has been identified the name of the application pool where to send. Now, let’s see how this request moves from HTTP.SYS to Application Pool.
In User Level of IIS, we have Web Admin Services (WAS) which takes the request from HTTP.SYS and pass it to the respective application pool.
When Application pool receive the request, it simply pass the request to worker process (w3wp.exe) . The worker process “w3wp.exe” looks up the URL of the request in order to load the correct ISAPI extension. ISAPI extensions are the IIS way to handle requests for different resources. Once ASP.NET is installed, it installs its own ISAPI extension (aspnet_isapi.dll) and adds the mapping into IIS.
Note : Sometimes if we install IIS after installing asp.net, we need to register the extension with IIS using aspnet_regiis command.
When Worker process loads the aspnet_isapi.dll, it start an HTTPRuntime, which is the entry point of an application. HTTPRuntime is a class which calls the ProcessRequest method to start Processing.
When this methods called, a new instance of HTTPContext is been created.  Which is accessible using HTTPContext.Current  Properties. This object still remains alive during life time of object request.  Using HttpContext.Current we can access some other objects like Request, Response, Session etc.
After that HttpRuntime load an HttpApplication object with the help of  HttpApplicationFactoryclass.. Each and every request should pass through the corresponding HTTPModule to reach to HTTPHandler, this list of module are configured by the HTTPApplication.
Now, the concept comes called “HTTPPipeline”. It is called a pipeline because it contains a set of HttpModules ( For Both Web.config and Machine.config level) that intercept the request on its way to the HttpHandler. HTTPModules are classes that have access to the incoming request. We can also create our own HTTPModule if we need to handle anything during upcoming request and response.
HTTP Handlers are the endpoints in the HTTP pipeline. All request that are passing through the HTTPModule should reached to HTTPHandler.  Then  HTTP Handler  generates the output for the requested resource. So, when we requesting for any aspx web pages,   it returns the corresponding HTML output.
All the request now passes from  httpModule to  respective HTTPHandler then method and the ASP.NET Page life cycle starts.  This ends the IIS Request processing and start the ASP.NET Page Lifecycle.

Conclusion

When client request for some information from a web server, request first reaches to HTTP.SYS of IIS. HTTP.SYS then send the request to respective  Application Pool. Application Pool then forward the request to worker process to load the ISAPI Extension which will create an HTTPRuntime Object to Process the request via HTTPModule and HTTPHanlder. After that the ASP.NET Page LifeCycle events starts.
This was just overview of IIS Request Processing to let Beginner’s know how the request get processed in backend.  If you want to learn in details please check the link for Reference and further Study section.

Monday, 26 January 2015

Answering the question of the clients asked - oDesk

Answering the question of the clients asked - oDesk

1. What past project or job have you had that is most like this one and why?

Ans: According to your job requirements, I have done many projects like yours. For more details you can check my portfolio, profiles and employment history where you will find the similar projects like your desire one.

2. Do you have suggestions to make this project run successfully?

Ans: Sure I have suggestions for you in this project. According to my concept, the updated strategy and proper methods can make this project successful. And surely I will make this project successful.

3. Which part of this project do you think will take the most time?

Ans: According to your job details, I have years of experiences in both fields. And I always use the updated techniques and win the competition. I have a strong belief that I would be able to make this project successful within short time.

4. Have you taken any oDesk tests and done well on them that you think are relevant to this job?

Ans: Yes I have taken oDesk Skill Tests and I have done well. You can check my tests area. Default system of odesk tests is a good method of justify oneself. And yes I appreciate it as well as I did well in here.

5. How much time do you think it will take to accomplish the task for google results ?

Ans: Competition is everywhere. Always want to be ranked in google. But failing in this competition is problematic. And I know this problem. The problem is the so called workers do not use the updated methods where I always hit the iron when it is hot. That’s why I can assure you that I will be able to do it in short times than the rest (2+ or 3+ months)

6. What part of this project most appeals to you?

Ans: Here the two parts of this project appeal me very much, one is that all the requirements are in favor of me and the second one is I like to do these kind of job. These kind of project and job give me mental satisfaction.

7. Why do you think you are a good fit for this particular project?

Ans: I think I am a good fit for this job because I have all the qualities that you are looking for. Experience is the golden factor in this project where you find in me at least 3+ years of working experiences over all the factors in your project.

8. Do you have any questions about the job description?

Ans: Your arrangement of the job description is fully understandable and I have understood it very well. Still I have no questions about your job description. If I need any information latter, I must convey you and discuss with you in a friendly circumstances.

9. Which of the required job skills do you feel you are strongest at?

Ans: I have carefully read your job description and I have more than 3 years of working experience in both of your required skills. And I am strongest at all of your required qualities. Hope I will be the perfect worker for you in this project.

 10. What SEO jobs have you done in the past?

Ans: I have successfully completed many seo projects before, you can see my employment history and portfolio projects. I hope I will also be successful in this project. You can undoubtedly hire me.

11. How much time will you need to work on this project to see results and how will you spend your time working on this project?

Ans: I have a strong belief that I would be able to make this project successful within short time. I will spend my time working on this project hourly with white hat updated method and make it successful.

12. Have you done high quality back-linking before? if so what sites do you use?

Ans: Sure I have done high PR back-inkling before and ranked many sites. You can check my employment history and portfolio. (You can also include some links here)

13. Why should i chose you over the other 100 that have applied for this Job?

Ans:  This is a good point you have asked. Here you will found many so called worker who do not know how to work. I am totally different from them. I have a long term plan to work in here, that’s why I am here with all qualities and experiences. I am here not to cheat you rather help you.

14. What challenging part of this job are you most experienced in?

Ans: Everything is now becoming challenging, If one has to win he or she should have the proper knowledge of the present situation. And I am most experienced in this factor. Hope I will make your project successful.

15. Who have you worked with that has yielded quick results. What was the cost to client to receive positive results?

Ans: I have successfully completed many projects. You can see my portfolio and employment history. And I took the relevant cost, I never ask for high price.

16. Tell me how you would go about increasing my rankings for my website?

Ans: Ranking a website on some certain keywords are now very difficult. But if one has relevant ideas and skills about the search engines’ logarithm, he/she must win this competition. According to that I will first make your site search engine friendly then I will make it popular to others and increase its rank.
17. Why did you apply to this particular job?
Ans: I have applied to this particular job because all the requirements of this project are in favor of me and I can 100% assure you that I must be successful in this project and satisfy you. I never apply to any job what doesn’t match my skills.

Sunday, 18 January 2015

c program to get ip address

c program to get ip address


#include<stdlib.h>
 
int main()
{
   system("C:\\Windows\\System32\\ipconfig");
 
   return 0;
}


This c program prints ip (internet protocol) address of your computer, system function is used to execute the command ipconfig which prints ip address, subnet mask and default gateway. The code given below works for Windows xp and Windows 7. If you are using turbo c compiler then execute program from folder, it may not work when you are working in compiler and press Ctrl+F9 to run your program.

Shutdown your PC using C program

C programming code for Windows XP

#include <stdio.h>
#include <stdlib.h>
 
int main()
{
   char ch;
 
   printf("Do you want to shutdown your computer now (y/n)\n");
   scanf("%c", &ch);
 
   if (ch == 'y' || ch == 'Y')
      system("C:\\WINDOWS\\System32\\shutdown -s");
 
   return 0;
}



C programming code for Windows 7

#include <stdio.h>
#include <stdlib.h>
 
int main()
{
   system("C:\\WINDOWS\\System32\\shutdown /s");
 
   return 0;
}


C programming code for Ubuntu Linux

#include <stdio.h>
 
int main() {
  system("shutdown -P now");
  return 0;
} 


You need to be logged in as root user for above program to execute otherwise you will get the message shutdown: Need to be rootnow specifies that you want to shutdown immediately. '-P' option specifies you want to power off your machine. You can specify minutes as:
shutdown -P "number of minutes"
For more help or options type at terminal: man shutdown.


HINTS

C Program to shutdown your computer: This program turn off i.e shutdown your computer system. Firstly it will asks you to shutdown your computer if you press 'y' then your computer will shutdown in 30 seconds, system function of "stdlib.h" is used to run an executable file shutdown.exe which is present in C:\WINDOWS\system32 in Windows XP. You can use various options while executing shutdown.exe, you can use -t option to specify number of seconds after which shutdown occurs. Syntax: shutdown -s -t x; here x is the number of seconds after which shutdown will occur.
By default shutdown occur after 30 seconds. To shutdown immediately you can write "shutdown -s -t 0". If you wish to restart your computer then you can write "shutdown -r".
If you are using Turbo C Compiler then execute your program from command prompt or by opening the executable file from the folder. Press F9 to build your executable file from source program. When you run program from within the compiler by pressing Ctrl+F9 it may not work.

Saturday, 17 January 2015

C programming code to merge two sorted arrays


C programming code to merge two sorted arrays


#include <stdio.h>
 
void merge(int [], int, int [], int, int []);
 
int main() {
  int a[100], b[100], m, n, c, sorted[200];
 
  printf("Input number of elements in first array\n");
  scanf("%d", &m);
 
  printf("Input %d integers\n", m);
  for (c = 0; c < m; c++) {
    scanf("%d", &a[c]);
  }
 
  printf("Input number of elements in second array\n");
  scanf("%d", &n);
 
  printf("Input %d integers\n", n);
  for (c = 0; c < n; c++) {
    scanf("%d", &b[c]);
  }
 
  merge(a, m, b, n, sorted);
 
  printf("Sorted array:\n");
 
  for (c = 0; c < m + n; c++) {
    printf("%d\n", sorted[c]);
  }
 
  return 0;
}
 
void merge(int a[], int m, int b[], int n, int sorted[]) {
  int i, j, k;
 
  j = k = 0;
 
  for (i = 0; i < m + n;) {
    if (j < m && k < n) {
      if (a[j] < b[k]) {
        sorted[i] = a[j];
        j++;
      }
      else {
        sorted[i] = b[k];
        k++;
      }
      i++;
    }
    else if (j == m) {
      for (; i < m + n;) {
        sorted[i] = b[k];
        k++;
        i++;
      }
    }
    else {
      for (; i < m + n;) {
        sorted[i] = a[j];
        j++;
        i++;
      }
    }
  }
}

Max in Array

C program to find maximum element in array


#include <stdio.h>
 
int main()
{
  int array[100], maximum, size, c, location = 1;
 
  printf("Enter the number of elements in array\n");
  scanf("%d", &size);
 
  printf("Enter %d integers\n", size);
 
  for (c = 0; c < size; c++)
    scanf("%d", &array[c]);
 
  maximum = array[0];
 
  for (c = 1; c < size; c++)
  {
    if (array[c] > maximum)
    {
       maximum  = array[c];
       location = c+1;
    }
  }
 
  printf("Maximum element is present at location %d and it's value is %d.\n", location, maximum);
  return 0;
}