TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Best example for teaching the basics of object oriented programming

3 点作者 bpesquet将近 10 年前
Hi all,<p>I&#x27;m in the process of writing yet another introductory course to programming for complete beginners.<p>I&#x27;m looking for a great example context for my OO chapter, beyond the ubiquitous Animal or Vehicle hierarchy.<p>Thanks in advance for all your great ideas!

3 条评论

Revell将近 10 年前
Why not use a real-world example of something you would write a class for? The best tutorials are the ones that teach you things you can actually use. I&#x27;ve never used an Animal or Vehicle class myself. A better example might be to write something like an Article class, and then build out to a very simple and minimal blog?
评论 #10113651 未加载
atmosx将近 10 年前
I&#x27;m not an expert on the topic, but this book[1] has an incredibly good and easy-to-understand introduction on the topic. It&#x27;s ruby-based but the ideas apply to OO design in general.<p>[1] <a href="http:&#x2F;&#x2F;poodr.com" rel="nofollow">http:&#x2F;&#x2F;poodr.com</a>
ghrifter将近 10 年前
How about a pen?<p>A pen is tangible and has properties.<p><pre><code> pen.brand = &#x27;bic&#x27;; pen.inkColor = &#x27;black&#x27;; </code></pre> etc