الجمعة، 7 فبراير 2014

Refinando la arquitectura de nuestro proyecto - Usando Autofac y Moq (1/2)

Después de algunos días retomo la serie de Congreso Visible, y no precisamente por que haya estado detenida en su totalidad, más bien estuve en el proceso de resolver algunos escenarios para el tema de acceso local a la base de datos, lo cual al momento es un post pendiente, pero que no quiero continuar sin antes aplicar al proyecto todas las mejoras que tengo planeadas a nivel de arquitectura, ya que espero llegar un día a una que pueda ser seguida como ejemplo por ustedes y además ofrecer alternativas.

Diré que el ejercicio hasta el momento me dejo demasiados aprendizajes, pero sobre todo una alta comprensión de lo que suponen cada uno de los escenarios que vimos, ya que estuvo complejo resolver de forma manual cada uno de los retos:
  • Tener codigo compartido por todas las plataformas
  • Tener codigo especifico para cada plataforma sin salirse del esquema general.
  • Aplicar pruebas unitarias a los dos escenarios anteriores bajo el mismo esquema.
  • Disminuir el acomplamiento entre las vistas y las vista modelo. Además de usar la menor cantidad de CodeBehind posible.
Todo esto fue una grata experiencia ya que evitamos al máximo usar librerías de terceros, lo que nos hizo tener un mayor entendimiento de la solución dada a cada escenario, sin embargo hoy después de ese proceso considero que podemos con mayor conciencia y aprovechar las ventajas que nos dan al crear código más limpio. En el repositorio quiero conservar los tags tanto a los intentos de no usar librerias como al cambio que realizaré a partir de este momento.
Al empezar este post pensé que podría mostrarles paso a paso el cambio, pero fue tan grande que ahora solo me queda enumerarles los cambios y compartirles los modelos actualizados y el código.

En este primer refinamiento vamos a usar las librerías Autofac para Injección de Dependencias y Moq para Mocking o creación de objetos dummy para los Test Unitarios.

Recuerden que cualquiera de estas librerías se instala en el proyecto que sea necesario a través del menú contextual Manage Nuget Package en la cabecera de sus proyectos.


Se consulta la librería que se desea añadir en las librerías en línea y se da Instalar


Ahora bien veamos cada uno de los cambios de este primer paso. Los cambios más evidentes se resumen en 3:

La eliminación de los servicios fake

Esto fue de los temas más interesantes debido a que comparar los test implementados con Moq versus los Test implementados a mano con Callbacks y Variables adicionales, se nota como el trabajo con Moq hace los Test menos mecanicos y más pensandos, es decir de verdad se necesita saber lo que se está haciendo para ensamblar los Mocks usando Moq


Espero que esten notando claramente la diferencia con la forma de crear Mocks, antes, si nó aquí les comparto una imagen del post en que iniciamos con TDD



De hecho si analizamos detenidamente en una línea haciamos la inyección de dependencias de la instancia de un Fake. Ahora vemos como hacemos la instancia usando Mocks. ¿Y la inyección de dependencias? Pues bien eso es el siguiente punto, por ahora veamos como se ven nuestros Test con Moq.



Si me permiten decirles, bastante bonitos, si desean ver los anteriores dirijanse al post en que iniciamos el montaje de los Test y verán la gran diferencia.

Actualización 10 de Febrero de 2013: Algo muy útil que encontré como compañero de Moq fue una librería adicional llamada Autofixture la cual nos permite añadir datos Fake para las pruebas. Si observa el tercer test de la tabla anterior en el tengo un DataTestHelper en el que uso Autofixture para generar datos y espero que les sea útil conocerlo. Para instalarlo en conjunto con Moq deben seleccionar el paquete correcto.


Luego de esto estarán listos para genera su Helper de generacion de datos Dummy, aquí un pequeño ejemplo, mejorado por mi amigo @HernanDgr


Cambio del manejo manual de dependencias

En este punto se implementó Autofac como contenedor de dependencias. Me hubiese gustado usar Unity, lastimosamente aun no tiene soporte para clases portables como si lo tiene Autofac.

Bien, Al mirar los test vemos como la inyección de dependencias cambió, ahora en vez de registrar una nueva instancia de un Fake, registramos el objeto que Moq crea.

Quisiera resaltar la última línea de la inicialización ya que esta es la manera como decidi resolver el acoplamiento entre las VistasModelo y el contenedor. Siendo que todas las Vistas Modelos heredan de la misma clase padre, dicha clase ahora tiene una referencia al contenedor haciendo que todas tengan la posibilidad de resolver correctamente las dependencias sin saber directamente de donde ellas provienen.

Otra cosa importante es ver como quedó en la aplicación implementado, cambiaron pocas cosas pero son importantes. Antes de mirar el cambio les mostraré que separé el ServiceLocator de las clases de Servicios creadas por ser propias de la plataforma.

En el futuro veremos cuan importante es tener en mente la estructura del proyecto, incluso el hecho de que por ejemplo estos servicios y el Service Locator compartan namespaces con los servicios que estan fuera de las clases. En Windows 8 tendremos que crear la mistra estructura Adicionar como Link el Service Locator y re implementar los servicios propios de la plataforma. Si en un futuro parte de estos servicios se vuelve común, será tan sencillo como implementarlo y pasarlo al assembly de servicios compartidos.
Por lo pronto conocer la reubicación de estas clases es importante debido a que para inicializar las dependencias en la app, es el ServiceLocator quien además de registrar las clases concretas, inicializa el contenedor de Autofac y observen la diferencia con como registramos las dependencias en los Test


Aquí vemos como en vez de registrar una instancia de Moq, registramos las clases concretas. Ahora bien la clase de infraestructura BindableBase quedó igual que antes responsable del contenedor pero esta vez del contenedor de Autofac.



El contenedor de Autofac se usa por las VistaModelo en el constructor, cuando se inicializan los servicios que dicha VistaModelo necesite


Es necesario decir que con este esquema los servicios podemos inicializarlos en el constructor o particularmente en los métodos que los usemos, finalmente siempre se recuperan del mismo contenedor de dependencias y se inicializarán solo una vez ya que solo existe una instancia de la Vista Modelo en el Service Locator. ¿Bonito eh? ¡Muy bonito!

Refactorización general

Se realizaron muchos cambios en nombres de clases, eliminación de interfaces innecesarias y reacomodación de clases en los assemblies. Hoy definitivamente valio la pena la pausa, aprender y pensar en mejores formas de hacer las cosas. Finalmente todos los cambios y el mismo proceso de ajustar el código ha quedado reflejado en el repositorio, un ejercicio interesante puede ser bajar los dos tags hasta el momento y observar las diferencias.

Por el momento en el solo modelo de paquetes, las diferencias son obvias.

Para finalizar quise dejar una reflexión sobre el por que intentar realizar tanto trabajo manual en los 9 post anteriores para no dejar demasiado texto al inicio, sin embargo como siempre me gusta compartirles mis posiciones.
Básicamente lo que más me inquieta de algunos de los devs Windows Phone que conozco son dos temas: Uno, no usan en absoluto ninguna buena práctica de MVVM y tienen vacios enormes a nivel de Programación Orientada a Objetos, o dos usan todas las buenas prácticas a través de librerías, sin entender lo que hacen, lo cual no redunda más que en lo mismo de los primeros, una falencia enorme de conceptos. 
Es importante entender que esto no es una crítica, es un llamado de atención. Como desarrolladores cada día deberiamos preocuparnos por mejorar nuestras habilidades para crear mejor código, todos aprendemos cada día, y deberíamos querer mejorar y avanzar, en la ruta correcta.

Conociendo el ecosistema de Windows Phone 8 y Windows 8

El día de hoy realizé una charla de contextualización para SUMA Conectivo de Mar de Plata Argentina, hablando de las plataformas móviles de Microsoft vistas como ecosistema. El hangout ha quedado publicado para que puedas reproducirlo, y compartirlo


A continuación comparto las diapositivas que espero les resulten útiles para refrescarse un poco.

Your entry to networking: CCENT & CCNA


By 

If you are intending to become a networking professional, this article is for you, as it will present you CCENT and CCNA, the two essential certifications for a successful networking career.  

Cisco Certified Entry Networking Technician (CCENT)

This certification is your ideal starting point as an entry-level network technician. The CCENT proves you have foundational knowledge for a small- to medium-sized network. Passing this exam is the very first step of entering into a network engineering job using Cisco routers and switches.

On the CCENT course you’ll learn about:
  • Networking fundamentals
  • WAN technologies
  • Basic security and wireless concepts
  • Routing and switching fundamentals
  • Configuring simple networks
The ICND exam required to pass is very challenging, therefore you must be very confident in your knowledge, because time is a critical factor. Once you have passed Exam 100-101 - (Interconnecting Cisco Networking Devices Part 1 (ICND1 v2.0) you’ll be CCENT certified. What next?

You should strongly consider taking the ICND2 course and exam 200-101 as well. By passing this exam, you’ll get the CCNA certification.

Cisco Certified Network Associate (CCNA)

The CCNA credentials show your abilities to install, configure, operate, and troubleshoot medium-sized routed and switched networks.

You’ll learn about the following:
  • Redundant topologies
  • Troubleshooting common network issues
  • Configuring EIGRP
  • Multi-area OSPF in both IPv4 and IPv6
  • Wide Area Network technologies
  • Device management
  • Cisco licensing
  • Using Cisco Catalyst switches
  • Cisco routers connected in LANs and WANs
In the ICND2 exam you can expect the same type of questions using simulators, drag and drop, as well as multiple-choice. To learn more about these certifications, visit our CCENT and CCNA course pages.

About the Author:        
Sarah writes for Firebrand Training on a number of IT related topics. This includes exams, training, certification trends, project management, certification, careers advice and the industry itself. Sarah has 11 years of experience in the IT industry. 

Firebrand goes digital


By 

Last weekend saw the launch of digital courseware. Firebrand currently offers 29 courses from Microsoft, Cisco and CompTIA, which are delivered in digital format across all the regions.

What's changing 

Firebrand’s intensive training courses are all about speed. Because we expect a lot from our students, we make sure that they are given the best resources to help them succeed.

Changing from books to digital courseware means that courses can be delivered faster and more efficiently, without having to wait for study material to arrive.

Digital courses at Firebrand are going to be delivered on Microsoft Surface RT devices, making logistics smoother, while also helping the environment.

Watch this video by Microsoft to see how digital courseware will further improve your Accelerated Learning experience with Firebrand: 



Digitally delivered courses include:
For the full list of digital courses visit Firebrand Learn.

About the Author:        
Sarah writes for Firebrand Training on a number of IT related topics. This includes exams, training, certification trends, project management, certification, careers advice and the industry itself. Sarah has 11 years of experience in the IT industry. 

الثلاثاء، 4 فبراير 2014

Microsoft's new CEO: Satya Nadella - First Look

By

On Feb. 04, 2014, Microsoft ushered in a new era announcing Satya Nadella as CEO. Nadella was selected by the Board of Directors, and assumes responsibility with immediate effect. A 22 year veteran of Microsoft, Nadella steps up from the position of Executive Vice President overseeing Microsoft’s Cloud and Enterprise group.

In his time with the company, Nadella has been the catalyst for major strategy and technical shifts across the organisation. Most notable amongst his achievements was the decision to transition Microsoft into the cloud, overseeing the development of one of the worlds largest cloud infrastructures. Foremost in his vision for Microsoft's future development is the desire to innovate, reflected upon in his email to employees on his first day in charge. Nadella says:

"Our industry does not respect tradition — it only respects innovation. This is a critical time for the industry and for Microsoft. Make no mistake, we are headed for greater places — as technology evolves and we evolve with and ahead of it. Our job is to ensure that Microsoft thrives in a mobile and cloud-first world."

To stay relevant in an ever changing environment, innovation will be the key Microsofts success, and forms the core of Microsoft's announcement. 

Alongside Nadella's appointment, Microsoft have announced Bill Gates is to step into a new role as Founder and Technology Advisor. It is reported that Gates will devote more time to the company and is there to support Nadella in shaping technology and product direction. 

On the new CEO, Gates  had this to say:

Satya is a proven leader with hard-core engineering skills, business vision and the ability to bring people together. His vision for how technology will be used and experienced around the world is exactly what Microsoft needs as the company enters its next chapter of expanded product innovation and growth.

Find out more about Satya Nadella in his first interview as CEO in the following video:



Here's more from Bill Gates and Steve Ballmer on the appointment.




About the Author

As part of Firebrand's global marketing team, Edward actively works to serve the IT community with news, reviews and technical how to guides. Working in the Industry for almost 3 years years, Edward has a wide variety of experience with Microsoft Technologies including SharePoint and Windows Server and Exchange Server. Edward is an active member of the IT community contributing to a variety of tech publications including Microsoft TechNet, Channel Pro and PC Advisor among others.

Now is the time to be an IT apprentice


By 

IT apprenticeships give young people the chance to earn while they learn in a real job; gaining technical skills and qualifications, as well as work experience. Considering the amount of career opportunities in the technology sector, it’s safe to say: there’s never been a better time to be an IT apprentice.

According to the Office for National Statistics, tens of thousands of university graduates are earning less than school leavers taking apprenticeships. Not to mention that more than a quarter of them now work in part-time roles, as opposed to a mere 11% of apprenticeships leavers.

Technology offers great opportunities

Technology is an area where committed and passionate apprentices can thrive to benefit both themselves and their employers. The career opportunities and salaries are ever-growing, but so is the knowledge gap, therefore thousands of roles remain unfilled each year.

However apprenticeships help to bridge that gap, giving young people a chance to build their confidence, prove their competencies and develop a broader skill-set, whilst earning a salary.


The benefits for employers

Young people have ample untapped talent, and businesses are increasingly beginning to realise this. Taking on an apprentice can be an extremely beneficial business decision. Not only do organisations have the support of a training provider, such as Firebrand that can work with them to ensure that apprentices are developing the right skills for a career in business, but they are also able to develop and nurture their skills in a direction completely suited to the company.

Besides these benefits, companies are also able reduce their employment costs by up to 75%, get a return on their investment in less than six months and potentially qualify for a £1,500 Government grant per apprentice (for up to 10 apprentices).

The benefits for apprentices

Technology is one of the lines of industry that hasn’t stopped flourishing during the economic crisis, with all signs pointing towards continued growth. Technology transforms businesses. Technology fundamentally changes the way that people do business and it is constantly evolving. If you can play a part in that you’ll develop skills that can underpin your entire career.

Because technology never stops changing, it offers varied roles and that makes your job a lot more challenging and interesting. There is a misconception that to work in technology you have to be a traditional ‘techie’ and need to be a fan of software development.
This is not always the case, the options are numerous and IT offers a lot more than just computing.

Watch the following testimonial by Tom, who took part in the Firebrand Apprenticeship scheme:



To learn more about apprenticeship opportunities, visit Firebrand Apprenticeships

About the Author:       
Sarah writes for Firebrand Training on a number of IT related topics. This includes exams, training, certification trends, project management, certification, careers advice and the industry itself. Sarah has 11 years of experience in the IT industry. 

الاثنين، 3 فبراير 2014

What you'll learn on the CISM course


By 

Certified Information Security Manager (CISM) is a top credential for IT security professionals specialising in managing, developing and overseeing information security systems and for developing best organisational security practices. The credential suits the needs of IT security professionals with enterprise level security management responsibilities.

CISM certified professionals have advanced and proven skills in:
  • Security Risk Management
  • Program Development and Management
  • Governance and Incident Management
  • Responding to Incidents
CISM credential holders must agree to the CISM Code of Professional Ethics, pass the examination, possess at least five years of security experience and submit a written application to qualify.

What CISM gives you

Organisations and government agencies increasingly recognise, require and expect their Information Security and Information Technology professionals to hold CISM certification, because it:
  • Demonstrates your understanding of the bigger picture, i.e. the relationship between an information security program and general business objectives
  • Distinguishes you as having not only the information security expertise, but also the knowledge and experience in developing and managing an information security program
  • Is considered essential to on-going education, career progression and value delivery to enterprises
  • Provides the organisation with a certification for Information Security Management that is recognised by multinational clients and enterprises, lending credibility to the yourself as well as your organisation

As a CISM, you’ll be able to:
  • Identify critical issues and tailor organisation-specific practices to support the governance of information and related technologies
  • Oversee and direct information security activities to execute the information security program
  • Develop and manage a capability to respond to and recover from disruptive and destructive information security events
  • Design, develop and manage an information security program(me) to implement the information security governance framework
To learn more about the benefits of CISM, watch the following short video featuring CISM certified IT professionals: 



About the Author:        
Sarah writes for Firebrand Training on a number of IT related topics. This includes exams, training, certification trends, project management, certification, careers advice and the industry itself. Sarah has 11 years of experience in the IT industry.