Fluent API consistency issues

Posted by Community Admin on 04-Aug-2018 14:21

Fluent API consistency issues

All Replies

Posted by Community Admin on 12-Aug-2011 00:00

Hi,

I see the SF fluent API lacks consistency.
For example, to get the published news, you'd do:

var news = App.WorkWith().NewsItems().Publihed();

But to get published pages, you'd do:

var pages = App.WorkWith().Pages().ThatArePublished();

Another example: I can call First() or FirstThat() on news and other content types, but not on pages (unless I call Get() first).

So this works:

var news = App.WorkWith().NewsItems().FirstThat(n => n.UrlName == "something");

But this doesn't work (missing FirstThat method):

var page = App.WorkWith().Pages().FirstThat(p => p.UrlName == "something");

Are there any plans to homogenize these things?

Thanks.

Posted by Community Admin on 16-Aug-2011 00:00

Hello Thomas,

We are aware of these discrepansies and we plan to unify our fluent API in the future. However we cannot give you a strict timeframe. We won't be able to simply rename a method, because that would break a lot of existing code, so we will probably have to create a duplicate method.

Greetings,
Lubomir Velkov
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 16-Aug-2011 00:00

Hi Lubomir,

Thanks for the answer. Yes, having duplicate methods is fine. You could just mark some as deprecated, telling programmers to use another method instead (through the Obsolete attribute), so people gradually move to the right methods.

This thread is closed