Coder Social home page Coder Social logo

Comments (5)

jackfranklin avatar jackfranklin commented on May 31, 2024

For me it's because I'm used to reading code from top to bottom, and I'm used to seeing what is exported by looking at the bottom of a file. This is a really common pattern in JS, particularly in NodeJS applications. Also, we think it makes more sense (at least to us) to have the definitions of the functions that are to be exported before the export of them.

from angularjs-style-guide.

feelepxyz avatar feelepxyz commented on May 31, 2024

Adding to this, having exports at the bottom fit with how you usually structure public/private code. So you will put your private functions and variables at the top, then re-use them in public functions. Having public exports at the top would work if you are using function declarations, but not work for variables/func expressions, so you will then end up having private variables followed by public exports and then private function declarations. It's just a bit easier to reference undeclared variables/functions.

from angularjs-style-guide.

dancancro avatar dancancro commented on May 31, 2024

Just one more question. Do you think there's a problem with having too many private variables in a class and if so would something that encourages you to use fewer of them be a good thing? That was a point made in the other conversation supporting the placement of the return at the top after a preferably short list of private vars.

from angularjs-style-guide.

feelepxyz avatar feelepxyz commented on May 31, 2024

Interesting point, never really thought about it that way tbh. We have generally just kept a limit on the length of our functions.

from angularjs-style-guide.

jackfranklin avatar jackfranklin commented on May 31, 2024

Do you think there's a problem with having too many private variables in a class and if so would something that encourages you to use fewer of them be a good thing?

Personally I don't think so - I'd rather a module have lots of private and fewer public than the other way round. Generally if a module is doing too much that will be apparent by it exposing way too many things that are often only tangentially related.

from angularjs-style-guide.

Related Issues (15)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.