4

EDIT: There's now a doc page on this so this question is irrelevant, also it's outdated. Read the docs not this question.

I've been toying with the SubSonic 3 code generation for a month or so now and I'm interested in getting some feedback from others on which template they use and why.

EDIT: Rob's been blogging about the different templates so I've added links to the posts

ActiveRecord - More details from Rob's blog

Pros

  • Supports a popular and well understood pattern
  • Allows easy migration from version 2.2
  • Built-in testing for ActiveRecord (See Rob's answer below)
  • Implements the Repository pattern

Cons

  • Considered heavyweight in the objects it generates

Simple - More details from Rob's blog

Pros

  • Generates POCOS
  • Implements the Repository pattern

Cons

  • Generates a massive single file for all classes that can make browsing the generated source a pain

Advanced

Pros

  • Generated file structure is much neater than simple
  • Generates POCOS
  • Implements the Repository pattern

Cons

  • ?
Adam Cooper
  • 8,077
  • 2
  • 33
  • 51

2 Answers2

4

Go for the advanced template as it will allow you to use repository pattern. I mainly picked advanced template as I like the file structure (easy to maintain) and wanted to use Repository pattern.

Srikar Doddi
  • 15,499
  • 15
  • 65
  • 106
4

Everything uses the Repo - it's at the core of all the templates and is now in SubSonic's core code. I can't help you in choosing, necessarily, but what I can say is that ActiveRecord will allow you the most options.

One thing I haven't shared with people (that I will soon) is the built-in testing for ActiveRecord. In your test project, just use "Test" as your connection string and the AR template will not hit your DB. Moreover you can use the static "Setup" method to pump test records into the in-memory list.

Adds/Updates/Deletes all work agains the in-memory stuff.

In terms of "Heavy" - I like to think "Easy" trumps. And it doesn't get any easier than ActiveRecord.

  • Thanks Rob, the Test stuff sounds awesome, is it in Subversion yet or are you saving it? I'm not really looking for the answer just interested in others opinion and reasons behind their choice. – Adam Cooper May 28 '09 at 20:19
  • Wow! Built-in active record testing without hitting the DB? Now that's a reason to upgrade! – Dave Neeley May 29 '09 at 20:49