architecture and design pattern in applications development on.net platform sergey baidachni mct,...
Post on 21-Dec-2015
215 views
TRANSCRIPT
Architecture and Design Pattern in Applications Development On .NET PlatformSergey Baidachni
MCT, MCSD, MCDBA
Overview
Introduction to the automobile design .NET Framework architecture OOP in .NET Framework (C#) Design Patterns
Introduction
About Cars A little about cars How cars are designed, or game of Puzzles
Car creation and program creation When should we talk about .NET? Requirements or how to please a car
amateur
When should you talk about .NET Should you start out with coding? Ford and model Т Collection of requirements MSF – Microsoft Solution Framework
Requirements
Business Interaction between goals and objectives, products and services,
financial structures and major organizational structures
Application Automated and Non automated services that support the
business process
Operation What the organization needs to know to run its business process
Technology Technical service needed to perform and support the business
mission
MSF
.NET Framework architecture What does it look like? What language should you choose? Common Language Runtime Developing interactions with data bases Windows application– what can be any
simpler? ASP.NET – development of Web applications Web Services or will there be any future Web
applications?
Как это выглядит?
Win32Win32
MessageMessageQueuingQueuing
COM+COM+(Transactions, Partitions, (Transactions, Partitions,
Object Pooling)Object Pooling)IISIIS WMIWMI
Common Language RuntimeCommon Language Runtime
.NET Framework Class Library.NET Framework Class Library
ADO.NET: Data and XMLADO.NET: Data and XML
XML Web ServicesXML Web Services User InterfaceUser Interface
VisualBasic C++ C#
ASP.NETASP.NET
Perl J# …
What language to choose? С# - New component-oriented language
for .NET VB.NET – New language version VB with
additions Managed Extensions to С++ J# - for Java amateurs …And any languages
What language to choose?
Microsoft Intermediate Language (MSIL)
Or
Common Intermediate Language
Common Language RuntimeBase Class Library SupportBase Class Library Support
Thread SupportThread Support COM MarshalerCOM Marshaler
Type CheckerType Checker Exception ManagerException Manager
MSIL to NativeMSIL to NativeCompilersCompilers
CodeCodeManagerManager
GarbageGarbageCollectorCollector
Security EngineSecurity Engine Debug EngineDebug Engine
Class LoaderClass Loader
Data Base interaction
ADO.NET Connected environment Disconnected environment System.Data: DataSet, DataTable,
DataRow,DataColumn .NET Providers: System.Data.SqlClient,
System.Data.Odbc, System.Data.OleDb, System.Data.OracleClient
Data Base Interaction
ADO
Connection
Command RecordSet
ADO.NET
XxxConnection XxxTransaction XxxCommand XxxDataReader
XxxDataAdapter DataSet
.NET Data Provider
Windows application
Convenient graphic designer for Visual Studio.NET
System.Windows.Forms Controls Form, TextBox, ComboBox e. t. c.
System.Drawing Drawing Pens, Brushes e. t. c.
Windows applications
It is an extremely short program
using System.Windows.Forms;class SimpleForm{
static void Main(){
Form form=new Form();Application.Run(form);
}}
ASP.NET – Development of Web applications Web Forms editor for VS.NET System.Web
User interface Security SessionState Caching Configuration
XML Web Services What is this?
URL-addressable set of functionality exposed over a network
Advantage HTTP: Stateless and text XML: Standard format Any platform and language
Standards XML SOAP WSDL XSD
OOP in .NET Framework (C#) Class and Object What’s missing? Class in C# Using UML Basics on OOP
Class and Object
Class Abstract notion Description of something A named syntactic construct that describes common behavior
and attributes
Object Instance of a class Identity Behavior State
What’s missing?
OOP – way of thinking of a human Can I set gears in motion? Access Modifiers
public private protected
…And additional in .NET internal protected internal
Class in C#
public class Bicycle
{
public Wheel leftWheel;
public Wheel rightWheel;
public void move the pedals (){…}
protected void move the gear (){…}
. . . . .
}
Using UML
Which language is of easy understanding to all?
UML – Universal modulation language
+К р у т и т ь п е д а л и ()#В р а ща т ь ше с т е р е н к и ()
+Р у л ь-П е р е д н е е к о л е с о-З а д н е е к о л е с о-Ц е п ь
bicycle
Basics on OOP
Encapsulation Combining Data and Methods Controlling access visibility
Polymorphism Inheritance Abstract base class Interfaces
Inheritance
Inheritance Specifies an “is a kind of” relationship Class relationship Specialize existing classes
+К р у т и т ь п е д а л и ()#В р а ща т ь ше с т е р е н к и ()
+Р у л ь-П е р е д н е е к о л е с о-З а д н е е к о л е с о-Ц е п ь
В е л о с и п е д
Г о р н ый в е л о с и п е д
Inheritance example (C#)
public class Bicycle{
public Wheel leftWheel;public Wheel rightWheel;public void Move the pedals (){…}protected void Move the gear (){…}. . . . .
}
public class ExtendBicycle: Bicycle{
protected void Move the gear (){…}. . . . .
}
Polymorphism
The method name resides in the base class The method implementations reside in the
derived classes
String MusicianString Musician
TuneYourInstrument( )TuneYourInstrument( )
Guitar PlayerGuitar Player
TuneYourInstrument( )TuneYourInstrument( )
Violin PlayerViolin Player
TuneYourInstrument( )TuneYourInstrument( )
A method with no implementation is called an operation
A method with no implementation is called an operation
Polymorphism example(C#)public class StringMusician
{
public virtual void Tune(){…}
}
public class GuitarPlayer: StringMusician
{
public override void Tune(){…}
}
public class ViolinPlayer: StringMusician
{
public override void Tune(){…}
}
StringMusician obj=new ViolinPlayer();
obj.Tune();
Abstract Base Classes
Some classes exist solely to be derived from It makes no sense to create instances of these
classes These classes are abstract
Stringed Musician{ abstract }
Stringed Musician{ abstract }
Guitar Player« concrete »
Guitar Player« concrete »
Violin Player« concrete »Violin Player« concrete »
You can create instances of concrete classes
You can create instances of concrete classes
You cannot create instances of abstract classes
You cannot create instances of abstract classes
Abstract base class example(C#)public abstract class StringMusician
{
public abstract void Tune();
}
public class GuitarPlayer: StringMusician
{
public override void Tune(){…}
}
public class ViolinPlayer: StringMusician
{
public override void Tune(){…}
}
StringMusician obj=new ViolinPlayer();
obj.Tune();
Interfaces
Contains only operations without implementation
+Compare(in Object) : bool
«interface»ICompare
+Compare(in Object) : bool
MyType
Interfaces example(C#)public interface StringMusician
{
void Tune();
}
public class GuitarPlayer: StringMusician
{
public void Tune(){…}
}
public class ViolinPlayer: StringMusician
{
public void Tune(){…}
}
StringMusician obj=new ViolinPlayer();
obj.Tune();
Design Patterns
What is this? Strategy Pattern Singleton Pattern Publish-Subscribe Pattern
What is this?
Solution of the problem that occurs most often
Patterns Name Strategy Proxy Iterator
Problem definition Solving Results
Strategy pattern
Problem Solving (UML) Solving (C#)
Problem
Do I need all the algorithms? How do I choose the proper method?
swith(type)
{
case 1:
FirstMethod();
case 2:
SecondMethod();
. . . . .
}
Solving (UML)
...
Client AbsrtractStrategy
operation( )
Uses
ConcreteStrategy1 ConcreteStrategy2
1 0..1
Solving (C#)interface AbstractStrategy
{
void Operation();
}
class ConcreteStrategy1: AbstractStrategy
{
public void Operation(){. . . }
}
class ConcreteStrategy2: AbstractStrategy
{
public void Operation(){. . . }
}
public class Client
{
private AbstractStrategy stat;
}
Singleton Pattern
Problem Solving (UML) Solving (C#)
Problem
Only one class sample What for?
One Garbage Collector One Explorer
Solving (UML)
+Instance()#Singleton()
-_instance
Singleton
Solving (C#)class Singleton{
public static Singleton Instance(){
if (_instance == null) {
_instance = new Singleton();}return _instance;
}
protected Singleton(){};
private static Singleton _instance;}
Publish-Subscribe
Problem Solving (UML) Solving (C#)
Problem
How Windows work Message Queue Repainting windows
Solving (UML)«interface»ObserverIF
notify
Observer
«interface»ObservableIF
addObserver(:ObserverIF)removeObserver(:ObserverIF)
Observable
Multicaster
addObserver(:ObserverIF)removeObserver(:ObserverIF)
Register-observers
1
1
Notifies
1
1
Registers-to-receive-notifications 10..*
Notifies
0..*
Solving (C#)
Event and Delegate Example