0

what is the correct starting case for functions and properties when using the revealing module pattern? I have it shown here with lower case for function and uppercase for properties but that does not feel correct.

return {
    getRecords: getRecords, // this is a function
    CurrentTitle: getCurrentRecord().title // this is a title
};
Peter Kellner
  • 14,748
  • 25
  • 102
  • 188
  • Regardless of the pattern you use for creating them, ordinary methods and properties are always lowercase. Use capitalised names only for constructor functions, and maybe for module identifiers. – Bergi May 13 '15 at 03:11

1 Answers1

1

There is not a hard-and-fast rule for which case to use for functions versus properties in the revealing module pattern, or any other design pattern for that matter. It's purely up to you which casing pattern you'd like to implement and from there it's important that you are consistent with your choice throughout the rest of your application.

I will say that in my experience I've never seen the use of two different casings for functions and properties, it's usually the same for both.

Nick Ball
  • 1,846
  • 1
  • 15
  • 9