├── LICENSE └── README.md /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 后端开发面试题 2 | ================ 3 | 4 | ## 说明 5 | 6 | 这篇文章翻译自一位外国友人的关于面试后端程序员的文章,我比较喜爱这篇文章。一是因为它极大的拓宽了我的视角,另一方面是其中的一些问题非常具有启发性。不仅对于面试者,对于面试官来说也是个不错的参考。于是迫不及待的翻译了一下,给各位看官做个参考。 7 | 8 | 这篇文章中,许多问题我并没有完全理解,所以翻译可能存在不准确的地方。如果有读者发现有一些翻译有误或者不好的地方,请不吝赐教。 9 | 10 | 原文参见 [@arialdomartini](https://github.com/arialdomartini)的: [Back-End Developer Interview Questions](https://github.com/arialdomartini/Back-End-Developer-Interview-Questions) 11 | 12 | 以下是原文翻译。 13 | 14 | 后端开发面试题 15 | ================ 16 | 17 | 在面试的时候,我并不特别喜欢问一些技术性的问题。我更喜欢的方式是这样的: 和面试者坐在一起,看一些实际的代码,解决一些实际的问题。并且用一整天的时间,让团队所有成员轮流和面试者进行结对编程。虽然如此,但是一些技术问题仍然可以用来很好地启动一段有深度的谈话,能够让面试者和面试官相互都有更加深入的了解。 18 | 19 | 这个仓库包含了可以用来考核面试者的一系列后端面试题。但绝不是说,面试官必须用每个面试题来考核面试者(这样可能要耗费好几个小时)。根据你期望面试者拥有的技能,从这个列表中有选择的挑一些题目,可以帮助你在特定技能上考核面试者。 20 | 21 | 应当承认的是,这个项目的灵感来自于[@darcyclarke](https://github.com/darcyclarke)的文章[Front-end Job Interview Questions](https://github.com/darcyclarke/Front-end-Developer-Interview-Questions) 22 | 23 | **注意:** 请记住,这些面试题中有许多问题是开放式的,能引导讨论一些有趣的问题。相比那些有直接答案的问题来说,这种问题能够让你对面试者的能力有更多的了解。再一次强调,我认为仅仅是问问题是不够的。要通过与面试者较长时间的结对编程来完成面试: 这是你们相互了解对方的风格和方法、让面试者了解未来工作的最佳手段之一。 24 | 25 | ## 目录 26 | 27 | 1. [通用问题](#general) 28 | 1. [开放式问题](#open) 29 | 1. [设计模式相关问题](#patterns) 30 | 1. [代码设计相关问题](#design) 31 | 1. [语言相关问题](#languages) 32 | 1. [Web相关问题](#web) 33 | 1. [数据库相关问题](#databases) 34 | 1. [非关系型数据库相关问题](#nosql) 35 | 1. [代码版本管理相关问题](#codeversioning) 36 | 1. [并发问题](#concurrency) 37 | 1. [分布式系统相关问题](#distributed) 38 | 1. [软件生命周期和团队管理相关问题](#management) 39 | 1. [逻辑和算法相关问题](#algorithms) 40 | 1. [软件架构相关问题](#architecture) 41 | 1. [面向服务架构(SOA)和微服务(Microservice)相关问题](#soa) 42 | 1. [安全相关问题](#security) 43 | 1. [比尔盖茨式问题](#billgates) 44 | 1. [代码示例问题](#snippets) 45 | 46 | #### 通用问题: [[↑]](#toc) 47 | 48 | * 语言设计中空引用([null reference](http://programmers.stackexchange.com/questions/12777/are-null-references-really-a-bad-thing))的存在有什么问题?假设你想要将空引用的概念从你的首选语言中移除,可能导致什么结果? 49 | * 为什么函数式编程重要?什么时候适用函数式语言? 50 | * 设计(design)、架构(architecture)、功能(functionality)和美学(aesthetic)之间有什么区别?讨论一下。 51 | * 微软、谷歌、欧朋(opera)和火狐这类公司是如何从他们的浏览器中获利的? 52 | * 为什么打开TCP套接字有很大的开销? 53 | * 封装的重要性体现在哪儿? 54 | * 什么是实时系统?它与普通系统有什么区别? 55 | * 实时语言(real-time language)和堆内存分配(heap memory allocation)之间的关系是什么? 56 | * 不变性(Immutability)是指: (变量的)值只能在创建的时候被设置一次,之后就不能被改变。为什么不变性对写更加安全的代码有帮助? 57 | * 可变值(mutable values)和不可变值(immutable values)有哪些优缺点? 58 | * 什么是O/R阻抗失衡(Object-Relational impedence mismatch)? 59 | * 如果你需要使用缓存,你使用哪些原则来确定缓存的大小? 60 | * TCP和HTTP有什么区别? 61 | * 在客户端渲染(client-side rendering)和服务端渲染(server-side rendering)之间,你是如何权衡的? 62 | * 如何在一个不可靠的协议之上构建一个可靠的通信协议? 63 | 64 | #### 开放式问题: [[↑]](#toc) 65 | 66 | * 为什么人们会抵制变化? 67 | * 如何向你的祖母解释什么是线程? 68 | * 作为一个软件工程师,你想要既要有创新力,又要产出具有可预测性。采用什么策略才能使这两个目标可以共存呢? 69 | * 什么是好的代码? 70 | * 解释什么是流(Streaming)和如何实现一个流? 71 | * 假设你的公司给你一周的时间,用来改善你和同事的生活: 你将如何使用这一周? 72 | * 本周你学了什么? 73 | * 所有的设计中都会有美学元素(aesthetic element)的存在。问题是,你认为美学元素是你的朋友还是敌人? 74 | * 列出最近你读过的5本书。 75 | * 假设目前有个大型公司(非常有钱),他们的开发流程是瀑布式流程(Waterfall),如果需要你在他们公司引入持续交付([Continue Devivery](https://en.wikipedia.org/wiki/Continuous_delivery)),你会怎么做? 76 | * 我们来谈谈"*重复造轮子*","*非我发明症*", "*吃自己做出来的狗粮*"的这些做法吧。 77 | 78 | (注: 重复造轮子: Reinventing the wheel; 非我发明症:Not Invented Here Syndrome; 吃自己做出来的狗粮: Eating Your Own Dog Food) 79 | 80 | * 在你当前的工作流中,什么事情是你计划下一步需要自动化的? 81 | * 为什么写软件是困难的?是什么使软件的维护变得困难? 82 | * 你更喜欢在全新项目(Green Field Project)上工作还是在已有项目(Brown Field Project)基础上工作?为什么? 83 | * [当你在浏览器地址栏输入google.com回车之后都发生了什么?](https://github.com/alex/what-happens-when) 84 | * 当操作系统CPU处于空闲的时候,它可能在处理哪些事情? 85 | * 如何向一个5岁的孩子解释什么是Unicode/数据库事务? 86 | * 如何维护单体架构(monolithic architecture)? 87 | * 一个"专业的开发者"意味着什么? 88 | * 软件开发是艺术、是技艺还是工程?你的观点是什么? 89 | * "喜欢这个的人也喜欢...",如何在一个电子商务商店里实现这种功能? 90 | * 为什么在创新上,企业会比创业公司慢些? 91 | * 为什么说,对于涉及密码学的问题,你不应该尝试应用自己的发明或者设计? 92 | 93 | #### 设计模式相关问题: [[↑]](#toc) 94 | 95 | * 请用一个例子表明,全局对象是邪恶的存在。 96 | * 假设你工作的系统不支持事务性,你会如何从头开始实现它? 97 | * 什么是好莱坞原则(Hollywood Principles)? 98 | * 关于迪米特法则(最少知识原则): 写一段代码违反它, 然后修复它。 99 | 100 | (注: 迪米特法则:the Law of Demeter, 最少知识原则: the Principle of Least Knowledge) 101 | * Active-Record模式有什么限制和缺陷? 102 | * Data-Mapper模式和Active-Record模式有什么区别? 103 | * 空对象模式(Null Object Pattern)的目的是什么? 104 | * 为什么组合(Composition)比继承(Inheritance)更好? 105 | * 什么是反腐败层(Anti-corruption Layer)? 106 | * 你可以写一个线程安全的单例(Singleton)类吗? 107 | * 数据抽象(Data Abstraction)能力是指能改变实现而不影响客户端的这种能力。请构造一个一个例子,违反这个特性,并且尝试修复它。 108 | * 你是如何处理依赖关系地狱(Dependency Hell)的? 109 | * 为什么说goto语句是恶魔般的存在? 110 | * 健壮性是进行软件设计时的一个通用原则,它建议 *“发送时要保守,接收时要开放”*。这也经常被写成,“做一个有耐心的读者,做一个谨慎的作者”。你能解释一些这背后的逻辑吗? 111 | 112 | 译者注: "发送时要保守,接收时要开发"的原文是: "Be conservative in what you send, be liberal in what you accept",有点类似于“严于律己,宽于待人”的意味。 113 | 114 | #### 代码设计相关问题: [[↑]](#toc) 115 | 116 | * 你在进行软件设计时会考虑软件测试吗?软件测试是如何影响软件设计的? 117 | * 内聚和耦合的区别是什么? 118 | * 重构在哪些场景下有用? 119 | * 代码中的注释有用吗? 120 | * 设计和架构有什么区别? 121 | * 为什么在测试驱动开发(TDD)中是先写测试,再写代码? 122 | * C++支持多继承,Java 允许类实现多个接口。这些特性对正交性有什么影响?使用多继承和使用多接口有区别吗?[这个问题来自Andrew .Hunt 和 David Thomas写的《程序员修炼之道》] 123 | * 在存储过程(Stored Procedures)中写业务逻辑有什么优缺点? 124 | 125 | #### 语言相关问题: [[↑]](#toc) 126 | 127 | * 告诉我你的首选语言的三个最坏的缺陷。 128 | * 为什么现在函数式编程这么越来越受关注? 129 | * 闭包是什么?它有什么用途?闭包和类有什么共同点? 130 | * 泛型有什么用途? 131 | * 什么是高阶函数?有什么用途?用你的首选语言写个例子出来。 132 | * 讨论一下,如何写一个循环,然后把它转换成递归函数,要避免易变性。 133 | * 有些语言将函数视为第一公民,这是什么意思? 134 | * 用一个例子说明匿名函数是有用的。 135 | * 什么是动态方法调度(Dynamic Method Dispatch)? 136 | * 名字空间(Namespace)有什么用?有什么可以替代它的吗? 137 | * 谈谈Java和C#之间的互操作性(Interoperability) (任选其他两门语言都行) 138 | * 为什么很多软件工程师不喜欢Java? 139 | * 你认为好的语言好在哪里?差的语言差在哪里? 140 | * 写两个函数,一个是"引用透明的(Referentially Transparent)",另一个是"引用不透明的(Referentially Opaque)"。讨论之。 141 | * 什么是栈?什么是堆? 142 | * 为什么一个语言中,"函数是第一公民"是很重要的? 143 | * 模式匹配(Pattern Matching)和Switch语句(Switch clauses)的区别在哪儿? 144 | * 为什么有些语言设计上没有异常机制?这有什么优缺点? 145 | * 如果`Cat`是一个`Animal`, 那么`TaskCare`是一个`TakeCare`吗? 146 | 147 | #### web相关问题: [[↑]](#toc) 148 | 149 | * 为什么"第一方cookie(first-party cookie)"和"第三方cookie(third-party cookie)"被如此不同的对待? 150 | 151 | #### 数据库相关问题: [[↑]](#toc) 152 | 153 | * 如果要你将一个项目从MySQL迁移至PostgreSQL中,你会如何迁移? 154 | * 为什么```SELECT * FROM table WHERE field = null```不能匹配空的字段? 155 | * 什么是ACID(原子性,一致性,隔离性,持久性)原则? 156 | * 你是如何进行数据库模式(Database schema)迁移的? 157 | * 延迟加载(lazy loading)是如何实现的?什么场景下有用?他有什么缺陷? 158 | * 什么是N+1问题? 159 | * 如何找出应用中开销最大的查询? 160 | 161 | #### 非关系型数据库相关问题: [[↑]](#toc) 162 | 163 | * 什么是最终一致性(Eventual Consistency)? 164 | * 关于CAP理论,举一些CP、AP、CA系统的例子。 165 | * NoSQL是如何解决可伸缩性的挑战的? 166 | * 什么情况下你会使用类似于MongoDB的文档数据库而不是关系型数据库(如Mysql或者PostgreSQL)? 167 | 168 | #### 代码版本管理相关问题: [[↑]](#toc) 169 | 170 | * 为什么在Mercurial或者git中(管理)分支比SVN容易? 171 | * 分散式版本控制系统(比如git),相比集中式版本控制系统(如svn)有哪些优势和劣势? 172 | 173 | (注:集中式版本控制系统: Centralized Version Control Systems;分散式版本控制系统: Distributed Version Control Systems) 174 | 175 | * 能描述一下什么是GitHubFlow和GitFlow工作流吗? 176 | * 什么是rebase? 177 | * 为什么合并操作(merge)在Mercurial和git中比在SVN和CVS中容易? 178 | 179 | #### 并发问题: [[↑]](#toc) 180 | 181 | * 为什么我们需要并发呢?解释一下。 182 | * 为什么测试多线程/并发代码这么困难? 183 | * 什么是竞争条件(Race Condition)?用任何一个语言写一个例子。 184 | * 什么是死锁?用代码解释一下。 185 | * 什么是饿死? 186 | * 什么是Wait-Free算法? 187 | 188 | #### 分布式系统相关问题: [[↑]](#toc) 189 | 190 | * 怎么测试一个分布式系统? 191 | * 什么场景下你会在两个系统中采用异步通信机制? 192 | * 远程过程调用的通用缺点是什么? 193 | * 如果你为了可扩展性和鲁棒性而构建一个分布式的系统,分别在封闭安全的网络环境情况下,和地理上的位置不同但是网络环境不是封闭和安全的情况下,你会考虑什么不同的事情? 194 | * 在Web应用中如何管理容错性?在桌面端呢? 195 | * 在分布式系统中,如何处理故障? 196 | * 让我们来谈谈在网络分区(network partitions)情况下的几种(一致性)解决方案吧。 197 | * 你认为分布式计算中有哪些谬论? 198 | * 你在什么时候会使用Request/Response模式,什么时候使用Publish/Subscribe模式? 199 | 200 | #### 软件生命周期和团队管理相关问题: [[↑]](#toc) 201 | 202 | * 什么是敏捷(Agility)? 203 | * 你是如何处理遗留代码(Legacy Code)的? 204 | * 假设我是你们公司的CEO,请向我解释什么是看板,并且说服我在它上面投资。 205 | * 敏捷(Agility)和瀑布(Waterfall)之间的最大区别是什么? 206 | * 作为团队管理者,你对会议太多这个问题是如何处理的? 207 | * 你会如何处理延期很长时间了的项目? 208 | * "*个体与交互重于过程和工具*"和"*客户协作重于合同谈判*"占了敏捷宣言(Agile Manifesto)的一半,谈论一下这两个观念。 209 | 210 | * 如果你是你们公司的CTO,你会采取什么样的决策? 211 | * 你觉得项目经理有用吗? 212 | * 如果要你组织一个弹性工作制的开发团队(即没有强制工作时间的要求),并且假期制度是"按需休假",你会如何做? 213 | * 你会如何管理一个人员流动非常高的团队?如何在不加薪的条件下说服团队成员不要离开? 214 | * 除了代码之外,你最关注你的同事的哪3项素质? 215 | * 关于代码,你最希望非技术人员能知道的的三件事是什么? 216 | 217 | #### 逻辑和算法相关问题: [[↑]](#toc) 218 | 219 | * 只用LIFO栈如何构造一个FIFO队列?只用FIFO队列如何构造一个LIFO栈? 220 | * 写一段有栈溢出的代码。 221 | * 写一个尾递归版本的阶乘函数。 222 | * 使用任何一个语言,写一个REPL,功能是echo你输入的字符串。然后将它演化成一个逆波兰表达式的计算器。 223 | * 如果需要你设计一个文件系统磁盘碎片整理程序,你会如何设计? 224 | * 写一个生成随机迷宫的程序。 225 | * 写一段有内存泄漏的示例代码。 226 | * 随机生成一个的数字序列,里面每个数字都不同。 227 | * 写一个简单的垃圾回收系统。 228 | * 使用任何一门语言,写一个基本的消息代理。 229 | * 写一个基础的web服务器,然后画一张线路图,展示你将来还想要实现的功能。 230 | * 如何对一个10GB的文件进行排序?如果是10TB的数据,你会采用什么方法? 231 | * 请实现`rnd()`函数 232 | 233 | #### 软件架构相关问题: [[↑]](#toc) 234 | 235 | * 什么情况下缓存是没用的,甚至是危险的? 236 | * 为什么事件驱动的架构能提高可扩展性(scalability)? 237 | * 什么样的代码是可读性强的代码? 238 | * 紧急设计(Emergent Design)和演化架构(Evolutionary Architecture)之间的区别是什么? 239 | * 横向扩展(scale out) vs 纵向扩展(scale up): 有什么区别?分别在什么场景下使用? 240 | * 分布式系统中如何处理"故障切换(failover)"和"用户会话(user session)"? 241 | * 什么是CQRS(Command Query Responsibility Segregation)?他和最早的Command-Query Separation原则有什么区别? 242 | * 什么是三层架构? 243 | * 如何设计一个可扩展性高的系统? 244 | * 处理C10k问题的策略有哪些? 245 | * 如果让你来设计一个去中心化的P2P系统,你会如何设计? 246 | * 为什么CGI的扩展性不好? 247 | * 在设计系统时,你如何防止供应商依赖([Vendor Lock-in](https://sourcemaking.com/antipatterns/vendor-lock-in))? 248 | * 在可扩展性上,发布/订阅(Publish-Subscribe)模式有什么缺点? 249 | * 80年代以后,CPU有哪些变化?这些变化,对编程产生了什么影响? 250 | * 性能生命周期(performace lifecycle)中,你认为哪个部分是需要考虑进去的? 如何管理? 251 | * 除了恶意攻击造成的拒绝服务现象以外,哪些设计或者架构上的问题会导致拒绝服务? 252 | * 性能和可扩展性之间有什么关系? 253 | * 什么时候紧耦合是OK的? 254 | * 一个系统要有什么特征才能适配云计算环境(Cloud Ready)? 255 | * Does unity of design imply an aristocracy of architects? 256 | 257 | #### 面向服务架构(SOA)和微服务(Microservice)相关问题: [[↑]](#toc) 258 | 259 | * 在SOA中,为什么长期存活的事务(Long-lived transation)不被看好,而Saga却被看好? 260 | * SOA和MicroService之间有什么区别? 261 | * 我们来谈谈Web服务的版本管理、版本兼容性、重大变更管理这些事情吧. 262 | * 在saga中事务和补偿操作(compensation operation)之间的区别是什么?在SOA中呢? 263 | * 微服务不能做得太"微",你认为什么时候微服务太"微"了? 264 | * MicroService架构的优劣是什么? 265 | 266 | #### 安全相关问题: [[↑]](#toc) 267 | 268 | * 什么是双因素认证(Two Factor Authentication)?在一个已有的Web应用中,你如何实现这种机制? 269 | 270 | #### 比尔盖茨式问题: [[↑]](#toc) 271 | 272 | * 如果你把一面镜子放在扫描仪上,会发生什么? 273 | * 假设有一个和你完全一样的克隆人,而他是你的上司,你愿意和他工作吗? 274 | * 现在请你面试一下我。 275 | * 为什么Quora上的回答会比Yahoo Answer上的回答好? 276 | * 对手是现代语言,你的任务是要为Cobol辩护,你会如何进行? 277 | * 10年后的你是什么样子? 278 | * 假设你是我老板,我被解雇了。你会如何通知我? 279 | * 我想要重构一个系统,而你想要从头重写。我们来争论一下该怎么弄吧。然后我们反转角色,再争论一下。 280 | * 老板要你对公司撒谎,你的反应是什么? 281 | * 如果你可以穿越到以前,你会给年轻时候的你什么建议? 282 | 283 | #### 代码示例问题: [[↑]](#toc) 284 | 285 | * 这段Javascript函数的输出是什么? 286 | 287 | ```javascript 288 | function hookupevents() { 289 | for (var i = 0; i < 3; i++) { 290 | document.getElementById("button" + i) 291 | .addEventListener("click", function() { 292 | alert(i); 293 | }); 294 | } 295 | } 296 | ``` 297 | 298 | * 关于类型擦除(Type Erasure),这段Java代码的输出是什么?为什么? 299 | 300 | ```java 301 | ArrayList li = new ArrayList(); 302 | ArrayList lf = new ArrayList(); 303 | if (li.getClass() == lf.getClass()) // evaluates to true 304 | System.out.println("Equal"); 305 | ``` 306 | 307 | * 你能指出哪儿有内存泄漏吗? 308 | 309 | ```java 310 | public class Stack { 311 | private Object[] elements; 312 | private int size = 0; 313 | private static final int DEFAULT_INITIAL_CAPACITY = 16; 314 | 315 | public Stack() { 316 | elements = new Object[DEFAULT_INITIAL_CAPACITY]; 317 | } 318 | 319 | public void push(Object e) { 320 | ensureCapacity(); 321 | elements[size++] = e; 322 | } 323 | 324 | public Object pop() { 325 | if (size == 0) 326 | throw new EmptyStackException(); 327 | return elements[--size]; 328 | } 329 | 330 | /** 331 | * Ensure space for at least one more element, roughly 332 | * doubling the capacity each time the array needs to grow. 333 | */ 334 | private void ensureCapacity() { 335 | if (elements.length == size) 336 | elements = Arrays.copyOf(elements, 2 * size + 1); 337 | } 338 | } 339 | ``` 340 | 341 | * `if`语句,或者更加通用点,条件表达式通常是过程式编程/命令式编程的形式。你能去掉这段代码中的`switch`语句,用面向对象的方式来修改这段代码吗? 342 | 343 | ```java 344 | public class Formatter { 345 | 346 | private Service service; 347 | 348 | public Formatter(Service service) { 349 | this.service = service; 350 | } 351 | 352 | public String doTheJob(String theInput) { 353 | String response = service.askForPermission(); 354 | switch (response) { 355 | case "FAIL": 356 | return "error"; 357 | case "OK": 358 | return String.format("%s%s", theInput, theInput); 359 | default: 360 | return null; 361 | } 362 | } 363 | } 364 | ``` 365 | 366 | * 你能去掉这里的`if`语句,将它改成更加面向对象吗? 367 | 368 | ```java 369 | public class TheService { 370 | private final FileHandler fileHandler; 371 | private final FooRepository fooRepository; 372 | 373 | public TheService(FileHandler fileHandler, FooRepository fooRepository) { 374 | this.fileHandler = fileHandler; 375 | this.fooRepository = fooRepository; 376 | } 377 | 378 | public String Execute(final String file) { 379 | 380 | final String rewrittenUrl = fileHandler.getXmlFileFromFileName(file); 381 | final String executionId = fileHandler.getExecutionIdFromFileName(file); 382 | 383 | if ((executionId == "") || (rewrittenUrl == "")) { 384 | return ""; 385 | } 386 | 387 | Foo knownFoo = fooRepository.getFooByXmlFileName(rewrittenUrl); 388 | 389 | if (knownFoo == null) { 390 | return ""; 391 | } 392 | 393 | return knownFoo.DoThat(file); 394 | } 395 | } 396 | ``` 397 | 398 | * 如何重构这段代码? 399 | 400 | ```javascript 401 | function() 402 | { 403 | HRESULT error = S_OK; 404 | 405 | if(SUCCEEDED(Operation1())) 406 | { 407 | if(SUCCEEDED(Operation2())) 408 | { 409 | if(SUCCEEDED(Operation3())) 410 | { 411 | if(SUCCEEDED(Operation4())) 412 | { 413 | } 414 | else 415 | { 416 | error = OPERATION4FAILED; 417 | } 418 | } 419 | else 420 | { 421 | error = OPERATION3FAILED; 422 | } 423 | } 424 | else 425 | { 426 | error = OPERATION2FAILED; 427 | } 428 | } 429 | else 430 | { 431 | error = OPERATION1FAILED; 432 | } 433 | 434 | return error; 435 | } 436 | ``` 437 | 438 | --------------------------------------------------------------------------------