Newbie CAB and ASP_NET

Topics: CAB & Smart Client Software Factory
Feb 22, 2006 at 5:02 PM
originally posted by: DingDongLars

Ooops, didn't look so good after I posted. Next time I'll try out some <br> tags
Feb 22, 2006 at 5:04 PM
originally posted by: DingDongLars

I am a complete newbie to CAB - and not that experienced in .net as a whole. So my question might seem daft to the old-timers :-). Ok, that was the standard disclaimer, here we go:

I am in the 'find out which way to go' phase of a new project. The present requirement is for a windows gui (forms), but I would like to be ready for a future where my app turns out so splendidly that everybody wants it enabled on the web :-)

In choosing the CAP as the foundation architecture for my application - providing that I keep my architecture MVC/MVP clean an tidy - will I burn any bridges regarding a later port to a ASP.NET interface?

Or to put it another way: How many parts of the architecture would I have to touch - views, surely. But how far down the chain should the port have consequences: WorkItems, Controllers ... ?

General advice on the CAP's relation to ASP.NET and design hints related greatly appreciated.

Thanks
Lars

PS: Working hard on the walks-throughs an the hands-on labs. Great product - and the architecture and the technologies implemented makes my head spin. How do you guys do it?

PPS: Somewhere deep down I found the tokens 'yield return ...' yield, is that some threading thing? Can't find anywhere in the C# reference
Feb 23, 2006 at 8:32 AM
originally posted by: BradWilson

We don't really have any specific guidance yet about how to bridge a single code base between WinForms and ASP.NET. Certainly, using patterns like MVP might make it easier for you to port the code, but the use of CAB in general might complicate things in unknown, unforseen ways. I can't really make any recommendations either way here, as we haven't explored everything fully.

~ ~ ~

"yield return" is a new statement in .NET 2.0 which allows one to more easily write an enumerator (i.e., implement IEnumerable) without writing an entirely new enumerator class. For instance, you might write this in .Net 1.x:

public class StoredThing
{
public string ID;
public string Name;
//... etc ...
}

public class MyClass : IEnumerable
{
private ArrayList _innerList;

// Return an enumerator over the IDs of the things I'm storing
public IEnumerator GetEnumerator()
{
return new MyEnumerator(_innerList);
}

private class MyEnumerator : IEnumerator
{
private ArrayList _innerList;
private int _index;

public MyEnumerator(ArrayList innerList)
{
_innerList = innerList;
_index = 0;
}

public object Current
{
get { return ((StoredThing)_innerListindex).ID; }
}

public bool MoveNext
{
if (index == (innerList.Count + 1))
return false;

++_index;
return true;
}

public void Reset()
{
_index = 0;
}
}
}

Lots of noise and boiler-plate code. Now, in .NET 2.0 you can write this:

public class MyClass : IEnumerable<string>
{
private List<StoredThing> _innerList;

public IEnumerator<string> GetEnumerator()
{
foreach (StoredThing thing in _innerList)
yield return thing.ID;
}
}

Much simpler and cleaner. The compiler writes the actual enumerator for you based on the loop and the yield return. (And, of course, the use of generics here from .NET 2.0 gives you some simpler, more type safe code as well.)