How a DotNet Program Execute ?

To understand how a DotNet program execution takes place we have to do the comparison between pre-Dotnet program execution with DotNet program execution. So before DotNet came into existence, we used to build the application using other programming languages like C++ or VB6. 

Let's, for example, build an application using VB6 and compile it using a language compiler then an assembly gets generated with .dll or .exe extension depending on the type of application. This assembly is in Native code or Machine code format. We have to do the compilation because our operating system doesn't understand high-level programming languages, they only understand binary code of 0s and 1s. So basically we deploy that assembly onto the system to get executed which is nothing but a native code. 

Now lets us understand what naive code means? Suppose you have Windows operating system and now you take the assembly which was compiled on the Windows operating system and try to run it on Linux or another operating system then it will give you an error because that code is native to only Windows operating system. That's why it is called Native code or Object code. This is the problem with the pre-DotNet application, they are not portable and we have to build different operating systems.

Now let's understand how a DotNet application executes. DotNet supports several programming languages like C#, VB, C++, etc. When you build a DotNet application using any of these languages and compile using the respective language compiler, we get an assembly here also but unlike pre-DotNet application, it does not contain native code, instead, it contains intermediate language. This is the main difference between a DotNet program and a Pre-DotNet program but your operating system cannot understand the intermediate language so we need a runtime environment name as CLR (Common Language Runtime) to convert the intermediate language to native code. 

Now the question is how does this CLR come in between to do this job? When we install DotNet on our system, we basically install two important components one is the DotNet framework class library and another one is CLR. This is like a heart for DotNet program execution. This CLR layer exists between Assembly and the Operating system. Within CLR there is a very important component named as JIT compiler which takes IL (Intermediate Language) as input and generates native code as the output for the Operating system. 

So the biggest advantage of the DotNet application is that is portable which means that the same code can run on any operating system with the help of CLR installed on that operating system. Another advantage of DotNet is that the runtime environment contains a garbage collector which will clean the object or memory that is not in use programmer doesn't have to worry much about memory management.

Note: The native code is not stored permanently anywhere after we close the program the native code is thrown away and when we execute the program again the native code will generate again. (alert-success)


 

ASP.NET Life Cycle.

ASP.NET is a server-side technology used for developing dynamic websites and web applications. It is the latest version of active server pages, active server pages is a server-side scripting language and engine used for developing web applications. It is essentially a web-based platform that helps to create a dynamic web-based platform that helps to create dynamic web pages for programmers. 

ASP.NET has some specific steps that are to be carried out for an application these steps are called Life Cycle.

ASP.NET Life Cycle is divided into two groups:

1. Application Life Cycle.

2. Page Life Cycle.

Application Life Cycle.

Application Start > Object Creation > HTTP Application > Dispose > Application End

  • Application start is a method that can be executed by the webserver when a user makes a request. 
  • The HTTP requests contain all the information about the current request, like cookies and browser information. 
  • An object helps to process each subsequent request sent to the application that is created by the web browser. 
  • Dispose is an event that can be called before the application is destroyed. This helps to release manually unmanaged resources. 
  • Application end is the final part of the application and this can help to unload the memory. 

Page Life Cycle.

ASP.NET web page life cycle has specific steps that are carried out during the execution. These phases include initialization, restoring, and execution. The important phases of the page life cycle are: 
  • Page Request: When the user requests a page, the server checks the request and then compiles the page and responds to the user. If the page is requested several times then the cache will check the request to see if the output exists or not and after that it will send a response back to the user. 
  • Page Start: In this phase, two steps are carried out request and response. The request holds all information that was sent when the page was requested and the response holds all the information which send back to the user. 
  • Page Initialization: In this phase, all the controls on the page are set and each has a particular ID, and themes are applied to the pages. 
  • Page Load: In this phase, all the controls properties are loaded, and information is set using view state and control state. 
  • Validation: Validation happens when the page execution goes successful and then it returns true else the execution fails and it returns false. 
  • Event Handling: Event handling happens in response to validation. In this case, the page is loaded again and displays the same information so the postback event handler is called in order to overcome this problem. This event helps in checking the credentials of the user.
  • Rendering: Rendering occurs before all the response information is sent to the user. It also stores all the information sent to the user. 
  • Unload: Unload phase helps to clean all the unwanted information, it also cleans the memory once the output is sent to the user. 

What is ASP.NET? Introduction to ASP.NET



Many questions come to our mind while building an application and all we think about is the speed, cost, and language. And ASP.NET is one of the best choices for building any application. 

Why use ASP.NET?

For building Web application ASP.NET is much easier compared to other technology like PHP and Node.js. It is much faster much efficient than many other languages. ASP.NET allows you to build many applications like REST API and Web pages. It takes less time for execution and execution takes place only once. 

What is ASP.NET?

ASP.NET is server-side technology used for developing dynamic Web applications. It was released in 2022 and had an extension of .aspx. It produces interactive, data-driven Web applications on the internet. It is developed by Microsoft and it is mainly used to develop websites and web applications. ASP.NET is the latest version of active server pages which Microsoft developers to build a website. 

The architecture of ASP.NET.

ASP.NET architecture help in increasing performance, stability, and flexibility. ASP.NET works on HTTP protocol and uses HTTP commands. First, ASP.NET request an HTML file from the server then IIS (Internet Information Services) passes that information to the ASP.NET engine, and after that ASP.NET engine read the file and execute the script. Then ASP.NET returns to the browser as an HTML file. 

Note: IIS is a powerful web server that provides a very reliable, scalable,  and manageable Web application Infrastructure. It lowers the system administration costs, which helps organizations to increase Website and application availability. 

Components of ASP.NET.

  • Language: This can help in developing the web application. Some of them are VB.net and C#.
  • Library: It is a prewritten class and coded template that a developer can use while developing an application. The most common library used in ASP.NET is the web library. 
  • Common Language Runtime: This is the platform that is used to execute the program. It is also use for performing activities like Garbage Collection. 
Skills required to Master ASP.NET.
  • Basic of C#, JavaScript, HTML.
  • Knownledge of ASP.NET MVC.
  • Good Knowledge of OOPs
  • Web Development.
Benefits of ASP.NET.
  • High Performance. 
  • Secure
  • Multiple Development modes.
  • Language Independent.
  • Globalization and Localization. 

What is Entity Framework ?

Entity Framework is an ORM framework. ORM stands for Object Relational Mapping. Object Relational Mapping automatically creates classes based on database tables, and vice-versa is also true, it means it can generate necessary SQL to create database tables based on classes. .Net applications may connect with any kind of data sources like flat files, XML data, or relational databases. Irrespective


If you have two tables showing on the left side and you want to create a new table using that data then you have to follow the following steps in ADO.NET:

1. We need to create Department and Employee classes. 

2. Write ADO.NET code to retrieve data from the database. 

3. Once the database is created, we need to create department and employee objects and populate them with the data.

Note: Entity Framework can do all the above automatically if we provide it with the database schema. 

Entity Framework provides us a class called DbContext which is our gateway to our database. A DbConext can have one or more DbSet and this DbSet represent a table in our database. We use LINQ query to query this DbSet and Entity Framework translates these LINQ queries to SQL queries at runtime. 

Three Important Entity Framework Approaches are: 

1. Database First Approach.

  • We design our tables.
  • Entity Framework generates domain classes.

2. Code First Approach.

  • We create our domain classes.
  • Entity Framework generates database tables.

3. Model First Approach.

  • We create a UML diagram.
  • Entity Framework generates domain classes and databases. 

Java Program for Concatenation of Array.

Given an integer array nums of length n, create a new array ans of length 2n such that ans is the concatenation of two nums arrays. 

Example:
Input: nums = [1, 2, 4]
Output: ans = [1, 2, 4, 1, 2, 4]

Input: nums = [1, 3, 2, 1]
Output: ans = [1, 3, 2, 1, 1, 3, 2, 1]

Steps:

  • Create a new array ans[] = new int[2*n] of size 2n where n is the size of the given array. 
  • Copy the elements given into the new array where ans[i] = nums[i] and ans[i+n] = nums[i]
  • Return ans.
public class Main
{
    public static int[] getConcatenation(int[] nums) {
        
        int ans[] = new int[2*nums.length];
        
        for(int i = 0; i<nums.length; i++){
            ans[i] = nums[i];
            ans[i+nums.length] = nums[i];
        }
        return ans;
    }
public static void main(String[] args) {
    int nums[] = {1, 2, 1, 3};
    
    int[] ans = getConcatenation(nums);
    
    for(int i = 0; i<ans.length; i++) {
        System.out.print(ans[i]+" ");
    }
}
}
Output:
1 2 1 3 1 2 1 3

Java Programming Complete Tutorial

Java Programming

The Java Programming Language is a general-purpose, high-level, strongly-typed, class-based object-oriented programming language. All Java applications first complied with the bytecode that can run on any Java Virtual Machine (JVM) regardless of the underlying computer architecture. 
 
Introduction to Programming:

Basic of Java:

Access Specifiers in Java.

The process of hiding information is implemented using Access Specifiers known as visibility modifiers. They regulate access to classes, fields, and methods. Access Specifiers specify if fields or methods in a class can be invoked from another class or sub-class. In simple words, they are used to restrict access. 

There are four types of Access Specifiers in Java. 

  • Public
  • Private
  • Protected
  • Default (no specifier)
Public: Classes, methods, and fields declared as public can be accessed from any class in an application. 
Default: If Classes, variables, and methods have a default specifier we can access them only within the same package but not from outside this package. 
When no access specifiers are specified for an element, its accessibility level is the default. There is no keyword default. (alert-passed)
Private: Private methods and fields can only be accessed within the same class to which the methods and field belong. 
Protected: Protected methods and fields are accessible within the package and outside the package but with the help of inheritance. It cannot be applied to a class and it provides more accessibility than the default access specifier.    


Access Modifiers default private protected public
Accessible inside the class Yes Yes Yes Yes
Accessible within the subclass inside the same package Yes No Yes Yes
Accessible outside the package No No No Yes
Accessible within the subclass outside the package No No Yes Yes

Accessors and Mutators in Java.

Java accessor and mutaotrs

Accessors and Mutators are two very important concepts in Java. It is used to read and update the private data member of a class. 

To understand this concept more clearly we first have to understand encapsulation and access specifiers. Encapsulation is an important concept in Object-oriented programming and it is implemented by wrapping up the data and methods into a single unit. 

The data present inside the class need to be secure and for this, we declare the data in a class as private. We cannot access the private data-member of other classes outside that class. To read and update the private data member a class outside that class we have to use public methods of that class. These methods are called Accessors or Getters and Mutators or Setters

Accessor or Getters are methods used to return the value of a private field of a class. It does not change the state of the Object. 

example:

public String getName() {
    return name; 
}    

Mutators or Setters are methods used to set a value of a private field of a class. It changes the state of the object. 

example:

public void setName(String fullName) {
    name = fullName;
}    


Example Java Program to Understand Accessors and Mutators.

public class Student {
    
    //attribute
    private int studId;
    private String studName;
    
    //Accessors or Getters
    public int getStudId() {
        return studId;
    }
    public String getStudName() {
        return studName;
    }
    //Mutators or Setters
    public void setStudId(int studId) {
        this.studId = studId;
    }
    public void setStudName(String studName) {
        this.studName = studName;
    }
}

import java.util.*;

public class Main
{
	public static void main(String[] args) {
	    //Object Creation
	    Student Obj = new Student();
	    
	    //assign value using Setters
	    Obj.setStudId(112);
	    Obj.setStudName("Rahul");
	    
	    //retrive value using Getters
	    System.out.println("Student ID: "+Obj.getStudId());
	    System.out.println("Student Name: "+Obj.getStudName());
	}
}
Output:
Student ID: 112
Student Name: Rahul

In the above example, we can see that how we are reading and updating the private data member of the Student class from the Main class with the help of the Object of Student class. 

Hope you found this article useful if you have any question related to this topic feel free to ask me in the comment section below. 

DON'T MISS

Nature, Health, Fitness
© all rights reserved
made with by templateszoo