arakitakashi / pomodoro Goto Github PK
View Code? Open in Web Editor NEWポモドーロタイマー&実績管理
ポモドーロタイマー&実績管理
index.js でシンプルに Timerを呼び出しているのはグッドですね。
短くてとてもわかりやすいです。
この部分の引数を渡す部分は、意味の通りに順番がきちんと並んでいるので、
それに合わせて変数の宣言部分の順番も揃えると親切かもしれませんね。
この部分ですが、処理をよく見てみると共通部分が見えてきませんか?
https://github.com/Delgadito-bamboo/pomodoro/blob/f40723c84ec32e23ade7e37d082d4ccae5da50b2/timer.js#L21-L36
以下の部分ですね。
if(this.isWorkTime && this.durationTime === 0){
this.durationTime = 10;
this.onTick = true;
this.interval = setInterval(this.tick,1000);
条件の一つにnotがついて、durationTimeの数字が違うだけなので、
関数化などをして、外からうまくdurationTimeを渡してあげる作りにするとシンプルにできそうですよね。
ここの共通化の方法を考えてみると一段進歩があると思います。😋
条件に関してもうまく共通化できるかどうかを考えてみましょう〜
この部分が一行で行なっている処理が長いので
右辺を独立した関数なりに分割するのがいいかもですね。
関数名はぱっとみて何やっているのかがわかる名前をつけるとより良いですね。
この辺りも何か匂ってきますね。
分岐の中で同じような処理をしている場合は? そう。まとめることができそうですよね。
先ほどと同じく、共通部分が見えてきたらまとめることできないかなぁと考えてみるとグッドです〜
きちんとインデントがあっていたり、ファイル分割などもわかりやすくできているので
どんどん書いていきましょう〜。
あとは、このGitHub上にはたくさんのサンプルがあるので、いろんなコードを眺めてみて、
どんなファイル分割の仕方をしていて、どんな関数の分割をしているのか、どういう共通化が行われているのかをみてみたりして、
良いコードとは何かを考えてみると良いかもしれませんね。 👏
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.