jordan.terrell
Just trying to make sense of things...

iSynaptic Commons - Release On Hold

Friday, 11 July 2008 09:23 by jordan.terrell

Back in April I mentioned that I was close to releasing my iSynaptic Commons framework - I've changed my mind on how soon I'm going to release it.  I've noticed a trend in short-changing my personal projects from certain quality practices that I am very strict about in my professional projects - practices such as unit tests with high code coverage, using a build server, well factored build scripts that compile, package, and publish builds, an active versioning policy,  code generation support (more on this later), etcetera.

The iSynaptic Commons framework represents my first public open source project envisioned and implemented by me.  As a result, I've become quite conscious of the missing quality practices mentioned above.  This in part of the reason why I chose to upgrade some software I've been using - I'm going to try to get strict about following all the best known practices with all of my iSynaptic projects, starting with the Commons framework.  I intend to get a build server up and running, and implementing all of these practices.

Towards that end, I want to communicate the inception of two other frameworks (extensions to the Commons framework):

    • iSynaptic.SolutionBuild - This will be a suite of reusable MSBuild scripts and tasks, aimed towards having a componentized build system where you can pick and choose build functionality

    • iSynaptic.Modeling - A set of class models, a XAML-like parser, and code generation templates for common infrastructure layers (e.g. db schema/data access, domain modeling, etcetera

    The Commons framework will be dependent on the SolutionBuild framework.  This will not unduly postpone the Commons framework, but should present a higher quality release.

    Thanks for your patience, and hopefully I can get a first release out soon...

    iSynaptic.Commons - Almost There

    Wednesday, 16 April 2008 09:47 by jordan.terrell

    This last weekend I hit 90% code coverage, so I'm about ready to release.  I need to update the build script to include headers at the top of the .cs files, and include the license (Artistic License 2.0) text in the distributable.  Once that's done, I will release a Community Tech Preview (CTP).

    Stay tuned...

    Tags:  
    Categories:   .NET | Programming
    Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

    Security Issues with Reflection.Emit

    Thursday, 6 March 2008 11:41 by jordan.terrell

    I was thinking through the Code Access Security (CAS) ramifications of my Cloneable<T> class, and stumbled upon a pretty useful article in the MSDN library.  It makes it clear what permissions are needed for various Reflection.Emit scenarios.

    I'm sure I have more testing to do in order to find which scenarios cannot use Cloneable<T>, but I'm hoping that list is a short one.

    iSynaptic.Commons - Update

    Monday, 25 February 2008 11:13 by jordan.terrell

    I'm learning the hard way that I should take my own advice when it comes to developing personal projects.  As a professional software consultant, I'm very consistent about writing unit tests for my production code, if not first, very shortly after (within the hour).  I've heard many a developer say "I'm busy right now, I'll come back and write those tests later."  Yeah  --  it almost never happens.

    So what did I do with my Commons library?  Wrote a whole bunch of code without tests!  Now I'm paying for it - I can't bring myself to release the library without more code coverage.  Right now I'm sitting at 81% code coverage, and I'm so glad that I'm working through the tests because they have exposed a few bugs.

    Let this be a lesson (mostly for myself) - don't write code without tests, even if it is for your own homegrown pet project!

    Tags:  
    Categories:   Programming
    Actions:   E-mail | del.icio.us | Permalink | Comments (1) | Comment RSSRSS comment feed

    iSynaptic.Commons - License

    Friday, 25 January 2008 15:48 by jordan.terrell

    I think I've pretty much decided that I'm going to release my Commons framework under the The Artistic License 2.0.  This will allow you to use the framework in a commercial product (terms outlined in the license).

    Any feedback?

    Tags:  
    Categories:  
    Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

    iSynaptic.Commons - Cloneable<T>

    Thursday, 24 January 2008 10:28 by jordan.terrell

    So as I was working to increase the code coverage for my Commons framework, I found some gnarly edge cases that caused issues in my Cloneable<T> class - specifically dealing with value types.  I have since fixed those.

    Cloneable<T> is really the guts of my Transactional<T> class, but I figured that it could be useful as a separate class.  When you start a transaction, Transactional<T> will use Cloneable<T> to create a copy of the object you want to be transactional.  Now historically the way that I've seen this done is to use in-memory binary serialization make a copy.

    This is both slow, and consumes unnecessary additional memory.  Really, what you want to be able to do is create an instance of an object, and then copy the contents of it's fields from the source to the clone.

    In order to create an instance of an object that might not have a parameter-less constructor, I use FormatterServices.GetSafeUninitializedObject(Type type).  This allows you to create an instance of an object without calling a constructor.  I first learned about this when reviewing how ObjectBuilder works.

    Once you've got an instance of the object, you could just use Reflection to copy the contents of the fields, however that is slow.  Enter DynamicMethods!  DynamicMethods allows you to create a method on the fly, and tack it on to a class.  Using Reflection *once* to enumerate what the fields are, I build a method that can copy the fields from the source to the clone by emitting IL (Intermediate Language).  When you call the Clone(T source) or ShallowClone(T source) method it calls this dynamically emitted method.

    DynamicMethods have a performance profile *almost* identical to that of normal compiled source code.  I did a test cloning 1 million instances of a class that had 6 fields - using in-memory binary serialization it took roughly 2 minutes (just shy of it by a few seconds) - using Cloneable<T> it took about 0.5 seconds!!!  This bodes well for my Transactional<T> class - creating copies of even complex objects is now a very cheap operation.  Is still have to investigate the Code Access Security (CAS) ramifications of emitting the DynamicMethod, but I still think it is a better approach.

    I'm still looking to release my Commons framework soon.  Code coverage is at 72% now, with Cloneable<T> at 100% covered (I'm sure there are still more edge cases I haven't tested).  Once I'm comfortable with the code coverage, I will release it.  I'm thinking of releasing it under something like the BSD or MIT license - because I want it to be usable for commercial purposes - but I haven't decided yet.

    Any license you would like to see it released under?  (and don't say GPL or anything very similar - not going to happen!)

    Tags:  
    Categories:   .NET | Programming
    Actions:   E-mail | del.icio.us | Permalink | Comments (1) | Comment RSSRSS comment feed

    iSynaptic.Commons - CTP coming soon

    Monday, 14 January 2008 10:02 by jordan.terrell

    Lately I've been working on a "Commons" framework that I am planning to release to the public.  There is two versions of the framework - one that targets the .NET 2.0 framework, and one that targets the 3.5 framework.  The goal is to create a framework that really leverages the new C# (or VB) language enhancements. I'm not sure how soon I will be releasing a CTP, but here is a list of things that it can do so far...

    • Custom Implementation of LINQ Standard Query Operators (partial implementation so far) so you can use LINQ when targeting .NET 2.0 framework (assuming you are using VS 2008).
    • Numerous extension methods, all in a separate namespace "iSynaptic.Commons.Extensions"
      • IEnumerable<T>.WithIndex()
      • IEnumerable<T>.LookAheadable()
      • IEnumerable<T>.Delimit(string delimiter)
      • Action<...>.Curry<...>(...)
      • Action<T>.MakeConditional(Predicate<T> condition)
      • ICollection<T>.Remove(params T[] itemsToRemove)
      • Enum.IsDefined() (useful/simpler as a extension method)
      • Func<...>.Curry<...>(...)
      • Func<T>.MakeConditional(Predicate<T> condition)
      • Func<T>.ToAction()
      • ...and many more
    • An implementation of the Specification pattern
    • Scope<T> and NestableScope<T> implementation
    • ReadOnlyDictionary<TKey, TValue>
    • Cloneable<T> - uses dynamic IL generation to clone objects really fast!
    • Transactional<T> - makes use of Cloneable<T> to create transactional objects that support System.Transactions
    • ScanningTextReader and SimpleScanner for custom text parsing
    • ProcessingInstructionParser to parse XML processing instructions when you are using XmlReaders
    • ...and much more

    I've got a number of things I plan to implement, but this is what is mostly functional now.  I want to get testing code coverage up a little higher (I'm at 66%), so stay tuned...