API's that Suck

December 30, 2010

The Story of UltraBase: Chapter 3

Filed under: UltraBase — Grauenwolf @ 8:35 pm

One of the best things about Fred’s UltraBase code generator is that it really pushes the boundaries of what’s possible in C#. The first couple of times I tried to open the ProductDomainMapper class is actually crashed my IDE. After disabling every extension I had I was finally able to see the code. I’m still not entirely sure why Visual Studio was crashing, but I think it may have something to do with the 92 interfaces declared on the class:

public partial class ProductDomainMapper : BaseDomainMapper,
    ISelect <AmountCategorySelectData,AmountCategorySelectInput>,
    ISelectByCode <BondOfferingSystemServiceModelSelectForRepData,BondOfferingSystemServiceModelSelectForRepInput>,
    ISelect <BondQualitySelectData,BondQualitySelectInput>,
    ISelectByKey <DisclaimerSelectByKeyData,DisclaimerSelectByKeyInput>,
    ISelect <IDCRankGroupSelectData,IDCRankGroupSelectInput>,
    IUpdate <OfferingUpdateTotalQuantityData,OfferingUpdateTotalQuantityInput>,
    ISelect <RatingCategorySelectData,RatingCategorySelectInput>,
    ISelectByCode <GetKeyData,GetKeyInput>,
    ISelectByKey <BondReportItemSelect1346Data,BondReportItemSelect1346Input>,
    ISelectByCode <AllBondsSearchData,AllBondsSearchInput>,
    ISelectByCode <CanadianSearchData,CanadianSearchInput>,
    […]
    IInsert <BondDisclosureMessageQueueInsertData,
    BondDisclosureMessageQueueInsertInput>

In case you were wondering what all these interfaces did, here is the complete implementation of one of them:

public IResponseDTO<AmountCategorySelectData> Select(IRequestDTO<AmountCategorySelectInput> input)
{
    var mapper = DataMapperFactory<ISelect<AmountCategorySelectData,AmountCategorySelectInput>>(DataMapperEnum.AmountCategory,BehaviorTypeEnum.Select);
    if (mapper != null)
        return mapper.Select(input);
    return InvalidConfig<AmountCategorySelectData>();
}

And no code sample would be complete without showing how the code is called:

var mapper = new ProductDomainMapper();
var input = new RequestDTO<AmountCategorySelectInput>();
input.Input = new AmountCategorySelectInput ();
input.Input.SortAscendingFlag = 1;
IResponseDTO<AmountCategorySelectData> result = mapper.SelectByCode(input);

Advertisements

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: