When it comes to code:
* 0.5
19.2%
/ 2
80.8%
Poll ended at .
You have a constant that’s used in only one place. You
Add a comment to explain what it represents
25%
Assign it so it gets a name
75%
Poll ended at .
The stuff your program operates over are:
Entities
45.8%
Models
54.2%
Poll ended at .

```
if let result { return result.union(frame) }
else { return frame }
```

or

```
guard let result else { return frame }
return result.union(frame)
```

If else
50%
Guard
50%
Poll ended at .
In case you wonder: yes I’m taking these seriously
@RosaCtrl i have no intuition about Swifts Syntax whatsoever. It's impossible to type a syntactically correct swift program by hand

@RosaCtrl I prefer guards for the reasons described here: https://testing.googleblog.com/2017/06/code-health-reduce-nesting-reduce.html

The TotT series is a pretty good resource from the times people still cared.

Code Health: Reduce Nesting, Reduce Complexity

This is another post in our Code Health series. A version of this post originally appeared in Google bathrooms worldwide as a Google Testin...

Google Testing Blog
@mlen right, I often go with guards, but in this tiny snippet I think if is more obvious

@RosaCtrl ```
return (if let result { result } else { emptySet() }).union(frame)

@samir you would think that in Swift if is an expression! This makes me so mad
@RosaCtrl You have some kind of ternary condition operator, surely? Do ? and : work?
@RosaCtrl Not sure I'm parsing these. Swift? Something else? I can't make any sense of the second form at all.
@RosaCtrl result.map(union)?? frame
@RosaCtrl wait the idiomatic way is frame?.union() isn't it
@Andrev @RosaCtrl Maybe (result ?? emptySet).union(frame) would work?
@samir @RosaCtrl ah yes! I like this one
@Andrev @samir guys you rendered this poll useless 😭
@RosaCtrl @Andrev When presented with two options, always choose option three!
@RosaCtrl what's the difference? 😭
@hecate exactly. Just curious what’s the consensus
@RosaCtrl I put my business domain types in a folder called "Model" so I guess for me it's model :')
@RosaCtrl Bits! 😃
@penryu what?
@RosaCtrl My program operates on, and is composed of, bits!
@penryu that’s fake!
@RosaCtrl FAKE?! Then all these bits I've been twiddling are imaginary?!

@RosaCtrl
I'd say a "Model" describes types of entities, while an "entity" is an instance of a model.

Example: a blog may have a "Post model" (in general).
One specific deployment of a blog may have 1000 "Post entities" (i.e. instances of the Post model).

If a model is backed by a database, I'd use the terms "entity", "record" and "row" synonymously.

@RosaCtrl "A constant that's used only in one place" like a magic string?
@RosaCtrl probably both a name and a comment if necessary
@RosaCtrl that really depends on whether the value as a more interesting semantic meaning than itself. 2, for example, is perfectly good when it's used to double a number. Not when it's the maximum number of retries for some operation.

@RosaCtrl Depends.

If the constant is, say, „This is not a number.“, then keep the string, it‘s self explaining. If the constant is, say, 299792458, give it a name like speedOfLight, as I heard that people exist who don‘t recognize that number.

@RosaCtrl Multiplication by a floating point may reduce precision when the value is an integer. Double precision floating point can represent signed integers up to 53 bits, then you'll lose low bits.

Compilers are generally smart enough to optimise division by a constant anyway.

@mlen insightful! But what do you like to see?
@RosaCtrl Depends on what is more readable in a given context, but usually division.
@RosaCtrl la di dah fancy people: >> 2
@huwr @RosaCtrl that's / 4
@leah @RosaCtrl …. touché….
@huwr @RosaCtrl and wrong for negative numbers or so ;)
@leah @RosaCtrl you can tell I’m not a la di dah fancy person!
@RosaCtrl Other, but depends on the language used if it is needed: / 2.0
@RosaCtrl `x / 2` is often clearer in purpose, but if x is already a float, or if the result is expected to be a float, I might prefer `x * 0.5` ... but more likely in that case I'd write `x / 2.0`.

@RosaCtrl For some reason I get the ick anywhere I see a division operator, so many edge-cases.

I think what you want is >>1 :)

@Profpatsch there’s room for brutality in programming for sure! But I don’t like this! 😂