Packages that bring in 'starter code'

Sep 21, 2010 at 12:02 AM

One powerful concept that we haven't discussed much is having packages bring in 'starter code' into the project.  You can see this concept coming up a few times in my screencast:

  • The SQL/EF package brings in code that shows how to set up the Default Connection Factory to actually use SQLCE with EF Code Only
  • The EFCTP4 package comes with a sample model so the user discovers how to declare a context (e.g. DbContext/DbSet classes)
  • The Ninject package comes with setup code that can be hooked up in one line in global.axax
  • The NUnit package comes with a couple default tests so teh user can discover the attribute

I have found this to be a huge benefit to actually get the user up and running with the library.  i.e. it's one thing to add the assembly reference and add some config entries, but doing this extra step really makes it super easy to become productive with the package.

Ideally, we would have a switch that might let users turn this off, though it's easy enough to delete the file if you don't want it.  In a sense, it's like the ASP.NET Project template containing a default.aspx.  It gets you on the right track.

Sep 21, 2010 at 1:04 AM

You are so right on this one.

I think it woukd make sense to make this a supported concept, so if advanced users wanted to disable this behavior they could. Package authors could designate the starter content in their packages. There could also be a flag on add-package so you could turn on example code for a specific package.

Sep 21, 2010 at 2:17 AM

Where it gets tricky is that there is a blurry line between necessary setup logic and sample code.  Consider the progression:

  1. Elmah web.config changes: pure setup
  2. The one line that makes EF code only work with SQLCE: also more fixes setup logic rather that 'sample'
  3. The Ninject starter code: this one is half way.  It contains some necessary glue, but then you need to add your own bindings
  4. The sample NUnit tests and EF model: these are pure sample

So I would say that only #4 would be affected by the samples flag, while the test would always happen.  But it can be blurry...

Sep 21, 2010 at 2:48 AM
Seems simpler to just let the user delete the files. But then again, are there examples where the sample files will be significant in number that we anticipate?

Can you log an issue with this behavior in mind? No matter what we decide for v1, it's worth tracking.
Sep 21, 2010 at 6:53 AM

For the short term, hand deleting the unwanted files is definitely the way to go.  Anything fancier is longer term here.