documented alternative to fluent-style API

Posted by Community Admin on 05-Aug-2018 01:01

documented alternative to fluent-style API

All Replies

Posted by Community Admin on 02-Feb-2011 00:00

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.

Posted by Community Admin on 02-Feb-2011 00:00

I guess in a lot of places, the developer documentation does have both examples. Just please make sure that you keep this practice.

Posted by Community Admin on 05-Feb-2011 00:00

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

This thread is closed