Symphono / wfh-slack-command

Tell your Google Domain calendar you're working from home (WFH)
MIT License
0 stars 1 forks source link

Wfh tomorrow #3

Closed TNagaraja closed 7 years ago

TNagaraja commented 7 years ago

Added functionality so users can optionally choose to specify wfh date and/or time interval. '/wfh MM-DD-YYYY time1 to time2'. Also accepts 'tomorrow' to specify tomorrow's date.

MarkLeMerise commented 7 years ago

Here are a few higher-level thoughts I thought of that you might want to consider as you re-read through your code:

  1. Many places in the logic, there is a lot of "weaving" in and out of moment objects, and the native Date format. Consistency is important here, especially given that date parsing is a pillar of this feature. If I were to make a recommendation, I would never even touch the native Date object, as the moment library is a battle-tested wrapper, which shields the developer from common Date pitfalls.
  2. You've got a good handle on parsing the date, but remember, this text comes directly from a user, and users screw up...a lot, so it's important to consider "edge" cases in testing. Consider this user experience, what happens if someone types one too many spaces between the times? (Or forgets spaces). Knowing when to "forgive" the input and do your best to parse it and knowing when to throw up in your hands and say this can't be parsed is an important balance to find. In general, I find user input parsing and searching to be one of the more difficult programming patterns to get right.
  3. Code readability is an important aspect of development that should not be overlooked. As a reviewer or fellow developer, I may or may not run your code. More than likely, I'm going to scan through to "execute in my head". Think of code authoring like authoring a book. A paragraph-long sentence may seem eloquent, but by the time I'm done, I probably won't grok the full thought. For example, instead of explicitly returning true or false, ask yourself can I simply return the expression which produces that boolean result? Developing this sense is a lifetime skill and you won't always please everyone, but we do our best to use tools (like ESLint) to keep the look & feel consistent.