Comments (8)
Signature typing
I think that both ways are valid but I prefer the tightly coupled way because:
- It doesn't contain the
=>
twice, making the readability better (we avoid confusing the signature for the real function) - It shares the way of typing it with functions written with the
function
keyword
If you wish to share signatures between multiple functions, prefer using a type. That makes its reusability explicit:
type ClickHandleSignature = (id: string) => void
const onClickHandler: ClickHandlerSignature = (id) => {
// ...
}
I prefer not to makes things generic until really necessary. It is way simpler to refactor.
Function keyword
I don't use the function
keyword in most cases for a few reasons:
- It is less verbose and can return without a return keyword, making it easy to write composable on-liners
- It makes it explicit that the
this
keyword isn't used here. You don't even think about it. Wit a function that has afunction
keyword, you never know.
from giessdenkiez-de.
It doesn't contain the => twice, making the readability better (we avoid confusing the signature for the real function)
Funny I find your way harder to digest then the one I prefer. :)
from giessdenkiez-de.
If you wish to share signatures between multiple functions, prefer using a type. That makes its reusability explicit:
That's what I said. :)
I prefer not to makes things generic until really necessary. It is way simpler to refactor.
Me too. But if I have to my way is faster
from giessdenkiez-de.
Funny I find your way harder to digest than the one I prefer. :)
Common, could we not talk about your way/ my way? An can you elaborate on why do you think it is easier to digest?
from giessdenkiez-de.
That's what I said. :)
Your suggestion included the signature as a prefix to the parameters, which as I said, has to risk to make the readability of the function more difficult as it contains two =>
. The developer has to first identify which is the signature and which is the function declaration.
In my suggestion, the signature is external to the function declaration. I would only use that in the case it really is used multiple time.
from giessdenkiez-de.
Me too. But if I have to my way is faster
🚀
Coding with speed is only good if it doesn't compromise the readability of the code. But sure, you might save some milliseconds.
from giessdenkiez-de.
Let's move that to discussions.
from giessdenkiez-de.
Let's keep on in #297
from giessdenkiez-de.
Related Issues (20)
- Update Mapbox-gl to v2 HOT 2
- Bug: Stacked Barchart shows different labels when using the production API than when using the test API
- Typo: Should say "70l Wasser" HOT 1
- Missing attribution for OpenStreetMap HOT 3
- Map manipulation with right-click gets reset HOT 2
- HIGH registration not possible HOT 2
- Offer more water quantities to chose from HOT 3
- Trees not coloured HOT 4
- Adapt color scale of trees to also be influenced by user waterings
- Position of disadopt tree button. HOT 1
- Dependency Dashboard
- Action Required: Fix Renovate Configuration
- Link to special OSM editor to update pump status HOT 9
- [Suggestion] Option to show all adopted trees in the map HOT 2
- [Bug] Homepage is always loading twice: first loading, then login, then again loading; this takes a lot of time and wastes resources HOT 2
- [Verbesserungsvorschlag] Feedback Link (github) besser platzieren HOT 1
- [Verbesserungsvorschlag] Laufende Wässerungssumme über 7 und über 30 Tage anzeigen HOT 2
- Test new DB with NextJs version of the App HOT 3
- Test new DB on Vercel Preview HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from giessdenkiez-de.