3
eo2875
4y

Obsessive variable naming...
I wrote it myself and just realizing how stupid it is

Comments
  • 3
    Depends.
    If `field.availability` is expensive to compute, it’s wise to use a cached `field_availability` var if you’re repeatedly referencing it. (Or memoize the function.)

    Similarly if you’re pulling and changing a few attributes, and building a new object with the rest of an existing’s raw values, `field_name` works well. (Or `new_field_name` to abundantly differentiate them)

    Js example:

    let field_title = “Something awful”
    let field_name = field.name + “_new” // whatever
    let field_align = complicated_align_logic(field)

    second_field = {...field, field_name, field_title, field_align}
  • 1
    @Root oh yeah I hadn't thought about caching properties. Good point
Add Comment