Git Product home page Git Product logo

Comments (3)

adriana-olszak avatar adriana-olszak commented on May 20, 2024

Hey,

I believe that this is only a stylistic choice. In general, it's a common JS convention and even though it's not needed in TS lot's of developers still use it for readability.

from white-label.

thiagodebastos avatar thiagodebastos commented on May 20, 2024

Hey,

I believe that this is only a stylistic choice. In general, it's a common JS convention and even though it's not needed in TS lot's of developers still use it for readability.

Thanks for getting back to me @adriana-olszak :)

I understand what you are saying, I was more curious because in The SOLID book, Khalil specifically says to not do that in TypeScript:

Rule: Don’t use unnecessary member prefixes
Sometimes, developers prepend their private member variables with an underscore to signify that it’s private.
Example: _firstName.
In JavaScript, there’s no concept of private access modifiers, so the convention is to signal that it’s private this way.
In TypeScript, we do have private access modifiers.
Page 167

In typed languages like Java and TypeScript, usage of the underscore convention is discour-
aged because we have access to scopemodifiers like private and protected. We should use
the language constructs, given their availability, and look to conventions when a common
task cannot be done with the language.
Page 252

I was curious if there was a particular reason, or just a mistake here :)

from white-label.

thiagodebastos avatar thiagodebastos commented on May 20, 2024

I think I understand now. We use _somePropOrMethod in an abstract class so that we can use somePropOrMethod in a concrete class.

from white-label.

Related Issues (16)

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.