Coffee, coffee, coffee. Oh we need coffee. Okay, got it now we're ready. It's been a crazy week and it's getting crazier. JP is coding at about 8,000 words and using about 40,000 ReSharper shortcuts per minute now. He's also talking at about 10,000 words a minute. If you blur your eyes when looking at him, he begins starts to look like Neo in the Matrix. There is no mouse.
Service Layers are Tasks
I really like this paradigm of naming the service layer classes. Rather than having something like CustomerService.GetAllCustomers(), it's named CustomerTasks.GetAllCustomers(). I've always used the ServiceXXX naming strategy but it makes more sense to name things as tasks because in reality, they are tasks. Tasks in the service layer to serve up information to external consumers. It's about readability so choose whatever works for you.
Recording Ordered Mocks
We were working on the database today (gasp) but started mocking out a data gateway. I found it amusing that we couldn't record an ordered mock (but there was a way).
Hey Oren, check this out (in case you didn't know). This block fails:
55 public void Should_be_able_to_get_a_datatable_from_the_database_ordered_failure()
57 using (mockery.Ordered())
59 using (mockery.Record())
67 using (mockery.Playback())
69 DataTable result = CreateSUT().GetADataTableUsing("Blah");
The error is:
failed: Can't start replaying because Ordered or Unordered properties were call and not yet disposed.
Message: Can't start replaying because Ordered or Unordered properties were call and not yet disposed.
In this case, the mock objects were created from interfaces that inherited from IDisposable. However it was a simple change to put the ordered call inside the record (because we don't care about ordering on playback). This slight change now works:
34 public void Should_be_able_to_get_a_datatable_from_the_database()
36 using (mockery.Record())
38 using (mockery.Ordered())
47 using (mockery.Playback())
49 DataTable result = CreateSUT().GetADataTableUsing("Blah");
Just in case you ever needed to do have run into this problem one day.
JP is doing this 5-day intensive course that stretches people to think outside the box of how they typically program and delve into realms they have potentially not event thought about yet, about one per month. For the next little while (he's a busy dude) he's going to be travelin' dude. In October he'll be in New York City. In September he'll be in London, England and other locations are booked up into the new year.
If you want to find out more details about the course itself, check out the details here and be sure to get on board with the master.