Innovation. Imagination. Delivered. RSS 2.0
# Monday, July 27, 2009

Enabling a Web Slice

Web Slices are new feature in IE 8 that allow your users to bookmark specify content on your site. Implementing this feature is easy and can be accomplished in a few lines of code. The keys are:

  1. Use the 'hslice' class
  2. Specify a slice id
  3. Specify an 'entry-title'
  4. Specify 'entry-content'
  5. Use optional attributes (see IE8 Readiness Toolkit)
The code sample below highlights the required attributes in red and the optional attributes in blue.

The Web Slice User Experience

When a user views your web slice enabled page in IE8, the user is presented with a button that allows him/her to add the slice.

A confirmation dialog appears, displaying the name of your web slice and the location.

Once the user has added the slice, a button is added to the browser toolbar. (User can delete the slice by 'right-clicking' the slice name and then choosing delete.)

When the user clicks the slice button. The slice content is displayed. Two buttons give the user the ability to both refresh the slice and to navigate to your page which contains the slice.

Monday, July 27, 2009 9:30:15 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
IE8 | Web Design
# Thursday, July 23, 2009
C# 4.0 New Features: Optional and Named Parameters
    Optional Parameters
  • removes the ceremony of method overloads to assign default values
  • static void GenerateChart(bool copyToWord = false)
    Named Parameters
  • call a method: GenerateChart(copyToWord: true);
Combining the two new features allow you to write concise code and not
specify values that are not needed in methods with a large number of arguments:
  • Old: MethodA('A', null, null, null, false, null);
  • New: MethodA(ArgA: 'A', ArgE: false);
Thursday, July 23, 2009 9:12:54 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
.Net v4.0 | C#
# Wednesday, July 22, 2009
Managed Extensibility Framework (MEF)

Below are my review notes from the 10-4 video on the upcoming Managed Extensibility Framework in version 4.0

  1. A new library available in v4.0
  2. Software entities should be open to extension, but closed to modification (Open/Closed Principle)
  3. Basics:
    • An application is built of parts or individual pieces composed together
    • Three Steps:
      1. Export a part (Attribute: [Export(typeof(IMortgageCalculator))])
      2. Import a part (Attribute: [Import(typeof(Logger))])
      3. Compose a part
        • Catalogs provide the parts (TypeCatalog, AssemblyCatalog, DirectoryCatalog, AggregatingCatalog)
        • Container is the matchmaker
  4. Why? - Build a network aware app without changing the core window code (i.e. extend behavior without modifying code)

Sample
namespace Sample
{
	public interface IMortgageRateRepository
	{
		public IList GetCurrentRates();
	}
}

Notice that in the concrete implementation of the interface we use the Export Attribute

namespace Sample
{
	[Export(typeof(IMortgageRateRepository))]
	public class ELoanMortgageRateRepository: IMortgageRateRepository
	{
		public IList GetCurrentRates()
		{
			return new List();
		}
	}
}

Alot of stuff happening here, we use the export attribute at the class level and then the Import attribute on our dependency. I also want to point out that we no longer 'new' up an object. Instead we implement the IPartImportsSatisfiedNotification interface and move out binding logic to that event handler (basically we can't use the objects until they have been imported by the container).

namespace Sample
{
	[Export]
	public partial class MortgageRates: Window, IPartImportsSatisfiedNotification
	{
		[Import]
		IMortgageRateRepository MortgageRateRepository  { get; set; }

		public MortgageRates()
		{
			InitializeComponent();

			//MortgageRateRepository = new MortgageRateRepository();
			//grid.ItemSource = MortgageRateRepository.GetCurrentRates();
		}

		public void OnImportsSatisified()
		{
			Dispatcher.Invoke(new Action(() =>
			{
				MortgageRateRepository = new MortgageRateRepository();
				grid.ItemSource = MortgageRateRepository.GetCurrentRates();	
			}));
		}
	}
}

Finally, where the magic happens. We create an AssemblyCatalog and then a CompositionContainer. Notice that instead of 'Newing' up an instance of the window directly. We get an instance of the exported object from the container.

namespace Sample
{
	public partial class App: Application
	{
		var catalog = new AssemblyCatalog(Assembly.GetExecutingAssembly());
		var container = new CompositionContainer(catalog);

		var window = container.GetExportedObject<MortgageRates>();
		//var window = new MortgageRates();

		window.Show();
	}
}
Wednesday, July 22, 2009 8:47:20 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
.Net v4.0 | Extensibility
# Tuesday, June 30, 2009

What is an application framework?

Application Frameworks are collections of libraries (or code) prevalent in many large IT shops. Frameworks can be expensive to develop properly but the cost is more than offset by the advantages they provide. Some of these advantages include things like code quality, promoting code reuse, standardization of tasks and alleviate overhead that can be common across multiple applications.

Open Source Examples

You could spend days on Google and Bing researching the vast number of available options. We'll save you some time though...The two most prevelant examples in the .Net world are Spring.NET (http://www.springframework.net/) and CSLA.NET (http://www.lhotka.net/Default.aspx). Both of these examples are truly fantastic, robust, open-source frameworks that are geared towards large enterprises. So why build our own?

The Rationale for Building Our Own

Our experience with frameworks is mixed at best. The advantages frameworks provide certainly outweigh the cost but even with the examples given above, complexity quickly becomes an issue. Because these frameworks are geared toward large enterprises and attempt to be all things to all people they are inheritantly complex. Don't get me wrong though, complexity in and of itself is not necessarily evil. In the situation where you are implementing an enterpise framework for a large organization complexity is a fact of life. We find that in the case of most clients the complexity these frameworks introduces an element of risk that is not necessary.

After evaluating the available options and weighing the pros and cons we decided that instead of trying to fit the proverbial square peg into a round hole, we would use our experience and expertise to develop an application framework that is more suited to a small or medium-sized business.

The Enterprise Framework

We chose the name Enterprise Framework because although the framework is geared towards small and medium sized businesses the framework is robust enough to accommodate growth and has the ability to easily scale to support an enterprise application. In fact, the major difference between our framework and other commercially available frameworks is simply scope. The scope of our framework is limited to provide features and functions that are most commonly used in our client projects (such as Data Access, Security, Logging, Error Handling, Email, etc). By taking removing the requirement that our framework accommodate 'everyone' we were able to remove alot of complexity associated with application frameworks.

Our framework currently consists of the following modules:

  • EnterpriseFramework - The base module that provides common functions such as Data Access, Security, Logging, Configuration, etc)
  • EnterpriseFramework.BusinessObjects - Specific to each client and is generated from the client database (Code Generation - Object-relational Mapping)
  • EnterpriseFramework.Services - Provides supports for Web Services (ASMX, WCF)
  • EnterpriseFramework.Web - Provides basically functionality for web application such as Security, Caching, URL Rewriting, Visitor Tracking, Localization, Globalization, etc.
  • EnterpriseFramework.Web.Controls - An advanced add-on for the web module that provides controls and utilities based on the Telerik Ajax Web controls
  • EnterpriseFramework.Windows - A mirror of the web module but geared toward providing similiar services to a windows application.

Tuesday, June 30, 2009 1:36:31 PM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
Enterprise Framework | General
# Wednesday, June 24, 2009
One of the things we frequently see when a client-project uses masterpages is the following type-cast:

MasterPageType myMasterPage = Page.Master as MasterPageType;

To avoid this type-cast you can simply add the following directive to your page:

<%@ MasterType VirtualPath="~/Site.master" %>

Adding this directive to your page will make the Master property strongly-typed (Page.Master remains loosely-typed) to your masterpage eliminating the need to do the aforementioned type-cast.

Wednesday, June 24, 2009 10:20:03 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
Coding Tips
# Tuesday, June 16, 2009
While there are many different ways to implement web services the two predominate architectural styles are REST (REpresentational State Transfer) and SOAP (Simple Object Access Protocol). Each style has is own pro's and con's and it is necessary to objectively balance the appropriateness of each when selecting the implementation of your next service. So what's the difference at a high level between the two?

SOAP (WS-*) services are geared toward the enterprise and are inheritently more complex. For each SOAP service you define a contract using the Web Service Definition Language (WSDL). This contract specifies precisely the XML request and response messages needed to interact with the service. The SOAP (WS-*) standards address things like reliability, transactions and message-based security which are important when dealing with any value added transactions. Obviously there is a cost for this functionality in terms of overhead and complexity.

If a SOAP service is consider the 'yin', then the REST service would definitely be the 'yang'. Simple to implement with no contract to define a REST service can be broken down to four actions:

- GET - Gets the Resource
- POST - creates the Resource
- PUT - Updates the Resource
- DELETE - Deletes the Resource

This simplicity means quicker development time, lower overhead although you sacrifice features. For services that are dealing with non-critical data REST services are definitely the way to go.

So which will you choose? We say let the REST versus SOAP debate rage on.Luckily for you, you don't have to be caught in the middle. The Microsoft Windows Communications Foundation (WCF) framework provides you with the flexibility to easily change the method your service uses to communicate and even allows you to service both REST and SOAP requests with the same service.
Tuesday, June 16, 2009 9:46:51 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
General | Web Services
# Monday, June 15, 2009
Central Florida Software Group Blog Introduction.
Monday, June 15, 2009 11:37:02 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
General
# Thursday, November 20, 2008
Thursday, November 20, 2008 8:45:27 AM (Eastern Standard Time, UTC-05:00)  #    Comments [0] - Trackback
SSIS
# Thursday, July 24, 2008

I should note that both of these reviews are from the perspective of an seasoned and experienced technologist. Your mileage may vary based on the knowledge your background and personal experiences...

Pro WPF in C# 2008: Windows Presentation Foundation with .NET 3.5 Second Edition - Matthew MacDonald

This book is a fairly easy, albiet long read. Coming from a web development background this book provides a solid introduction to to all things WPF. A few of my comments:

- Excellent introduction to the underlying foundation of WPF
- Excellent coverage of Xaml
- Good sections on documents, printing, add-ins and custom elements
- In my experience in the corporate development world I have never seen a business app with either animation or 3-d imaging (yeah...I know its used somewhere), which is why I struggled to understand the long, long, long winded sections on animation and 3D topics

Between this book and the MeasureUp practice exams I was able to passed the WPF certification exam, with no prior WPF experience. (And for those that are wondering...the book is a significantly better exam prep than the MeasureUp practice questions were.)

Microsoft Windows Communication Foundation Step by Step - John Sharp

This book was a very quick read (took less than 2 days to read through) and does little more that introduce WCF. The exercises are contrived and provide little real-world value. The highlights of the book are really the chapters on security. If your looking for something more granualar than an introductory overview I would search out a different book.

Thursday, July 24, 2008 8:39:48 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
Book Reviews
# Wednesday, April 23, 2008

‘Sexy’ Extensibility Design and Patterns

“Programming to the interface” is important when addressing extensibility.

Provider Pattern – If you are familiar with asp.net then you have been beat over the head with this pattern enough that I won’t spent much time on it. If your not familiar with asp.net, I’ll give you 50,000ft view…… it allows for abstraction of data and behavior by using an interface that the client is aware of and an external class library that contains the actual implementation of whatever you are trying to do.

Plug-Ins – This is pretty straight-forward. Plug-ins are implemented in a way similar to modules below. The real difference is that you have to explicitly iterate through a list either from a configuration file or a pre-defined directory.

Modules – This was the most interesting pattern and basically defines multiple parts of extensibility in one class. Related patterns are Chain of Responsibility, Loosely Coupled Events and Interception Filter. This methodology is event-driven and in an extremely flexible manner allows modules to hook into the events. The modules are identified to the client or web app through a configuration file and are loaded using reflection.

Wednesday, April 23, 2008 8:38:37 AM (Eastern Daylight Time, UTC-04:00)  #    Comments [0] - Trackback
Conferences
Archive
<March 2010>
SunMonTueWedThuFriSat
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Copyright 2010
Christopher L Price
Sign In
Statistics
Total Posts: 13
This Year: 0
This Month: 0
This Week: 0
Comments: 0
Themes
Pick a theme:
All Content © 2010, Christopher L Price
DasBlog theme 'Business' created by Christoph De Baene (delarou)