Tuesday, August 6, 2013

Build vs Consume


Recently when working on Scarlet, I came across an issue in which I had to choose between using an existing framework or creating my own function to do the same thing.

See my new GitHub blog for all the details

Friday, August 2, 2013

Blogging with Github Pages and Prose

I have created a new blog which I will be transitioning to soon.  The blog is created with Github Pages and Prose.

Check out my new blog and my post on how to get started using Github Pages and Prose http://tjchaplin.github.io/

Saturday, July 20, 2013

How to license your open source project

Every time I begin writing and making my open source projects available I seem to always omit the licensing bit.

The GitHub team have created the below site to help[1]:

http://choosealicense.com/

You can easily find out more about which license to choose, in addition to the license text itself.

[1] - https://github.com/blog/1530-choosing-an-open-source-license

Sunday, July 7, 2013

Aspect Interceptor With Castle Windsor C#

Purpose


  1. Show how to create an interceptor using Castle Windsor
  2. Describe when interceptors should be used

Code

An Interceptor

Intercepts the target, and then calls proceed

Windsor Registration

Initializes windsor, and then assigns the SimpleInterceptor as an implementation for IInterceptor.

Using an interceptor

By adding the interceptor attribute and making the method virtual.  The TestClass's DoStuff() method will now be intercepted when the method is called and after the method has returned

When

Interceptors should be implemented to allow you to create a "Cross Cutting Concerns".  The best example is logging.  With logging you may want to know when a method was started and when it returned.

Besides logging there are several use cases.  One that I wrote recently was the ability to publish domain/events when a certain method was called.  This allowed me to implement the domain business logic, and then to publish that event independently.

From a Single Responsibility standpoint this allows your class to do "One thing and do it well", but then allows you to independently spin off into different set of concerns.


Saturday, June 29, 2013

Grunt - Getting Started

Purpose


To provide a brief overview of Grunt.  Along with some examples and addons to get started.

About Grunt


Grunt(http://gruntjs.com) is a task based automation tool for NodeJs.  Grunt needs to be part of any NodeJs developers tool belt.

Getting Started


Here are the installs to get going:


What Just Got Installed

  • grunt-cli - this is the command line interface that allows you to use grunt in a command window
  • grunt - this is the core library
  • grunt-contrib-jshint - this is an add-on that does linting, warnings/errors for invalid javascript.
  • grunt-contrib-watch - will spin up a task that does file watching.  This allows you to potentially do linting or testing after every file change
  • grunt-release - this will bumpup your NPM package version, git tag the release, commit to github, and then push to NPM.  Everything you need to release

Now what


Add the Grunt configuration file gruntfile.js. 



Finally 


ensure the added dev dependencies are in your package.json.




References


Saturday, May 11, 2013

C# Covariance With Castle Windsor

Purpose

  • Show Simple Examples on how to use covariance in C# .net4 and above
  • Show Simple Examples on how to use with Castle Windsor container
  • Describe what Covariance is and how it might be used.

Code


Covariance Interface

A covariance interface is simply defined with a Type T precluded by the out keyword. The interface can then be used to access more derived types.  That is the key and what covariance gives you.

This can be implemented as follows:

Covariant Registration and Resolution using Castle Windsor


In the registration we have declared the type of the covariant interface to be of a base type(in the For<>). In the implemented declaration we reference the derived type. When ResolveAll is called we use the base type, that was specified in the For<>, and get a covariant array with all our types.


Covariant Registration and Resolution by convention using Castle Windsor


In the registration we have declared that all Classes in the assembly that are of a specific type(BasedOn(typeOf(someType)), should resolve to a service using an IEnumerable with the Base type(Select(new []{tyoeOf(someBaseType)}. When ResolveAll is called we use the base type, that was specified in the For<>, and get a covariant array with all classes in the assembly that are based on our covariant interface.

Covariance Definition


MSDN defines Covariance as Covariance allows interface methods to have more derived return types than that defined by the generic type parameters.[1] What this provides is a mechanism to use generics in a polymorphic way. Without using this technique one might get into a situation where you have to continually cast and/or use non-generic objects. A situation where this might be useful is when a generic service is called on several unrelated types. An example is a database extract/loader service, in which we need to load several unrelated types and return the results. Here is the complete example that can be run as a test:

Additional information regarding syntax rules and other examples can be found on Eric Lippert's Blog[2]

References: [1] - MSDN definition
References: [2] - Eric Lippert's Blog

Monday, May 30, 2011

Xcode 4 Version Control with Subversion



Vision
To create an example of how to use Xcode 4's version control with subversion.

Example

1. Import the Project into the repository

1.1 On the bottom toolbar of the Organizer - Repositories select the import button



1.2 Select the project folder you want to import and click the import button.



1.3 Set the initial comment for the import


1.4 Confirm the import in the Organizer - Repositories



2. Checkout the project for editing

2.1 On the bottom toolbar of the Organizer - Repositories select the "Checkout" button



2.2 Now select the local working copy location to check the code out to.



2.3 Finally select if you want to Open the checked out project.



Built Using
XCode 4


Reference

http://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/SCM/SCM.html