architecture and design pattern in applications development on.net platform sergey baidachni mct,...

45
Architecture and Design Pattern in Applications Development On .NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Post on 21-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Architecture and Design Pattern in Applications Development On .NET PlatformSergey Baidachni

MCT, MCSD, MCDBA

Page 2: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Overview

Introduction to the automobile design .NET Framework architecture OOP in .NET Framework (C#) Design Patterns

Page 3: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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

Page 4: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

When should you talk about .NET Should you start out with coding? Ford and model Т Collection of requirements MSF – Microsoft Solution Framework

Page 5: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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

Page 6: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

MSF

Page 7: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

.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?

Page 8: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Как это выглядит?

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# …

Page 9: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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

Page 10: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

What language to choose?

Microsoft Intermediate Language (MSIL)

Or

Common Intermediate Language

Page 11: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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

Page 12: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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

Page 13: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Data Base Interaction

ADO

Connection

Command RecordSet

ADO.NET

XxxConnection XxxTransaction XxxCommand XxxDataReader

XxxDataAdapter DataSet

.NET Data Provider

Page 14: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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.

Page 15: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Windows applications

It is an extremely short program

using System.Windows.Forms;class SimpleForm{

static void Main(){

Form form=new Form();Application.Run(form);

}}

Page 16: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

ASP.NET – Development of Web applications Web Forms editor for VS.NET System.Web

User interface Security SessionState Caching Configuration

Page 17: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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

Page 18: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

OOP in .NET Framework (C#) Class and Object What’s missing? Class in C# Using UML Basics on OOP

Page 19: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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

Page 20: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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

Page 21: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Class in C#

public class Bicycle

{

public Wheel leftWheel;

public Wheel rightWheel;

public void move the pedals (){…}

protected void move the gear (){…}

. . . . .

}

Page 22: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Using UML

Which language is of easy understanding to all?

UML – Universal modulation language

+К р у т и т ь п е д а л и ()#В р а ща т ь ше с т е р е н к и ()

+Р у л ь-П е р е д н е е к о л е с о-З а д н е е к о л е с о-Ц е п ь

bicycle

Page 23: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Basics on OOP

Encapsulation Combining Data and Methods Controlling access visibility

Polymorphism Inheritance Abstract base class Interfaces

Page 24: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Inheritance

Inheritance Specifies an “is a kind of” relationship Class relationship Specialize existing classes

+К р у т и т ь п е д а л и ()#В р а ща т ь ше с т е р е н к и ()

+Р у л ь-П е р е д н е е к о л е с о-З а д н е е к о л е с о-Ц е п ь

В е л о с и п е д

Г о р н ый в е л о с и п е д

Page 25: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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 (){…}. . . . .

}

Page 26: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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

Page 27: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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();

Page 28: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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

Page 29: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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();

Page 30: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Interfaces

Contains only operations without implementation

+Compare(in Object) : bool

«interface»ICompare

+Compare(in Object) : bool

MyType

Page 31: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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();

Page 32: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Design Patterns

What is this? Strategy Pattern Singleton Pattern Publish-Subscribe Pattern

Page 33: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

What is this?

Solution of the problem that occurs most often

Patterns Name Strategy Proxy Iterator

Problem definition Solving Results

Page 34: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Strategy pattern

Problem Solving (UML) Solving (C#)

Page 35: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Problem

Do I need all the algorithms? How do I choose the proper method?

swith(type)

{

case 1:

FirstMethod();

case 2:

SecondMethod();

. . . . .

}

Page 36: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Solving (UML)

...

Client AbsrtractStrategy

operation( )

Uses

ConcreteStrategy1 ConcreteStrategy2

1 0..1

Page 37: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Solving (C#)interface AbstractStrategy

{

void Operation();

}

class ConcreteStrategy1: AbstractStrategy

{

public void Operation(){. . . }

}

class ConcreteStrategy2: AbstractStrategy

{

public void Operation(){. . . }

}

public class Client

{

private AbstractStrategy stat;

}

Page 38: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Singleton Pattern

Problem Solving (UML) Solving (C#)

Page 39: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Problem

Only one class sample What for?

One Garbage Collector One Explorer

Page 40: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Solving (UML)

+Instance()#Singleton()

-_instance

Singleton

Page 41: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Solving (C#)class Singleton{

public static Singleton Instance(){

if (_instance == null) {

       _instance = new Singleton();}return _instance;

}

protected Singleton(){};

private static Singleton _instance;}

Page 42: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Publish-Subscribe

Problem Solving (UML) Solving (C#)

Page 43: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Problem

How Windows work Message Queue Repainting windows

Page 44: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

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..*

Page 45: Architecture and Design Pattern in Applications Development On.NET Platform Sergey Baidachni MCT, MCSD, MCDBA

Solving (C#)

Event and Delegate Example