Simple but useful generic repository pattern
February 16, 2009
I have pointed here several times before – but it’s so nice.
It’s an implementation of the Repository Pattern using generics, that will minimize your code in a very nice way. I am sure that the FindAll can be refined into something very nice with LINQ, that allows you to send a specification criteria or so.
Here is my implementation that uses a common interface (IBaseEntity) for all my entities. It basically has an ID, so that the abstract implementation can use it as a key:
namespace Marcusoft.SprintPlannerHelper.Repositories { /// \<summary\> /// A generic repository interface that dictates all the methods that a repository should map to /// \</summary\> /// \<typeparam name="T"\>the type of the interface\</typeparam\> public interface IRepository<T> where
Read More
Sprint Planner Helper – Session 10
February 16, 2009
You could call the last session my first “sprint demo.” What happened was that I could finally see where this was going. As the Product Owner, I was not happy – I couldn’t even yell at the team (also me) because the result was quite poor.
What Went Wrong
Firstly, I was not happy that certain actions were only available to specific roles (e.g., “As Product Owner,” “As Scrum Master”). I want the Sprint Planner Helper to be open and useful without hindering you with role checks.
Secondly, I was too detailed in my model. For instance, why bother with a ProductOwnerController when it’s just an attribute on the ProductBacklog? The same applies to the Product attribute.
The Solution
I had a meeting with the team, designer, and domain experts (in this case, me on all three accounts) to do some domain...
Read More
Sprint Planner Helper – Session 9
February 15, 2009
Today I focused on finally getting the controller for my Product Owner tested and done.
For now, the controller will always use my test data repository so that I will know the state of the data. I really want to create my first view also – which will be that list of products.
Look at this really nice feature that helps you create views with the ASP.NET MVC kit.
This promises great things for the final release. More to read about this in this post by the Gu.
Oh yeah – my first view is realized…
At this point, I also realized two things: I will need to sketch out the GUI and I will be needing to add products, product owner, and backlog. So I will probably rip the generic template for repositories from here.
But … hey – my first view! Me so proud. Me want...
Read More
Sprint Planner Helper – Session 8
February 12, 2009
This hour almost entirely was reading. I didn’t not feel comfortable yet with terms Repository and Service, or how they relate to each other.
Also I feel that I have looked to much at the architecture of ASP.NET MVC Storefront Starter Kit. I have incorporated stuff that I didn’t thought to much about – stupid, but I did it anyway.
But after a while I found this introduction to DDD and it explained some things for me. Here is how I understand the two fore-mentioned concepts:
- A Repository are classes and methods that is used to load stuff from a data store. They are often written in a way that is easily mocked or replaced during testing.
- A Service is used to hold a process or a flow through a business logic that does not fit well on a class in the domain model. They are stateless...
Read More
Sprint Planner Helper – Session 7
February 11, 2009
I’ve been doing some major reworking of the repository that I am using, from being a product repository to being a ProductOwnerRepository and a ProductBacklogRepository. This took me more than one hour and therefore I did it as a prolonged check-out session.
Halfway through that prolonged session, I realized that I still don’t quite get the repository pattern (by the way, here is a great post about the repository pattern) or rather the way it’s being used in the ASP.NET MVC Storefront Starter Kit. The thing that had me confused is the service… It feels like an extra layer on top of the repository that I don’t understand.
But 06:03 into part 8 of the video series, I got it… What Rob Conery is doing is to overload the constructor of the controller so that he can send in a fake version...
Read More
Sprint Planner Helper – Session 6
February 9, 2009
OK – I did some reading about repositories, and they basically constitute a way for the domain model to perform CRUD operations – in a language needed by the domain model.
This great document provides an example and some very good explanations on what the difference between an Entity (has an ID), a Value Object (doesn’t have an ID in the model), and Aggregates (things that consist of other things) are.
So today I’ll back up and create a repository that can retrieve the products for a product owner – the IProductRepository. I am test-driving it forward, of course.
After a while…
Oh yeah – I love the way TDD is leading me forward. Really nice code is emerging.
I didn’t get quite as far as I hoped. I was hoping to be able to code a bit of controller-action (hehe…) today. Well – tomorrow maybe.
...
Read More
Norwegian Championships – the aftermath
February 9, 2009
OK – my guess wasn’t completely off (got the first right, didn’t I). Oslo Brass Band shocked by coming second in their first year in the championship section. Since I have played with a few of the bandsmen (and women) in that band, I was really proud. Well done – Tone, Mattias, and Clare!
Also, Eikanger has my favorite euphonium player – Patrik Randefalk – and he and the rest of the band were marvelous, especially on the Extreme Makeover.
But the thing that impressed me most was that the whole event was taped for Norwegian television. You can see every performance afterwards here.
Read More
Sprint Planner Helper – Session 5
February 8, 2009
OK – this was a really short session and it also marks the end of the first week of the project. Five hours a week – I’d love to work with this all the time…
I managed to get around the understanding of controllers. This article was a great help… BUT they have changed some stuff. So, in order to get hold of the actual model in a view you now (ASP.NET MVC RC 1) need to go:
[TestMethod] public void indexViewModelIsAProductListWithOneElementsForTheTestUser() { var c = new ProductOwnerController(); var view = c.Index() as ViewResult; var model = (List<Product>) view.ViewData.Model; Assert.AreEqual(1,
Read More
Snippet for creating test method in C#
February 8, 2009
Here is a short snippet that saves me a lot of time. It simply creates a
test method with the correct attributes and stuff. Simply but useful –
and now you don’t have to write it.
<?xml version=”1.0” encoding=”utf-8” ?>
<Header>
TestMethod
tm
Code snippet for creating a test method
Marcusoft (www.marcusoft.net)
Expansion
SurroundsWith
</Header>
methodName
The name of the test
methodName
<![CDATA[<TestMethod()> _
public void should_$methodName$()
{
// Arrange
// Act
// Assert
Assert.Fail("Implement test");
}]]>
Read More
Together in transformation – An agile Salvation Army
February 7, 2009
Today I did a presentation for the Salvation Army at a Hearing day that our Territorial Commander, Victor Poke has assembled. I was a bit confused at first but then I felt quite at easy with the whole thing since my topic suited me perfect. It was Together in Transformation.
Of course I couldn’t resist to preach the Agile gospel even for the Salvation Army. We are often quite rigid in our structures so that could be needed from time to time.
It was well received with a very rewarding discussion afterwards. It also felt very good for me to be able to put some quotes form the bible on a PowerPoint slide. Haven’t done that before.
Read More