完全菜鸟的设计原则?
我已经编程大约一年了,我写的所有东西都有效 - 从我的角度来看,它写得非常糟糕。我想知道是否有任何(免费)关于软件设计的好书可以为初学者程序员提供一些指导?如果我对软件设计的思维过程有所了解,我认为我不会遇到那么多问题。
I've been programming for around a year now, and all the stuff that I've written works - it's just extremely poorly written from my point of view. I'd like to know if there are any (free) good books on Software Design out there that can offer a little guidance to the beginning programmer? I don't think I'd have as many problems if I knew a little about the thought processes that go into software design.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(18)
这不是一本书(书已经过时了),但花几个小时阅读 波特兰模式存储库。
虽然它也不是教程,但它有很好的代码示例,以及对设计模式和一般编程的同样精彩的讨论。这是学习如何像程序员一样思考的绝佳资源。
It's not a book (books are so passé), but it's definitely good to spend a few hours reading through the Portland Pattern Repository.
While it's also not a tutorial, it has great code examples, and equally great discussion on design patterns and programming in general. It's an excellent resource on learning how to think like a programmer.
我建议 结构和计算机程序的解释,以书籍形式在线提供,以及在线课程。
这不是一本关于设计模式的书,但它将帮助您为构建应用程序奠定良好的基础。
I suggest Structure and Interpretation of Computer Programs, which is available on-line in book form, as well as an on-line course.
It's not a book on design patterns, but it will help you develop good fundamentals for building applications.
我肯定会添加另一本书。我认为 Bob Martin 的整洁代码是一本非常好的书。如何编写可维护的代码。它引入了一些简单的规则,这些规则可以使代码结构良好且可读。
I would definitely add another book. I think that Clean Code by Bob Martin is a very good book to tell you how to write code that is maintainable. It introduces several easy rules that leads to code that is very well structured and readable.
学习优秀软件设计的最佳方法是以多种不同的方式编写代码,阅读其他人编写的代码,并直接了解哪些有效,哪些无效。
当您编写代码时,请询问以下问题:
我相信其他人根据自己的经验也会有其他想法。
The best way to learn good software design is to write code in a bunch of different ways, read code written by others, and learn what works and what doesn't first-hand.
When you are writing code, ask the following questions:
I'm sure other people have other ideas, based on their own experiences.
Head First 设计模式对于初学者来说是一个很好的起点。这可能比四人帮的书更容易进入。
Head First Design Patterns would be a good place to start for a beginner. It's probably easier to get into than the Gang of four book.
您可能应该了解更多有关面向对象编程的知识。这是一个基于 Python 的很好的教程:
Python 中的 OOP 教程
面向对象编程是一种以反映您要解决的问题中的内容的方式组织程序的方法。
嗨
...里奇
You should probably learn more about object oriented programming. Here is a nice tutorial that's based on Python:
OOP Tutorial in Python
Object oriented programming is a way to organize you programs in a way that mirrors the things in the problem you are trying to solve.
HIH
...richie
学习不同的语言!我喜欢 python,而且,不管大家怎么说,我的 python 更好,因为我了解 java。 (有些人抱怨从 java 开始会导致你一开始写出笨重的 python,但如果你已经或多或少知道用 python 做某事的简单方法,你就不会遇到这种情况。)
让我做一点电锯手术这里。第一次写Python很容易。我用 vim 写它,因为我可以并且因为我喜欢 vim。如果你有IDE,那么维护和重构java就很容易了。我在 Eclipse 中编写 java,因为没有它我就没有希望了。但关键是,使用一种迫使您使用抽象的语言和一种使抽象更容易的工具来编写将慢慢塑造您的大脑,以更加抽象地编码。您将把它带回 Python,尽管首选的抽象会略有不同。
Learn a different language! I love python, and, despite what everyone says, my python is better because I know java. (Some people complain that starting with java causes one to initially write clunky python, but if you already know more or less the easy way to do something in python, you will be safe from this.)
Let me do a little bit of chainsaw surgery here. It is easy to write python the first time. I write it in vim, because I can and because I love vim. It is easy to maintain and refactor java if you have an IDE. I write java in Eclipse, because I'd be hopeless without it. But the point is, writing in a language that forces you to use abstractions with a tool that makes abstractions easier will slowly shape your brain to code more abstractly. You will bring that back to python, even though the preferred abstractions will be slightly different.
哇,我想知道为什么直到现在还没有人说你真的不应该太深入理论。一年后,你的代码变得丑陋了。对此无能为力。如果你完成了大部分你想要完成的事情,那就已经非常了不起了。但你不能用理论欺骗你的大脑。继续写作并对你的代码感到愤怒。这是写得更好的最好方法。花点时间思考如何尽可能多地以更具可读性/可用性/可维护性的方式编写工作代码。
并且:阅读其他人的代码+获得对你的代码的评论!应该有人比你写得更好。通过例子学习!
也许你用 20% 的编程时间(这意味着如果你每天都编码,一年不超过 2 个月!) 来了解一些理论。
为什么不从大量的理论开始呢?你扼杀了你的动机和你的本能。但当你坐在那里试图解决问题时,这主要取决于正确的本能。太多的理论会让你过度思考问题和解决方案。但无论你读了多少书,你的本能仍然停留在你的经验水平上。
(抱歉,如果英语不好。不是我的母语)
Wow, I wonder why nobody said until now that U really should not go too deep into theory. After one year Ur code is ugly. Nothing to do about it. If U get most things done U want to finish, it is already very awesome. But U cannot cheat Ur brain with theory. Just go on writing and be angry about Ur code. That is the best way to write better. Take Ur time to think about how to write working code in a more readable/usable/maintainable way as often as U can.
AND: Read other peoples code + get reviews on Ur code! There should be people out there who can write better then U. Learn by example!
And maybe 20% of Ur programming time (that means if U code every day, not more than 2 months a year!) get some theory.
Why not start with masses of theory? U kill Ur motivation and Ur instinct. But when U sit there and try to solve a problem it is mostly about the right instinct. With too much theory U overthink the problem and Ur solutions. But Ur instinct will be still on the level of Ur experience, no matter how much U read.
(sorry, if bad english. not my mothertounge)
获取《四人帮》一书 - 设计模式..
但请不要过度遵循它并尝试在任何地方使用 Singleton :)
只要了解它并明智地使用它即可。之后还要研究好的开源代码并尝试从它们的结构中学习..我建议谷歌代码和sourceforge
Get the Gang of four book - Design Patterns..
But please don't over follow it and try to use Singleton everywhere :)
Just know it and use it wisely. Also after that look into good open source code and try to learn from their structures.. I suggest google code and sourceforge
根据您的背景(以及某种程度上的经验),您可能还想研究基本算法。像算法简介这样的书是一个好的开始。
除此之外,我还投票支持 Head First 设计模式。 GoF 作为以后的参考效果更好。
Depending on your background (and to some degree, experience) you might also want to look into how basic algorithms. A book like Introduction to Algorithms is a good start.
Besides that, I also vote for Head First Design Patterns. The GoF works better as a reference later on.
忘记书吧。根据我的经验(包括作为面向对象设计课程的讲师和作者的时间),有些人可以做设计,有些人不能——这是一种天赋,就像成为一名雕塑家一样。如果你没有天赋,阅读有关该主题的书籍充其量只会让你设计得很糟糕。
Forget the books. In my experience (which includes time as an instructor and writer of OO design courses) some people can do design and some pople can't - it's a talent, like being a sculptor. At best, reading books on the subject will enable you to design badly, if you don't have the talent.
Head First Design Patterns 可能是对 GoF“设计模式”一书
Steve McConnell 的 Code Complete 是许多代码方面的很好的指南,包括如何在本身不支持它们的语言中使用好的策略。
Martin Fowler 的 重构 大量引用了设计模式,但它是马马虎虎的代码和更好方法的一个很好的目录编写它的过程(我大约在阅读《代码完成》的同时读到它,比阅读《设计模式》早了几年 [tsk tsk],而“重构”对我如何看待我所编写的代码产生了重大影响。更好,我喜欢这样想)。
这些都不是“免费的”。但你想要多好的建议呢?如果您想投资自己的职业生涯,这是最便宜的方法。
Head First Design Patterns might be a gentler intro to the GoF "Design Patterns" book
Steve McConnell's Code Complete is a good guide to many things code, including how to use good strategies in languages that don't natively support them.
Martin Fowler's Refactoring refers heavily to Design Patterns, but is a great catalog of so-so code, and better ways of writing it (I read it about the same time I read "Code Complete", a couple of years [tsk tsk] before reading Design Patterns, and "Refactoring" had a major impact in how I looked at code I wrote. For the better, I like to think).
None of these are "free." But how good of advice do you want? If you're trying to invest in your career, this is the cheapest way to do it.
干 和 YAGNI 对于初学者来说是很好的起点,您需要学习和理解OOP。
关于设计模式(比DRY和OOP更高级和抽象)你可以学习免费的设计模式 - Java Companion。它不是 Python 的事实不应该困扰您 - 经典的设计模式在任何地方都适用。
如果您想进一步了解DDD (Eric Evans 的免费 DDD 书籍),当然还有 单元测试,不管你信不信,它都会改进你的代码和你作为设计师的表现。
DRY and YAGNI are good starting points for beginners and you need to study and understand OOP.
Regarding Design Patterns (which are a bit more advanced and abstract than DRY and OOP) you can study from the free Design Patterns - Java Companion. The fact that it's not Python should not bother you - classic design patterns are applicable everywhere.
When you feel like going further have a look at DDD (free DDD book from Eric Evans) and of course Unit Testing which, believe it or not, will improve your code and you as a designer.
阅读别人的代码。这是学习更好的设计原则的最佳方式。在你的工作中阅读人们的代码,在论坛上阅读人们的代码,看看开源项目......并且永远不要停止编码,因为最好的老师是你一路上犯的错误......
看看这本书,务实的程序员,从新手到大师。这是一本很棒的书,可以帮助填补您正在寻找的知识空白。
Read other people's code. That is the best way to learn better design principles. Read people's code at your work, read people's code on forums, take a look at open source projects... and never stop coding, because the best teacher is the mistakes you make along the way...
Check out the book, Pragmatic Programmer, from Journeyman to Master. This is a great book to help fill that gap in knowledge you are looking for.
听起来你想要一本关于设计模式的书。
请查看:设计模式 - 可重用面向对象软件的元素。警告它不是特定于 Python 的。
您还可以访问此在线资源了解 Python 设计模式。
Stackoverflow 用户 @S.Lott 也有很多他编写的非常好的 Python 资源。你可以在他的 Stackoverflow 页面上看到它们。
Sounds like you want a book on design patterns.
Take a look at: Design Patterns - Elements of Reusable Object-Oriented Software. Warning it is not Python specific though.
You could also take at this online resource for Python design patterns.
Stackoverflow user @S.Lott also has a lot of really good Python resources that he wrote. You can see them on his Stackoverflow page.
其他一些可能值得注意的原则:
废话:四个声音设计原则 - 对于可用性来说,这些是需要了解的好原则。
Pablo 本月主题 - 三月:SOLID 原则 - 也有一些好主意。
A couple of other principles that may be worth noting:
C.R.A.P.:The Four Principles of Sound Design - For usability these are good principles to know.
Pablo's Topic of the Month - March: SOLID Principles - Has some good ideas as well.
有了一年的编程经验,我不会建议设计模式(或 Head First 设计模式),因为我认为一旦你有更多的编程经验,设计模式(概念)最好处理,也许
更像 5-10多年经验。我认为实用程序员:从熟练工到大师这本书由安德鲁·亨特 和 大卫·托马斯也许是您目前水平上最划算的最佳选择。这是主题和内容的精彩摘要(来自《编码恐怖》的杰夫·阿特伍德)。如果您无力购买自己的副本,请使用馆际互借。
另外两本与语言无关的经典书籍,强烈推荐给新程序员,您可以保留记住的是 Fred Brooks 的 The Mythical Man-Month(1995 年出版的周年纪念版),以及代码完成(第二版),作者:Steven McConnell。
这些书籍将帮助扩展您的编程知识,而不会让您在当前的开发阶段感到不知所措,并为成为更好的程序员奠定坚实的基础。所有这些书都始终位于的顶部推荐 编程 面向严肃程序员的书籍,它们都足够“老”,显然不是一种时尚,而是持久的推荐,不受限于特定的语言、环境或工具集。
With a year of programming experience, I won't suggest Design Patterns (or Head First Design Patterns), as I think Design Patterns (the concepts) is best processed once you have more programming experience, perhaps
more like 5-10 years of experience.I think the book, The Pragmatic Programmer: from Journeyman to Master by Andrew Hunt and David Thomas is perhaps your best bet for the most bang for your buck at the level you are at currently. Here is an excellent summary of the topics and contents (from Jeff Atwood at Coding Horror). Use inter-library loan if you cannot afford to purchase your own copy.
Two other titles that are also language-agnostic yet classic books highly recommended for new programmers that you can keep in mind are The Mythical Man-Month (anniversary edition published in 1995) by Fred Brooks, and Code Complete (second edition) by Steven McConnell.
These books will help expand your programming knowledge without overwhelming you at your current stage of development, and make for a solid foundation for becoming a better programmer. All of these books are constantly on the top of recommended programming books for serious programmers, and they are all "old" enough that they are clearly not a fad, but enduring recommendations not limited by a particular language, environment or tool-set.
看看这本书:Head First 设计模式 ...字面意思。一探究竟。从图书馆。
Check out this book: Head First Design Patterns ...literally. Check it out. From the library.