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

CAPTCHA Challenge

Thursday, 31 January 2008 14:22 by jordan.terrell

A friend of my built a CAPTCHA generator out of his frustration with commonly available ones being easily circumvented.  As a test, he has issued a challenge to see if his generator can be defeated.

My gut tells me that it can be defeated, but I hope that I'm wrong.  If it ends up being highly successful, I would love to see some kind of proof-of-concept, person-to-person (non-automated) email protocol built around it.  This would absolve the need to have all emails digitally signed - only the automated ones would need it.

Categories:  
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

Language Filters Please

Thursday, 17 January 2008 09:06 by jordan.terrell

I've got a pretty extensive list of blogs that my aggregator (now Google Reader) pulls down.  I will see roughly 500-700 posts a day (not that I read them all).  However, for the last year or so I'm seeing a lot of foreign (to me) language posts that make up a good bit of those numbers.  I really wish that there was a way to filter out posts that are not written in languages you are interested in (similar though here).

Does anyone know of a way to accomplish this without it being a feature of your aggregator?

Categories:   General
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...