NET Review - Computer Science

Download Report

Transcript NET Review - Computer Science

C# & .NET
Review
The Essence
Concepts
Computer
Science
Programming
Description
The science of data
processing
Data Structures &
Algorithms
Data Structures Formatted data store
Reference
WP Overview
Algorithms
WP Overview
Methods to process data
efficiently
WP Overview
WP Overview
The Essence
Concepts
Code Reuse
Systems
Skills
Description
Reference
Across functions (modules) WP Overview
Across modules (DLL)
Across processes (OLE,
object-linking-embedding)
Across systems (WS, Cloud
Computing)
Solution systems for
WP Overview
solving real world problems
Knowledge, Solution,
Design, Create
WP Overview
Online Object Sharing (Tim Reynolds, 2005)
Data Structures
Data Structures
Concepts
Value Types
Reference Types
Properties
Boxing
Unboxing
Dataset
DataGrid
Description
Stack objects
Heap objects
Secured data with accessors
Value to reference
Reference to value
Memory mapping of a
database table
GUI for a database table
Reference
C2
C2
C2
C2
C2
C10
C10
Data Structures
Concepts
Meta Data
Schema
Manifesto
Reflection
Description
Data that describes data
Collection of meta data
Meta data describes assemblies
APIs for reading meta data.
Allowing the creation of classes and
objects dynamically.
Reference
C3
C3
C3
C3
Data Structures for the Internet
Concepts
IP Packets
XML
SOAP
Description
The format for transmitting data
Text format for describing data
Object-oriented XML data format
Reference
C9
C13
C11
Data Structures for the Internet
Concepts
Web.config
Description
XML data for configure web
applications
Session
For storing web application
Cache
global data
Cookies
For storing web data at clients
Database
Persistent data store on a server.
Session
Persistent web application data
State Server store on another server
Reference
C9
C9
C11
C12
C9
Algorithms
Algorithms
Concepts
Properties
Reflections
EDP
GUI
Controls
Description
Safe and convenient way to
access protected data
APIs for dynamical creation of
classes and objects.
Event-driving programming
Graphical User Interface
representing algorithms
GUI items for generating
events.
Reference
C2
C3
C4
C4
C4
Algorithms
Concepts
Web Forms
Code
Behind
XCopy
DB Access
Patterns
Transaction
Description
GUI EDP programming model
Protecting source code by
creating DLLs to share.
Object-oriented deployment
Protocols for dynamically
access data online.
All-or-None DB operations
Reference
C5/C9
C9
C9
C12
C12
Algorithms (Security)
Concepts
Authentication
Authorization
DB-based
Authentication
Description
Identifying users
Giving user permissions
Storing credentials in a
database
Reference
C10, PA5
C10, PA5
C10, PA5
Role-based
Authorization
Code-based
Authorization
Giving group permissions
C10, PA5
Dynamically giving user
permissions
C10, PA5
Algorithms (WS)
Concepts
Web
Services
WS Proxies
For-fee WS
WSDL
Description
Protocols for dynamically
sharing algorithms online.
Representing WS at client side.
Authentication protocols for
web services
Format for describing web
methods (APIs to algorithms)
Reference
C11
C11
C11
C11
Systems
Systems (Foundations)
Concepts
CIL/CTS
CLR
DLL
Web
Services
Description
For language-independent
programming
For platform-independent
execution
Secured way of sharing code
Protocols for dynamically
sharing code online
Reference
WP
Overview
WP
Overview
C3, PA1
C11
Systems (Applications)
Concepts
Console
Application
Windows
Forms
Web
Applications
Enterprise
Applications
Online Visual
Programming
Studio
Description
Stand-alone command-line
applications
For developing stand-alone
GUI EDP applications
For developing web-based
GUI EDP applications
For developing multi-tier
web applications
For building GUI EDP
applications online.
Reference
C1/C3, PA1
C4, PA2
C5, PA3
C9/C10/C12,
PA4/PA5
C3/C5, PA3
Systems (Cloud Computing)
Concepts
Web Services
Description
Protocols for dynamically
sharing code online
WS
Protocols for developing
Consumptions applications that consumes
WSs.
Cloud
Virtualized on-demand
Computing
scalable web applications.
SaaS (Software Cloud-based applications to
as a Service)
be shared online with users
and programmers.
Reference
C11
C11
C11
C11
More .NET Features
Remoting,
WCF, WPF, WF,
MVC,
LINQ,
Multithreading,
Task Parallel,
IoT
Remoting
XML Web Services
Client 1
Proxy of Interface 2
UDDI Registry 2
SOAP
UDDI Registry 1
Client 2
Proxy of Interface 1
SOAP
Application 1
WSDL Interface 1
Application 2
WSDL Interface 2
WEB
WS Class, Contract, Registry, Proxy.
XML/HTML: inefficient communication, limited representation power.
Remoting
.
• Remoting is for closely coupled applications with a tighter
coupling of client and server.
• Such applications have their own client programs and don’t
depend on browsers to communicate with the servers. They are
“rich-client” applications and distributed applications.
• Better suited for two-way communication between clients and
servers than are conventional Web applications.
• Closely coupled applications utilize network bandwidth more
efficiently because they can use lean binary protocols in lieu
of HTTP.
• “Rich-clients” can use Windows forms to better overcome the
limitations of HTML.
• Close coupling facilitates stateful connections between clients
and servers, which in turn simplifies the task of building stateful
applications.
Remoting
• Closely coupled applications building tools:
– DCOM (Distributed Component Object Model),
– CORBA (Common Object Request Broker Architecture),
– Java RMI (Remote Method Invocation).
.
• .NET Remoting: System.Runtime.Remoting is for building
closely coupled rich-client applications without the hassles that
come with COM programming—apartments, IDL (Interface
Definition Language), reference counting, lack of exception
handling, incompatible languages and data types, and so on.
• .NET remoting is a better COM than COM.
Windows Communication
Foundation
(WCF)
WCF: Windows Communication Foundation
• For distributed applications.
• Using service oriented architecture (SOA).
• Clients can consume multiple services; Services can be consumed by
multiple clients. (M:M)
• Services have WSDL interface.
• WCF examples: WSS (Web Services Security, extension to SOAP to
apply security to web services), WS-Discovery (Web Services
Dynamic Discovery, a multicast discovery protocol to locate
services),
• For building WS-based Multi-tier web application.
WCF: Windows Communication Foundation
• Endpoints: client connects to a WCF service at an Endpoint, each
service exposes its contract via endpoints.
• End point ABC: address, binding, contract
• WCF endpoints use SOAP envelope to communicate with clients
(for platform independence).
• Behaviors allow the developer to customize how the
messages are handled.
Windows Presentation Foundation
(WPF)
WPF: Windows Presentation Foundation
•
•
•
•
•
•
•
Graphical subsystem.
Based on DirectX
2D and 3D graphics, vector graphics and animation
Remote or standalone
Safe remote view with IE.
Uses XAML to define UI elements.
XAML: eXtensible Application Markup Language
Windows Workflow Foundation
(WF)
WF: Windows Workflow Foundation
•
•
•
•
•
Workflow: a series of distinct programming steps.
An activity at each step.
Workflow Designer in Visual Studio.
Workflow Engine: scheduling, managing, tracking workflows.
To create applications that execute an ordered business
process (UA curriculum proposal approval system).
LINQ
Language Integrated Query
Embedded SQL in C# as strings
StringBuilder builder = new StringBuilder ();
builder.Append ("select count(*) from users " +
"where username = \'");
builder.Append (username);
builder.Append ("\' and pwd = \'");
builder.Append (password);
builder.Append ("\';");
MySqlCommand command = new MySqlCommand (builder.ToString (), connection);
Int64 count = (Int64) command.ExecuteScalar ();
LINQ: Language Integrated Query
var results = from c in SomeCollection
where c.SomeProperty < 10
select new {c.SomeProperty};
foreach (var result in results) Console.WriteLine(result);
MVC
(Model View Controller)
Architecture of a Four-Tier Application
Supporting Software
App User Interface
VIEW
WEB
WEB
S
E
R
V
E
R
C
L
I
E
N
T
User Interface
Database Engine
Database
DBMS / Database Server
Application Logic
CONTROLLER
Database API
MODEL
Application Server
Architecture of a Four-Tier Application
Multithreading
Multithreading
Multithreading is a mechanism for performing two or more
tasks concurrently.
 In the managed world of the common language runtime,
the fundamental unit of execution is the thread.
.
 A managed application begins its life as a single thread
but can spawn additional threads.
 Threads running concurrently share the CPUs/GPUs by
using scheduling algorithms provided by the system.
 To an observer, it appears as if all the threads are running
at once.
Example
using System;
using System.Threading;
class MyApp
{
static void Main ()
{
for (int i=0; i<10; i++) {
Thread thread = new Thread(
new ThreadStart(ThreadFunc));
thread.Name = "My thread # " + i;
thread.Start ();
}
}
Example
static void ThreadFunc ()
{
String name = Thread.CurrentThread.Name;
for (int i=0; i<10; i++) {
for( int j=0; j<100000000; j++); //work
System.Console.WriteLine
(name + " running at "+ DateTime.Now);
}
}
}
Task Parallel
Parallel Extensions
•
•
•
•
•
Managed concurrency library
TPL: Task Parallel Library
PLINQ: Parallel LINQ
Multithreading based.
Take advantages of muti-core (Intel) and many core (Nvidia GPU)
Microsoft Universal Windows Platform
•
•
•
•
Device independence
PCs, Surfaces, Smart Phones, Xboxes
Any language supported by .NET
Use XAML (eXtensible Application
Markup Language) to define application
IoT
Internet of Things
Connecting everything over the Internet
Microsoft:
https://www.microsoft.com/IoT
• Can be connected to Microsoft Cloud
(Azure)
• Tim and Cory use IoT to connect to
their RasberryPI to play video games
• Will be taught in HCI (Human Computer
Interaction) course in the summer.