Skip to content

232. Implement Queue using Stacks#79

Open
kitano-kazuki wants to merge 1 commit into
mainfrom
232-implement-queue-using-stacks
Open

232. Implement Queue using Stacks#79
kitano-kazuki wants to merge 1 commit into
mainfrom
232-implement-queue-using-stacks

Conversation

@kitano-kazuki
Copy link
Copy Markdown
Owner

Comment thread memo.md
def _fill_retrievable(self):
while self.store:
self.retrievable.append(self.store.pop())
return
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好みかもしれませんが、このreturnは一般的には書かない場合が多いのではないかと思います。

Comment thread memo.md

def push(self, x: int) -> None:
self.store.append(x)
return
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

こちらのreturnも個人的には少し気になりました。型が -> None で明示されているので書いたのかなと思ったのですが、そうすると、一応_から始まるprivate的な扱いではありますが_fill_retrievable()にも型がある方がよいかも?などと少し気になったりしました。
致命的な問題があるということではありません。実務上では、チームの規約などによると思います。private的なものには型定義をあまりつけないという判断もあると思います。
趣味の範囲かもしれません。

Comment thread memo.md

def __init__(self):
self.store = []
self.retrievable = []
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...ableという変数名はboolであることを期待させるように思います。また、意味的にも、storeもretrievableもどちらもstoreされた値ではあるので、
storeはunprocessedとかtemporaryみたいなもの、
retrievableはprocessedみたいなもの、
ぐらいが良いのかなと思いました。
(あとで出てくるif retrievableというのを見て、取得可能かどうかという風に読んで、間違ってはいないのですが、少し違和感がありました)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants