Skip to main content

Posts

Showing posts from 2012

Object Discovery

Recently we had @kevinrutherford in to talk about object discovery. While TDD is a great tool, it is no excuse for some sort of design process. If you don't, you'll most likely end up with a mess. This session was based around this principle.One point that was discussed what that the first few seconds of a test for a new class is the most important part of the TDD process. It is here where you will decide whether to take a state or interaction based approach to testing. This first test will dictate the structure of the new class. Once you start with tests, it becomes difficult to evolve or change the design of a class without friction.There is generally two types of code at Codeweavers.The trick comes from the fact that just because you use C#/Java/etc.. most of the time you aren't actually writing OO code. You often end up writing procedural code in a rather obtuse manner. A takeaway from this afternoon was to try and perform mo…

Recommended Reading 2012

Here is my updated reading list for 2012. We might have missed something so if you think we should be reading it, let us know.ProcessThe Toyota Way - Jeffrey LikerThe Goal - Eli GoldrattXP Explained - Kent BeckThe Pragmatic Programmer- Andrew Hunt and David ThomasThe Clean Coder - Robert C. MartinCodeClean Code - Robert C. Martin Test-Driven Development by Kent BeckRefactoring - Martin FowlerRefactoring Workbook - William WakePatterns of Enterprise Application Architecture - Martin FowlerHead First Design Patterns - Freeman, et alGrowing Object-Oriented Software, Guided by Tests - Steve Freeman and Nat Pryce97 Things Every Programmer Should Know- Kevlin HenneyPro ASP.NET MVC x+ - Steve SandersonFramework Design Guidelines - Brad Abrams and Krzysztof Cwalina

MVC is Broken

If you look up the definition of MVC or Model View Controller, it will hail the definition as being able to change your front end without affecting other parts of the application and vice versa. This sounds great in theory, however this claim is nothing more than a blatant lie.A failing of the architectural pattern comes from the whole codebase being tied to a specific stack. Take ASP.NET MVC. The domain logic will most likely be in C#. Therefore your models will be in C#. Your controllers will be in C#. Your views will be a mixture of C# and some form of a templating language. If you want to change your stack to the "next big thing" you are forced to take a big bang approach. ASP.NET MVC won't be around forever. Being tied to a specific technology feels wrong. Therefore this coupling means your designers are forced to use the templating language that your framework supports. This should be a flexible option that should be easy to chang…

Codeweavers Code Retreat

Last week we had @kevinrutherford in to run a coderetreat. It was the first retreat I've taken part in personally, the same applying to much of the team. The day was to focus on one challenge - Conway's Game of Life though each iteration would introduce new constraints.Iteration 1The four rules of simple code were discussed, aka "Extreme Normal Form".Passes testsCommunicates intentNo duplicationNothing unncessaryOur first run through was somewhat of a disaster. We became too obsessed with how the grid was to be stored. This meant we spent a long time messing around with arrays and multidemionsal arrays in C#. Both are somewhat tedious and not something we use often, therefore we concluded a more "grid agnostic" approach would be needed. After all, there is nothing stating the grid need be a square, fixed layout.Iteration 2The concept of Arrange, Act, Assert or AAA was discussed.Arrange - set up pre conditionsAct - do something on the sub…

The Problem with Auto Updating Browsers

At the time of writing the latest version of Firefox (version 13) has just been released. Bear in mind that a week ago I updated our Selenium bindings so that we could use Firefox 9+ for running our browser tests.The latest release is another great release for the Firefox team, except there is software out there will be broken. The software in question I'm talking about is any code that uses Selenium 2.22.0 that was released 2012-05-29. It turns out the bindings only work for Firefox 12 or less.For whatever reason any tests that used Selenium this morning just stopped working for us - and others. The tests in question caused the runner to hang as no window could be opened. I'm not sure what causes this, as the browser is essentially the same to the end user, bar some new features. Not being a Selenium developer I cannot comment how or why this has happened, nor can I suggest the Selenium team should be version agnostic.Our solution in the end …

Achieving more Isolated Unit Testing

Good unit tests should be:fastindependentwell focusedisolatedIf your unit tests are slow, you're not gonna run them as often as you should. Therefore one of the main benefits of unit testing is lost - the lack of instant feedback.Each of your unit tests should be independent. The order in which you run your tests should not matter. By keeping your tests focused you should be able to refactor, add new code and not have the majority of your tests fail. If you change class A, you would expect class A's tests to fail at worst. If other tests outside of this scope fail, your tests are not focused enough. This lack of focus leads on to isolation.Tests should be isolated from other dependencies. Dependencies such as other classes should not affect each other, providing the contract between the code is maintained. Likewise the file system, the web and databases should not be involved anywhere with your unit tests. If any of these dependencies come into play…

Recursively Building a Web Service using the same Web Service

Back during the later part of 2011 there was a common theme occurring in our retrospectives each week. How can we replicate our live environment as close as possible?We took steps to achieve this goal by creating a single machine image to ensure all our machines were configured correctly. Another quick win was to ensure certain aspects of our live data was restored to our local development databases during the night. This enabled us to take stack traces from our logs, and quite literally paste them into our IDE and replicate the users problem instantly. Without the same data set we could have seen different results. Despite these positive steps, there was a missing link in our replication process. How do we simulate the traffic of our live environment? As an example, we average anywhere from four to five thousand calculations per minute with our current web services, with our local and demo environment no where near this figure.During 2011 I found mys…

Warnings as Errors

One thing that annoyed me when starting at Codeweavers was the amounts of warnings that would occur during a build of any of our projects. Seeing the build progress only to spew out a screenful of text was something that did not sit right with me. I was not the only one who felt this was wrong, but as there was so many warnings in some cases, it was easier just to pretend they were not there. After all everything was working fine.The broken window theory is very much in action here. During our last standards review we decided that there should ideally be zero warnings per project. It is worth mentioning that most of our warnings were just that, warnings about something that was not really a major issue. Warnings such as unused variables and so on fall into this area.On the other hand, while 90% of our warnings were ignorable, there were a handful which were rather important. Examples such as referencing different versions of required .dlls. Warnings l…

Write Unit Tests? Start deleting them

A recent blog post by Steve Klabnik concluded with a statement about tossing unit tests if you have end to end tests covering the code in question.Don't be afraid to change the tests! As soon as you've verified that you've transcribed the code correctly, don't be afraid to just nuke things and start again. Especially if you have integration level tests that confirm that your features actually work, your unit tests are expendable. If they're not useful, kill them!A few people on Twitter found this odd, and I'd have included myself in this statement a while back.@isaacsanders@avdi seeing @KentBeck delete unit tests during his screencasts changed my TDD process forever.— Shaun Finglas (@F1nglas) January 21, 2012Kent Beck's TDD screencasts changed my view on deleting unit tests however. During the later videos, he actually deleted some tests. Pretty much all TDD resources don't really mention this. One of the key points beginner…

Log Everything

This post was originally conceived back in mid 2011, starting a new project made me think back to this event, hence the post.Any developer worth their salt will know what logging is. You could argue there are two types of logging, either developer logging or auditing. Developer logging would be what we log when something goes wrong. Using the results of this logging we can track down what went wrong, and put fixes in place to stop this event from occurring again. If this logging fails, or logs the incorrect thing it is not the end of the world. Due to this, I generally do not care for testing such scenarios. The code should behave the same with our without this logging.Auditing would come under logging which as part of the application needs to be carried out at all times. Consider visiting a cash machine. When withdrawing fifty pounds, you want to make sure your bank logs this in case anything goes wrong. This sort of logging is crucial, and must wor…