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

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.

Language Oriented Programming

Tuesday, 26 February 2008 10:05 by jordan.terrell

Unless you've been hiding under a rock inside of a cave in the middle of the desert without an Internet connection, you have undoubtedly noticed that Microsoft and other vendors are hard at work developing new and updated languages that target the .NET runtime (there are also new languages targeting native code), and the upcoming Dynamic Language Runtime, or DLR.

Here is just a few (this list just scratches the surface):

All of these seem to have surfaced within the last few years, and there appears to be added emphasis to new language concepts and languages.  If we look at the history of software development and the eras, if you will, that it has gone through, you'll see three eras that are quite prominent:

  1. Object Oriented Programming
  2. Component Oriented Programming
  3. Service Oriented Programming (or SOA)

The last one, Service Oriented Programming seems to have become fully adopted into the development culture.  There are many toolkits and frameworks that allows one to build and consume services in multiple development platforms.

With this broad acceptance of Service Oriented Programming, I'm thinking that we are beginning the next era of advancement in software development: Language Oriented Programming.  I think this is a great move by the industry and as a result I feel we will see some really expressive horizontal (general purpose) and vertical (domain specific) languages come from this shift.

However, as it was with the adoption of Object Oriented Programming, I think there is going to be a significant learning curve for many of the developers out there.  Just look at the changes to C# and VB - the addition of functional and query (set algebra) programming concepts, although very powerful (and in my personal opinion very welcomed), they present a huge learning curve to those who are more junior in their understanding of languages and software development concepts.  Those of us who "grok" it, I think now have the responsibility to train as best as we can developers who are new to all these dynamic and functional language concepts.  We need to do our best to encourage them to learn about these changes.  But, even more so, all self-proclaimed software developers need to take (at least some) time to learn about these changes and their underlying concepts - because like it or not, they are coming.

Okay, I'll get off my soap box now.  As you may have noticed in one of my recent posts, I'm working on understanding compilers and languages.  This has been an enjoyable process.  I'm reading two books to help me do this:

I've stayed away from books that are too specific or narrowly focused.  I want to get a well-rounded understanding of language and compiler design and implementation concepts, without confining it to a specific platform.

If anyone has suggestions on resources that I should check out - please do let me know!

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...

Is Visual Basic, the language, in its golden years?

Monday, 12 November 2007 11:26 by jordan.terrell

I may be setting up myself for a flame war, but I just had to ask this question.

Visual Basic has been around for some time, and will soon be releasing version 9.0 of the language.  Visual Basic has gone through two major platform shifts - first with the move to COM, and then with the move to .NET.  Through each of these shifts, the language has had to change to participate in these platform changes.  When I recall the 1.0 release of .NET, many Visual Basic 6 programmers viewed VB.NET as an entirely different language because sheer number of changes to the language.  However, many have successfully transitioned to the .NET platform and continued to move forward.

However, look at the new features in VB 9.0 - I have to say, in my opinion, the language is starting to look quite bloated - especially when you look at the XML literals features.

Can Visual Basic continue to survive shifts in platform directions, especially with the continued functional and dynamic focus of languages such as C#, F#, IronPython and IronRuby?

Is Visual Basic in its golden years?  What do you think?

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

UnitRun discontinued...

Thursday, 8 November 2007 13:57 by jordan.terrell

I was very saddened today to find out that my favorite unit testing front end was discontinued.  I wish that it was still available for download, even if it wasn't being supported.

JetBrains - can you please put UnitRun back up for download?

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

ObjectBuilder Documentation

Thursday, 4 October 2007 15:48 by jordan.terrell

I've heard many times both in conversation and in blog posts that ObjectBuilder doesn't have any documentation.  Granted, yes it doesn't have good (if any) official documentation.

However, the Composite UI Application Block (CAB for short) does have a good bit of documentation on ObjectBuilder in the hands-on-labs (VB version, if you are so inclined).  Section 8 will give you a full architectural run down, which to me is far more valuable than class-by-class documentation.  After that, the best source of documentation is probably the source code.

Anyone else know of any good documentation for ObjectBuilder, official or otherwise?

Request to add operator to the C# language

Friday, 14 September 2007 11:01 by jordan.terrell

I just submitted a suggestion to add an operator to C#.  I kept the sample on the suggestion simple, but I'm really trying to enable a scenario like this:

   1:  public class SomeClass
   2:  {
   3:      private List<string> _Strings = null;
   4:   
   5:      public List<string> Strings
   6:      {
   7:          get { return _Strings ?= new List<string>(); }
   8:      }
   9:  }

 

In this sample if _Strings was null, it would create a new list of strings, assign it to the _Strings variable, and return the newly created list from the getter.  However, if _Strings was not null, the getter would simple return the list referenced by the _Strings variable.

If you like this idea, go ahead and vote on it!

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

The First Compile

Friday, 7 September 2007 11:19 by jordan.terrell

When I first create a .NET project (really any software project, not just .NET), I have a general rule that I try to follow throughout the project:

Anytime someone retrieves the project's source code, so long as they have the correct version of the compiler installed, the first compile should be flawless - no errors, no warnings.

Anytime I pull down a project/solution (open source or internal company project) and this is not the case, I already have a sour taste in my mouth, so to speak.  I've seen binary references that were not included with the source, tools needed to build that were missing, hard coded paths, and so on.

Having a continuous integration server build your project is a good way to ensure that this experience happens throughout a project's life cycle.  Plus, you don't have to deal with other developers interrupting you to ask: "Can you help me get this project to compile?"

Just something to think about...