This project is read-only.

Convention discussion

Apr 9, 2010 at 2:52 PM

I'm going to be fleshing out conventions shortly, a few discussion points if anybody wishes to interject

What conventions should be the Defaults?

  • String Properties called EmailAddress
  • String Properties called FirstName
  • String Properties called LastName
  • String Properties called Postcode
  • Setting all unrecognised properties to non-null defaults (strings, other objects)
  • Tying methods to properties
    • Set<PropertyName> maps to PropertyName
    • Change<PropertyName> maps to PropertyName

How should convention precedence be worked out?

Consider the following

  • Convention to set all strings to sensible defaults
  • Convention to set all strings called "Bob" to a special value

I can't guarantee the order in which these conventions will apply, my proposal is to have

  • IMemberTypeConvention
  • IMemberNameConvention<T>

And have the IMemberTypeConventionContext only give the type of the member, and the IMemberNameConvention be bound to a type already

Then I'll apply all IMemberTypeConventions and then the IMemberNameConvention<t>

The alternative is a system similar to FNH's, whereby conventions can register 'requirements' against a context

require.Type(x=>x == typeof(string))


And work out a precedence based on which requirements have been added to the context?

Apr 9, 2010 at 2:58 PM

Actually, I like the second option better, but it's potentially more tricky to deal with

Apr 11, 2010 at 8:19 PM

As nobody has suggested anything better, I've gone with the last option because it at least makes it easy to score conventions