#
sleuth
For the last week or so I have been thinking about a way to get a higher level of automation and strong typing within the “custom” Cuyahoga code base. In my experience as projects grow, methodologies that were manageable for 1 or 2 developers quickly become a nightmare for a team of developers.
I believe that one of the ways to allow continued development by multiple people and maintain a sustainable level of robustness is by automating the decoupled / weak type areas of the project. One of the biggest decoupled areas that I see is the relationship of the database to the mapping files to the Domain / state objects.
Thinking about this process it seemed to me that you would need to decide what the “master” would be when starting the generation process. To me it seemed natural that the database would fulfill this role; although I have talked to developers that consider the mapping files as the “master”. The best free Code Generator that I could find that supported NHibernate and several databases (PostgreSQL for me) was MyGeneration (http://www.mygenerationsoftware.com). Using this tool I pointed the NHibernate template at the existing PostgreSQL Cuyahoga schema and generated C# classes and NHibernate mapping files for the Cuyahoga core. The C# files and mapping files were very (if you squint you can see the same pattern) close to the existing Cuyahoga objects. The main difference that I noticed was that the original Cuyahoga files had a couple extra properties (usually an added array or list such as IList _childNodes) and code to maintain these extra properties.
Should the template be able to maintain this relationship? I would think that any one to many foreign key relationships could be generated as a List / array / collection with an associated class property?
My thought was that if we separated and structured the “custom code base” to enable generated code to propagate database changes then we could make much more rapid modifications with a higher level stability; allowing the compiler to catch many more bugs. For instance if I wanted to add a new column to the node table then I would just add it to the existing database schema, regenerate the mapping files and C# classes and change the code in the area that specifically dealt with using the new object properties. It is my assumption that we could find or make templates that generated database install scripts from the new mapping files.
While I am on the subject of strong typing; would it be overkill to generate a strong typed object from the web.config?
What would be the best way to strong type these kinds of statements:
(CoreRepository)HttpContext.Current.Items["CoreRepository"]
Context.Request.QueryString["ShortDescription"]
Place all of the “Name” strings in a public const area?
I believe that one of the ways to allow continued development by multiple people and maintain a sustainable level of robustness is by automating the decoupled / weak type areas of the project. One of the biggest decoupled areas that I see is the relationship of the database to the mapping files to the Domain / state objects.
Thinking about this process it seemed to me that you would need to decide what the “master” would be when starting the generation process. To me it seemed natural that the database would fulfill this role; although I have talked to developers that consider the mapping files as the “master”. The best free Code Generator that I could find that supported NHibernate and several databases (PostgreSQL for me) was MyGeneration (http://www.mygenerationsoftware.com). Using this tool I pointed the NHibernate template at the existing PostgreSQL Cuyahoga schema and generated C# classes and NHibernate mapping files for the Cuyahoga core. The C# files and mapping files were very (if you squint you can see the same pattern) close to the existing Cuyahoga objects. The main difference that I noticed was that the original Cuyahoga files had a couple extra properties (usually an added array or list such as IList _childNodes) and code to maintain these extra properties.
Should the template be able to maintain this relationship? I would think that any one to many foreign key relationships could be generated as a List / array / collection with an associated class property?
My thought was that if we separated and structured the “custom code base” to enable generated code to propagate database changes then we could make much more rapid modifications with a higher level stability; allowing the compiler to catch many more bugs. For instance if I wanted to add a new column to the node table then I would just add it to the existing database schema, regenerate the mapping files and C# classes and change the code in the area that specifically dealt with using the new object properties. It is my assumption that we could find or make templates that generated database install scripts from the new mapping files.
While I am on the subject of strong typing; would it be overkill to generate a strong typed object from the web.config?
What would be the best way to strong type these kinds of statements:
(CoreRepository)HttpContext.Current.Items["CoreRepository"]
Context.Request.QueryString["ShortDescription"]
Place all of the “Name” strings in a public const area?