Download presentation
Presentation is loading. Please wait.
Published byNoel Harvey Modified over 6 years ago
1
Introduction to .NET Florin Olariu & Andrei Arusoaie
“Alexandru Ioan Cuza”, University of Iași Department of Computer Science
2
Organization People: Florin Olariu & Andrei Arusoaie & Dan Nastasa
14 weeks (full activity) + 2 weeks for evaluation Final grade = round(40% * Exam + 60% * Lab + 10% * Kata’s) Exam: max 40 points, midterm exam Lab: max 70 points = 20 lab activity + 40 semester project + 10 coding kata’s * bonus points! Criteria: min 50 (Exam + Lab) WEB:
3
Resources Books/movies: Microsoft: Getting started:
(create your Microsoft account!) Ask for books using Facebook Microsoft: Getting started:
4
Questions? Contact: Facebook: andrei.arusoaie@gmail.com
Facebook: Introduction to .NET (click!)
5
Motivation Why C#? Open source
The platform is new (written from scratch) Is the first time when we can say: “Write once => deploy everywhere!” It has been oriented to performance It has a very strong middleware system built-in According with the trends it is the most recommended high-level language that should be learned in The sources can be found in github.
6
Goal Learn how to: Write business applications using .NET Core 2.0
Using best practices in writing maintainable software How to use design patterns How to use architectural patterns How to write decoupled code How to build responsive web applications How to work in teams using Agile Development (SCRUM approach) How to prepare for an interview .NET oriented (Andrei&Florin&Dan)Open for new challenges according with your(and market) needs
7
Agenda What is .NET Core? What is .NET Framework?
Overview on ASP.NET Core What is new about this framework? Sample: Developing sample web application. OOP in .NET Core NET Framework – C# access modifiers and other common types
8
What is .NET Core? What is .NET Framework?
9
What is .NET Core? What is .NET Framework?
Open Source. Developed & run on Cross Platform. Built on the .NET Core runtime & also on .NET Framework. Facility of dynamic compilation. Built in Dependency Injection (DI). MVC & Web API Controller are unified, Inherited from same base class. Smart tooling (Bower, NPM, Grunt & Gulp). Command-line tools. What is .NET Framework? Developed and run on Windows platform only. Built on the .NET Framework runtime. Supported (MVC, Web API & SignalR) Dependency Injection (DI). MVC & Web API Controller are separated. Image source:
10
Overview on ASP.NET Core
11
Overview on ASP.NET Core
A unified story for building web UI and web APIs Integration of modern client-side frameworks and development workflows A cloud-ready environment-based configuration system Built-in dependency injection New light-weight and modular HTTP request pipeline Ability to host on IIS or self-host in your own process Built on .NET Core, which supports true side-by-side app versioning Ships entirely as NuGet packages New tooling that simplifies modern web development Build and run cross-platform ASP.NET apps on Windows, Mac and Linux Open source and community focused
12
What is new about this framework?
Note: show the trick with dot.net!!!! -> open an browser and write down dot.net!!!!
13
What is new about this framework?
Cross platform Cross platform First thing that needs to be signaled here is that till this version all the others .NET Framework version 1.0->4.5 were for development only for/in Windows platforms. During this period there was a framework called Mono Framework, open source and compatible with .NET With this new version Microsoft changed completely their attitude and created this new platform that now can be used not only on Windows but also on other platforms like: Mac or Linux. In the past the only IDE available to build strong/large applications was Visual Studio. Now we can use any editor (the best one is Visual Code -> can be installed on Mac or Linux as well) and we can execute any program using a console. To make it work on a cross platform, Microsoft built up a new set of runtime & libraries called CoreCLR and CoreFX which they compiled for every platform and generated builds. With making .NET Core a Cross Platform, Microsoft removed the tightly IIS bound "System.Web" and made it "Microsoft.AspNetCore" which will work for all platform hosting environment.
14
What is new about this framework?
Cross platform Open source Open source With the world moving towards open source, Microsoft made this framework totally an open source. Also, the source code is available on GIT. You can now easily customize this framework according to your need.
15
What is new about this framework?
Cross platform Open source Optimized .NET runtime & libraries Optimized .NET runtime & libraries With these changes, Microsoft also made changes to its libraries which were available in our GAC on installation of .NET Framework. One example that I can think of, is “System” library. The “System” library consists of many logical libraries, such as System.IO, System.Net, System.Configuration, etc. which getsloaded into memory every time you use “System” library. But, do you think there is a need to load the whole library when only a portion is needed? Suppose I need only System.IO, then my project should only refer System.IO instead of System as a whole. To make it a light weight and optimized, .NET Core now supports nuGet packages for each of this logical library and they will no more refer from GAC (which was available only on Windows platform)
16
What is new about this framework?
Cross platform Open source Optimized .NET runtime & libraries Completely modular Completely modular Every time when there was a new feature added in any component of .NET framework, a new version was released by Microsoft. For example – with ASP.NET MVC, there was a routing concept introduced until ASP.NET MVC 4 which was there in Visual Studio 2012 (.NET framework 4.5). But with ASP.NET MVC 5, they introduced something called as Attribute Level Routing which was added in Visual Studio 2013 (.NET Framework 4.5.1). This kind of change in components may lead to introducing new release of framework version. But now, that is all gone with .NET Core, where everything is nuGet package. It became very easy to upgrade the component as it will introduce the release of nuGet package and not the whole framework. This makes everything modular.
17
What is new about this framework?
Cross platform Open source Optimized .NET runtime & libraries Completely modular Introduction to CLI Introduction to CLI .NET Core also introduces a Command line application called as dotnet.exe. This application allows us to, create an application execute the application run the Intermediate language host the CLR for any platform.
18
What is new about this framework?
Cross platform Open source Optimized .NET runtime & libraries Completely modular Introduction to CLI Cloud ready environment Cloud ready environment With .NET Core, we can build cloud based internet connected applications, like Web Apps, IOT apps & mobile backend.
19
Sample: Developing sample web application
DEMO Show the code Explain some parts like: controllers, views, models, startup, routing etc Explain CLI commands Host in IISExpress, Self-Hosting,
20
OOP in .NET Core Inheritance Inheritance Classes may derive from exiting classes. Existing classes are called : parent class. => and it is a generalization of the exiting class. Inheritance creates an “is –a ” relationship Example: Employee<=Manager, Architect, Technical Lead, Developer
21
OOP in .NET Core – inheritance
Derived class indicates base class with colon. Notes: classes can contain properties and fields (built-in like int, string or custom like other classes or struct’s) Fields are used to support private methods Properties are used to expose functionality to other classes
22
OOP in .NET Core - inheritance
Identify : properties, methods/behavior
23
OOP in .NET Core - polymorphism
The possibility of taking many forms. Method overriding -> modify a method in the derived class : C# in order to be able to use method overriding we need to know: virtual override. Virtual exists in base class, override in derived class.
24
OOP in .NET Core - polymorphism
25
OOP in .NET Core - polymorphism
Another important aspect for polymorphism is “method overloading”. Means: we can have in the same class methods with the same name but different number of parameters.
26
OOP in .NET Core - encapsulation
Encapsulation : a class should have a single responsibility. => don’t forget here, there is another set of principles : SOLID. Within the class we should have private functionality, that should not be exposed and only a : few well-defined methods that are public. Question: Why the method should be public?
27
OOP in .NET Core Inheritance Polymorphism Encapsulation
There are 3 pillars in OOP. => Inheritance, polymorphism and encapsulation.
28
NET Framework – C# access modifiers and other common types
29
NET Framework – C# access modifiers and other common types
What is an access modifier?
30
NET Framework – C# access modifiers and other common types
What is an access modifier? An access modifier is a keyword used to specify the accessibility of a member or a type.
31
NET Framework – C# access modifiers and other common types
How many access modifiers exists in C#?
32
NET Framework – C# access modifiers and other common types
How many access modifiers exists in C#? In C# we have four access modifiers public protected internal private
33
NET Framework – C# access modifiers and other common types
How many access modifiers exists in C#? In C# we have four access modifiers public protected internal private
34
NET Framework – C# access modifiers and other common types
How many access modifiers exists in C#? In C# we have four access modifiers public protected internal private public => there is no restriction in regards with accessibility
35
NET Framework – C# access modifiers and other common types
How many access modifiers exists in C#? In C# we have four access modifiers public protected internal private
36
NET Framework – C# access modifiers and other common types
How many access modifiers exists in C#? In C# we have four access modifiers public protected internal private protected => access is limited to the containing class or types derived from the containing class
37
NET Framework – C# access modifiers and other common types
How many access modifiers exists in C#? In C# we have four access modifiers public protected internal private
38
NET Framework – C# access modifiers and other common types
How many access modifiers exists in C#? In C# we have four access modifiers public protected internal private internal => access is limited to the current assembly
39
NET Framework – C# access modifiers and other common types
How many access modifiers exists in C#? In C# we have four access modifiers public protected internal private
40
NET Framework – C# access modifiers and other common types
How many access modifiers exists in C#? In C# we have four access modifiers public protected internal private private => access is limited to the containing type
41
NET Framework – C# access modifiers and other common types
42
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual
43
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual
44
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual readonly const
45
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual readonly const Can be initialized: at declaration or in a constructor
46
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual readonly const Can be initialized: at declaration or in a constructor Can be initialized only at the declaration
47
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual readonly const Can be initialized: at declaration or in a constructor Can be initialized only at the declaration Can be used only by fields
48
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual readonly const Can be initialized: at declaration or in a constructor Can be initialized only at the declaration Can be used only by fields
49
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual readonly const Can be initialized: at declaration or in a constructor Can be initialized only at the declaration Can be used only by fields If is initialized via constructor can have different values
50
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual readonly const Can be initialized: at declaration or in a constructor Can be initialized only at the declaration Can be used only by fields If is initialized via constructor can have different values Is a compile-time constant
51
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual readonly const Can be initialized: at declaration or in a constructor Can be initialized only a the declaration Can be used only by fields If is initialized via constructor can have different values Is a compile-time constant
52
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual
53
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual Can be used for classes and methods
54
NET Framework – C# access modifiers and other common types
Classes => prevents other classes to inherit from it. Methods => prevents from overriding virtual methods. Other common types readonly vs const sealed virtual
55
NET Framework – C# access modifiers and other common types
Classes => prevents other classes to inherit from it. Methods => prevents from overriding virtual methods. Other common types readonly vs const sealed virtual
56
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual
57
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual It is used for: methods, properties indexer and events.
58
NET Framework – C# access modifiers and other common types
readonly vs const sealed virtual It is used for: methods, properties indexer and events. This allows us to override the behavior in a derived class.
59
One more thing…
60
One more thing… “Talk is cheap. Show me the code.”
61
One more thing… “Talk is cheap. Show me the code.” ― Linus Torvalds
Write comments only when strictly necessary and keep them in sync with the code.
62
One more thing… “Talk is cheap. Show me the code.” ― Linus Torvalds
Write comments only when strictly necessary and keep them in sync with the code. Establish a set of shared coding standards
63
One more thing… “Talk is cheap. Show me the code.” ― Linus Torvalds
Write comments only when strictly necessary and keep them in sync with the code. Establish a set of shared coding standards. “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”
64
One more thing… “Talk is cheap. Show me the code.” ― Linus Torvalds
Write comments only when strictly necessary and keep them in sync with the code. Establish a set of shared coding standards. “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.” – Martin Fowler
65
Questions Do you have any other questions?
66
Thanks! See you next time!
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.