>Build list classes

>This message will be repeated in english.

(dotnet-kod)
Gör listklasser av dina klasser.
D.v.s. gör en egen klass
    class UserList : List
    {
        …
    }

För då blir anropen

    UserList userList = new UserList( “whatever parameters” );
    User user = userList.FindByName( userName );

istället för

    List userList = GetUsersByWhatever( “whatever parameters” );
    User user = FindUserByName( userList );

Lika många rader kod och ungefär lika lättläst men bättre “information hiding” i de senare exemplet.

(dotnet code)
Make list classes of you classes.
Make it like

    class UserList : List
    {
         …
    }

Then you can have calls like

    UserList userList = new UserList( “whatever parameters” );
    User user = userList.FindByName( userName );

instead of

    List userList = GetUsersByWhatever( “whatever parameters” );
    User user = FindUserByName( userList );

About as many rows of code and about as readable but better information hding in the latter example.

Leave a Reply