DEV Community

Cover image for How do I resolve problems in an effective way?
Phan Công Thắng
Phan Công Thắng

Posted on • Edited on • Originally published at thangphan.xyz

How do I resolve problems in an effective way?

A problem usually includes issues and many small issues(I call sub-issues) in it. So the effective way to resolve the problem is resolving sub-issues. It's very difficult to resolve a big problem. We need to divide that problem into many small pieces.

Template

Every morning, I usually take time to write down the issues that I'd like to resolve and analyze.

I have been using the issues template below that I thought it helps me a lot.

This is my template:


/**
 * Issue: 
 * 🤬sub-issue: 
 * 🤬sub-issue: 
 * 🤬sub-issue:
 */

/**
 * Sky(sub-issue):
 * 
 * Rain(I have to consider):

 * 👉 
 * Umbrella(I’m going to do):
    * ✌️
    * ✌️
    * ✌️

 * 👉
 * Umbrella(I’m going to do):
    * ✌️
    * ✌️
    * ✌️

 * 👉
 * Umbrella(I’m going to do):
    * ✌️
    * ✌️
    * ✌️

 * Why-What-How-Where
 *
 * ✌️Why A?
 * ✌️Why B?
 * ✌️Why C?
 */

Enter fullscreen mode Exit fullscreen mode
  1. With each issue I have three sub-issue.
  2. With each sub-issue I'm going to create three things that I have to consider(Rain).
  3. With each Rain I have to analyze and create things to do specifically.

My problem

The matter that I really felt annoyed about was every morning, I have to find the template, copy it, and paste it in Quokka that I'm using in Visual Studio Code. It takes tons of time.

So I decided I'm going to make an npm package that helps me removing the annoying above. I called mainichi-issues.

mainichi-issues helps me generate the issues template automatically way. I only need to type the number of issues I'd like to have, it will generate the template and copy it to the clipboard for me.

Coding

I have issue template:

const ISSUE_TEMPLATE = `
/**
 * Issue: TODO
 * 🤬sub-issue:
 * 🤬sub-issue:
 * 🤬sub-issue:
 */
Enter fullscreen mode Exit fullscreen mode

sub-issues template:


const SUB_ISSUE_TEMPLATE = `
/**
 * Sky(sub-issue):
 * 
 * Rain(I have to consider):
 * 👉
 * Umbrella(I’m going to do):
    * ✌️
    * ✌️
    * ✌️
 * 👉
 * Umbrella(I’m going to do):
    * ✌️
    * ✌️
    * ✌️
 * 👉
 * Umbrella(I’m going to do):
    * ✌️
    * ✌️
    * ✌️

 * Why-What-How-Where
 *
 * ✌️Why A?
 * ✌️Why B?
 * ✌️Why C?
 */
`
Enter fullscreen mode Exit fullscreen mode

I also do need to create a function to copy to the clipboard.


function pbcopy(data) {
  const proc = require('child_process').spawn('pbcopy')
  proc.stdin.write(data)
  proc.stdin.end()
}
Enter fullscreen mode Exit fullscreen mode

and code in order to combine them together.

const inquirer = require('inquirer')

async function makeIssues() {
  const {numberOfIssue} = await inquirer.prompt({
    type: 'number',
    name: 'numberOfIssue',
    message: 'How many issues do you have today?',
  })
  const hr = Array.from({length: 50}, () => '-').join('')
  const subIssues = Array.from({length: 3}, () => SUB_ISSUE_TEMPLATE).join('')
  const issues = Array.from(
    {length: numberOfIssue},
    () => ISSUE_TEMPLATE + subIssues,
  ).join(`\n// ${hr}\n`)

  pbcopy(issues)
}

makeIssues()
Enter fullscreen mode Exit fullscreen mode

Finally, I only need to publish this package to npm.
I already create an account in npm and only need to run:

npm publish
Enter fullscreen mode Exit fullscreen mode

Now I had mainichi-issues in the npm market. I'm going to install it to my computer.

npm install mainichi-issues
Enter fullscreen mode Exit fullscreen mode

and add this bash code to .zshrc:

alias mkis="node node_modules/mainichi-issues/index.js";
Enter fullscreen mode Exit fullscreen mode

Now, every morning, I only need to type mkis, and input the number of issues I'd like to have. I will have the issues templates.😃

Everyday Issues

Top comments (2)

Collapse
 
vineyrawat profile image
Viney Rawat

Good but I don't know what is happening

Collapse
 
thangphan37 profile image
Phan Công Thắng

I think you can use the template for whatever problem(programming) you have.