Edgar Sánchez's .NET Blog
Doing .NET in South America

My Links

Blog Stats
  • Posts - 18
  • Stories - 0
  • Comments - 13
  • Trackbacks - 4

Archives

Post Categories

Blogs I (try to) read

Places

Login
    u:
    p:
    Remember Me:
     
 

Saturday, June 14, 2003

As Christian points out very well, this is what will come next Monday morning:

Web Matrix 0.6 (Build 812)

Be sure to go there and grab it!

 

posted @ 11:27 PM | Feedback (3)

Friday, June 13, 2003

On Monday June 16, first thing in the morning go check www.asp.net/webmatrix, when you get it tell your friends you first read about it on weblogs.asp.net ;-)

 

posted @ 12:22 AM | Feedback (1)

Monday, May 26, 2003

I was trying to refresh my skills on tab controls and tab pages reading Erik Brown's very good Windows Forms Programming with C# when I found this pearl:

"As a rule of thumb, make sure the controls in each tab page are all related, and try to limit yourself to not more than seven controls per page. The number seven here is not arbitrary, as user interface research has shown that this is a reasonable maximum number of items to present to a user at once."

The bolding is mine. Unfortunately, he doesn't point out to the specific source but I suspect it is Ben Schneiderman's Designing the User Interface (amazingly, it seems like it's not available in Amazon).

posted @ 1:37 AM | Feedback (0)

Wednesday, May 21, 2003

A long time ago (in blog time) Fabrice pointed out this nice tip from ScottGu:

Private Sub SetFocus(ByVal controlToFocus As Control)

    Dim scriptFunction As New StringBuilder
    Dim scriptClientId As String

    scriptClientId = controlToFocus.ClientID

    scriptFunction.Append("<script language='javascript'>")
    scriptFunction.Append("document.getElementById('" & scriptClientId & "').focus();")
    scriptFunction.Append("</script>")

    RegisterStartupScript("focus", scriptFunction.ToString())

End Sub

I think it looks nicer like this:

private void setFocus(Control controlToFocus)
{
    string scriptCode = string.Format(
        "<script language='javascript'>"
        + "document.getElementById('{0}').focus();"
        + "</script>",
        controlToFocus.ClientID );

    RegisterStartupScript("focus", scriptCode);
}

Of course, I *don't* mean the C# syntax vs. the VB.NET syntax (both languages are as powerful, which one looks better is a personal preference, please don't flame me) but to the use of String.Format() as opposed to StringBuilder. May be (just may be) StringBuilder is marginally faster, but the String.Format() code is definitively shorter and (just) probably easier to understand. Opinions?

posted @ 1:58 AM | Feedback (5)

Tuesday, April 22, 2003

Sunday, April 20, 2003


I just had a faint memory of an e-mail by Clemens Vasters about a small set of .NET attributes for managing ASP.NET sessions. The idea was (now I know) to do something like this:

public class MyPage : StateManagingPage
    {
         [PersistentPageState] public int pageVisitsEver;
         [PersistentPageState("Visits")] public int siteVisitsEver;
         [SessionPageState] public int pageVisitsThisSession;
         [SessionPageState("Visits")] public int siteVisitsThisSession;
         [TransientPageState] public int roundtripsThisPage;
     
    
     // omissions...
         
         private void Page_Load(object sender, System.EventArgs e)
         {
                pageVisitsEver++;
                siteVisitsEver++;
                pageVisitsThisSession++;
                siteVisitsThisSession++;
                roundtripsThisPage++;            
         }


         // omissions...

So there you go: use plain class fields to manage session (also page and application) state, a cool demo of .NET attributes versatility. But I didn't remember how it worked, let alone when it was... So of course I used a Google search ("clemens vasters session attribute") and was immediately taken to this entry in his weblog. Somebody should measure the impact on programmer's productivity of supposedly collateral things like google, weblogs and attributes.

posted @ 8:20 PM | Feedback (1)

Thursday, April 10, 2003

Robert and Darren are probably going to hit me, but I really don't understand what's the fuss about old (he he) and current versions of .NET Framework and Visual Studio .NET, I mean, I've been using both versions of the product for months now with hardly a glitch. 1.0 apps work only with 1.0 (VS .NET included). 1.1 apps could work with 1.0 but why? If you have a 1.1 app just install the 1.1 Framework and go for it. I have had both versions side by side and used 1.0 and 1.1 apps right here in this laptop without any major loose of time (let alone data or code). May be I am just so silly that I don't get it...
posted @ 8:18 PM | Feedback (3)

Wednesday, April 09, 2003


Everytime I have to convert a string to an integer I use int.Parse() instead of Convert.Int32(). Until today, I basically recommended it because it looked more O-O to me (besides, I get the chance to pick my Java pals because int behaves more like a real class in C# ;-). But today Clemens Vasters, a fellow RD, gave me a really sound reason for doing so: int is a higher level abstraction than Int32 and, by default, higher level abstractions are friends of the (business) developer. Nice one, Clemens.

posted @ 12:57 AM | Feedback (0)

Wednesday, April 02, 2003


In countries like mine, it is very important to have entry level tools for developers to adopt any new technology. That's why Web Matrix plays such an important role down here. And that's why I get so excited when Scott Guthrie comments that they are about to deploy a new version of the thing. I look forward to it.
posted @ 1:12 AM | Feedback (0)

Monday, March 31, 2003


I have no problem admitting that I learnt object oriented programming with Bruce Eckel's Thinking in Java. Even more, I am absolutely convinced that if from time to time I manage to look "solidly backgrounded" in O-O it is due to what I learnt in Thinking in Java. Third edition just received a Jolt award (I learnt while moving from 1st to 2nd Ed, time do fly, sigh). Thinking in C# is in the works and I am looking forward to it. In the mean time, Bruce has started his web log and it's got some mind opening content, go browse around, you won't repent.

posted @ 11:52 PM | Feedback (0)

Sunday, March 30, 2003


I've forgotten to mention what I use to synchronize my (so far very light) work on NHibernate: TortoiseCVS. Once installed, it becomes part of Windows Explorer right-click menu, so you can check out, update, commit, etc. from the comfort of your explorer. Cool.

posted @ 12:02 AM | Feedback (0)

Friday, March 28, 2003


Make it +2, as I already made a posting on this very subject. I guess I cannot get to be as emphatic as David Stone in NUnit Rocks! But I can be redundant all right: use NUnit, your family will thank you.

 

posted @ 12:38 AM | Feedback (1)

Wednesday, March 26, 2003


A title taken from Jill Nicola et al.'s Streamlined Object Modeling.

One of my concerns about Java and .NET Framework alike is that, as more and more people use O-O platforms, it is more and more frequent that the paradigm is badly misused. The point I am trying to make is: if you don't create an object model to represent your business problem, then there is no point in getting tangled with [insert-your-favourite-O-O-language-here]'s inheritance, polimorphism, etc.

So I decided to prepare a small presentation for potential customers with some tips and tricks for identifying objects taken directly from the book. From time to time the book takes a patronizing air, but it is bareable, and it is full of sharp and usable advice. One example:

The Context Principle

A context of participation exists whenever a person or organization undertakes actions that are tracked and recorded. Actions that require different permissions or information from the person or organization belong in different contexts.

The Role Principle

For each context an entity participates in, create a separate role object. Put the information and permissions needed for that context into the role.

In other words, to the ancient problem of Jane Doe who is at times customer, at times employee, at times manager, create the person class and the customer, employee and manager role classes. Later you will define a composition between a person and the set of roles she has. Don't invent the wheel, better follow these modeling patterns. The book not only gives you the somewhat abstract principles but explain them with simple but real world examples. Definitively worth reading for someone trying to create an object oriented system.

 

posted @ 11:33 PM | Feedback (1)

Tuesday, March 25, 2003


It's been a few days since my last post. Let me explain why: from time to time Objeq actually demands me to do some billable work ;-). It's funny but, as passionate as I am for VM architectures, low level design patterns, and down-to-earth coding, nowadays I usually get paid for determining the business value of a software project, doing high level project design, assessing risk and generally helping teams start a project on the right foot. What they call the envisioning phase in MSF.

I've been writing code for some 18 years now and still believe the most challenging (and fun!) part of a project is writing the code. Yet, there is that (perhaps) 20% of the efforts that must be used for finding out why we want to do the project and how we plan to accomplish it. And, as many of you, I feel wary of those dense methodologies that makes you fill reams and reams of paper just because they say so. That's one of the reasons I like MSF: it's almost as light as it gets. And most of it is common sense that rings true for developers and managers as well.

In the envisioning we finished just yesterday, it was particularly delightful to create the initial risk list for the project. The team began the exercise with some suspicion but as we started to articulate what could go wrong with the project, they soon realized they could actually help, with specific actions, to raise the success chance of the project. They also found a number of additional activities to be considered on the schedule and ended finding reasonable a delivery date that on principle they tought was unacceptably far. And, as so usually happens with this lucky guy, all I had to do is just sit and watch while they themselves allotted more time for completing the project.

By the way, in the unlikely event that someone around here happens to need a Spanish translation of the MSF Risk Management Discipline slides just drop me a line, I will be happy to comply.

posted @ 11:47 PM | Feedback (0)

Wednesday, March 19, 2003

 

Another commiter at NHibernate has created a StringTokenizer class that mimics the one existing in Java. I suppose it works but I can see that for getting the token it uses a loop and a number of concatenations. Kludgy. I feel tempted to write a more efficient version that uses String.IndexOf() and String.Substring() but I feel worried whether my "enhancements" will break the code.

Enter NUnit (a pretty smart C# implementation of venerable JUnit). As from the Java documentation, it is clear what StringTokenizer is supposed to do, what I did is to create a number of tests that check how the class works, like this:

[TestFixture]

public class StringTokenizerUnitTesting

{

[Test]

public void SimpleStringWithoutDelimiters()

{

string s = "Hello world!";

StringTokenizer st = new StringTokenizer(s);

IEnumerator enumerator = st.GetEnumerator();

enumerator.MoveNext();

Assertion.AssertEquals("Can't get first token", "Hello", (string) enumerator.Current);

enumerator.MoveNext();

Assertion.AssertEquals("Can't get second token", "world!", (string) enumerator.Current);

Assertion.AssertEquals("Still thinking there are more tokens", false, enumerator.MoveNext());

}

}

Tedious but easy. And now I can mangle with confidence the code! As a matter of fact I did make a couple of mistakes (shame, shame, in a 12 lines method). Moreover, the tests tell other developers how the class is supposed to be used and work. My tests don't cover all the angles of StringTokenizer but as time goes by, other commiters or myself will add more tests, so the class will become more and more resilient. And last but even more significant, as I wrote the tests I started to mentally design the inner workings of the class. Cool stuff NUnit. I look forward to writing a lot of tedious and easy tests.

posted @ 2:39 AM | Feedback (0)