DEV Community

Cover image for Stop naming functions `fetch()`.
Mike Stemle
Mike Stemle Subscriber

Posted on

1 1

Stop naming functions `fetch()`.

Hello everybody, this is just a quick PSA. Here goes: STOP NAMING YOUR FUNCTIONS fetch()!

Between the Fetch API, and the wide variety of modules involving functions named fetch(), we don't need any more functions named fetch().

Here are some alternatives:

  1. fetch_user_profile_from_email()
  2. load_remote_web_content()
  3. something_descriptive_that_will_challenge_your_typing_speed()
  4. literally_anything_other_than_fetch()
  5. there_are_a_lot_of_words_in_english_which_are_not_the_word_fetch()

But I digress.

In most of my years since I stopped programming C primarily, namespace confusion hasn't been a huge problem. This fetch() business, however, is absolutely a massive namespace confusion, and we should stop it. Please. I'm begging you.

Top comments (0)

typescript

11 Tips That Make You a Better Typescript Programmer

1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields

...

Read the whole post now!