Software Engineering


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Software Engineering

  1. 1. Software Engineering Robbie Clutton
  2. 2. readme.txt <ul><li>Started City University 2001 </li></ul><ul><li>Did industrial placement with Lloyds TSB 2003-2004 </li></ul><ul><ul><li>Coding Cobol 74, editing code written before I was born! </li></ul></ul><ul><li>Graduated Software Engineering BEng 2005 </li></ul><ul><li>Joined BT graduate scheme </li></ul>
  3. 3. readme.txt <ul><li>SDK to access BT Web Services in .NET C# </li></ul><ul><li>Worked with customers to build prototypes against BT Web Services </li></ul><ul><li>RESTful website using Ruby on Rails </li></ul><ul><li>SIP Application Server to support BT Web Services using Java </li></ul><ul><li>IVR Web Service using SIP A/S using Java </li></ul><ul><li>Website using PHP </li></ul>
  4. 4. Unit Testing <ul><li>Tests a unit of code (e.g. a method) </li></ul><ul><li>Doing the simplest thing that could possibly work </li></ul><ul><li>Living documentation </li></ul><ul><li>Allows refactoring </li></ul><ul><li>Assert upon the correctness of the application </li></ul>
  5. 5. @Test public void testHelloWorld(){ // setup HelloWorld helloWorld = new HelloWorld(); // act String result = helloWorld.sayHello(); // assert assertEquals(&quot;Hello&quot;, result); } <ul><li>package com.iclutton.seday; </li></ul><ul><li>public class HelloWorld { </li></ul><ul><ul><li>public String sayHello() { </li></ul></ul><ul><ul><li>return language.sayHello(); </li></ul></ul><ul><ul><li>} </li></ul></ul><ul><li>} </li></ul>
  6. 6. <ul><li>Benefits unit testing </li></ul><ul><li>Makes code cleaner </li></ul>Interfaces
  7. 7. package com.iclutton.seday.language; public interface Language { String sayHello(); } package com.iclutton.seday.language; public class English implements Language{ @Override public String sayHello() { return &quot;Hello&quot;; } } package com.iclutton.seday.language; public class French implements Language{ @Override public String sayHello(){ return &quot;Bonjour&quot;; } }
  8. 8. Mocking <ul><li>Useful when you want to ‘mock’ out external dependencies </li></ul><ul><ul><li>Databases </li></ul></ul><ul><ul><li>Web services </li></ul></ul><ul><ul><li>Etc </li></ul></ul><ul><li>Useful for simulating error conditions and handling </li></ul>
  9. 9. <ul><li>@Test </li></ul><ul><li>public void testHelloWorldWithMock(){ </li></ul><ul><ul><li>// setup </li></ul></ul><ul><ul><li>English english = mock(English. class); </li></ul></ul><ul><ul><li>when(english.sayHello()).thenReturn(&quot;Alright&quot;); </li></ul></ul><ul><ul><li>HelloWorld helloWorld = new HelloWorld(); </li></ul></ul><ul><ul><li>helloWorld.setLanguage(english); </li></ul></ul><ul><ul><li>// act </li></ul></ul><ul><ul><li>String result = helloWorld.sayHello(); </li></ul></ul><ul><ul><li>// assert </li></ul></ul><ul><ul><li>assertEquals(&quot;Alright&quot;, result); </li></ul></ul><ul><ul><li>verify(english).sayHello(); </li></ul></ul><ul><li>} </li></ul><ul><li>@Test(expected=IllegalStateException. class) </li></ul><ul><li>public void testHelloWorldWithMockException(){ </li></ul><ul><ul><li>// setup </li></ul></ul><ul><ul><li>English english = mock(English. class); </li></ul></ul><ul><ul><li>when(english.sayHello()).thenThrow( new RuntimeException()); </li></ul></ul><ul><ul><li>HelloWorld helloWorld = new HelloWorld(); </li></ul></ul><ul><ul><li>helloWorld.setLanguage(english); </li></ul></ul><ul><ul><li>// act </li></ul></ul><ul><ul><li>helloWorld.sayHello(); </li></ul></ul><ul><ul><li>// assert - see exception annotation </li></ul></ul><ul><li>} </li></ul>
  10. 10. Dependency Injection <ul><li>We’ve already seen dependency injection </li></ul><ul><li>Now let’s look at Spring, which supports </li></ul><ul><ul><li>Reduces complexities of using interfaces </li></ul></ul><ul><ul><li>Great way to configure applications </li></ul></ul><ul><ul><li>Promotes the use of singletons </li></ul></ul><ul><ul><li>Improves testability </li></ul></ul>
  11. 11. <bean id=&quot;language&quot; class=&quot;com.iclutton.seday.language.English&quot;/> <bean id=&quot;hello&quot; class=&quot;com.iclutton.seday.HelloWorld&quot;> <property name=&quot;language&quot; ref=&quot;language&quot;/> </bean> @Test public void testSpring(){ // setup ApplicationContext applicationContext = new ClassPathXmlApplicationContext(&quot;applicationContext.xml&quot;); HelloWorld helloWorld = (HelloWorld)applicationContext.getBean(&quot;hello&quot;); // act String result = helloWorld.sayHello(); // assert assertEquals(&quot;Hello&quot;, result); }
  12. 12. Build Scripts <ul><li>Manual processes are more error prone </li></ul><ul><li>Build scripts bring consistency and automation </li></ul><ul><li>There are many varieties </li></ul><ul><ul><li>Ant (Java) </li></ul></ul><ul><ul><li>nAnt (.NET) </li></ul></ul><ul><ul><li>Make (C/C++) </li></ul></ul><ul><ul><li>Rake (Ruby) </li></ul></ul><ul><ul><li>etc </li></ul></ul>
  13. 13. Property Driven Builds <ul><li>Useful when more that one person becomes involved </li></ul><ul><li>Or deploying to different environments </li></ul>
  14. 14. Source Control
  15. 15. Automating the Build <ul><li>Continuous Integration </li></ul>
  16. 16. Logging <ul><li>Until you support an application you’ve built you will never know the value of logging </li></ul>
  17. 17. # Root category log4j.rootLogger=DEBUG, stdout # CONSOLE log4j.appender.stdout.Threshold=DEBUG log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout log4j.appender.stdout.layout.ConversionPattern=%d %X{stackname}[%t] %-5p [%C {1}.%M() %L] - %m%n 2008-11-18 18:06:39,953 [main] DEBUG [AbstractAutowireCapableBeanFactory$ 411] - Finished creating instance of bean 'hello' 2008-11-18 18:06:39,953 [main] DEBUG [AbstractApplicationContext.publishEvent() 273] - Publishing event in context []: org.springframework.context.event.ContextRefreshedEvent[ display name []; startup date [Tue Nov 18 18:06:39 GMT 2008]; root of context hierarchy] 2008-11-18 18:06:39,953 [main] DEBUG [AbstractBeanFactory.doGetBean() 214] - Returning cached instance of singleton bean 'hello'
  18. 18. Q&A
  1. A particular slide catching your eye?

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