问题描述
我需要8051的代码,该代码将检测一辆马赫型厢式货车,并在检测到该厢式货车时亮起.
I need a code for an 8051 that will detect a mach box car and light up if one is detected.
推荐答案
您尝试了什么?
2008年12月8日
如果您是一名开发人员,并且打算(在论坛上,通过电子邮件,在聊天频道上或亲自面对)向另一位开发人员提出技术问题,则最好准备回答您有什么问题"的问题.尝试过吗?"
当然,这不是特定于软件开发人员的,但这是我的专业领域,也是我最熟悉该问题的领域,这促使我写了这篇文章.无论如何,我(非常)确信它也适用于您自己的行业.
事实是,软件开发界存在一种疾病.一种疾病.这是一种不寻常的疾病,因为一旦您真正加入该行业,通常就不会获得任何东西(例如,头发变白,咖啡因成瘾和溃疡),而是新员工到来时已经有了的东西.
现在,在继续之前,请先快速澄清一下:当我说新兵"时,我不仅是指毕业生和其他年轻人.有些人会说这种疾病是现代西方教育体系的产物,而且当下情况可能会更好.也许是正确的,也许不是,但是我没有资格说,这也不是我要提出的立场.我说的这种病似乎对年轻人和老年人都一样.
当然,这种疾病是解决问题的有缺陷的方法.这是一个示例,是来自网络论坛的实际报价:
What have you tried?
DEC 8TH, 2008
If you’re a developer and you’re about to ask another developer a technical question (on a forum, via email, on a chat channel, or in person), you’d better be ready to answer the question "What have you tried?"
This of course isn’t specific to software developers, but that’s my field and it’s thus the area in which I’m most familiar with the issue which motivated me to write this. I’m (sadly) quite sure that it applies to your own industry too, whatever that might be.
The thing is, there’s a disease in the software development world; a sort of sickness. It’s an unusual sickness in that it’s often not something you acquire once you actually join the industry (like greying hair, caffeine addiction and an ulcer), but rather it’s something that new recruits already have when they arrive.
Now, a quick clarification before I continue: when I say "new recruits", I don’t just mean graduates and other young people. There are those who will say that this sickness is a product of modern western education systems, and that things were perhaps better back in the day. Maybe that’s true and maybe it’s not, but I’m not qualified to say and that isn’t the position I’m putting forward here anyway. The illness I’m talking about seems to apply to both young and old alike.
The illness, of course, is a flawed approach to solving problems. Here’s an example, which is an actual quote from a web forum:
1)我们可以在应用程序中建立http连接吗?
如果是这样,我需要该代码.
我检查了NSURLconnection.我无法整合该代码.
2)我想显示网站上的图像
有人可以给我提供代码吗?
如果有人有示例程序,请给我.
1) Can we establish http connection in application.
if so, i need that code.
I checked NSURLconnection. I cannot intergrate that code.
2) I want to display a image from the website
Can anybody please provide me the code?
If anybody having sample program please give me.
那么问题出在哪里呢?这不是英语的特质(有理由很明显地证明英语可能不是这个人的母语,并且只要意图很明确就没有关系).它不是标点符号和语法,因为在这种情况下,只要它们不会成为理解所问内容的障碍,这些东西在这里就不再特别重要.
问题在于此人的解决问题的技术是寻求解决方案.不是要寻求有关如何执行任务的建议,也不是要寻求可能的类的名称或示例的链接-而是索要完全形成并可以使用的代码.这不是解决问题,软件工程完全是解决问题.
这里要注意的有趣的事情是,上面的示例实际上并不像它可能的那样糟糕.这个人检查了NSURLConnection"的断言中发现了一丝微光.由于NSURLConnection确实是想要在Cocoa中进行HTTP连接时要学习的一类,因此这激发了一点信心.但是,似乎检查"几乎是我们朋友努力的总和-他们无法集成该代码",因此放弃了.
这是我们大家不断看到的一个问题(我并不是说很难建立HTTP连接).有一整类所谓的开发人员,一旦解决问题,他们的首要策略就是简单地在其他地方(通常是在网络论坛或其他合适的帮助渠道)索要完整的解决方案.他们的目标与我们的目标相同-拥有解决问题的代码,然后可以将其交付给客户.这个目标是合理且很正常的.
不正常的是不愿意(我会毫不犹豫地说无能,因为毕竟,如果您运用足够的思想和努力,很少有事情是真正的,从根本上来说是艰苦的"),这是通过自我教育,诚实的过程来实现这一目标的.尝试和改进和改进的经典迭代过程,直到创建出可以接受的东西.这个过程反过来使您更好地应对下一个挑战,迟早您会发现:
您已经知道了答案并可以放心地解决所有熟悉的问题;和:
您可以通过总结当前的知识并进行一些简单的重点研究来解决不熟悉的问题.
这不是软件工程的窍门;这是学习如何做所有事情的全过程.
这不是在高等教育机构中传授的秘密,而是事情的方式:首先,您对一个主题缺乏了解,并且需要解决该主题领域的问题.诚实,可持续的做法是提高您的理解力.这是通过以下方式实现的:
提出一个问题,如果正确回答,将以某种方式改善您的理解;然后:
尝试回答.
请注意上面的第二步.争辩说以某种方式获取完整的解决方案可以满足此过程,这是懒惰和智力上的不诚实,并且可能使您不值得得到帮助.毕竟,为什么还要有人为您做您的工作?
我有很多与人交往的经历,他们表现出这种令人不安的学习,研究或尝试的不愿意.多年来,我发布了许多代码,并且在与我合作的平台的开源社区中非常引人注目.由于开源贡献者似乎是自由职业者的老师,所以这意味着我收到很多电子邮件,寻求关于另一件事情的帮助.而且,我会尽一切可能提供帮助.
自Mac OS X首次发布以来,我已经帮助了数百名希望开始使用Cocoa的人们.我也没有发送任何重复答复-我分别回复了每封电子邮件.从特定的代码问题(包括但绝不限于与我自己的代码有关的查询),书籍建议到有关如何从整体上开始编程的建议,应有尽有;在这方面,我已经履行了职责,而且我确实相信这是一项职责.可以做任何事情的人应该帮助希望做同样事情的其他人;当然,这是一个基本真理,确实是我们所有人的愿望.
但是,这是现实生活,没有考虑到某些现实的原则.帮助在大多数情况下可能是免费的,但这并不意味着没有成本效益比可供考虑.我的好处可能来自温暖的模糊感觉而不是冷落的现金,但是如果您浪费我的时间,那么您似乎就不会像真正想学习的人那样值得.
这是一个秘密:学习的意愿和欲望才是真正的资格.
没有能力;我们都有不同的先天和发达水平,掌握某些技能.其中的一些(可能大多数)可以通过实践加以改善,而某些则不能,而且-在一个完整的学科中深化或概括一个人的能力是错误的,因为他们在该学科的某个特定方面似乎很困难.但是,如果您希望某人花时间和精力(特别是如果他们有时间免费提供),那么最好赚钱.
赚钱并不是要向老师扔几学分的货币,甚至也不是成功完成任务,而是流血的尝试.我正在谈论的许多开发人员似乎都非常不愿意这样做.因此,当然,我们许多人都忽略了它们.问题解决了吧?错误.
这种不愿自行解决问题的意愿激增会带来巨大的连锁负面影响.有能力帮助停止访问聊天室,论坛和邮件列表的人.他们说,信噪比差"有一定道理.失败者是真正的开发人员(我的意思是善意的,愿意学习的人,刚好在特定区域是新手),他们自然选择这些地方来提出自己的合法问题.由于要努力找出谁是懒惰的人,而谁不是懒惰的人,这些人却很难获得有意义的指导.
这是一件可怕的事情,而且从来没有像现在这样有意义,因为从逻辑上讲,年轻和/或正在经历普及的平台最容易受到这种现象的影响.真正有经验的人会减少,平均经验水平会减少,需要的帮助量会更高,并且所有类型中混合在一起的懒惰,抢钱和奔跑类型的比例要高得多.这是iPhone,Android等.
因此,如果您要提出技术问题,我想我要对您说的第一件事是:太好了!您在问一个问题,这意味着我们比您想学习的东西要好得多.通常很棒,我随时准备向你致敬.
可是等等.您是否考虑过-真正考虑过-您要问什么?是时候问这个问题了吗,还是您可以先采取进一步的措施,这也许会使您的问题更清楚(好的),甚至可以使您的问题变得不必要(可能更好)?
尝试花几分钟来解决这些问题:
您是否已将问题分解成足以真正提出具体问题的地方?在软件工程中,您可以将问题大致分为两类:(1)可以进一步细分的事物,以及(2)您已经知道如何做或可以轻松查找的事物.
您的问题是标准问题吗,肯定已经有了一些示例代码和文档?世界上没有一个GUI工具包,该教程中没有关于如何在屏幕上放置窗口的部分.没有一种编程语言不会告诉您如何读取文件的内容.浏览文档,或进行快速搜索.如果您的问题如此简单,答案可能就在片刻之内.你可以找到它!
尝试搜索网络.我知道这是glib的建议,但请留在我身边.如果您无法获得令人满意的结果,则需要缩小范围.如果您只对红宝石的if陈述感兴趣,请不要搜索"if陈述";而是尝试"ruby if语句".最好是找到一个特定于您正在使用的语言或技术的网站,然后在该网站中进行搜索.对于Cocoa,这是CocoaBuilder列表档案.可能有人问过您的问题-也许是一百个人.
谁创造了您的语言,框架或API或其他人创建了许多示例代码;确实,他们做到了.它旨在帮助您着手处理各种常见任务,并且可能会有一些代码至少可以完成您想要做的一些事情.您只需花几分钟的时间进行检查,并且至少可以获取大量的代码,这些代码将在将来的某个时候派上用场.
使用您的IDE的在线参考或其他内置文档. Xcode具有文档浏览器. Eclipse等将向您展示Java类文档. PHP.net涵盖了您的PHP脚本.找到您正在使用的规范参考,然后进行搜索.您几乎每次都会找到有用的信息.
好的,您已经完成了这些步骤,并至少尝试了其中的一些步骤.我现在终于可以祝贺你.您已经解决了自己的问题(很好),或者您现在已经准备好正式获得帮助.
当我问您您尝试了什么吗?"时,您可以自信地说您已经尝试了上面的所有内容,并且可以告诉我所有有希望的发现,或者可以说您至少是空无一人的.诚实地.此时,我会为您提供帮助,因为我可以看到您想学习,并且愿意为此而努力,所以我想教您.
这就是关键的认识.当系统询问您您尝试了什么?"时,它的意思不是告诉我您编写的代码,或者生气".您要做的至少是尝试帮助自己-尝试是重要的事情.
不仅是为了避免惹恼某个愿意付出宝贵时间来帮助您的人,而且实际上是为了您自己的发展.做足够的时间,您实际上要问的问题就会开始减少.您还将可以帮助其他人(包括我),这样每个人都会赢.
因此,下次您考虑提出问题时,当系统提示您您尝试了什么?"时,最好准备一个令人信服的答案.
如果您的回答是不是很多",请相信我:下一个要回答的问题是那我为什么要帮助您?"
更新:我已经将域名whathaveyoutried.com指向了这篇文章.
So where’s the problem? It’s not in the quality of English (it’s reasonably evident that English may not be this person’s first language, and that doesn’t matter as long as the intent is clear - which it is). It’s not in punctuation and grammar, because those things again aren’t particularly important in this context as long as they don’t become barriers to understanding what’s being asked.
The problem is that this person’s problem-solving technique is to ask for the solution. Not to seek advice on how to approach the task, or ask for the names of likely classes to look into, or a link to an example - but to just ask for the code, fully formed and ready to go. This is not problem solving, and software engineering is entirely about problem solving.
The interesting thing to note here is that the above example isn’t actually as bad as it could be; there’s one tiny glimmer of light to be found in the assertion that this person "checked NSURLConnection". That inspires some small amount of confidence, since NSURLConnection is indeed a suitable class to learn about when wanting to make HTTP connections in Cocoa. However, it seems that "checking" it was pretty much the sum of our friend’s effort - they "cannot integrate that code", and have thus given up.
This is an issue we all see constantly (and I don’t mean having trouble making HTTP connections). There’s an entire class of so-called developers whose first and final tactic when given a problem to solve is to simply ask for the completed solution elsewhere, commonly on web forums or other suitable help channels. Their goal is the same as ours - to have code which solves the problem, which can then be presumably delivered to the client. This goal is reasonable and quite normal.
What isn’t normal is the unwillingness (I hesitate to say inability - because after all, very few things are truly, fundamentally "hard" if you apply sufficient thought and effort) to achieve that goal by a process of self-education, honest attempts and the classic iterative process of refinement and improvement until something acceptable is created. This process in turn equips you better to handle the next challenge, and sooner or later you find that:
there are entire sets of familiar problems to which you already know the answer and can approach with confidence; and:
you’re quite capable of approaching unfamiliar problems by generalising your current knowledge and conducting some simple focused research.
This isn’t some trick of software engineering; this is the entire process of learning how to do anything at all.
It’s not a secret handed out at institutions of higher education, it’s just how things work: you begin with a lack of understanding about a topic, and a need to solve a problem in that topic area. The honest, sustainable means of doing so is to improve your understanding. This is achieved by:
Formulating a question which, when correctly answered, will improve your understanding in some way; then:
Attempting to answer it.
Note the second step above. To argue that grabbing the completed solution in some way satisfies this process is laziness and intellectual dishonesty, and probably renders you unworthy of being helped. For after all, why should someone else do your work for you?
I’ve had a lot of personal experience with people displaying this troubling unwillingness to learn or research or try. I’ve released a lot of code over the years, and I’m very visible in the open source community for the platforms I work with. Since open source contributors seem to be seen as freelance teachers, that means I get a lot of email asking for help with one thing or another. And I provide that help whenever I can.
I’ve helped literally hundreds of people looking to get started with Cocoa, since Mac OS X was first released. I don’t send boilerplate replies, either - I replied to each email individually. Everything from specific code issues (including but by no means limited to queries relating to my own code), book recommendations, right up to advice on how to get started with programming as a whole; I’ve done my duty in that regard, and I really do believe it is a duty. People who can do something to whatever extent ought to help others who wish to be able to do the same; surely that’s a fundamental truth and indeed a desire for all of us.
But this is real life, and no principle comes without the consideration of certain realities. Help may be free for the most part, but that doesn’t mean there isn’t a cost-benefit ratio to be considered. My benefit may come from a warm fuzzy feeling rather than cold hard cash, but if you’re wasting my time then you’re not going to seem as worthy as someone who genuinely wants to learn.
Here’s a secret: willingness and desire to learn are the true qualifications.
Not ability; we all have differing innate and developed levels of ability to acquire certain skills. Some (probably most) of these can be improved with practice, and some can’t - and it’s wrong to pigeonhole or generalise a person’s ability in an entire discipline just because of their seeming difficulty in one particular aspect of that discipline. But if you want someone to spend time and effort (especially if it’s time they’re giving freely), then you’d better earn it.
Earning it isn’t about throwing a few units of currency at your teacher, and it’s not even about successfully completing your task - it’s about bloody trying. And trying is what so many of the type of developers I’m talking about seem bizarrely unwilling to do. So, of course, many of us ignore them. Problem solved, right? Wrong.
There’s a huge knock-on negative effect of the proliferation of this unwillingness to make the effort to solve problems yourself. People who are in a position to help stop frequenting the chatrooms, forums and mailing lists. "Bad signal to noise ratio", they say, with some justification. The losers are the genuine (by which I mean well-meaning, willing-to-learn people who just happen to be new to a particular area) developers who naturally choose those places to ask their legitimate questions. These people have a reduced chance to get meaningful guidance because of the effort involved in working out who’s a lazy time-waster and who isn’t.
This is an awful thing, and it’s never been more relevant - since logically, platforms which are young and/or experiencing a surge in popularity are exposed to this phenomenon the most. There are fewer people who are genuinely experienced, the average level of experience is less, the amount of help being requested is higher, and there’s a far higher proportion of lazy, grab-the-money-and-run types mixed up in it all. This is the iPhone, Android and so on.
So, if you’re going to ask a technical question, I guess the first thing I have to say to you is: Great! You’re asking a question, and that means we have a better than even chance that you want to learn something. That’s usually awesome, and I stand ready to salute you.
But wait. Have you considered - really considered - what it is you’re about to ask? Is this the right time to ask, or can you take one more step first, which might either make your question clearer (good) or even unnecessary (probably better)?
Try taking a few minutes to run through these points:
Have you broken the question or problem down sufficiently to really ask something concrete? In software engineering, you can pretty much divide problems into the two categories of (1) things that can be broken down further, and (2) things you already know how to do or can look up trivially.
Is your problem the sort of standard question for which there’s definitely already some sample code and documentation available? There isn’t a GUI toolkit in the world that doesn’t have a section in the tutorial on how to put a window on screen. There’s no programming language that doesn’t tell you how to read the contents of a file. Skim the documentation, or do a quick search. If your problem is that simple, the answer is probably just moments away. You can find it!
Try searching the web. This is glib advice, I know, but stay with me. If you’re having trouble getting a decent result, you need to narrow things down. Don’t search for "if statement" if you’re just interested in an if-statement in ruby; instead, try "ruby if statement". What might be even better is finding a site that’s specific to the language or technology you’re working with, and searching there. For Cocoa, this is the CocoaBuilder list archives. Someone else has probably asked your question - or maybe a hundred someones.
Whoever made your language or framework or API or whatever also created a bunch of sample code; really, they did. It’s designed to help you get on your feet with various common tasks, and there might be some code that does at least some of what you want to do. It’ll take you only a few minutes to check, and at the very least you can grab a load of code which will come in handy at some point in the future.
Use your IDE’s online reference or other built-in documentation. Xcode has a documentation browser. Eclipse etc will show you the Java class documentation. PHP.net has you covered for your PHP scripts. Find the canonical reference for what you’re working with, and search it. You’re going to find something that’s helpful almost every time.
OK, you’ve gone through those steps and tried at least a few of them. I can now finally say congratulations. Either you’ve solved your own problem (great), or you are now officially ready to be helped.
When I ask you "what have you tried?", you can say with confidence that you’ve tried all that stuff above, and you can tell me anything promising you found, or you can say that you’ve at least come up empty honestly. I’m going to help you at this point, because I can see that you want to learn and that you’re willing to work for it, and so I want to teach you.
That’s the key realisation. When you’re asked "what have you tried?", it doesn’t mean "show me the code you’ve written, or piss off". What you have to do is at least try to help yourself - and the trying is the important thing.
Not just for avoiding pissing off someone who would otherwise be willing to give freely of their valuable time to help you, but actually for your own development. Do it enough times and the number of questions you’ll actually have to ask will start to go down. You’ll also be in the position to help others (including me), and that way everybody wins.
So next time you’re considering asking a question, you’d better be ready with a convincing answer when you’re asked "What have you tried?"
If your answer amounts to "not a lot", take my word for it: the next question you get back will be "then why should I help you?"
Update: I’ve pointed the domain whathaveyoutried.com to this post.
这篇关于我需要用C ++编写代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!