References:
Echis Framework on Source Forge
Echis Framework Wiki
Echis Framework "MSDN" Style Documentation
Introduction
As I stated earlier, one of the primary reasons for me to start a blog was to talk about the Echis "framework." While I call it a framework (I don't know what else to call it), it pales in comparison to true Application Frameworks. Essentially the Echis Framework is a collection of classes, utilities and components which I've developed over the years. For the most part (with the exception of a class or two, or a method here and there) the implementations are my own, however many of the concepts I've adapted into the framework were learned by various colleagues over the years and from the various places where I've worked. I have released this "framework" as Public Domain; the intention being that developers can pick and choose what components they want, (if they want) modify them for their own use and/or even change the names to suit their evironment/naming conventions.
As part of an effort to document the Echis Framework, I've installed ScrewTurn Wiki on my website and have begun adding pages there. The intention behind the Wiki is to discuss the reasons for the classes/utilities and how to use them. In many cases I plan on showing sample code. In some cases sample code may be too complex; in those instances I plan on creating sample applications that hopefully will help demonstrate the capabilities and features of the component(s). For now, I am the only one working on both the Framework code and the Wiki documentation, so please, be patient. :) So far I have documented two components (well, I've documented one and started on the other): Collections and Configuration.
Echis Framework - Collections
The collections part of the framework started with ListEx and IListEx, it was primarily an attempt to "fix" the .Net Framework's lack of functionality in IList. I started using the ForEach, Find, FindAll and Exists methods of the List class as soon as I learned about them. I was dissapointed to find that IList had NONE of these methods! How was I supposed to use Interface driven design, if the interface I was starting with didn't have the methods I wanted to use? Casting an IList to List just to use these functions breaks the very idea of using interfaces. So I created IListEx to "add" the functions that List already had, and then I created ListEx as the "implementation" of IListEx. Originally ListEx was empty, simply extending List. Later I added Events to deal with an issue of a background thread adding items to a List which I had bound to a WinForms DataGrid (the DataGrid would obviously not display the items added by the background thread until it was manually refreshed). I also added the AddIf, AddRangeIf and CountIf methods because I found myself in need of this functionality at one time or another.
I was also disappointed to find that many of the collections and, of course, arrays did not have the ForEach method added to them like List did. So upon learning about Extension methods I created a Collection Utilities class and added a ForEach for any IEnumerable<T> collection. I also added an IsNullOrEmpty for Arrays and while working on comparing and matching products by name, I added the Edit Distance method. This came in very handy for matching products that had the same name components, but in different orders (e.g. "Rice Krispies, Kelloggs" and "Kelloggs Rice Krispies"). The version on SourceForge hasn't been updated yet, but I've also recently added Extension methods for Find, FindAll and Exists.
DictionaryEx (and IDictionaryEx) were created out of the need for an XmlSerializable Dictionary. Since I was going through the trouble of making this new class, I decided to go ahead and add the missing ForEach, Find, FindAll, etc... functions. While doing so I also added ByKey and ByValue methods for each of those as well (e.g., FindByKey, FindByValue)
Echis Framework - Configuration
One of the annoyances I've had to deal with at various places is inheriting an application with an overly used AppSetting section in the config file. Seems every developer who ever had a need for a setting would just add a new one to the list. Nevermind that the clever name they chose ("ConnStr") just happened to already be in use by someone else. Or that someone else may have already defined an AppSetting that they could have used instead. I've seen some rather ugly, ugly web and app config files; most recently I had to deploy code into a massive environment where multiple development teams have all had their hand in wrenching on the web.config file, and every single one of them just used the AppSettings section. The AppSettings section was colossal, literally hundreds of settings.
I designed the SettingsBase<T> class to eliminate these kinds of scenarios. I used the IConfigurationSectionHandler interface and created my own Section Handler that would simply deserialize the contents of a config section using the XmlSerializer. This allows for a much more structured configuration file; with each component having it's clearly defined settings in it's own section. Further it enabled settings to have collections of simple or complex types; it allowed settings to have properties that were complex types. As a developer, you simply derive from SettingsBase, provide properties decorated with XmlAttribute or XmlElement attributes and then add your config section. Visit the link above to more details including code samples.
Later I added the ability to "redirect" to an external configuration file. This allowed me to "break up" large overwhelming configurations into multiple files (e.g. in the case above where multiple Development teams were all modifying the same config file, it would be possible for each team to have it's own config file separate from the main Web.Config) and it also allowed simplified deployment to various environments; all I needed to do was change the file the section was redirecting to (e.g. Dev.Config, QA.Config, or Prod.Config).
Lately I've been working on taking the redirection a step further by creating a Centralized Configuration Repository. Thus far I have the classes written, but I have yet to fully test this functionality. The concept is that instead of reading the configuraion from a local file, that a Service will deliver the configuration section instead. Thus the only configuration needed locally is the information on the Configuration Service. I have yet to document this, but the way it works is a request is made, including credentials (e.g. User, machine, domain, application, environment), to the Configuration Service. The Service then confirms that the user and machine has access to the requested configuration section for the specified environment (e.g. Dev, QA, Prod); this way, the service can block someone from accidentally running against Production databases while working in the QA or Dev environment. Once the user and machine pass validation, the service looks up the configuration section for the application and returns it as an Xml string.
Well, that's all I have for now folks, if you are a .Net developer then I suggest you at least take a look. If nothing else you may come away with a few classes that will come in handy for you. Next up I will be working on documenting the Data Access components which, in my opinion, are what ADO.Net should have been like to start with. For instance, using the Echis components you can literally change from SqlClient to OleDbClient simply with a configuration change. You can execute queries with just one or two lines of code; and you can let Jr. Developers have access to a DataReader without worrying if they are going to close it when they are finished or not.
Until next time...