Thursday, 18 December 2008

Domain Specific Languages (I)

Domain Specific Languages are a relatively unknown piece of Visual Studio Extension technology. In this series of posts, I'm going to describe how to create a Domain Specific Language for modelling simple inheritance, and generating code from the model. The purpose is to do it from scratch, see the process, and understand the concepts involved. You’ll require Visual Studio 2008 Service Pack 1, and the Visual Studio SDK 1.1 to do this on your own machine.

Unlike a general purpose language such as C#, a domain-specific language is designed to handle a particular problem space, or domain. Domains can be defined in many different ways. Some domains are associated with specific industries or kinds of business (insurance domain, financial services domain, library domain). Other domains relate to specific kinds of software development (Web service components, GUI components etc.).

Typically, DSLs are created when a development team has to write similar code for different projects. For example, a team may have to develop several different insurance policy applications. The applications may use the same constructs, for example, a table that specifies the policy prices in different areas, in different ways. In a DSL, the price/area table can be a language element that is handled differently in each application.

DSLs can either be textual or graphical. An example of a textual DSL is an XML schema. Textual DSLs are difficult to develop and debug, and non-technical people may find them hard to understand. Graphical DSLs are easier to work on and easier to use for communicating with non-developers.

Domain-specific development is the process of identifying the parts of your applications that can be modelled by using a DSL, and then constructing the language and deploying it to application developers. The developers use the DSL to construct models that are specific to their applications, use the models to generate source code, and then use the source code to develop the applications.

The benefits of DSL development include:
  • DSL consists of elements and relationships that directly represent the logic of the problem space. Therefore, its easier to design the application, and find and correct errors of logic.
  • They let non-developers and people who do not know the domain understand the overall design.
  • Developers can use the code that their model generates to quickly create a prototype application that they can show to clients.
DSL Tools let you create a DSL that has your own graphical designer and your own diagram notation, and then use the language to generate appropriate source code for each project.

Wednesday, 17 December 2008

The CM Christmas Card - Powered by Deep Zoom!

Take a look for yourself by clicking the following link!

http://www.contentmaster.com/holiday-08/

Note that you will need the Silverlight plug-in installed to view the card. If you do not have it (or are unsure if you have it or not) the link will guide you the official Silverlight website where you can download it.

Deep Zoom was introduced to the world by Vertigo at the Mix 08 conference with their amazing Hard Rock Café Memorabilia application. It is an implementation of the Microsoft SeaDragon project that is more commonly used in Silverlight applications but is now appearing in other technologies such as Ajax.

As you can see from the Christmas card, DeepZoom gives the impression that the user is able to pan and zoom a very large image in a very smooth and seamless manner with very little lag and loading time. This is made possible by Deep Zoom’s XML based file format and a large “collection” of separate images that are arranged in a pyramid. These are then loaded as on the fly depending on where the user is located within the collection.

To help you on your journey across the sea of pixels, we have wrapped the Deep Zoom control (Silverlight’s MultiScaleImage control) with a navigation menu to give you easy access to a pan control, a Zoom slider and a “Home” button in case you loose your way.

Also check out the CM and Luminosity websites by clicking the relevant logos

Happy Holidays!

Visual Studio Project System

Following on from the previous post on Visual Studio extensibility (VSX), I'd like to point out an extremely useful resource for anyone looking at extending Visual Studio's project system. The IronPython project is hosted on CodePlex with all of it's source code for you to look at. From the perspective of Visual Studio, this shows you how to create a complete project system! So you can see implementations of new project and item templates with parameter substitution along with wizards. It also includes things like intellisense and a custom build environment for the IronPython language. A lot of this is achieved using another Codeplex project - the Managed Package Framework for Projects (MPFProj) - which gives you a framework for building a custom project environment in Visual Studio. At the moment MPFProj is not included as part of the Visual Studio SDK, and you need to include all the MPFProj source in your own project - but keep an eye on this project here (VSXtra) for a DLL containing a pre-compiled version of the MPFProj code.

Extending Visual Studio

I've recently had the opportunity to investigate some of the extensibility features in Visual Studio 2008, and not surprisingly there are a lot of different methods open to you. By extensibility I mean extending the functionality of Visual Studio over and above what's in the box in some way, not just customising the IDE to suit your way of working. Here are the main ways you can set about extending Visual Studio, starting with the simplest and moving to the most advanced.

Templates enable you to define your own variations on standard project types or items. So if you find yourself repeatedly recreating the same basic project over and over again, a new project template can save you a lot of effort. Simply create the basic project you'd like to reuse, and then use the "Export Template Wizard" from the File menu in Visual Studio. Then you'll have a new project type available whenever you create a new project in Visual Studio. You can do the same kind of thing with individual items, so for example you could have a new form type, already populated with some controls and code.

Macros are the next step up, and they work in a very similar way to macros in Office applications. Visual Studio has a macro recorder, so you can record a sequence of operations in the IDE for later play back. These macros are recorded as Visual Basic code, and Visual Studio has a built macro editing environment for tweaking the recorded code. Macros also work as a great learning tool, so if you want to learn how to automate something in Visual Studio you can record a macro and then analyse the code to see how it's done. For an overview of the range of functionality available check out this diagram of the Visual Studio Automation Object Model.

Add-ins come next and offer a couple of features over and above macros. For a start they can be distributed as compiled code and they can be written in any language that supports COM automation. Most importantly they provide a greater degree of integration with Visual Studio, allowing you to add commands to Visual Studio menus and toolbars, add new pages to Visual Studio's Options dialog, and create new tool windows in Visual Studio.

Top of the range though are Visual Studio Packages. To create a package you'll need to download and install the latest version of the Visual Studio SDK and accompanying documentation. The Visual Studio SDK and the package system enables you to do pretty much anything with Visual Studio. All of Visual Studio's existing functionality is written in the form of packages, so you can implement new editors, tool windows, project systems and even re-purpose the basic shell. The VSX website has loads of material on extending the Visual Studio IDE, and a catalogue of available extensions (some free, some commercial).

Friday, 12 December 2008

Libraries and Homegroup in Windows 7

Libraries

The Windows 7 team have introduced a new feature in Windows Explorer called Libraries. Libraries are a collection of indexed folders, such as Documents, Downloads, Music, Pictures, and Video libraries. In these libraries, you can group files that are stored anywhere on your computer or even externally, and view them all in one experience without physically copying or moving any files.

Let's take a look at the Documents library and see what features are new. In the Documents library folder, there is a new Documents library pane at the top of the window where you can rearrange the folder structure.


If you were looking for documents created by a particular author, you can choose to arrange your folder structure by Author, and hey presto, the Documents library window stacks all your files by author.

This is great, but what else can it do? And how can this help me? Well for me, saving documents to the desktop is an easy way to open and grab files when I need to, I’m unorganised I know! In Windows 7 tidying up messy documents is easy; you can simply drag them from your desktop for example, and drop them into the Documents library window, and when in the Arrange by Author category, Windows Explorer creates the new author stacks.

You do need to make sure that you remember to add relevant document details such as the author etc in order for the, arrange by filters to be most useful.



You can switch back to the Arrange by Folder view, which is a classic view, to look at a list of your folders, or choose from other views that are most appropriate to your needs.

You can manage folders in your library by clicking the Library Locations button. I want to view a collection of all my music in the Music library, so the first step would be to click Library Locations in my Music library window.

In the Music library window you can add folders from your computer or from an external drive to your Music library. You can also decide which folder will be the default save folder for the library. The default save folder in a library is the location where if you save a document to a specific library, by default, it will be saved in the default save folder.

For those of you that store music on a secondary partition, or an external drive, or both, can now have access to all your music in one place without copying everything into the one folder. Simply click Add, and then navigate to the required folder / drive that your music is stored on. Now in your Music library folder, you will see a collection of all your gathered music. You can do everything with your music that you could do before, click play, click next / previous, and listen to songs.

Unfortunately if you disconnect your external drive from your PC, you will be unable to continue listening to music in your Music library, this is a little annoying, but if your music is stored on your computer somewhere or on another partition, as long as you have established the location, you can still listen to your music in the Music library.

The same principle applies to all your libraries including any new libraries that you want to create, you can gather documents or videos etc from anywhere on your computer by adding folder locations to your desired library.



Homegroup

A homegroup is a new feature in windows 7 that is a way of setting up several computers on a home network, and sharing files with other homegroup members. Only members in your homegroup can view files on your computer, and gaining access to the homegroup network requires a secure password.

Setting up a homegroup in Windows 7 does not require any of the hassle and technical knowledge that is required to set up sharing in Vista. Once you have configured homegroup, you can view homegroup members in Windows Explorer, and here you can drag and drop files into the folders of members who are connected to your homegroup. This is a fantastic way to share files, and it’s easy. You don’t even need to worry about permissions, as Windows 7 have developed the Windows Explorer so that you have private and public libraries.


Before you go ahead and set up a homegroup network, your home computers network location should be set to Home network. Follow these simple steps to set your Windows 7 home computer network location to Home network: -


Setting the Network Location

  1. Click the Start menu.

  2. Click Control Panel.

  3. Click Network and Internet.

  4. Click Networking and Sharing Centre.

  5. In the View your active networks section, underneath your network name, click on the network location link.

  6. In the Set Network Location dialog box, click Home network.


Your network location is now a Home network, and you can set up a homegroup network.

Setting up a homegroup network is also simple, you can set up a homegroup network on a Windows 7 computer at home, by following these simple steps: -

Creating a Homegroup Network
  1. Click the Start menu.

  2. Click Control Panel.

  3. Click Network and Internet.

  4. Click Networking and Sharing Centre.

  5. In the Change your network settings section, click Set up sharing with homegroup.

  6. In the Do you want to create a homegroup? window, click Create now.



  7. In the Create a HomeGroup window, select the library check boxes that you want to share out, and then click Create now.



  8. In the Use this password to add other computers to your homegroup window, jot down the password, and then click Finish.



You have now successfully created a homegroup network!

Finally, you now need to set up other home computers so that the network locations are set to Home network. By doing so, this will enable you to be able to join the homegroup network that you just created. Follow the Setting the Network Location steps above to set your other home computer network location to Home network.

Joining a Homegroup Network

  1. Click the Start menu.

  2. Click Control Panel.

  3. Click Network and Internet.

  4. Click Networking and Sharing Centre.

  5. In the Change your network settings section, click Set up sharing with homegroup.

  6. In the Do you want to join a homegroup? window, click Join now.



  7. In the Computer name has created a homegroup that you can join window, select the library check boxes that you want to share, and then click Join now.



  8. In the Type your homegroup password window, type the homegroup network password, and then click Join now.



  9. In the You have joined the homegroup window, click Finish.



You have now successfully created and joined a homegroup!

To get sharing, open Windows Explorer, and in the navigation pane, click Homegroup. You can now click on the user in your homegroup, open / edit / delete documents (if these permissions are enabled) and even drag and drop documents into homegroup user's folders.


Homegroup is a great way to share you files, and also be more in control. You may notice that the folder structure in Windows 7 differs from that of previous windows OS's, and this is all to do with homegroups.

In Windows Explorer, you have private and public folders for all your libraries. Both folders have different permissions set so that you can manage them in the correct manner. You can also customise them so that the permission settings are exactly what you want. This means that you can make sure your personal folders are kept personal, and you public folders are kept public.

I think that libraries and homegroup are great additions to the new Windows OS, they make the experience much more user friendly and now anyone can use libraries and set up a homegroup and get sharing straight away.


I will be taking a look at Internet Explorer 8 next and I will be posting some more blogs and keeping you updated on what's new :)