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
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?
Как это выглядит? Win32 MessageQueuingCOM+ (Transactions, Partitions, Object Pooling) IISWMI Common Language Runtime.NET Framework Class Library ADO.NET: Data and XML XML Web Services User Interface Visual Basic C++C# ASP.NET PerlJ#…
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 Runtime Base Class Library Support Thread Support COM Marshaler Type Checker Exception Manager MSIL to Native CompilersCodeManagerGarbageCollector Security Engine Debug Engine Class 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
Basics on OOP Encapsulation Combining Data and Methods Controlling access visibility Polymorphism Inheritance Abstract base class Interfaces
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 Musician TuneYourInstrument( ) Guitar Player TuneYourInstrument( ) Violin Player 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
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
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)
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)
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)
Solving (C#) Event and Delegate Example