Procedure
~ a series of actions conducted in a certain order or manner.If excellence is a habit, then procedure is the perfection of practice.
Code Review
Submitting For Review:
- Smaller Chunks: It's easier to review smaller chunks of code. Code reviews are easiest when you're only reviewing between 10 - 100 lines of code.[4]
- Clear Description: Provide some context to the what the code solves. Describe the problem that it solves. Add comments for addressing unrelated changes that are necessary for the code to function.[4]
Reviewing Other's Code:
- Clear Comments: Review comments and ensure that they clear, and expressive. Ensure that comments can be understood by a fellow programmer with minimum context.[4]
- Established Procedure: Agree upon what rules and standards are to approve or disapprove pull requests.[4]
Reviewing Your Own Code:
This procedure is for when you are reviewing your own code before you submit it for review. I've found that a little bit of time double checking things before I submit it can save more time in the review process and occasionally catch a few bugs that I had missed before.
If the code I'm writing is for a personal project, then I'm more lenient. If its for a professional, or client project I try to hold myself to a higher standard. When the stakes are lower I can move faster and explore new implementations. I do try to conduct a code review on my personal projects every so often (5 - 10 commits?).
The code review helps ensure that the overall health of the code improves over time, while also making progress on the current task(s)[5].
The goal of the code self-review is not to take conduct the code review by yourself. Rather it is to help you find the obvious things you may have missed, and to help make the code review process go smoother. It also provides you with a time to refresh your memory of the changes you have made, especially if the changes took place over multiple weeks.
-
Design: Verify the overall code design.
- Do the interactions of various pieces of code make sense?
- Does it integrate well with the rest of our system?
-
Functionality: Confirm that the code works as intended.
- Does this code do what you intended it to do?
- Does this code improve the experience for both the end users, and the developers who will have to read or modify this code?
- Have all the edge cases been considered and addressed?
- If the changes affect UI, have you reviewed and tested the visual changes?
- Are the types of objects and structures used efficient for the context they are used in?
- Can you explain why you choose one type of structure over another?
-
Complexity: Look out for unnecessary complexity.
- Are there any lines/functions/classes that are too complex?
- Can the code be quickly understood by code readers?
- Is there a risk that developers may introduce bugs when they try to call or modify this code?
- Have you speculated on what the code might need to do in the future, rather than what you know it needs to do now?
-
Testing: Review that tests are checking for the right things.
- Are the tests correct, sensible, and useful?
- Would the tests fail when the code doesn't work as expected?
- If the code changes, would the tests start giving false positives?
- Do each of the test make simple and useful assertions?
-
Naming: Look at the names of variables, functions, classes, etc.
- Are the names long enough to clearly communicate what the item is or does, but not so long that they're hard to read?
-
Comments: Review the comments included, ensure they aren't redundant, and that they are clear.
- Are the comments clear, understandable and actually necessary?
- Do the comments explain why some of the code exists, rather than what the code is doing?
- If the code is not self-explanatory, has it been simplified?
- Are there any existing comments that should be removed or updated due to the changes?
- Are there any exceptions such as regular expressions or complex algorithms that might require detailed commenting?
-
Style: Ensure the code you are writing is consistent with the style guides.
- Does your code follow the appropriate style guides for the language your using?
- Does your code follow your projects, or teams style guide?
-
Consistency: Ensure the code you are writing is consistent with the rest of the code base.
- Does the code stay consistent with the style guide?
- If its not specified in the style guide, Is the code consistent with the rest of the code base?
-
Documentation: Ensure that the documentation is up to date.
- Has the associated documentation been updated?
- Have you removed or deprecated any code, have you updated the documentation accordingly?
-
Cleanliness: Ensure that the code is clean.
- Have you removed or commented out any unused variables, methods, etc. ?
- Will there be any automatically generated code that isn't needed, or should be deleted?
{ Note: } Nearly all of the above lists of questions from from [5]. I still need to add the cite notes, as well as cross reference these tips with [6], and other sources.
Also recommend conducting a GPT code review.
Debugging
- Read: Really read the code, and the error message. Look into the implementation of functions.[1]
- Research: Google the problem, look into stack overflow. Master Google Foo.[1]
- Logging:[1]
- Reproduce:[1]
- Create Tests:[1]
- Static Analysis:[1]
- Get back to a working state.
- Slowly retrace steps to locate bug.
Focusing
Focus
- Music: Depending on the task, music makes a big difference on my focus. Physical tasks favor music with lyrics. Mental tasks require instrumentals, or just white noise.[3]
- Remove Distractions: Some tasks require higher levels of concentration than others. For high concentration tasks even having my phone in my pocket is distracting. I find that powering it off and putting it in another room, along with my smart watch, makes a subtle improvement. (I check my phone during every break, which acts as a little reward as well)
- Focus Meditation: I've been experimenting with a focus meditation before I work. So far, taking 5 minutes to breath deeply and set an intention for my work session has made me feel more focused than days without the meditation.
- Breaks: I find that going on frequent walks, stretching, and getting water throughout the day greatly increases my ability to focus.
Regaining From Fractured Focus
Fractured focus is that state that I hit where focusing is abnormally difficult. My mind is scattered. I'm either overwhelmed with ideas, tasks or stuck analyzing a problem. I can't seem to sit still. I want to pace around and idle on wider range of ideas.
Here are a list of the things that seem to help get me back on track:
- Create A Thought Dump: Don't act on the ideas or tasks that pop into you head. Instead, write them down. [8]
- Walk Away: Sometimes, stepping away from an unfinished task will create a fixation that helps regain focus.[8]
- Regain Clarity: It's easy to get lost when working on a lot of things at once. Start by figuring out what the larger goal is that you are trying to accomplish. Then figure out what the next step is.[8]
-
Break Tasks Down: Tasks can be overwhelming. Chunk larger tasks down into roughly 15 minute increments. Only focus on the next 3 increments, you can think about the rest later. This gives you roughly 45 minutes of work.
Sometimes, its better to break it down into 5 minute tasks, in which case you can write down the next 5 increments.
- Clean Workspace: Tidying my workspace makes me feel organized.[8]
- Mindfulness Meditation: A 5 to 10 minute guided meditation can do wonders for my focus. When my focus fractures, it feels as if my mind forgets about my body. Concentrating on my breath brings my mind back to the present moment.
- Exercise: The intensity of exercise depends on your environment and availability. Sometimes a 5-10 minute causal walk is enough. Sometimes I need a good 25 minute strength training session. Especially if I'm hitting my afternoon slump (1pm - 4pm).
Monthly Procedures
Essentially, my monthly routines.
Budgeting
I try to budget as soon as I can during the beginning of the month. I start with Taxes -> Bills -> Giving (~5%) -> Monthly Savings -> Spending.
Monthly Accomplishments
I've been keeping a monthly reflection for each month, for the past 5 years. I've recorded 50/60 months for that time period, and I intend to keep in going until I pass. I usually go through my photos for the past month and pick out the photo that I want to remember the month for. I'll also clean out unnecessary photos during this time. Then I'll record some of the following information for the month:
- Number of books read (I use goodreads to keep track of what I've read)
- Hobby or Side project progress
- Any significant or fun adventures (vacations, outings, etc.)
- Any big career project or progress
- Shows or Movies that were worth remembering
- New life changes (getting glasses, birthdays, etc.)
- Recently I started adding the song that I found or enjoyed the most that month.
Reading
Analyzing A Book
For when you're reading a dense book, thats worth thinking deeply about.
- Gather quotes through the book. Collect them into a single place.
- Idle on these ideas. Add your own thoughts to these quotes and make connections between these ideas and your own.
- Write on these ideas.
Research
Google Foo
For when you need to really specifically google something.
- (filetype:) can be used to only see results of a specific filetype, such as a pdf. [10]
- (") Surrounding a word or phrase will only include results with that exact word or phrase in it.[10]
- (*) Use an asterisk to substitute for an unknown word.[10]
- (-) Eliminate results with certain words.[10]
- (~) Include all of a words synonyms.[10]
- (..) Between two numbers to search for ranges.[10]
- (site:) Search on a specific site.[10]
- (define:) Search dictionaries for a definition for a word.[10]
- (link:) Find websites that include a specific URL.[10]
- (Reverse Image Search) Upload an image to do a reverse image search.[10]
Reporting Experiment
I have recently taken an interest in conducting my own experiments. This procedure is mostly an outline to keep my reports uniform:
-
TLDR
- 250 words
- Context and purpose of experiment
- Design and scope of study
- Key findings
- Conclusions drawn, future directions
-
Introduction
- Background of the topic
- Your interest and the problem statement
- Briefly, how your experiment addresses the problem
-
Research
- Brief overview of previous findings relevant to your experiment
- The gap your experiment is trying to fill
-
Hypotheses
- Clear statement of what you aim to discover or prove
- Your prediction based on prior knowledge
-
Study
- Description of your experiment setup and procedure
- Explanation of measures used for data collection
- Overview of participants, if any
-
Findings
- Presentation of data and results obtained from the experiment
- Interpretation of results and whether they aligned with your hypothesis
-
Discussion and Implications
- Comparison of your findings with prior work
- Discussion on surprising results, if any
- Implication of your findings and how it could impact the future
- Acknowledgement of any limitations or potential errors in your experiment
-
References
- Citing the sources of any external information you've used in your report
Sleeping
Going To Bed
- Brush Teeth.
-
Reflect On Today:
- 10 Minutes Optimism Writing
- 3 Things I'm Grateful For
- Acts of kindness received?
- Acts of kindness given?
- What am I excited for?
- Prepare For Tomorrow: Set alarm for the next day.
- Prepare Space: Turn on fans, get everything ready for bed. Ideal temp is between 68 - 72 degrees Fahrenheit.
- Sleep Timer: Start a sleep time playlist that you know stops after ~25 minutes.
Can't Fall Asleep
If you can't fall asleep within 25 minutes:
- Take melatonin or other sleep supplement. Disclaimer: [2]
- Avoid video games, drinks, food.
- Double check the temperature. Do what you can to cool or heat yourself if possible. If not possible, and if the situation allows, relocate to an area or position with a better temperature.
- Do something relaxing for at least 30-45 minutes. If thinking about a project or an idea is keeping me up, I just start working on it while the idea is fresh. This helps me get it out of my head.
- Don't go to bed unless you feel tired. Might as well get some stuff done that you would need to get done tomorrow if you can't sleep. I find that forcing myself to do the boring things either helps me fall asleep, or feel less stressed.
Work
After Work
The things that I do when I wrap up work for the day.
- Review: Write down all of the big accomplishments and tasks tackled today. Helps with the end of the week or month when I send an update. Also is satisfying to see what I've done today.
- Meditation: I have a end of work meditation that I listen to. It helps me distinguish between 'work mode' and the rest of my life.
Writing
- Pray to the muse in the sky that manna falls down upon you
Footnotes:
- [Video] Fireship: How to never write bug
- I am not a healthcare professional, and the suggestion to take melatonin or a sleep supplement should not be considered as medical advice. Please consult with a qualified healthcare professional before starting any new medication or supplement, as individual results may vary and there may be potential risks or side effects.
- This [not listening to lyrical music while working] has been something that has taken a long time for me to really get. I LOVE listening to music. I spend an average of 5 hours of music a day. But there is a very specific type of song that helps me focus, especially for writing tasks. So now I've learned that if I need to type, code or otherwise think, It should be while listening to white noise.
- [Video] Clement Mihailescu: Code Review Best Practices
- How to do a code review
- HN Discussion: How to do a code review
- HN Discussion: Code Review Checklist
- Tips For Focusing With ADHD
- Stack Overflow Blog: Best Practices For Writing Comments
- Perkins: Google Tips