Introduction to TDD and CI <ul><li>Antonio Radesca </li></ul>
Test Driven Development <ul><li>Defined by Kent Beck in Test Driven Development By Examples </li></ul><ul><li>Rules </li><...
Practices and Tool <ul><li>Nunit,MBUnit... </li></ul><ul><li>Resharper (Refactoring)‏ </li></ul><ul><li>Gallio suite </li>...
Refactoring <ul><li>Process of rewriting code for improve readability, semplification, performances and design </li></ul><...
Some Examples namespace  ERP.UnitTests.Repository.NHibernate { [ TestFixture ] public   class   FixtureNHibernateClientRep...
Behaviour Driven Development <ul><li>TDD + DDD </li></ul>
BDD:Practices <ul><li>A SubjectMatterExpert (typically a business user) works with a BusinessAnalyst to identify a busines...
Mocks <ul><li>Do you need to test something that is related to other components? </li></ul>
Rhino Mocks <ul><li>Created by Ayende </li></ul><ul><li>Simple, documented and updated </li></ul><ul><li>CODE... </li></ul>
An Example
Continuous Integration <ul><li>Extende and improve build automation </li></ul><ul><li>Prevent from integration problems </...
CI:Practices <ul><li>Maintain a Single Source Repository </li></ul><ul><li>Automate the Build </li></ul><ul><li>Make Your ...
Continuous Integration
Introduction to IOC and AOP
Inversion Of Control <ul><li>Good software: High coesion,low coupled </li></ul>
What is IOC <ul><li>From Wikipedia: abstract principle describing an aspect of some software architecture designs in which...
Example
IOC
<ul><li>Hollywood Principle </li></ul><ul><li>Don't call us, we'll call you. </li></ul><ul><li>High cohesion and low coupl...
Dependency Injection <ul><li>Dependency Injection (DI) in computer programming refers to the process of supplying an exter...
IOC Framework for .NET <ul><li>Managed Extensibility Framework </li></ul><ul><li>Autofac </li></ul><ul><li>Castle MicroKer...
Example <ul><li>using  System; </li></ul><ul><li>using  System.Collections.Generic; </li></ul><ul><li>using  System.Linq; ...
Aspect Oriented Programming
What is an aspect? <ul><li>Paradigm programming based on crosscuts concepts </li></ul><ul><li>Examples:Logging,Transaction...
Some Examples using  System; using  System.Collections.Generic; using  System.Linq; using  System.Text; using  Castle.Dyna...
Upcoming SlideShare
Loading in...5
×

Tdd,Ioc

1,022

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
1,022
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
20
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Tdd,Ioc

  1. 1. Introduction to TDD and CI <ul><li>Antonio Radesca </li></ul>
  2. 2. Test Driven Development <ul><li>Defined by Kent Beck in Test Driven Development By Examples </li></ul><ul><li>Rules </li></ul><ul><li>Never write a single line of code unless you have a failing automated test </li></ul><ul><li>Eliminate duplication </li></ul>
  3. 3. Practices and Tool <ul><li>Nunit,MBUnit... </li></ul><ul><li>Resharper (Refactoring)‏ </li></ul><ul><li>Gallio suite </li></ul>
  4. 4. Refactoring <ul><li>Process of rewriting code for improve readability, semplification, performances and design </li></ul><ul><li>“ Refactoring” by Martin Fowler </li></ul><ul><li>There you can find more informations and patterns </li></ul><ul><li>Automated from some tools: VS refactoring, Resharper,Visual Assist... </li></ul>
  5. 5. Some Examples namespace ERP.UnitTests.Repository.NHibernate { [ TestFixture ] public class FixtureNHibernateClientRepository { [ SetUp ] public void SetupMethod()‏ { TestUtilities obj= new TestUtilities (); obj.ExecuteQuery( &quot;DELETE FROM CLIENTS&quot; ); obj.ExecuteQuery( @&quot;DBCC CHECKIDENT(Clients,RESEED,0)&quot; ); } [ Test ] public void SaveClient()‏ { Client obj= new Client (); obj.NameSurname = &quot;name&quot; ; obj.City = &quot;city&quot; ; obj.Address = &quot;Address&quot; ; ERP.Repository.NHibernate. ClientRepository objRep= new ClientRepository (); objRep.Save(obj); objRep.Commit(); Client tmp = objRep.Load(1); Assert .AreEqual( true , CompareClients(tmp, obj)); } private bool CompareClients( Client tmp, Client obj)‏ { if (tmp.ID == obj.ID && obj.City == tmp.City && tmp.NameSurname == obj.NameSurname && tmp.Address == obj.Address)‏ return true ; return false ; } } }
  6. 6. Behaviour Driven Development <ul><li>TDD + DDD </li></ul>
  7. 7. BDD:Practices <ul><li>A SubjectMatterExpert (typically a business user) works with a BusinessAnalyst to identify a business requirement. This is expressed as a story using the following template </li></ul><ul><li>As a Role </li></ul><ul><li>I request a Feature </li></ul><ul><li>To gain a Benefit </li></ul><ul><li>The speaker, who holds the Role, is the person who will gain the Benefit from the requested Feature. </li></ul>
  8. 8. Mocks <ul><li>Do you need to test something that is related to other components? </li></ul>
  9. 9. Rhino Mocks <ul><li>Created by Ayende </li></ul><ul><li>Simple, documented and updated </li></ul><ul><li>CODE... </li></ul>
  10. 10. An Example
  11. 11. Continuous Integration <ul><li>Extende and improve build automation </li></ul><ul><li>Prevent from integration problems </li></ul><ul><li>Examples:CruiseControl.NET,TFS,Draco.NET... </li></ul>
  12. 12. CI:Practices <ul><li>Maintain a Single Source Repository </li></ul><ul><li>Automate the Build </li></ul><ul><li>Make Your Build Self-Testing </li></ul><ul><li>Everyone Commits Every Day </li></ul><ul><li>Every Commit Should Build the Mainline on an Integration Machine </li></ul><ul><li>Keep the Build Fast </li></ul><ul><li>Test in a Clone of the Production Environment </li></ul><ul><li>Make it easy to get the latest deliverables </li></ul><ul><li>Everyone can see the results of the latest build </li></ul><ul><li>Automate Deployment </li></ul>
  13. 13. Continuous Integration
  14. 14. Introduction to IOC and AOP
  15. 15. Inversion Of Control <ul><li>Good software: High coesion,low coupled </li></ul>
  16. 16. What is IOC <ul><li>From Wikipedia: abstract principle describing an aspect of some software architecture designs in which the flow of control of a system is inverted in comparison to the traditional architecture of software libraries. </li></ul><ul><li>Instead of specifying a sequence of decisions and procedures to occur during the lifetime of a process, the user of an IoC framework writes the desired responses linked to particular events or data requests. External entities then take control over the precise calling order and additional maintenance that are to be carried out to execute the process. </li></ul>
  17. 17. Example
  18. 18. IOC
  19. 19. <ul><li>Hollywood Principle </li></ul><ul><li>Don't call us, we'll call you. </li></ul><ul><li>High cohesion and low coupling </li></ul>
  20. 20. Dependency Injection <ul><li>Dependency Injection (DI) in computer programming refers to the process of supplying an external dependency to a software component. It is a specific form of inversion of control where the concern being inverted is the process of obtaining the needed dependency. </li></ul><ul><li>The object simply provides a property that can hold a reference to that type of service; and when the object is created a reference to an implementation of that type of service will automatically be injected into that property - by an external mechanism. </li></ul><ul><li>See Martin Fowler for types... </li></ul>
  21. 21. IOC Framework for .NET <ul><li>Managed Extensibility Framework </li></ul><ul><li>Autofac </li></ul><ul><li>Castle MicroKernel/Windsor </li></ul><ul><li>ObjectBuilder </li></ul><ul><li>PicoContainer.NET </li></ul><ul><li>Puzzle.NFactory </li></ul><ul><li>Spring.NET </li></ul><ul><li>StructureMap </li></ul><ul><li>Ninject </li></ul><ul><li>Unity </li></ul><ul><li>NauckIT.MicroKernel </li></ul>
  22. 22. Example <ul><li>using System; </li></ul><ul><li>using System.Collections.Generic; </li></ul><ul><li>using System.Linq; </li></ul><ul><li>using System.Text; </li></ul><ul><li>using Castle.Core.Resource; </li></ul><ul><li>using Castle.Windsor; </li></ul><ul><li>using Castle.Windsor.Configuration.Interpreters; </li></ul><ul><li>using Microsoft.Practices.Unity; </li></ul><ul><li>namespace ERP.Services </li></ul><ul><li>{ </li></ul><ul><li>public interface IServicesFactory </li></ul><ul><li>{ </li></ul><ul><li>T GetService<T>(); </li></ul><ul><li>} </li></ul><ul><li>public class ServicesFactory : IServicesFactory </li></ul><ul><li>{ </li></ul><ul><li>private static </li></ul><ul><li>IWindsorContainer container; </li></ul><ul><li>static ServicesFactory()‏ </li></ul><ul><li>{ </li></ul><ul><li>container = new WindsorContainer ( </li></ul><ul><li>new XmlInterpreter ( new ConfigResource ( &quot;notification&quot; ))); </li></ul><ul><li>} </li></ul><ul><li>public T GetService<T>()‏ </li></ul><ul><li>{ </li></ul><ul><li>return container.GetService<T>(); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  23. 23. Aspect Oriented Programming
  24. 24. What is an aspect? <ul><li>Paradigm programming based on crosscuts concepts </li></ul><ul><li>Examples:Logging,Transactions,Caching... </li></ul><ul><li>AOP Containers:Spring.NET,Castle Windsor,Unity Application Block... </li></ul>
  25. 25. Some Examples using System; using System.Collections.Generic; using System.Linq; using System.Text; using Castle.DynamicProxy; using Utils; namespace ERP.Services.AOP { //Classe che gestisce il logging instanziando oggetti generici public class LoggingManager <T> { public void Log<T>( string method)‏ { ProxyGenerator generator = new ProxyGenerator (); T logger = generator.CreateClassProxy<T>( new LoggingInterceptor ()); ReflectionHelper .CallMethod(logger,method); } } }
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×