Sitecore-Community / Sitecore.Speak.Guidance

Living SPEAK guideline used internally to share same structure and code style. It is work in progress and you are welcomed to pull request it.
http://sitecore-community.github.io/Sitecore.Speak.Guidance
12 stars 8 forks source link

Guidelines for JavaScript based page code #6

Closed Artyom-ARS closed 9 years ago

dervalp commented 9 years ago

Hello Artem,

IMO,I think the line is not clear enough in its current state.

   Avoid using Speak core directly in applications, try to use appropriate Speak controls.

I am not sure what are you referring to when you speak about the Speak Core. Is it Sitecore.Speak namespace or Sitecore.Speak.app (the root application) ? What you are maybe saying is that you should avoid referencing global object through the code and use module definition (define from requireJS) ?

Artyom-ARS commented 9 years ago

I agree with you that it's not clear enough. As an example I saw that developers in their application use insertRendering instead of using LoadOnDemandPanel. So it's better to use existing control than implement the same behavior using Speak core api.

Artyom-ARS commented 9 years ago

Using global scope it's a separate issue. As I can see global scope (window) is littered a lot in applications. I think it's because of misstakes. But I saw somewhere guidance about it.

dervalp commented 9 years ago

Oh ok. I see you mean try to use as much as possible existing components instead of trying to build your application directly using the SPEAK Core API in order to increase code re-use.

As an example:

Favor the use of an LoadOnDemandPanel instead of the InsertRendering

Is that right? And do you see other example other than the LoadOnDemandPanel?

Artyom-ARS commented 9 years ago

Yes, you're right. I can't remember other examples.

kerrybellerose commented 9 years ago

OK, so I suggest that we add the following guidance to the Application Development/PageCode/JavaScript.md file:

Do you both agree? If so, I will close this pull request and make this change myself.

dervalp commented 9 years ago

I agree with that.

Artyom-ARS commented 9 years ago

Me too.

kerrybellerose commented 9 years ago

Done.