(adj) naif, naïve  -- marked by unaffected simplicity

- Merriam Webster

I have been working for a while on a library of simple components, which I have called Project “Naif”.  Naif is the masculine form of the more common adjective “naïve”.   Both words are originally French and while naïve is in fairly common usage in English, naif is much less used.  But they mean the same thing – marked by unaffected simplicity - as defined by Merriam Webster.

There are two major reasons for this project. 

Firstly, as I have been doing quite a bit of development on Windows Phone “Mango” I have realized that some of the more sophisticated frameworks do not work on the reduced “Client Profile” that Windows Phone supports, and I needed something lightweight that would accomplish these tasks. 

Secondly, I saw this as a challenge – a way to learn some new concepts and techniques.

This Project is a living project - as I need a component I will build one, but at the time of writing – my little library has the following components:

  • A simple lock based on the Monitor object
  • Thread safe collections – SynchronizedDictionary and SynchronizedList
  • A simple DI (dependency injection) container
  • A cache provider model with two simple implementations – one based on the ASP.NET runtime cache and one based on a simple Dictionary
  • A simple data framework which supports Unit of Work, the Repository pattern, caching and transactions
  • An oAuth 2 Client

For most of these components there are some quite well-known open source projects available – many of them though can be quite complex, and as stated above, my goal is to be as simple as possible. 

Inspired by some of the recent micro-ORMs (Dapper, Massive and Peta-Poco) – many of these components are single classes and all of the components mentioned above are compiled into a single assembly which is currently about 35-40K in size.  They may not work in every scenario, but they certainly provide a robust set of tools for my Windows Phone development.

So in this series, I am going to describe many of these components, and why I made some of the design choices.


Posted in: Development , Patterns  Tags: ,

In the first post in this series I pointed out that DotNetNuke places few requirements on module developers, and this is often daunting to new developers – “where do I start?” being a common refrain.

So where do you start? 

Before we actually start to build our first module lets look at what constitutes a module.  In the default DotNetNuke skin/template that is used when installing DotNetNuke there are a number of examples of Text/HTML modules. 

As an example Figure 1 shows 3 such modules on the Home Page.

Figure 1: Examples of HTML modules on the Home Page of the Default Template
image

Some of the content on the page is provided by the module and some of the content is provided by the framework.  In figure 1, while all three modules are HTML modules they all have slightly different “headers”.

Module 1’s heading is in a larger font than Module 2 and Module 3 doesn’t have a heading at all.  This module “chrome” is provided by the container which has been applied to the module.  The module header text is provided by the framework (Figure 2 – red box), the styling of the chrome is provided by the container, and the text/images in the “body” of the module are provided by the module itself (Figure 2 – blue box).

Figure 2: The components of a Module
image

This means that as a module developer, I don’t need to worry about the external chrome – or the module header – this is done for me, I can focus on the content inside the blue box.

IModuleControl

DotNetNuke is built on top of Microsoft’s ASP.NET Web Framework, using the Web Forms model.  This model is based on Web Forms (.aspx files) and Web User Controls (.ascx files), as well as Web Controls (which are compiled as part of a class library). 

Every page in DotNetNuke is a Web Form – in fact every page is the same Web Form – Default.aspx.

Sections of the page are made up of dynamically injected Controls – most of which are Web User Controls, and in most cases a module is implemented as a Web User Control (.ascx).  So in order to create a module we need to first create a User Control. 

But not just any User Control. 

DotNetNuke needs to know certain things about a module – and conversely the module might need certain things from the DotNetNuke core, so there is an additional requirement that the User Control needs to implement a DotNetNuke interface – IModuleControl

Figure 3: The IModuleControl interface which defines a Module Control
    public interface IModuleControl
    {
        Control Control { get; }
        string ControlPath { get; }
        string ControlName { get; }
        string LocalResourceFile { get; set; }
        ModuleInstanceContext ModuleContext { get; }
    }

To make life easier for module developers, the core provides a few base classes which already implement this interface and which can be used as a base by module developers.

  • PortalModuleBase – this was the original base class for all modules – In DotNetNuke 5.0 the requirement was modified to implement IModuleControl, and this class was refactored to accomplish this.  It exposes a lot of extra properties and methods (in addition to the 5 properties that constitute IModuleControl) – most of which can also be accessed through the ModuleContext property.
  • ModuleUserControlBase – this new (in DotNetNuke 5.0) base class is a simple implementation of IModuleControl, based on the UserControl base class.  In addition to the 5 members of IModuleControl it adds a simple method LocalizeString which is a helper method for localization.
  • ModuleControlBase – this base class (introduced in DotNetNuke 5.0) is based on the WebControl base class (rather than UserControl).  To use this base class the module control would be compiled as part of a class library.

Basically all we have to do then is to create a “control” which inherits from any of these 3 base classes.  This is the only requirement for building a DotNetNuke Module.  There is much more that DotNetNuke offers to module developers, but the minimum requirement is to create a “control” which implements the IModuleControl interface. 

For most of the rest of this series we will be using the ModuleUserControlBase class as our starting point, and in part 3 of this series we will actually create our first DotNetNuke module.


Posted in: DotNetNuke  Tags:

DotNetNuke has a rich eco-system of Modules, both Open Source and Commercial.  In many ways this is our biggest strength as a CMS platform.  No matter what you want to do with your site – there is often a module that already does it.

In my opinion this is due to the flexibility provided by the core DotNetNuke Framework.  Many other platforms are very prescriptive – as an extension developer you have to follow a fixed shopping list of rules – there is invariably only one way to create an extension, which may not work for what you want to do. 

But DotNetNuke places very few requirements on what must be done to build an extension.  This frees developers to be creative – to think outside the box – which I feel explains the rich ecosystem of modules that already exists and continue to be developed.

I have been working as a developer on DotNetNuke for nearly 8 years now.  During that time I have built many modules for personal use as well as a number of modules that are now part of the core distributions.  In addition, I have designed and created many of the hooks in the core which Module Developers can take advantage of.

Recently, I have heard comments that “Module Development with DotNetNuke is difficult”. 

I don’t agree with this sentiment – but, I think that our strength (flexibility) that I described above is also our weakness. There are a multitude of ways to build DotNetNuke modules -  and we don’t provide a prescriptive method of development.  While this provides flexibility, it can be somewhat daunting for new DotNetNuke developers – where do I start? is a common refrain.

My goal in this series of posts is to provide some guidance – from my perspective – for both the beginner module developer and for more advanced developers, who may not be aware of all the hooks/features that DotNetNuke provides. 

This is not “The Definitive Way of Module Development” – its not even “A Definitive Way of Module Development”, but (with apologies to Frank Sinatra) it is “My Way”.


Posted in: DotNetNuke  Tags:

 Search Blog

 Calendar

«  May 2012  »
MoTuWeThFrSaSu
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910
View posts in large calendar

 Tags

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

© Copyright 2012 Thoughts from the Wet Coast