Download - Arquitectura Net
![Page 1: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/1.jpg)
Arquitectura .NET
César Julio Bustacara M.2008
![Page 2: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/2.jpg)
Agenda
Guías de arquitectura, diseño y códigoArquitectura del .NET Framework y la CLRAcceso a datos: ADO.NET
![Page 3: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/3.jpg)
Guías de arquitectura / diseño y código
Guías de Arquitectura (PAG)Estándares de desarrolloApplication BlocksGuías de migración
![Page 4: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/4.jpg)
Guías de arquitectura
Guías de diseño para aplicaciones .NETMuestran como encaja todo junto
Blueprint para decisiones a nivel de diseñoAlto riesgo en la etapa de diseñoArquitectos son contrarios al riesgo
No es una solución para todos los diseñosHay escenarios específicos
Preservar las inversiones“¿Tendré que rehacer todo en el futuro?”
![Page 5: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/5.jpg)
Operatio
nal M
anag
emen
tO
peratio
nal M
anag
emen
t
Secu
ritySecu
rity
Com
municatio
nCom
municatio
n
Users and DevicesUsers and Devices
Data Sources
ServicesSvc InterfacesSvc Interfaces
Svc AgentsSvc Agents
Guías de Arquitectura
BusinessBusiness
PresentationPresentation
Data Data
![Page 6: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/6.jpg)
Operatio
nal M
anag
emen
tO
peratio
nal M
anag
emen
t
Secu
ritySecu
rity
Com
municatio
nCom
municatio
n
Users and DevicesUsers and Devices
Data Sources
UI ComponentsUI Components
UI Process ComponentsUI Process Components
Data Access ComponentsData Access Components
Business WorkflowsBusiness Workflows
Business ComponentsBusiness Components
Business EntitiesBusiness Entities
ServicesSvc InterfacesSvc Interfaces
Svc AgentsSvc Agents
Guías de Arquitectura
![Page 7: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/7.jpg)
Guías de Arquitectura
Application Architecture for .NET: Designing Applications and Services
.NET Data Access Architecture Guide
Building Secure ASP.NET Applications
Debugging .NET Applications
Exception Management in .NET
![Page 8: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/8.jpg)
Guías de Arquitectura
.NET/COM Migration and Interoperability
Monitoring in .NET
Deploying .NET Applications
Team Development with SourceSafe
UNIX Code Migration Guide http://msdn.microsoft.com/practices/
![Page 9: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/9.jpg)
Estándares de desarrolloAyudan a escribir código robusto y seguro que funciona de manera consistente con el Framework .NETFacilitan la propiedad colectiva del código.NET Framework Design Guidelines
http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconnetframeworkdesignguidelines.asp
FxCop: analiza el código managed para chequear las prácticas recomendadas
http://www.gotdotnet.com/team/libraries/
![Page 10: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/10.jpg)
Application Blocks
Data Access Application Block for .NET Componente .NET que contiene códigooptimizado de acceso a datos
Exception Management Application Block for .NET
Provee un framework simple y extensible paramanejar excepciones
![Page 11: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/11.jpg)
Arquitectura del Framework de .NET y la CLR
Objetivos de diseñoArquitecturaBeneficiosCompilación
![Page 12: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/12.jpg)
Introducción a .NET Objetivos de diseño de .NET Framework
Entorno consistente de orientación a objetos:
mismo modelo para ejecución local, código remoto o entorno distribuido en Internet
Minimizar conflictos: implantación y versionesProporcionar ejecución segura de código
![Page 13: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/13.jpg)
Introducción a .NET Objetivos de diseño de .NET Framework
Eliminar problemas de rendimientode código interpretado o con scriptingMayor productividad del desarrollador tanto para aplicacionesWindows como WebComunicación basada en estándaresde la industria
![Page 14: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/14.jpg)
Introducción a .NET Framework, Lenguajes y Herramientas
SistemaSistema OperativoOperativo
Common Language RuntimeCommon Language Runtime
Base Class LibraryBase Class Library
ADO.NET y XMLADO.NET y XML
ASP.NETASP.NETWeb Forms Web ServicesWeb Forms Web Services
Mobile Internet ToolkitMobile Internet Toolkit
WindowsWindowsFormsForms
(.NET CF)(.NET CF)
Common Language SpecificationCommon Language Specification
VBVB C++C++ C#C# JScriptJScript® J#J#V
isual StudioV
isual Studio®
.NE
T.N
ET
![Page 15: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/15.jpg)
System System
System.DataSystem.Data System.XmlSystem.Xml
System.WebSystem.Web
GlobalizationGlobalizationDiagnosticsDiagnosticsConfigurationConfigurationCollectionsCollections
ResourcesResourcesReflectionReflectionNetNetIOIO
ThreadingThreadingTextTextServiceProcessServiceProcessSecuritySecurity
CommonCommonOleDbOleDb
SQLTypesSQLTypesSqlClientSqlClient
XPathXPathXSLTXSLT
RuntimeRuntimeInteropServicesInteropServicesRemotingRemotingSerializationSerialization
SerializationSerialization
ConfigurationConfiguration SessionStateSessionStateCachingCaching SecuritySecurity
ServicesServicesDescriptionDescriptionDiscoveryDiscoveryProtocolsProtocols
UIUIHtmlControlsHtmlControlsWebControlsWebControls
System.DrawingSystem.Drawing
ImagingImagingDrawing2DDrawing2D
TextTextPrintingPrinting
System.Windows.FormsSystem.Windows.FormsDesignDesign ComponentModelComponentModel
Introducción a .NET Framework, Languajes y herramientas
![Page 16: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/16.jpg)
Introducción a .NET Beneficios del .NET Framework
Simplifica el desarrollo y la implantaciónProporciona un entorno de ejecuciónseguro y robustoUnifica modelos de programaciónSoporta múltiples lenguajes de programaciónIndependiente de la plataforma
![Page 17: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/17.jpg)
Introducción a .NET Beneficios del .NET Framework
Sistema común de tiposInstancias y definición de tipos comunes
Orientación a objetos:Clases e interfacesConstructores, propiedades, métodos, eventosHerencia cruzada entre lenguajes
InteroperabilidadCon COMCon DLLs nativas (del estilo Win32)
![Page 18: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/18.jpg)
Introducción a .NET Beneficios del .NET Framework
Elimina la “fontanería” de COMNo más …
Registro
GUIDs
Archivos .IDL
HRESULTs
IUnknown
AddRef/Release
CoCreateInstance
=>=>ApsAps autodescriptivasautodescriptivas
=>namespaces =>namespaces jerjeráárquicosrquicos
=>=>objetosobjetos autodescriptivosautodescriptivos
=>=>excepcionesexcepciones estructuradasestructuradas
=>=>objetoobjeto raizraiz comcomúúnn
=>garbage collector=>garbage collector
=>=>operadoroperador ””newnew””
![Page 19: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/19.jpg)
AssemblyAssembly
Introducción a .NET Compilación y ejecución
CCóódigodigo fuentefuente
Compilador Compilador del del lenguajelenguaje
CompilaciCompilacióónn
En En instalaciinstalacióónn o la o la primeraprimera vezvez queque se se
invocainvoca a a cadacada mméétodotodoEjecuciEjecucióónn
Compilador Compilador JITJIT
CCóódigodigo NativoNativo
CCóódigodigo (IL)(IL)
MetadatosMetadatos
![Page 20: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/20.jpg)
Acceso a datos: ADO.NET
ADO vs ADO.NETCaracterísticas de ADO.NETArquitecturaEnlace a datos (binding)
![Page 21: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/21.jpg)
ADO trabaja bien, pero:Necesita COM y WindowsLos recordsets no viajan bien a través de Internet
ADO.NET resuelve estos problemas:Utiliza XML (a bajo nivel) para realizar el transportede datosXML no tiene requisitos específicos de runtime/transporte⌧
No se necesita un código especial para hacer el marshaling a través de Internet
ADO .NET, una nueva mentalidad:Entorno desconectadoTodo el transporte de datos utiliza XML
ADO vs ADO.NET
![Page 22: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/22.jpg)
ADO.NET
DBLib, ODBC, DAO, RDO, ADO, …. ADO.NETSystem.Data: la clase raizA partir de ahí, principales namespaces:
System.Data.OleDBSystem.Data.SQLClientSystem.Data.ODBC, System.Data.OracleClient
System.XML: para trabajar directamentecon XML
![Page 23: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/23.jpg)
ADO.NET
System.Data.OleDb: trabaja con todas las fuentes OLE DB
Soporta unmanaged providers de ADO
System.Data.SQLClient: sólo SQL Server (managed)VStudio 2003: System.Data.ODBC, System.Data.OracleClient
![Page 24: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/24.jpg)
NegocioNegocio DatosDatos
PresentaciónWindows Forms
Web formsWeb forms
Business to businessBusiness to business
Data object (class)Data object (class)
DataSetDataSet
DataSetDataSetDataSetDataSet
InternetInternet intranetintranet Data adapterData adapter
Data adapterData adapter
(BizTalk, (BizTalk, porpor ejemploejemplo))
XmlXml
MiAp.ExeMiAp.Exe
IEIE
Arquitectura de ADO.NET
![Page 25: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/25.jpg)
Buffer de datos
Acceso a datos
DataAdapterDataSet
Diferencia fundamental
Buffer de datos
Acceso a datos
RecordsetEn ADO:
En ADO.NET:
![Page 26: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/26.jpg)
ADO.NET: ConnectionOleDbConnection/SQLConnectionRepresenta la sesión contra la BDUtilizado por objetos Data Adapter y Command para recuperar/actualizarInicia las transacciones
Connection.BeginTransaction() devuelve un objeto TransactionxxxTransaction⌧Un comando se enlista en una transacción⌧IsolationLevel⌧Commit() / Rollback()
Configuración del pool de conexiones en el connection string
![Page 27: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/27.jpg)
ADO.NET: Command
OleDbCommand/SQLCommandRepresenta Transact-SQL o procedimientosalmacenadosDevuelve un resultset (ExecuteReader), un valor (ExecuteScalar), o ejecuta sentenciasde modificación (ExecuteNonQuery)Generación automática con el objetoCommandBuilder
![Page 28: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/28.jpg)
ADO.NET: DataReaderOleDbDataReader/SQLDataReader
Stream forward-only read-only
Utilizado por el DataAdapter
Muy rápido
Creado por un objeto Command (ExecuteReader)
![Page 29: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/29.jpg)
ADO.NET: DataAdapter
OleDbDataAdapter/SQLDataAdapter
Representa un conjunto de Commands y unaConnection
Puente entre el DataSet y la BD
Lee y actualiza la BD:SelectCommand, UpdateCommand, InsertCommand, DeleteCommand
![Page 30: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/30.jpg)
ADO.NET – DataAdapter
DataAdapterDataAdapter
SelectCommandSelectCommand
InsertCommandInsertCommand
UpdateCommandUpdateCommand
DeleteCommandDeleteCommand
TableMappingsTableMappings
Base de Base de datosdatos
DataSetDataSet
![Page 31: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/31.jpg)
ADO.NET: DataSet
Objeto estrella en ADO.NET
Representa una caché de datos en memoria
Contiene DataTables
Lee y escribe datos y esquemas en XML
Serializable
![Page 32: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/32.jpg)
ADO.NET: DataSet
Puede ser tipado o no tipado:Ambos heredan de la clase DataSet
El tipado se apoya en un esquema XML (.XSD) para generar la clase
El tipado tiene ventajas:⌧Expone estructura como propiedades y métodos:
Intellisense
⌧Recoge la Primary key
![Page 33: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/33.jpg)
ADO.NET: Otros objetosDataTable
Representa una tabla en memoriaLo rellena un DataAdapter o a manoComponente principal de los objetos DataSet y DataView
DataViewVista personalizada de un objeto DataTableFiltros, ordenación, búsquedas …
DataRelationDefine relaciones entre tablasUtiliza columnas de un DataTable
![Page 34: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/34.jpg)
ADO.NET - DataSet
DataSetDataSet
DataTableDataTable
DataTableDataTable
DataRowDataRow
DataColumnDataColumn
RelationsRelations
ConstraintsConstraintsXML SchemaXML Schema
![Page 35: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/35.jpg)
ADO.NET: Lecturas
Método Fill del objeto DataAdapterSe utiliza el SelectCommand del DataAdapterInserta/actualiza datos del DataSet
Si la tabla existe, actualiza datosSi no existe, crea y rellena la tablaUna tabla por cada resultset
Mantiene la conexión en su estado original
![Page 36: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/36.jpg)
ADO.NET: ActualizacionesLa funcionalidad en ADO es implícita. Recordset = caja negra.
Ejemplo: UpdateBatchEn ADO.NET: Se crea un modelo más explícito y transparente.
InsertCommand, UpdateCommand, DeleteCommandEventos de Update
CommandBuilderCommandBuilder: generación automática de los comandos de Insert, Update y Delete a partir del SelectCommand
![Page 37: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/37.jpg)
ADO.NET: Actualizaciones
DataAdapter.Update:Analiza los cambios del DataSetEjecuta los comandos Insert, Update y Delete necesariosRefresca el DataSet
Orden de ejecución por defecto:Insert, Update y Delete.
![Page 38: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/38.jpg)
ADO.NET: Enlace a datos
ADO.NET soporta enlazar (binding) DataSets a Windows Forms / Web Forms y sus controlesVStudio .NET incluye bastanteswizards para hacer el enlace entredatos y controles
![Page 39: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/39.jpg)
Resumen
![Page 40: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/40.jpg)
Resumen
![Page 41: Arquitectura Net](https://reader031.vdocuments.pub/reader031/viewer/2022013111/54fb50384a7959f9348b4916/html5/thumbnails/41.jpg)
Ejemplo
Solo lectura