+1-888-365-2779
Try Now
More in this section

Forums / Suggestions / documented alternative to fluent-style API

documented alternative to fluent-style API

3 posts, 0 answered
  1. Eric
    Eric avatar
    18 posts
    Registered:
    22 Nov 2010
    02 Feb 2011
    Link to this post
    I'm not sure about you guys, but I really hate code like this:
    01.    sf.Documents().GetManager().Provider.SuppressSecurityChecks = true;
    02.    sf.Document().CreateNew().Do(item =>
    03.        {
    04.            item.Parent = sf.DocumentLibraries().Where(l => l.Title == "JobApplications").Get().FirstOrDefault();
    05.            item.Title = title; item.UrlName = title + "_Application";
    06.            item.SetValue("FirstName", firstName);
    07.            item.SetValue("LastName", lastName);
    08.            item.SetValue("Phone", phone);
    09.            item.SetValue("HowDidYouHear", howDidYouHear);
    10.        }).CheckOut().UploadContent(applicationFile.InputStream, applicationFile.GetExtension()).CheckInAndPublish();
    11.}

    There are all sorts of drawbacks to this sort of code. Not the least of which is that it's not clear when you've made all the necessary calls and in what order. There's no intellisense support when you get down into the later code bits, and it's just verbose() with() lots() of() unnecessary() parenthesis()!!!

    It's like writing in nothing but run-on sentences and expecting your teacher to give a good grade because its short and dense and efficient and maybe you think it looks nicer but it's a lot harder to read because there's no separation of thought.
  2. Eric
    Eric avatar
    18 posts
    Registered:
    22 Nov 2010
    02 Feb 2011
    Link to this post
    I guess in a lot of places, the developer documentation does have both examples. Just please make sure that you keep this practice.
  3. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    05 Feb 2011
    Link to this post
    Hi Eric,

    Thank you for the remark.

    We will keep providing both Fluent API and Native API examples. We will also try to explain the Fluent API as clearer as possible so that it is easy to understand how it is used and what are its advantages.

    Greetings,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
3 posts, 0 answered