Friday 18 November 2011

Friday 29 July 2011

Choosing a Database Model: Dataset vs Entity Data Model

When configuring a data source in MSVS, use the Entity Data model because that's compatible with LINQ.

Monday 11 April 2011

ObservableCollections using System.Collections.ObjectModel;

First off, ObservableCollection: What's the Added Value?

I want to do data binding. I can use ObservableCollection - but I don't have to. Data binding will work against anything IEnumerable. The added value of an ObservableCollection is that it implements INotifyCollectionChanged which raises an event whenever the collection is modified (i.e. an element is added, removed or replaced). There is no contract in place though for elements being modified as this is not an addition, removal or replacement. That's a gotcha.

Where is ObservableCollection?

If you've been off dot net a while you may forget. Is it in System.Collections, is it in System.ComponentModel?  Neither. The namespace you need is System.Collections.ObjectModel. Not exactly intuitive, but logical when you think about it.

Philosophy of System.Collections.ObjectModel

The System.Collections.ObjModel namespace is famous for ObservableCollection (part of .Net 3 onwards and also Silverlight, recall WPF was born in .Net 3).

More generally, though, this namespace formalises the base classes for building collections (i.e. the implicit architecture underlying the Collection classes).

List based approach to Collections

For example. The base class for a GenericCollection is Collection<T>.

What properties do you think we might ascribe to a class to represent GenericCollections? What do we do with Collections?

We count the number of items (property Count), we want the items (property Items), anything else? You get an item at a specific index. Note, this a very list-oriented approach to building collections, rather than a set-oriented approach...in fact, GenericCollection inherits from IList<T>. Also, a generic collection can be initialise with an IList<T&gt.

Evolution 2.0: The ObservableCollection

ObservableCollections are a whole different ball game, providing notifications when objects are added and removed, and when the whole list is refreshed. The events an ObservableCollection (henceforth OC) exposes are:
* CollectionChanged (for the aforementioned change events), and
* PropertyChanged.

(This is actually enforced by the INotifyProperyChanged and INotifyCollectionChanged interfaces). ObservableCollection builds on GenericCollection by inheriting directly from Collection<T&gt. Its one of the building blocks of data binding.

using System.ComponentModel;

For PropertyChangeEventArgs.

The Use of Reference Documents in Software Development

Useful to develop and maintain reference documents throughout a project, as a point of reference, so a more conscious change control process can be applied. Also, very useful to record complex methodologies which are difficult to memorise due to several moving parts. The reference document can be used to refresh understanding at any stage of the project. Hoo-rah for Reference Documents!

Thursday 7 April 2011

The Quest for Comments with Practical Information Content

Before you start deleting someone else's useless comments (just because they are not useful) contemplate replacing them with something more useful. Don't just get disenfranchised with comments altogether and dismiss all comments as useless. Comments ARE useful, but have to be written in such a way that they are useful and have practical information content.

The 5-step scale of information content:

1. No comment => no information. The Base Case. Extremely common. Action: read the code and then comment it.
2. Comments without information content, programmer has just written drivel. Surprisingly very common. Action: delete and replace with something more sensible.
3. Comments do have information content, but are useless. Also common. Action: Delete and Replant with something practically useful.
4. Practical information content. Rare. Action: Refine.
5. Practical information content written clearly and concisely. Rare. Action: Enjoy

Remember, when you remove a tree, plant a new one.

Wednesday 6 April 2011

The IIS Application Pool Process and Windows Account Privileges

w3wp.exe is the IIS application pool process. Application pool was a new feature in IIS 6.0allowing isolation between different web applications. Each application pool runs in its own worker process, so exception in one won't bring down another. App pools can be configured to enhance reliability but also for security e.g. lower security apps could belong to a common pool. Running the worker process using a LOW PRIVILEGE account, you minimise security implications.

In pre-version 6.0 IIS, worker processes used to run as LocalSystem. This had security implications. Now the default account is NetworkService, which has low-level access rights.

Tuesday 5 April 2011

The World According to Adobe - ADM and other Adobe Specific Acronyms

Adobe is rewriting the world of the Windows user by introducing awesome new Adobe-specific acronyms.

ADM - Adobe Download Manager
MUI - Multilingual User Interface
X - Version 10

The ADM is also an AWESOME advertising platform for Adobe's partners. How cool is that? Get adverts streaming to your desktop as you download! It's user friendly and won't affect the performance of your machine much either. Howzat!!