Introducing .NET, .Net Framework, ASP.NET, OOP

Tram Ho

1 – What is Object Oriented Programming (OOP)?

  • Creating objects in code that abstracts real-life objects.
    • When using OOP, we must define classes to model the real objects (objects with similar properties and actions are grouped into 1 object class – Understand: class it as 1 the template is an instance of the instance based on that template).
    • Class defines an object including attributes (information, characteristics of the object: Human has attributes – eyes, nose, legs, arms …, Computer will have properties such as color, size , memory, …) and methods (Actions and actions that the object can perform: Humans have action – eat, talk, drink …, Computer has methods such as: scanning for viruses , shutdown, start up, …)
  • Basic principles in OOP:
    • Encapsulation: The encapsulation has two main points:
      1. Data and related methods are packaged into classes for easy management and use (expressed in the way that we build a class).
      2. A guard that prevents the variable or method from being accessed by code outside of this shield (i.e. controlling access (and altering) the value of the property as well as the right to call the object’s method. (or class) and object (or class)).
        2.1. Technically in encapsulation, class variables or data are hidden from any other class as well as outside the class, and can only be accessed through the member functions of the class.
        2.2. To achieve encapsulation, declare the variables inside the class to have private scope and write methods (these methods have scope of access: public / protected) in the class to set and get the price. value for that private variable.
    • Inheritance: The subclass uses the properties and methods of the parent class. In addition, it is possible to extend the inheritance and add new components.
    • Polymorphism: An action that can be performed in different ways or polymorphism is a concept in which two or more classes have the same methods but execute differently. This is a property that can be said to contain most of the power of OOP programming. Example: The same action is to cry, but the cat and the chicken sound differently.
    • Abstraction:
      1. Generalizing something up, no need to pay attention to inner detail. (Example: We have a method A that handles a function, so we don’t need to care about the details of the processing, just care what the purpose of this method is).
      2. In OOP, the abstraction is to choose the properties and methods of the object that we need to do, not all of them. For example: The student management problem, we only need information such as Name, date of birth, student code, hometown … without any other information such as height, weight, lover? ….
  • Refer:
    https://topdev.vn/blog/oop-la-gi/
    https://codelearn.io/sharing/tat-tan-tat-ve-lap-trinh-huong-doi-tuong-phan-1
    https://nguyenvanhieu.vn/tinh-da-hinh-trong-lap-trinh-huong-doi-tuong/?amp
    https://codegym.vn/blog/2019/01/20/mon-hoc-lap-trinh-huong-doi-tuong/
    https://www.freecodecamp.org/news/object-oriented-programming-concepts-21bb035f7260/

2 – .Net concept

  • .Net is a free, open source, cross-platform development platform for building a wide variety of applications.
  • With .Net, you can use .Net languages ​​(such as: C #, F #, or Visual Basic), editors (such as: Visual studio, Visual Studio Code …), libraries to write applications .Net (such as web, mobile, desktop, games, and IoT …) and some .Net applications are cross-platform, some applications work on 1 operating system or 1 .NET implementations (I roughly translated as .1 implementation of .Net). Specifically:
  • Compile and Execute in .Net: Applications written in .Net-supported languages ​​will be converted into the intermediate language by the respective compiler (Also known as MSIL (Microsoft Intermediate Language) or CIL ( Common Intermediate Language) or IL (Intermediate Language)) along with its metadata (Contains information about class, method, data fields, runtime information, etc.) and they are stored in the assembly file (.dll or .exe), when running a .Net application, the CLR takes the assembly and uses the JIT compiler to convert that assembly (That is, convert CIL) to machine code and then the CPU on your machine will execute the machine code. there. In the picture below, “Compile Time” is the “built” process, “Run time” is the running process (This process starts from the moment you start your application).

  • In .Net there is one thing that everyone should definitely need: Nuget. So what is Nuget?
    1. Nuget is a package manager built specifically for .Net. This Package Manager provides a platform with certain tools for you to create, share and use the packages available on Package Manager. And this Nuget is available on Visual Studio if you don’t have one, you can go here to install.
    2. Other related concepts (like what is framework …):
      2.1 – What is Libraries?
      2.1.1 – Libraries are built-in code for a certain function and you can reuse that function without re-coding, for example: jquery, underscore, lodash … There are many tools to manage libraries such as: NPM, Composer, Bower …
      2.1.2 – For example you create reusable functions like this:

      When you create these 2 functions, you are creating your own library already!

      2.2 – What is Framework?
      2.2.1 – Framework is pre-written code that constitutes a set of frameworks and programming libraries packed in the framework. (Basic understanding: Framework is like a framework that has a foundation, foundation, foundation. and from there you can build more, add paint colors, interior design … as you like without having to dig the foundation, make a foundation, make a pillar from scratch).
      2.2.3 – The core feature of the Framework is to help increase performance when developing apps, extend functions and provide libraries available for you to program without code from scratch. Mobile application development and these frameworks have a feature, when you use it to write apps as “Write one place, run anywhere” (Specifically: if you write code that runs on Android, that code also runs on iOS) : React Native, Flutter …

      2.3 – What is Platform?
      With Platform, it requires you to completely follow all the rules it sets forth and not do it differently. (A broader definition of platform: platforms include hardware (computers or laptops) and software. (Operating system) that applications or frameworks can operate. For example, .Net is a platform because in order to use .Net on windows you have to install .Net framework or .Net Core for win, .NET Core on linux and macOS, to write applications on .Net, you must use languages ​​that .Net supports such as: C #, F #, Visual Basic.

      2.4 – Refer to:
      https://dotnet.microsoft.com/learn/dotnet/what-is-dotnet https://www.freecodecamp.org/news/the-difference-between-a-framework-and-a-library-bd133054023f/
      https://kipalog.com/posts/La-framework–hay-la-library
      https://topdev.vn/blog/framework-la-gi/

  • Cross Platform in .Net:
    In order for the application that you write in C #, F # or Visual Basic to run on the operating system you are using, you must use 1 of 3 implementations of .Net (.Net implementations), namely:
    1 – .NET Core is a cross-platform .Net implementation for websites, servers, and console apps running on Windows, Linux, and macOS.
    2 – The .NET Framework helps websites, services, desktop apps … run on Windows.
    3 – Xamarin / Mono is a .Net implementation to run applications on mobile operating systems such as Android, IOS …

2.1 – .NET Framework

2.2 – .Net Core vs .NET Framework

  1. Difference: I have listed a few differences between .net core and .net framework, you can see in detail the differences between them in medium and stackoverflow!

    • .Net Framework helps create Console apps, Windows and web applications. Specifically, you can use Windows Forms, WPF, and UWP to build Windows applications, ASP.NET MVC to build web applications running on IIS in the .Net framework.
    • .Net Core is used to build cross-platform console apps, build web applications using asp.net core and cloud services, .Net core also supports UWP (Universal Windows Platform (UWP): Helping to develop applications. using Metro style that runs on both Windows 10 and Windown 10 mobile without having to rewrite the application for each platform.)
    • .Net core is cross-platform, can run on windows, linux, macos, and .Net framework only runs on win.
    • .Net core is open source so it is developed by the community, .Net framerword is not.
    • Most of the changes in .Net happen on .Net Core
    • .Net framework is automatically updated by window update, .Net Core is updated manually.
  2. Use .Net Core given on the server side when:
    • Your application (Web / service) needs to run on multiple platforms (Windows, Linux, and macOS).
    • You are using Docker containers.
    • You need a high performance and scalable system.
    • You need an application that uses a .Net version and uses .Net Core (Because for each .Net framework it replaces the previous one).
  3. Use the given .Net Framework on the server side when:
    • Your application uses third-party libraries or NuGet packages that are not available in .Net Core.
    • Your App uses .Net technologies not available .Net Core.
    • Your App runs on a platform that does not support .Net Core (Window, Linux, MacOs with .Net Core support).
  4. Refer:
    https://docs.microsoft.com/en-us/dotnet/standard/choosing-core-framework-server
    https://docs.microsoft.com/en-us/archive/msdn-magazine/2017/september/net-standard-demystifying-net-core-and-net-standard
    https://www.c-sharpcorner.com/article/difference-between-net-framework-and-net-core/
    https://en.wikipedia.org/wiki/Universal_Windows_Platform

2.3 – Asp.Net and Asp.net Core

  1. Asp.Net concept:
    • Open source framework used to create dynamic websites, web applications and web services.
    • Cross-platform: Applications written in Asp.Net can run on Windows, Linux, macOS, and Docker.
    • Allows you to build many types of web applications, including: Web pages, REST APIs, microservices and real-time.
    • Compiled as a Common Language Runtime (CLR), you can write Asp.Net in any language supported by .Net such as C #, Visual Basic.Net , Jscript …
    • Asp.Net Core is open source, cross-platform and it is an enhanced version of Asp.Net (Before the advent of Asp.Net Core (released in 2016), Asp.Net versions (released in 2016). 2002 with .Net Framework) window only and commonly referred to as Asp.Net )
  2. Asp.Net extends .Net
    Asp.Net extends the .Net platform to add tools and libraries dedicated to web building. (Website Template Creation Syntax: Razor, Library for popular web templates: MVC, syntax highlighting ….)
  3. Create dynamic web pages using C #, HTML, CSS, and JavaScript.
    • Razor provides syntax for creating dynamic web pages using HTMl vs C # (The code on the server side we use C # to write and the server side returns the HTML to the client.)
    • Asp.Net is integrated with JavaScript frameworks, and aggregates pre-configured templates for SPA frameworks (single page app – basically, when using frameworks, we don’t have to reload the page multiple times every time. request to server) such as React and Angular.
  4. Programming models (Programming models): Asp.Net supports several programming models for building web applications:
    • ASP.NET Web Forms: Build dynamic web pages using the drag-and-drop event-driven model.
    • ASP.NET MVC: Build web pages according to Design pattern: MVC
    • ASP.NET Web Pages – Is a Framework for creating dynamic web pages (ie using lightweight syntax (Razor) to add code to get and process data displayed in HTML).
    • ASP.NET Single Page Applications.
  5. Refer:
    https://dotnet.microsoft.com/learn/aspnet/what-is-aspnet
    https://www.tutorialspoint.com/asp.net/asp.net_introduction.htm
    https://en.wikipedia.org/wiki/ASP.NET
    https://www.slideshare.net/rishikothari/developing-an-aspnet-web-application

3. Suggestions

Thank you for reading my article, where there are mistakes in my article, misunderstanding or something, I hope you give me your comments so that I can improve the best way, thank you!

Share the news now

Source : Viblo