[
  {
    "path": "LICENSE",
    "content": "GNU GENERAL PUBLIC LICENSE\n                       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>\n 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicense is intended to guarantee your freedom to share and change free\nsoftware--to make sure the software is free for all its users.  This\nGeneral Public License applies to most of the Free Software\nFoundation's software and to any other program whose authors commit to\nusing it.  (Some other Free Software Foundation software is covered by\nthe GNU Lesser General Public License instead.)  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthis service if you wish), that you receive source code or can get it\nif you want it, that you can change the software or use pieces of it\nin new free programs; and that you know you can do these things.\n\n  To protect your rights, we need to make restrictions that forbid\nanyone to deny you these rights or to ask you to surrender the rights.\nThese restrictions translate to certain responsibilities for you if you\ndistribute copies of the software, or if you modify it.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must give the recipients all the rights that\nyou have.  You must make sure that they, too, receive or can get the\nsource code.  And you must show them these terms so they know their\nrights.\n\n  We protect your rights with two steps: (1) copyright the software, and\n(2) offer you this license which gives you legal permission to copy,\ndistribute and/or modify the software.\n\n  Also, for each author's protection and ours, we want to make certain\nthat everyone understands that there is no warranty for this free\nsoftware.  If the software is modified by someone else and passed on, we\nwant its recipients to know that what they have is not the original, so\nthat any problems introduced by others will not reflect on the original\nauthors' reputations.\n\n  Finally, any free program is threatened constantly by software\npatents.  We wish to avoid the danger that redistributors of a free\nprogram will individually obtain patent licenses, in effect making the\nprogram proprietary.  To prevent this, we have made it clear that any\npatent must be licensed for everyone's free use or not licensed at all.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                    GNU GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License applies to any program or other work which contains\na notice placed by the copyright holder saying it may be distributed\nunder the terms of this General Public License.  The \"Program\", below,\nrefers to any such program or work, and a \"work based on the Program\"\nmeans either the Program or any derivative work under copyright law:\nthat is to say, a work containing the Program or a portion of it,\neither verbatim or with modifications and/or translated into another\nlanguage.  (Hereinafter, translation is included without limitation in\nthe term \"modification\".)  Each licensee is addressed as \"you\".\n\nActivities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning the Program is not restricted, and the output from the Program\nis covered only if its contents constitute a work based on the\nProgram (independent of having been made by running the Program).\nWhether that is true depends on what the Program does.\n\n  1. You may copy and distribute verbatim copies of the Program's\nsource code as you receive it, in any medium, provided that you\nconspicuously and appropriately publish on each copy an appropriate\ncopyright notice and disclaimer of warranty; keep intact all the\nnotices that refer to this License and to the absence of any warranty;\nand give any other recipients of the Program a copy of this License\nalong with the Program.\n\nYou may charge a fee for the physical act of transferring a copy, and\nyou may at your option offer warranty protection in exchange for a fee.\n\n  2. You may modify your copy or copies of the Program or any portion\nof it, thus forming a work based on the Program, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) You must cause the modified files to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    b) You must cause any work that you distribute or publish, that in\n    whole or in part contains or is derived from the Program or any\n    part thereof, to be licensed as a whole at no charge to all third\n    parties under the terms of this License.\n\n    c) If the modified program normally reads commands interactively\n    when run, you must cause it, when started running for such\n    interactive use in the most ordinary way, to print or display an\n    announcement including an appropriate copyright notice and a\n    notice that there is no warranty (or else, saying that you provide\n    a warranty) and that users may redistribute the program under\n    these conditions, and telling the user how to view a copy of this\n    License.  (Exception: if the Program itself is interactive but\n    does not normally print such an announcement, your work based on\n    the Program is not required to print an announcement.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Program,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Program, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote it.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Program.\n\nIn addition, mere aggregation of another work not based on the Program\nwith the Program (or with a work based on the Program) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may copy and distribute the Program (or a work based on it,\nunder Section 2) in object code or executable form under the terms of\nSections 1 and 2 above provided that you also do one of the following:\n\n    a) Accompany it with the complete corresponding machine-readable\n    source code, which must be distributed under the terms of Sections\n    1 and 2 above on a medium customarily used for software interchange; or,\n\n    b) Accompany it with a written offer, valid for at least three\n    years, to give any third party, for a charge no more than your\n    cost of physically performing source distribution, a complete\n    machine-readable copy of the corresponding source code, to be\n    distributed under the terms of Sections 1 and 2 above on a medium\n    customarily used for software interchange; or,\n\n    c) Accompany it with the information you received as to the offer\n    to distribute corresponding source code.  (This alternative is\n    allowed only for noncommercial distribution and only if you\n    received the program in object code or executable form with such\n    an offer, in accord with Subsection b above.)\n\nThe source code for a work means the preferred form of the work for\nmaking modifications to it.  For an executable work, complete source\ncode means all the source code for all modules it contains, plus any\nassociated interface definition files, plus the scripts used to\ncontrol compilation and installation of the executable.  However, as a\nspecial exception, the source code distributed need not include\nanything that is normally distributed (in either source or binary\nform) with the major components (compiler, kernel, and so on) of the\noperating system on which the executable runs, unless that component\nitself accompanies the executable.\n\nIf distribution of executable or object code is made by offering\naccess to copy from a designated place, then offering equivalent\naccess to copy the source code from the same place counts as\ndistribution of the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  4. You may not copy, modify, sublicense, or distribute the Program\nexcept as expressly provided under this License.  Any attempt\notherwise to copy, modify, sublicense or distribute the Program is\nvoid, and will automatically terminate your rights under this License.\nHowever, parties who have received copies, or rights, from you under\nthis License will not have their licenses terminated so long as such\nparties remain in full compliance.\n\n  5. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Program or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Program (or any work based on the\nProgram), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Program or works based on it.\n\n  6. Each time you redistribute the Program (or any work based on the\nProgram), the recipient automatically receives a license from the\noriginal licensor to copy, distribute or modify the Program subject to\nthese terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties to\nthis License.\n\n  7. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Program at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Program by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Program.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system, which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  8. If the distribution and/or use of the Program is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Program under this License\nmay add an explicit geographical distribution limitation excluding\nthose countries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n  9. The Free Software Foundation may publish revised and/or new versions\nof the General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Program\nspecifies a version number of this License which applies to it and \"any\nlater version\", you have the option of following the terms and conditions\neither of that version or of any later version published by the Free\nSoftware Foundation.  If the Program does not specify a version number of\nthis License, you may choose any version ever published by the Free Software\nFoundation.\n\n  10. If you wish to incorporate parts of the Program into other free\nprograms whose distribution conditions are different, write to the author\nto ask for permission.  For software which is copyrighted by the Free\nSoftware Foundation, write to the Free Software Foundation; we sometimes\nmake exceptions for this.  Our decision will be guided by the two goals\nof preserving the free status of all derivatives of our free software and\nof promoting the sharing and reuse of software generally.\n\n                            NO WARRANTY\n\n  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\nFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\nOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\nPROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\nTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\nPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\nREPAIR OR CORRECTION.\n\n  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\nREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\nOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\nTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\nYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\nPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    {description}\n    Copyright (C) {year}  {fullname}\n\n    This program is free software; you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation; either version 2 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License along\n    with this program; if not, write to the Free Software Foundation, Inc.,\n    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n\nAlso add information on how to contact you by electronic and paper mail.\n\nIf the program is interactive, make it output a short notice like this\nwhen it starts in an interactive mode:\n\n    Gnomovision version 69, Copyright (C) year name of author\n    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, the commands you use may\nbe called something other than `show w' and `show c'; they could even be\nmouse-clicks or menu items--whatever suits your program.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the program, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the program\n  `Gnomovision' (which makes passes at compilers) written by James Hacker.\n\n  {signature of Ty Coon}, 1 April 1989\n  Ty Coon, President of Vice\n\nThis General Public License does not permit incorporating your program into\nproprietary programs.  If your program is a subroutine library, you may\nconsider it more useful to permit linking proprietary applications with the\nlibrary.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License."
  },
  {
    "path": "README.md",
    "content": "Back-End Developer Interview Questions\n======================================\n\nThis page has been translated to [Chinese](https://github.com/monklof/Back-End-Developer-Interview-Questions) by [monklof](https://github.com/monklof).\n\nI started writing down this list as my personal notes of topics I discussed with colleagues and friends, and that I wanted to deepen...\n\nI'm not a big fan of asking technical questions in job interviews: I rather prefer to sit together with candidates in front of some real code, hands on the keyboard, facing a real problem, and to have a full day of pair programming, hopefully rotating with all the other team members. It is one of the best opportunities to know each others' style and to let candidates know some details about their future job.\n\nYet, I feel some categories of technical questions could be a good starting point to begin an engaging conversation. \n\nThis repo collects a number of back-end related questions that can be used when vetting potential candidates. It is by no means recommended to use every single question on the same candidate: that would take hours, and would have no sense at all, as they cover a too broad set of topics for a single developer's to possibly know. Browse the section you find more relevant for your context, and pick the questions that give you more ideas on the conversation to have.\n\nThis project is admittedly inspired by [Front-end Job Interview Questions](https://github.com/darcyclarke/Front-end-Developer-Interview-Questions) by [@darcyclarke](https://github.com/darcyclarke)\n\n## Where are the answers?\nI didn't include any.<br/>\nMost of the questions are open-ended, and some of them just don't have a *right* or a *wrong* answer. On the contrary, they are intended to be used as the starting point for a conversation that hopefully tells you more about the person's capabilities than a straight answer would. Personally, I would even choose the questions whose answers are not yet clear to me.\n\nFeel free to open a [Discussion](https://github.com/arialdomartini/Back-End-Developer-Interview-Questions/discussions).\n\n\n\n\n\n## <a name='toc'>Table of Contents</a>\n\n* [Questions about Design Patterns](#patterns)\n  * [Globals Are Evil](#globals-are-evil)\n  * [Inversion of Control](#inversion-of-control)\n  * [Law of Demeter](#law-of-demeter)\n  * [Active-Record](#active-record)\n  * [Data-Mapper](#data-mapper)\n  * [Billion-Dollar Mistake](#billion-dollar-mistake)\n  * [Inheritance vs Composition](#inheritance-vs-composition)\n  * [Anti-Corruption Layer](#anti-corruption-layer)\n  * [Singleton](#singleton)\n  * [Data Abstraction](#data-abstraction)\n  * [Don't Repeat Yourself](#dont-repeat-yourself)\n  * [Dependency Hell](#dependency-hell)\n  * [Goto Is Evil](#goto-is-evil)\n  * [Robustness Principle](#robustness-principle)\n  * [Separation of Concerns](#separation-of-concerns)\n\n* [Questions about Code Design](#design)\n  * [High Cohesion, Loose Coupling](#high-cohesion-loose-coupling)\n  * [Index 0](#index-0)\n  * [TDD](#tdd)\n  * [DRY Violation](#dry-violation)\n  * [Cohesion vs Coupling](#cohesion-vs-coupling)\n  * [Refactoring](#refactoring)\n  * [Code Comments](#code-comments)\n  * [Design vs Architecture](#design-vs-architecture)\n  * [Early Testing](#early-testing)\n  * [Multiple Inheritance](#multiple-inheritance)\n  * [Domain Logic in Stored Procedures](#domain-logic-in-stored-procedures)\n  * [OOP Took Over the World](#oop-took-over-the-world)\n  * [Bad Design](#bad-design)\n\n* [Questions about languages](#languages)\n  * [3 Worst Defects](#3-worst-defects)\n  * [Functional Programming](#functional-programming)\n  * [Closures](#closures)\n  * [Generics](#generics)\n  * [High-Order Functions](#high-order-functions)\n  * [Loops and Recursion](#loops-and-recursion)\n  * [Functions as First-Class Citizens](#functions-as-first-class-citizens)\n  * [Anonymous Functions](#anonymous-functions)\n  * [Static and Dynamic Typing](#static-and-dynamic-typing)\n  * [Namespaces](#namespaces)\n  * [Language Interoperability](#language-interoperability)\n  * [Hate of Java](#hate-of-java)\n  * [Good and Bad Languages](#good-and-bad-languages)\n  * [Referential Transparency](#referencial-transparency)\n  * [Stack and Heap](#stack-and-heap)\n  * [Pattern Matching](#pattern-matching)\n  * [Exceptions](#exceptions)\n  * [Variant and Contravariant Inheritance](#variant-and-contravariant-inheritance)\n  * [Constructors and Interfaces](#constructors-and-interfaces)\n  * [Node.js](#node-js)\n  * [Java and Time Traveling](#java-and-time-traveling)\n  * [Eliminate Null](#eliminate-null)\n\n* [Web Questions](#web)\n  * [3rd Party Cookies](#3rd-party-cookies)\n  * [API Versioning](#api-versioning)\n  * [SPAs](#spas)\n  * [Statelessness](#statelessness)\n  * [REST vs SOAP](#rest-vs-soap)\n  * [MVC and MVVM](#mvc-and-mvvm)\n\n* [Databases Questions](#databases)\n  * [DB Migrations](#db-migrations)\n  * [NULL is special](#null-is-special)\n  * [ACID](#acid)\n  * [Schema Migrations](#schema-migrations)\n  * [Lazy Loading](#lazy-loading)\n  * [N+1 Problem](#n1-problem)\n  * [Slowest Queries](#slowest-queries)\n  * [Normalization](#normalization)\n  * [Blue/Green Deployment](#bluegreen-deployment)\n\n* [NoSQL Questions](#nosql)\n  * [Eventual Consistency](#eventual-consistency)\n  * [CAP Theorem](#cap-theorem)\n  * [NoSql](#nosql)\n  * [NoSQL and Scalability](#nosql-and-scalability)\n  * [Document and Relational DBs](#document-and-relational-dbs)\n\n* [Code Versioning Questions](#codeversioning)\n  * [Branching in HG and in Git](#branching-in-hg-and-in-git)\n  * [DVCS](dvcs)\n  * [GitFlow and GitHubFlow](#gitflow-and-githubflow)\n  * [Rebase](#rebase)\n  * [Merging in HG and in Git](#merging-in-hg-and-in-git)\n\n* [Questions about Concurrency](#concurrency)\n  * [Why?](#why)\n  * [Testing Concurrency](#testing-concurrency)\n  * [Race Conditions](#race-conditions)\n  * [Deadlocks](#deadlocks)\n  * [Process Starvation](#process-starvation)\n  * [Free Algorithm](#free-algorithm)\n\n* [Questions about Distributed Systems](#distributed)\n  * [Testing Distributed Systems](#testing-distributed-systems)\n  * [Async Communication](#async-communication)\n  * [Pitfalls of RPC](#pitfalls-of-rpc)\n  * [Design of Distributed Systems](#design-of-distributed-systems)\n  * [Fault Tolerance](#fault-tolerance)\n  * [Failures](#failures)\n  * [Network Partitions](#network-partitions)\n  * [Fallacies of Distributed Computing](#fallacies-of-distibuted-computing)\n  * [Request/Reply vs Publish/Subscribe](#requestreply-vs-publishsubscribe)\n  * [Implement Transactions](#implement-transactions)\n\n* [Questions about Software Lifecycle and Team Management](#management)\n  * [Agility](#agility)\n  * [Legacy Code](#legacy-code)\n  * [Legacy Code ELI5](#legacy-code-eli5)\n  * [Sell me Kanban](#sell-me-kanban)\n  * [Agile vs Waterfall](#agile-vs-waterfall)\n  * [Death by Meetings](#death-by-meetings)\n  * [Late Projects](#late-projects)\n  * [Agile Manifesto](#agile-manifesto)\n  * [If I were the CTO](#if-i-were-the-cto)\n  * [PMs](#pms)\n  * [Team Organization](#team-organization)\n  * [Turn Over](#turn-over)\n  * [Qualities](#qualities)\n  * [3 Things About Code](#3-things-about-code)\n  * [1 Month's Revolution](#1-months-revolution)\n\n* [Questions about logic and algorithms](#algorithms)\n  * [FIFO with LIFO](#fifo-with-lifo)\n  * [Stack Overflow](#stack-overflow)\n  * [Tail Recursive n!](#tail-recursive-n)\n  * [REPL](#repl)\n  * [Defragger](#defragger)\n  * [Mazes](#mazes)\n  * [Memory Leaks](#memory-leaks)\n  * [PRNG](#prng)\n  * [Garbage Collecting](#garbage-collecting)\n  * [Queues](#queues)\n  * [Simple Web Server](#simple-web-server)\n  * [Sorting Huge Files](#sorting-huge-files)\n  * [Duplicates](#duplicates)\n\n* [Questions about Software Architecture](#architecture)\n  * [No Cache](#no-cache)\n  * [Event-Driven Architecture](#event-driven-architecture)\n  * [Readability](#readability)\n  * [Emergent and Evolutionary](#emergent-and-evolutionary)\n  * [Scale-Out, Scale-Up](#scale-out-scale-up)\n  * [Failures User Sessions](#failures-user-sessions)\n  * [CQRS](#cqrs)\n  * [n-tier](#n-tier)\n  * [Scalability](#scalability)\n  * [C10K](#c10k)\n  * [P2P](#p2p)\n  * [CGI](#cgi)\n  * [Vendor Lock-in](#vendor-lock-in)\n  * [Pub/Sub](#pubsub)\n  * [CPUs](#cpus)\n  * [Performance](#performance)\n  * [DDOS](#ddos)\n  * [Performance and Scalability](#performance-and-scalability)\n  * [Tight Coupling](#tight-coupling)\n  * [Cloud Readiness](#cloud-readiness)\n  * [Emergent Architecture](#emergent-architecture)\n  * [Design, Architecture, Functionality, Aesthetic](#design-architecture-functionality-aesthetic)\n\n* [Questions about Service Oriented Architecture and Microservices](#soa)\n  * [Long-lived Transactions](#long-lived-transactions)\n  * [SOA and Micro Services](#soa-and-micro-services)\n  * [Versioning and Breaking Changes](#versioning-and-breaking-changes)\n  * [Sagas and compensations](#sagas-and-compensations)\n  * [Too Micro](#too-micro \"Too Micro\")\n  * [Micro Services Architecture](#micro-services-architecture)\n\n* [Questions about Security](#security)\n  * [Security by Default](#security-by-default)\n  * [Don't Invent Cryptography](#dont-invent-cryptography)\n  * [2-FA](#2-fa)\n  * [Confidential Data in Logs](#confidential-data-in-logs)\n  * [SQL Injection](#sql-injection)\n  * [Detect SQL Injection](#detect-sql-injection)\n  * [XSS](#xss)\n  * [Cross-Site Forgery Attack](#cross-site-forgery-attack)\n  * [HTTPS](#https)\n  * [MITM Attack](#mitm-attack)\n  * [Stealing Sessions](#stealing-sessions)\n\n* [General Questions](#general)\n  * [Why FP?](#why-fp)\n  * [Browsers](#browsers)\n  * [TCP Sockets](#tcp-sockets)\n  * [Encapsulation](#encapsulation)\n  * [Real-time systems](#real-time-systems)\n  * [Real-time and memory allocation](#real-time-and-memory-allocation)\n  * [Immutability](#immutability)\n  * [Mutable vs Immutable](#mutable-vs-immutable)\n  * [Object-Relational Impedance Mismatch](#object-relational-impedance-mismatch)\n  * [Sizing a Cache](#sizing-a-cache)\n  * [TCP and HTTP](#tcp-and-http)\n  * [Client-Side vs Server-Side](#client-side-vs-server-side)\n  * [Reliable and non-reliable channels](#reliable-and-non-reliable-channels)\n\n* [Open Questions](#open)\n  * [Resistance to Change](#resistance-to-change)\n  * [Threading ELI5](#threading-eli5)\n  * [Innovation and Predictability](#innovation-and-predictability)\n  * [Good Code](#good-code)\n  * [Streaming](#streaming)\n  * [1 Week Improvement](#1-week-improvement)\n  * [Learnt this week](#learnt-this-week)\n  * [Aesthetic](#aesthetic)\n  * [Last 5 books](#last-5-books)\n  * [Introducing CI/CD](#introducing-cicd)\n  * [Reinvent the Wheel](#reinvent-the-wheel)\n  * [Not Invented Here](#not-invented-here)\n  * [Next Thing to Automate](#next-thing-to-automate)\n  * [Coding is Hard](#coding-is-hard)\n  * [Green Fields and Brown Fields](#green-fields-and-brown-fields)\n  * [Type \"Google.com\"](#type-googlecom)\n  * [While idle](#while-idle)\n  * [Unicode](#unicode)\n  * [Defending Monoliths](#defending-monoliths)\n  * [Professional Developers](#professional-developers)\n  * [It's an art](#its-an-art)\n  * [People who like this also like...](#people-who-like-this-also-like)\n  * [Corporations vs Startups](#corporations-vs-startups)\n  * [I'm proud of](#im-proud-of)\n\n* [Questions based on snippets of code](#snippets)\n  * [Beware the Closure](#beware-the-closure)\n  * [Type Erasure](#type-erasure)\n  * [Memory Leak](#memory-leak)\n  * [Kill the switch](#kill-the-switch)\n  * [Kill the if](#kill-the-if)\n  * [Kill the if-chain](#kill-the-if-chain)\n\n* [Bill Gates Style Questions](#billgates)\n  * [Mirrors](#mirrors)\n  * [Clones](#clones)\n  * [Revert](#revert)\n  * [Quora](#quora)\n  * [Cobol](#cobol)\n  * [10 years](#10-years)\n  * [Fire me](#fire-me)\n  * [From scratch](#from-scratch)\n  * [Telling lies](#telling-lies)\n  * [Your past self](#your-past-self)\n\n\n\n\n### [[↑]](#toc) <a name='patterns'>Questions about Design Patterns:</a>\n#### Globals Are Evil\nWhy are global and static objects evil? Can you show it with a code example?\n\n#### Inversion of Control\nTell me about Inversion of Control and how it improves the design of code.<br/>\n[Resources](design-patterns/inversion-of-control.md)\n\n\n#### Law of Demeter\nThe Law of Demeter (the Principle of Least Knowledge) states that each unit should have only limited knowledge about other units and it should only talk to its immediate friends (sometimes stated as \"don't talk to strangers\").<br/>\nWould you write code violating this principle, show why it is a bad design and then fix it?<br/>\n[Resources](design-patterns/law-of-demeter.md)\n\n#### Active-Record\nActive-Record is the design pattern that promotes objects to include functions such as Insert, Update, and Delete, and properties that correspond to the columns in some underlying database table. In your opinion and experience, which are the limits and pitfalls of the this pattern?<br/>\n[Resources](design-patterns/active-record.md)\n\n#### Data-Mapper\nData-Mapper is a design pattern that promotes the use of a layer of Mappers that moves data between objects and a database while keeping them independent of each other and the mapper itself. On the contrary, in Active-Record objects directly incorporate operations for persisting themselves to a database, and properties corresponding to the underlying database tables. Do you have an opinion on those patterns? When would you use one instead of the other?\n\n#### Billion Dollar Mistake\n[Tony Hoare](https://en.m.wikipedia.org/wiki/Tony_Hoare) who invented the null reference once said \"*I call it my billion-dollar mistake*\" since it led to \"*innumerable errors, vulnerabilities, and system crashes, which have probably caused a billion dollars of pain and damage in the last forty years*\".\n\nWould you discuss the techniques to avoid it, such as the Null Object Pattern introduced by the GOF book, or Option types?\n\n#### Inheritance vs Composition\nMany state that, in Object-Oriented Programming, composition is often a better option than inheritance. What's you opinion?\n\n#### Anti-Corruption Layer\nWhat is an Anti-corruption Layer?\n\n#### Singleton\nSingleton is a design pattern that restricts the instantiation of a class to one single object. Writing a Thread-Safe Singleton class is not so obvious. Would you try?\n\n#### Data Abstraction\nThe ability to change implementation without affecting clients is called Data Abstraction. Produce an example violating this property, then fix it.\n\n#### Don't Repeat Yourself\nWrite a snippet of code violating the Don't Repeat Yourself (DRY) principle. Then, fix it.\n\n#### Dependency Hell\nHow would you deal with Dependency Hell?\n\n#### Goto is Evil\nIs goto evil? You may have heard of the famous paper \"Go To Statement Considered Harmful\" by Edsger Dijkstra, in which he criticized the use of the `goto` statement and advocated structured programming instead. The use of `goto` has always been controversial, so much that even Dijkstra's letter was criticized with articles such as \"'GOTO Considered Harmful' Considered Harmful\". What's your opinion on the use of `goto`?\n\n#### Robustness Principle\nThe robustness principle is a general design guideline for software that recommends \"*be conservative in what you send, be liberal in what you accept*\". It is often reworded as \"*be a tolerant reader and a careful writer*\". Would you like to discuss the rationale of this principle?\n\n#### Separation of Concerns\nSeparation of Concerns is a design principle for separating a computer program into distinct areas, each one addressing a separate concern. There are a lot of different mechanisms for achieving Separation of Concerns (use of objects, functions, modules, or patterns such as MVC and the like). Would you discuss this topic?\n\n\n### [[↑]](#toc) <a name='design'>Questions about Code Design:</a>\n\n#### High Cohesion, Loose Coupling\nIt is often said that one of the most important goals in Object-Oriented Design (and code design in general) is to have High Cohesion and Loose Coupling. What does it mean? Why is it that important and how is it achieved?\n\n#### Index 0\nWhy do array indexes start with '0' in most languages?\n\n#### TDD\nHow do tests and TDD influence code design?\n\n#### DRY Violation\nWrite a snippet of code violating the Don't Repeat Yourself (DRY) principle. Then, explain why it is a bad design, and fix it.\n\n#### Cohesion vs Coupling\nWhat's the difference between cohesion and coupling?\n\n#### Refactoring\nWhat is refactoring useful for?\n\n#### Code Comments\nAre comments in code useful? Some say they should be avoided as much as possible, and hopefully made unnecessary. Do you agree?\n\n#### Design vs Architecture\nWhat is the difference between design and architecture?\n\n#### Early Testing\nIn TDD, why are tests written before code?\n\n#### Multiple Inheritance\nC++ supports multiple inheritance, and Java allows a class to implement multiple interfaces. What impact does using these facilities have on orthogonality? Is there a difference in impact between using multiple inheritance and multiple interfaces? Is there a difference between using delegation and using inheritance? [This question is from The Pragmatic Programmer, by Andrew Hunt and David Thomas]\n\n#### Domain Logic in Stored Procedures\nWhat are the pros and cons of holding domain logic in Stored Procedures?\n\n#### OOP Took Over the World\nIn your opinion, why has Object-Oriented Design dominated the market for so many years?\n\n#### Bad Design\nWhat would you do to understand if your code has a bad design?\n\n\n### [[↑]](#toc) <a name='languages'>Questions about Languages:</a>\n\n#### 3 worst defects\nTell me the 3 worst defects of your preferred language\n\n#### Functional Programming\nWhy is there a rising interest on Functional Programming?\n\n#### Closures\nWhat is a closure, and what is useful for? What's in common between closures and classes?\n\n#### Generics\nWhat are generics useful for?\n\n#### High-Order Functions\nWhat are higher-order functions? What are they useful for? Write one, in your preferred language.\n\n#### Loops and Recursion\nWrite a loop, then transform it into a recursive function, using only immutable structures (i.e. avoid using variables). Discuss.\n\n#### Functions as First-Class Citizens\nWhat does it mean when a language treats functions as first-class citizens?\nWhy is it important that in a language functions are first-class citizens?\n\n#### Anonymous Functions\nShow me an example where an anonymous function can be useful.\n\n#### Static and Dynamic typing\nThere are a lot of different type systems. Let's talk about static and dynamic type systems, and about strong and weak ones. You surely have an opinion and a preference about this topic. Would you like to share them, and discuss why and when would you promote one particular type system for developing an enterprise software?\n\n#### Namespaces\nWhat are namespaces useful for? Invent an alternative.\n\n#### Language Interoperability\nTalk about interoperability between Java and C# (in alternative, choose 2 other arbitrary languages)\n\n#### Hate of Java\nWhy do many software engineers not like Java?\n\n#### Good and Bad Languages\nWhat makes a good language good and a bad language bad?\n\n#### Referential Transparency\nWrite two functions, one referentially transparent and the other one referentially opaque. Discuss.\n\n#### Stack and Heap\nWhat is a stack and what is a heap? What's a stack overflow?\n\n#### Pattern Matching\nSome languages, especially the ones that promote a functional approach, allow a technique called pattern matching. Do you know it? How is pattern matching different from switch clauses?\n\n#### Exceptions\nWhy do some languages have no exceptions by design? What are the pros and cons?\n\n#### Variant and Contravariant Inheritance\nIf `Cat` is an `Animal`, is `TakeCare<Cat>` a `TakeCare<Animal>`?\n\n#### Constructors and Interfaces\nIn Java, C# and many other languages, why are constructors not part of the interface?\n\n#### Node.js\nIn the last years there has been a lot of hype around Node.js. What's your opinion on using a language that was initially conceived to run in the browser in the backend?\n\n#### Java and time-traveling\n* Pretend you have a time machine and pretend that you have the opportunity to go to a particular point in time during Java's (or C#, Python, Go or whatever) history, and talk with some of the JDK architects. What would you try to convince them of? Removing checked exceptions? Adding unsigned primitives? Adding multiple-inheritance?\n#### Eliminate Null\nImagine you want to remove the possibility to have null references in your preferred language: how would you achieve this goal? What consequences would this have?\n\n\n### [[↑]](#toc) <a name='web'>Questions about Web development:</a>\n\n#### 3rd Party Cookies\nWhy are first-party cookies and third-party cookies treated so differently?\n\n#### API Versioning\nHow would you manage Web Services API versioning?\n\n#### SPAs\nFrom a backend perspective, are there any disadvantages or drawbacks on the adoption of Single Page Applications?\n\n#### Statelessness\nWhy do we usually put so much effort for having stateless services? What's so good in stateless code and why and when is statefulness bad?\n\n#### REST vs SOAP\nREST and SOAP: when would you choose one, and when the other?\n\n#### MVC and MVVM\nIn web development, Model-View Controller and Model-View-View-Model approaches are very common, both in the backend and in the frontend. What are they, and why are they advisable?\n\n\n### [[↑]](#toc) <a name='databases'>Questions about Databases:</a>\n\n#### DB Migrations\nHow would you migrate an application from a database to another, for example from MySQL to PostgreSQL? If you had to manage that project, which issues would you expect to face?\n\n#### NULL is special\nWhy do databases treat null as a so special case? For example, why does ```SELECT * FROM table WHERE field = null``` not match records with null ``field`` in SQL?\n\n#### ACID\nACID is an acronym that refers to Atomicity, Consistency, Isolation and Durability, 4 properties guaranteed by a database transaction in most database engines. What do you know about this topic? Would you like to elaborate?\n\n#### Schema Migrations\nHow would you manage database schema migrations? That is, how would you automate changes to database schema, as the application evolves, version after version?\n\n#### Lazy Loading\nHow is lazy loading achieved? When is it useful? What are its pitfalls?\n\n#### N+1 Problem\nThe so called \"N + 1 problem\" is an issue that occurs when code needs to load the children of a parent-child relationship with a ORMs that have lazy-loading enabled, and that therefore issue a query for the parent record, and then one query for each child record. How to fix it?\n\n#### Slowest Queries\nHow would you find the most expensive queries in an application?\n\n#### Normalization\nIn your opinion, is it always needed to use database normalization? When is it advisable to use denormalized databases?\n\n#### Blue/Green Deployment\nOne of the Continuous Integration's techniques is called Blue-Green Deployment: it consists in having two production environments, as identical as possible, and in performing the deployment in one of them while the other one is still operating, and than in safely switching the traffic to the second one after some convenient testing. This technique becomes more complicated when the deployment includes changes to the database structure or content. I'd like to discuss this topic with you.\n\n\n### [[↑]](#toc) <a name='nosql'>Questions about NoSQL:</a>\n\n#### Eventual Consistency\nWhat is eventual consistency?\n\n#### CAP Theorem\nBrewer's Theorem, most commonly known as the CAP theorem, states that in the presence of a network partition (the P in CAP), a system's designer has to choose between consistency (the C in CAP) and availability (the A in CAP). Can you think about examples of CP, AP and CA systems?\n\n#### NoSQL\nHow would you explain the recent rise in interest in NoSQL?\n\n#### NoSQL and Scalability\nHow does NoSQL tackle scalability challenges?\n\n#### Document and Relational DBs\nWhen would you use a document database like MongoDB instead of a relational database like MySQL or PostgreSQL?\n\n\n### [[↑]](#toc) <a name='codeversioning'>Questions about code versioning:</a>\n\n#### Branching in HG and in Git\nWhy is branching with Mercurial or git easier than with SVN?\n \n#### DVCS\nWhat are the pros and cons of distributed version control systems like Git over centralized ones like SVN?\n\n#### GitFlow and GitHubFlow\nCould you describe GitHub Flow and GitFlow workflows?\n\n#### Rebase\nWhat's a rebase?\n\n#### Merging in HG and in Git\nWhy are merges easier with Mercurial and Git than with SVN and CVS?\n\n\n### [[↑]](#toc) <a name='concurrency'>Questions about Concurrency:</a>\n\n#### Why?\nWhy do we need concurrency, anyway? Explain.\n\n#### Testing Concurrency\nWhy is testing multithreaded/concurrent code so difficult?\n\n#### Race Conditions\nWhat is a race condition? Code an example, using whatever language you like.\n\n#### Deadlocks\nWhat is a deadlock? Would you be able to write some code that is affected by deadlocks?\n\n#### Process Starvation\nWhat is process starvation? If you need, let's review its definition.\n\n#### Free Algorithm\nWhat is a wait free algorithm?\n\n\n### [[↑]](#toc) <a name='distributed'>Questions about Distributed Systems:</a>\n\n#### Testing Distributed Systems\nHow would you test a distributed system?\n\n#### Async Communication\nWhen would you apply asynchronous communication between two systems?\n\n#### Pitfalls of RPC\nWhat are the general pitfalls of remote procedure calls?\n\n#### Design of Distributed Systems\nIf you are building a distributed system for scalability and robustness, what are the different things you'd think of if you are working in a closed and secure network environment versus when you are working in a geographically distributed and public system?\n\n#### Fault Tolerance\nHow would you manage fault tolerance in a web application? What about in a desktop one?\n\n#### Failures\nHow would you deal with failures in a distributed system?\n\n#### Network Partitions\nLet's talk about the several approaches to reconciliation after network partitions.\n\n#### Fallacies of Distributed Computing\nWhat are the fallacies of distributed computing?\n\n#### Request/Reply vs Publish/Subscribe\nWhen would you use request/reply and when publish/subscribe?\n\n#### Implement Transactions\nSuppose the system you are working on does not support transactionality. How would you implement it from scratch?\n\n\n### [[↑]](#toc) <a name='management'>Questions about Software Lifecycle and Team Management:</a>\n\n#### Agility\nWhat is agility?\n\n#### Legacy Code\nHow would you deal with legacy code?\n\n#### Legacy Code ELI5\nSay I'm your project manager, and I'm no expert in programming. Would you try explaining to me what legacy code is and why should I care about code quality?\n\n#### Sell me Kanban\nI'm the CEO of your company. Explain to me Kanban and convince me to invest in it.\n\n#### Agile vs Waterfall\nWhat is the biggest difference between Agile and Waterfall?\n\n#### Death by Meetings\nBeing a team manager, how would you deal with the problem of having too many meetings?\n\n#### Late Projects\nHow would you manage a very late project?\n\n#### Agile Manifesto\n\"*Individuals and interactions over processes and tools*\" and \"*Customer collaboration over contract negotiation*\" comprise half of the values of the Agile Manifesto. Discuss\n\n#### If I were the CTO\nTell me what decisions would you take if you could be the CTO of your Company.\n\n#### PMs\nAre program managers useful?\n\n#### Team Organization\nOrganize a development team using flexible schedules (that is, no imposed working hours) and \"take as you need\" vacation policy\n\n#### Turn Over\nHow would you manage a very high turn over and convince developers not to leave the team, without increasing compensation? What could a company improve to make them stay?\n\n#### Qualities\nWhat are the top 3 qualities you look for in colleagues, beyond their code?\n\n#### 3 Things About Code\nWhat are the top 3 things you wish non-technical people knew about code?\n\n#### 1 month's revolution\nImagine your company gives you 1 month and some budget to improve your and your colleagues' daily life. What would you do?\n\n\n### [[↑]](#toc) <a name='algorithms'>Questions about logic and algorithms:</a>\n\n#### FIFO with LIFO\nMake a FIFO queue using only LIFO stacks. Then build a LIFO stack using only FIFO queues.\n\n#### Stack Overflow\nWrite a snippet of code affected by a stack overflow.\n\n#### Tail Recursive n!\nWrite a tail-recursive version of the factorial function.\n#### REPL\nUsing your preferred language, write a REPL that echoes your inputs. Evolve it to make it an RPN calculator.\n\n#### Defragger\nHow would you design a \"defragger\" utility?\n\n#### Mazes\nWrite a program that builds random mazes.\n\n#### Memory Leaks\nWrite a sample program that produces a memory leak.\n\n#### PRNG\nGenerate a sequence of unique random numbers.\n\n#### Garbage Collecting\nWrite a simple garbage collection system.\n\n#### Queues\nWrite a basic message broker, using whatever language you like.\n\n#### Simple Web Server\nWrite a very basic web server. Draw a road map for features to be implemented in the future.\n\n#### Sorting Huge Files\nHow would you sort a 10GB file? How would your approach change with a 10TB one?\n\n#### Duplicates\nHow would you programmatically detect file duplicates?\n\n### [[↑]](#toc) <a name='architecture'>Questions about Software Architecture:</a>\n\n#### No Cache\nWhen is a cache not useful or even dangerous?\n\n#### Event-Driven Architecture\nWhy does Event-Driven Architecture improve scalability?\n\n#### Readability\nWhat makes code readable?\n\n#### Emergent and Evolutionary\nWhat is the difference between emergent design and evolutionary architecture?\n\n#### Scale-Out, Scale-Up\nScale out vs scale up: how are they different? When to apply one, when the other?\n\n#### Failures User Sessions\nHow to deal with failover and user sessions?\n\n#### CQRS\nWhat is CQRS (Command Query Responsibility Segregation)? How is it different from the oldest Command-Query Separation Principle?\n\n#### n-tier\nThe so called \"multitier architecture\" is an approach to design a client–server system aimed to keep physically and logically separated presentation, application processing, data management and other functions. The most widespread of the multitier architectures is the three-tier architecture. Would you discuss the pros and cons of such an approach?\n\n#### Scalability\nHow would you design a software system for scalability?\n\n#### C10K\nSomeone gave the name \"The \"C10k problem\" to the problem of optimising network sockets to handle over 10.000 open connections at once. While handling 10.000 concurrent clients is not the same as handling 10.000 open connection, the context is similar. It's a tough challenge anyway, and no one is expected to know every single detail to solve it. It may be interesting to discuss the strategies you know to deal with that problem. Would you like to try?\n\n#### P2P\nHow would you design a decentralized (that is, with no central server) P2P system?\n\n#### CGI\nYou may recall that Common Gateway Interface (CGI) is a standard protocol for web servers to execute programs (CGI scripts) that execute as Command-line programs on a server, and that dynamically generate HTML pages when invoked by a HTTP request. Perl and PHP used to be common languages for such scripts. In CGI, a HTTP request generally causes the invocation of a new process on the server, but FastCGI, SCGI and other approaches improved the mechanism, raising the performance, with techniques such as preforking processes. Can you discuss why CGI became obsolete, and was instead replaced with other architectural approaches?\n\n#### Vendor Lock-in\nHow would you defend the design of your systems against vendor Lock-in?\n\n#### Pub/Sub\nWhat are the disadvantages of the publish-subscribe pattern at scale?\n\n#### CPUs\nWhat's new in CPUs since the 80s, and how does it affect programming?\n\n#### Performance\nIn which part of the lifecycle of a software performance should be taken in consideration, and how?\n\n#### DDOS\nHow could a denial of service arise not maliciously but due to a design or architectural problem?\n\n#### Performance and Scalability\nWhat’s the relationship between performance and scalability?\n\n#### Tight Coupling\nWhen is it OK (if ever) to use tight coupling?\n\n#### Cloud Readiness\nWhat characteristic should a system have to be cloud ready?\n\n#### Emergent Architecture\nDoes unity of design imply an aristocracy of architects? Putting it simple: can good design emerge from a collective effort of all developers?\n\n#### Design, Architecture, Functionality, Aesthetic\nWhat's the difference between design, architecture, functionality and aesthetic? Discuss.\n\n\n\n### [[↑]](#toc) <a name='soa'>Questions about Service Oriented Architecture and Microservices:</a>\n\n#### Long-lived Transactions\nWhy, in a SOA, long-lived transactions are discouraged and sagas are suggested instead?\n\n#### SOA and Micro Services\nWhat are the differences between SOA and microservice?\n\n#### Versioning and Breaking Changes\nLet's talk about web services versioning, version compatibility and breaking changes.\n\n#### Sagas and compensations\nWhat's the difference between a transaction and a compensation operation in a saga, in SOA?\n\n#### Too Micro\nWhen is a microservice too micro?\n\n#### Micro Services Architecture\nWhat are the pros and cons of microservice architecture?\n\n\n### [[↑]](#toc) <a name='security'>Questions about Security:</a>\n#### Security by Default\nHow do you write secure code? In your opinion, is it one of the developer's duties, or does it require a specialized role in the company? And why?\n\n#### Don't Invent Cryptography\nWhy is it said that cryptography is not something you should try to invent or design yourself?\n\n#### 2-FA\nWhat is two factor authentication? How would you implement it in an existing web application?\n\n#### Confidential Data in Logs\nIf not carefully handled, there is always a risk of logs containing sensitive information, such as passwords. How would you deal with this?\n\n#### SQL Injection\nWrite down a snippet of code affected by SQL injection and fix it.\n\n#### Detect SQL Injection\nHow would it be possible to detect SQL injection via static code analysis? I don't expect you to write an algorithm capable of doing this, as it is probably a huge topic, but let's discuss a general approach.\n\n#### XSS\nWhat do you know about Cross-Site Scripting? If you don't remember it, let's review online its definition and let's discuss about it.\n\n#### Cross-Site Forgery Attack\nWhat do you know about Cross-Site Forgery Attack? If you don't remember it, let's review online its definition and let's discuss about it.\n\n#### HTTPS\nHow does HTTPS work?\n\n#### MITM Attack\nWhat's a man-in-the-middle Attack, and why does HTTPS help protect against it?\n\n#### Stealing Sessions\nHow can you prevent the user's session from being stolen? Chances are you remember what session or cookie hijacking is, otherwise let's read its Wikipedia page together.\n\n\n### [[↑]](#toc) <a name='general'>General Questions:</a>\n\n#### Why FP?\nWhy does functional programming matter? When should a functional programming language be used?\n\n#### Browsers\nHow do companies like Microsoft, Google, Opera and Mozilla profit from their browsers?\n\n#### TCP Sockets\nWhy does opening a TCP socket have a large overhead?\n\n#### Encapsulation\nWhat is encapsulation important for?\n\n#### Real-time systems\nWhat is a real-time system and how is it different from an ordinary system?\n\n#### Real-time and memory allocation\nWhat's the relationship between real-time languages and heap memory allocation?\n\n#### Immutability\nImmutability is the practice of setting values once, at the moment of their creation, and never changing them. How can immutability help write safer code?\n\n#### Mutable vs Immutable\nWhat are the pros and cons of mutable and immutable values.\n\n#### Object-Relational Impedance Mismatch\nWhat's the Object-Relational impedance mismatch?\n\n#### Sizing a Cache\nWhich principles would you apply to define the size of a cache?\n\n#### TCP and HTTP\nWhat's the difference between TCP and HTTP?\n\n#### Client-Side vs Server-Side\nWhat are the tradeoffs of client-side rendering vs. server-side rendering?\n\n#### Reliable and non-reliable channels\nHow could you develop a reliable communication protocol based on a non-reliable one?\n\n\n\n\n### [[↑]](#toc) <a name='open'>Open Questions:</a>\n\n#### Resistance to Change\nWhy do people resist change?\n\n#### Threading ELI5\nExplain threads to your grandparents\n\n#### Innovation and Predictability\nAs a software engineer you want both to innovate and to be predictable. How those two goals can coexist in the same strategy?\n\n#### Good Code\nWhat makes good code good?\n\n#### Streaming\nExplain streaming and how you would implement it.\n\n#### 1 Week Improvement\nSay your company gives you one week you can use to improve your and your colleagues' lifes: how would you use that week?\n\n#### Learnt this week\nWhat did you learn this week?\n\n#### Aesthetic\nThere is an aesthetic element to all design. The question is, is this aesthetic element your friend or your enemy?\n\n#### Last 5 books\nList the last 5 books you read.\n\n#### Introducing CI/CD\nHow would you introduce Continuous Delivery in a successful, huge company for which the change from Waterfall to Continuous Delivery would be not trivial, because of the size and complexity of the business?\n\n#### Reinvent the Wheel\nWhen does it make sense to reinvent the wheel?\n\n#### Not Invented Here\nLet's have a conversation about \"*reinventing the wheel*\", the \"*not invented here syndrome*\" and the \"*eating your own food*\" practice\n\n#### Next Thing to Automate\nWhat's the next thing you would automate in your current workflow?\n#### Coding is Hard\nWhy is writing software difficult? What makes maintaining software hard?\n\n#### Green Fields and Brown Fields\nWould you prefer working on green field or brown field projects? Why?\n\n#### Type \"Google.com\"\n[What happens when you type google.com into your browser and press enter?](https://github.com/alex/what-happens-when)\n\n#### While idle\nWhat does an operating system do when it has got no custom code to run, and therefore it looks idle? I would like to start a discussions about interrupts, daemons, background services, polling, event handling and so on.\n\n#### Unicode\nExplain Unicode and database transactions to a 5 year old child.\n\n#### Defending Monoliths\nDefend the monolithic architecture.\n\n#### Professional Developers\nWhat does it mean to be a \"professional developer\"?\n\n#### It's an art\nIs developing software Art, Engineering, Crafts or Science? Your opinion.\n\n#### People who like this also like...\n\"People who like this also like... \". How would you implement this feature in an e-commerce shop?\n\n#### Corporations vs Startups\nWhy are corporations slower than startups in innovating?\n\n#### I'm proud of\nWhat have you achieved recently that you are proud of?\n\n\n\n### [[↑]](#toc) <a name='snippets'>Questions about snippets of code:</a>\n\n#### Beware the Closure\nWhat's the output of this Javascript function?\n```javascript\nfunction hookupevents() {\n  for (var i = 0; i < 3; i++) {\n    document.getElementById(\"button\" + i)\n      .addEventListener(\"click\", function() {\n        alert(i);\n      });\n  }\n}\n```\n\n#### Type Erasure\nAbout Type Erasure, what's the output of this Java snippet, and why?\n```java\nArrayList<Integer> li = new ArrayList<Integer>();\nArrayList<Float> lf = new ArrayList<Float>();\nif (li.getClass() == lf.getClass()) // evaluates to true\n  System.out.println(\"Equal\");\n```\n\n#### Memory Leak\nCan you spot the memory leak?\n```java\npublic class Stack {\n    private Object[] elements;\n    private int size = 0;\n    private static final int DEFAULT_INITIAL_CAPACITY = 16;\n\n    public Stack() {\n        elements = new Object[DEFAULT_INITIAL_CAPACITY];\n    }\n\n    public void push(Object e) {\n        ensureCapacity();\n        elements[size++] = e;\n    }\n\n    public Object pop() {\n        if (size == 0)\n            throw new EmptyStackException();\n        return elements[--size];\n    }\n\n    /**\n     * Ensure space for at least one more element, roughly\n     * doubling the capacity each time the array needs to grow.\n     */\n    private void ensureCapacity() {\n        if (elements.length == size)\n            elements = Arrays.copyOf(elements, 2 * size + 1);\n    }\n}\n```\n\n#### Kill the witch\n`if`s and in general conditional statements lead to procedural and imperative programming. Can you get rid of this `switch` and make this snippet more object oriented?\n\n```java\npublic class Formatter {\n\n    private Service service;\n\n    public Formatter(Service service) {\n        this.service = service;\n    }\n\n    public String doTheJob(String theInput) {\n        String response = service.askForPermission();\n        switch (response) {\n        case \"FAIL\":\n            return \"error\";\n        case \"OK\":\n            return String.format(\"%s%s\", theInput, theInput);\n        default:\n            return null;\n        }\n    }\n}\n```\n\n#### Kill the if\nCan you get rid of these `if`s and make this snippet of code more object oriented?\n\n```java\npublic class TheService {\n    private final FileHandler fileHandler;\n    private final FooRepository fooRepository;\n\n    public TheService(FileHandler fileHandler, FooRepository fooRepository) {\n        this.fileHandler = fileHandler;\n        this.fooRepository = fooRepository;\n    }\n\n    public String Execute(final String file) {\n\n        final String rewrittenUrl = fileHandler.getXmlFileFromFileName(file);\n        final String executionId = fileHandler.getExecutionIdFromFileName(file);\n\n        if (executionId.equals(\"\") || rewrittenUrl.equals(\"\")) {\n            return \"\";\n        }\n\n        Foo knownFoo = fooRepository.getFooByXmlFileName(rewrittenUrl);\n\n        if (knownFoo == null) {\n            return \"\";\n        }\n\n        return knownFoo.DoThat(file);\n    }\n}\n```\n\n#### Kill the if-chain\nHow would you refactor this code?\n\n```js\nfunction()\n{\n    HRESULT error = S_OK;\n\n    if(SUCCEEDED(Operation1()))\n    {\n        if(SUCCEEDED(Operation2()))\n        {\n            if(SUCCEEDED(Operation3()))\n            {\n                if(SUCCEEDED(Operation4()))\n                {\n                }\n                else\n                {\n                    error = OPERATION4FAILED;\n                }\n            }\n            else\n            {\n                error = OPERATION3FAILED;\n            }\n        }\n        else\n        {\n            error = OPERATION2FAILED;\n        }\n    }\n    else\n    {\n        error = OPERATION1FAILED;\n    }\n\n    return error;\n}\n```\n[Resources](snippets/kill-the-if-chain.md)\n\n### [[↑]](#toc) <a name='billgates'>Bill Gates Style Questions:</a>\nThis section collects some weird questions along the lines of the [Manhole Cover Question](https://en.wikipedia.org/wiki/Microsoft_interview#Manhole_cover_question).\n\n#### Mirrors\nWhat would happen if you put a mirror in a scanner?\n\n#### Clones\nImagine there's a perfect clone of yourself. Imagine that that clone is your boss. Would you like to work for him/her?\n\n#### Revert\nInterview me.\n\n#### Quora\nWhy are Quora's answers better than Yahoo Answers' ones?\n\n#### Cobol\nLet's play a game: defend Cobol against modern languages, and try to find as many reasonable arguments as you can.\n\n#### 10 years\nWhere will you be in 10 years?\n\n#### Fire me\nYou are my boss and I'm fired. Inform me.\n\n#### From scratch\nI want to refactor a legacy system. You want to rewrite it from scratch. Argument. Then, switch our roles.\n\n#### Telling lies\nYour boss asks you to lie to the company. What's your reaction?\n\n#### Your past self\nIf you could travel back in time, which advice would you give to your younger self?\n"
  },
  {
    "path": "design-patterns/active-record.md",
    "content": "# Active Record\n\nRelated topics suggested by [Krzysztof Grzybek](https://github.com/krzysztof-grzybek)\n\n- How hard is to test code that uses Active Record? How is domain model tied or independent from data layer?\n- What's the relation between objects implementing Active Record and the Single Responsibility Principle?\n- How easy is to hit the database multiple times (e.g. in foreach loop) because of the leaking abstraction?\n"
  },
  {
    "path": "design-patterns/dont-repeat-yourself.md",
    "content": "# Don't Repeat Yourself\n\n## [Krzysztof Grzybek](https://github.com/krzysztof-grzybek)\n\nCode violating the DRY principle:\n```javascript\nclass Employee {\n    calculateSalaryNet() {\n        return this.hoursWorked * this.hourlyWage;\n    }\n\n    calculateSalaryGross() {\n        return this.hoursWorked * this.hourlyWage + TAX;\n    }\n}\n```\n\nFixed code:\n```javascript\nclass Employee {\n    calculateSalaryNet() {\n        return this.hoursWorked * this.hourlyWage;\n    }\n\n    calculateSalaryGross() {\n        return this.calculateSalaryNet() + TAX;\n    }\n}\n```\n"
  },
  {
    "path": "design-patterns/inversion-of-control.md",
    "content": "# Inversion of Control\n\n## Links\n\n* [InversionOfControl - Fowler](https://martinfowler.com/bliki/InversionOfControl.html)\n* [Inversion of Control Containers and the Dependency Injection pattern - Fowler](https://martinfowler.com/articles/injection.html)\n* [DIP in the Wild - Brett L. Schuchert](https://martinfowler.com/articles/dipInTheWild.html)\n\n## Related topics\n\n* Topics that might be confused with each other\n  - Inversion of Control\n  - Dependency Inversion Principle (from SOLID)\n  - Dependency Injection\n\nThey are all related, but in fact separate.\n\n### Relation with Hollywood Principle\nFor some the Hollywood Principle (or Law) is just a synonym of Inversion of Control; some others see subtle differences. See  [Confusion between Inversion of Control and Hollywood Principle](https://stackoverflow.com/questions/43786221/confusion-between-inversion-of-control-and-hollywood-principle).\n\nIn this context, another related topic is the difference between libraries and frameworks, as it is stated that frameworks follow the Hollywood Principle (see [What is the difference between a framework and a library?](https://stackoverflow.com/questions/148747/what-is-the-difference-between-a-framework-and-a-library)).\n"
  },
  {
    "path": "design-patterns/law-of-demeter.md",
    "content": "# Law of Demeter\n\n* [Law of Demeter - Wikipedia](https://en.wikipedia.org/wiki/Law_of_Demeter)\n* [Law of Demeter - WikiWikiWeb](https://wiki.c2.com/?LawOfDemeter)\n* [Introducing Demeter and its Laws](http://www.bradapp.net/docs/demeter-intro.html)\n\n## Mnemonic for the Law of Demeter\nThe post [Visualization Mnemonics for Software Principles](http://www.daedtech.com/visualization-mnemonics-for-software-principles) by [Erik Dietrich](https://github.com/erikdietrich) provides a very effective trick to understand (and never forget anymore) what the Law of Demeter is. An Italian translation is available [here](https://github.com/arialdomartini/mnemonics/blob/law-of-demeter/README-italian.md).\n"
  },
  {
    "path": "snippets/kill-the-if-chain.md",
    "content": "# Kill the if-chain\n\nThe nested structure could be unrolled, as suggested by [Vahid Najafi](https://github.com/vahidvdn)\n\n```js\nfunction()\n{\n    HRESULT error = S_OK;\n\n    if( !SUCCEEDED(Operation1() ) return OPERATION1FAILED;\n    if( !SUCCEEDED(Operation2() ) return OPERATION2FAILED;\n    if( !SUCCEEDED(Operation3() ) return OPERATION3FAILED;\n    if( !SUCCEEDED(Operation3() ) return OPERATION3FAILED;\n    if( !SUCCEEDED(Operation4() ) return OPERATION4FAILED;\n\n}\n```\n\nActually, I feel there is way more space for refactoring, but it all depends on the economic of the projects.\n\nIt is worth to discuss the smells and design flaws of that code, to set up the refactoring goals.\n\n## Smells\nI see these problems:\n\n* The code violates some of the [SOLID principles][2]. It surely violates the [Open Closed Principle][3], as it is not possible to extend it without changing its code. E.g., adding a new operation would require adding a new `if`/`else` branch;\n* It also violate the [Single Responsibility Principle][4]. It just does too much. It performs error checks, it's responsible to execute all the 4 operations, it contains their implementations, it's responsible to check their results and to chain their execution in the right order;\n* It violates the [Dependency Inversion Principle][5], because there are dependencies between high-level and low-level components;\n* It has a horrible [Cyclomatic complexity][6]\n* It exhibits high coupling and low cohesion, which is exactly the opposite of [what is recommended][7];\n* It contains a lot of code duplication: the function `Succeeded()` is repeated in each branch; the structure of `if`/`else`s is replicated over and over; the assignment of `error` is duplicated.\n* It could have a pure functional nature, but it relies instead on state mutation, which makes reasoning about it not easy.\n* There's an empty `if` statement body, which might be confusing.\n\n## Refactoring\nLet's see what could be done.<br/>\nHere I'm using a C# implementation, but similar steps can be performed with whatever language.<br/>\nI renamed some of the elements, as I believe honoring a naming convention is part of the refactoring.\n\n```csharp\n  internal class TestClass\n    {\n        HResult SomeFunction()\n        {\n            var error = HResult.Ok;\n\n            if(Succeeded(Operation1()))\nv            {\n                if(Succeeded(Operation2()))\n                {\n                    if(Succeeded(Operation3()))\n                    {\n                        if(Succeeded(Operation4()))\n                        {\n                        }\n                        else\n                        {\n                            error = HResult.Operation4Failed;\n                        }\n                    }\n                    else\n                    {\n                        error = HResult.Operation3Failed;\n                    }\n                }\n                else\n                {\n                    error = HResult.Operation2Failed;\n                }\n            }\n            else\n            {\n                error = HResult.Operation1Failed;\n            }\n\n            return error;\n        }\n\n        private string Operation1()\n        {\n            // some operations\n            return \"operation1 result\";\n        }\n        private string Operation2()\n        {\n            // some operations\n            return \"operation2 result\";\n        }\n        private string Operation3()\n        {\n            // some operations\n            return \"operation3 result\";\n        }\n        private string Operation4()\n        {\n            // some operations\n            return \"operation4 result\";\n        }\n\n        private bool Succeeded(string operationResult) =>\n            operationResult == \"some condition\";\n    }\n\n    internal enum HResult\n    {\n        Ok,\n        Operation1Failed,\n        Operation2Failed,\n        Operation3Failed,\n        Operation4Failed,\n    }\n}\n```\n\nFor the sake of simplicity, I supposed each operation returns a string, and that the success or failure is based on an equality check on the string, but of course it could be whatever. In the next steps, it would be nice if the code is independent from the result validation logic.\n\n### Step 1\nIt would be nice to start the refactoring with the support of some test harness.\n\n```csharp\npublic class TestCase\n{\n    [Theory]\n    [InlineData(\"operation1 result\", HResult.Operation1Failed)]\n    [InlineData(\"operation2 result\", HResult.Operation2Failed)]\n    [InlineData(\"operation3 result\", HResult.Operation3Failed)]\n    [InlineData(\"operation4 result\", HResult.Operation4Failed)]\n    [InlineData(\"never\", HResult.Ok)]\n    void acceptance_test(string failWhen, HResult expectedResult)\n    {\n        var sut = new SomeClass {FailWhen = failWhen};\n\n        var result = sut.SomeFunction();\n\n        result.Should().Be(expectedResult);\n    }\n}\n```\n\nOur case is a trivial one, but being the quiz supposed to be a job interview question, I would not ignore it.\n\n\n### Step 2\nThe first refactoring could be getting rid of the mutable state: each if branch could just return the value, instead of mutating the variable `error`. Also, the name `error` is misleading, as it includes the success case. Let's just get rid of it:\n\n```csharp\nHResult SomeFunction()\n{\n    if(Succeeded(Operation1()))\n    {\n        if(Succeeded(Operation2()))\n        {\n            if(Succeeded(Operation3()))\n            {\n                if(Succeeded(Operation4()))\n                    return HResult.Ok;\n                else\n                    return HResult.Operation4Failed;\n            }\n            else\n                return HResult.Operation3Failed;\n        }\n        else\n            return HResult.Operation2Failed;\n    }\n    else\n        return HResult.Operation1Failed;\n}\n```\n\nWe got rid of the empty `if` body, making in the meanwhile the code slightly easier to reason about.\n\n### Step 3\nIf now we invert each `if` statement (the step suggested by Sergio)\n\n```csharp\ninternal HResult SomeFunction()\n{\n    if (!Succeeded(Operation1()))\n        return HResult.Operation1Failed;\n\n    if (!Succeeded(Operation2()))\n        return HResult.Operation2Failed;\n\n    if (!Succeeded(Operation3()))\n        return HResult.Operation3Failed;\n\n    if (!Succeeded(Operation4()))\n        return HResult.Operation4Failed;\n\n    return HResult.Ok;\n}\n```\n\nwe make it apparent that the code performs a chain of executions: if an operation succeeds, the next operation is invoked; otherwise, the chain is interrupted, with an error. The GOF [Chain of Responsibility Pattern][8] comes to mind. \n\n### Step 4\nWe could move each operation to a separate class, and let our function receive a chain of operations to execute in a single shot. Each class would deal with its specific operation logic (honoring the Single Responsibility Principle).\n\n```csharp\ninternal HResult SomeFunction()\n{\n    var operations = new List<IOperation>\n    {\n        new Operation1(),\n        new Operation2(),\n        new Operation3(),\n        new Operation4()\n    };\n\n    foreach (var operation in operations)\n    {\n        if (!_check.Succeeded(operation.DoJob()))\n            return operation.ErrorCode;\n    }\n\n    return HResult.Ok;\n}\n```\n\nWe got rid of the `if`s altogether (but one).\n\nNotice how:\n\n* The interface `IOperation` has been introduced, which is a preliminary move to decouple the function from the operations, complying the with the Dependency Inversion Principle;\n* The list of operations can easily be injected into the class, using the [Dependency Injection][9].\n* The result validation logic has been moved to a separate class `Check`, injected into the main class (Dependency Inversion and Single Responsibility are satisfied).\n\n```csharp\ninternal class SimpleStringCheck : IResultCheck\n{\n    private readonly string _failWhen;\n\n    public Check(string failWhen)\n    {\n        _failWhen = failWhen;\n    }\n\n    internal bool Succeeded(string operationResult) =>\n        operationResult != _failWhen;\n}\n\n```\n\nWe gained the ability to switch the check logic without modifying the main class (Open-Closed Principle).\n\nEach operation has been moved to a separate class, like:\n\n```csharp\ninternal class Operation1 : IOperation {\n    public string DoJob()\n    {\n        return \"operation1 result\";\n    }\n\n    public HResult ErrorCode => HResult.Operation1Failed;\n}\n```\n\nEach operation knows its own error code. The function itself became independent from it.\n\n### Step 5\nThere is something more to refactor on the code\n\n```csharp\nforeach (var operation in operations)\n{\n    if (!_check.Succeeded(operation.DoJob()))\n        return operation.ErrorCode;\n    }\n\n    return HResult.Ok;\n}\n```\n\n* First, it's not clear why the case `return HResult.Ok;` is handled as a special case: the chain could contain a terminating operation never failing and returning that value. This would allow us to get rid of that last `if`.\n\n* Second, our function still has 2 responsibility: to visit the chain, and to check the result.\n\nAn idea could be to encapsulate the operations into a real chain, so our function could reduce to something like:\n\n```\nreturn operations.ChainTogether(_check).Execute();\n```\n\nWe have 2 options:\n\n* Each operation knows the next operation, so starting from operation1 we could execute the whole chain with a single call;\n* Operations are kept unaware of being part of a chain; a separate, encapsulating structure adds to operations the ability to be executed in sequence.\n\nI'm going on with the latter, but that's absolutely debatable. I'm introducing a class modelling a ring in a chain, moving the code away from our class:\n\n```csharp\ninternal class OperationRing : IRing\n{\n    private readonly Check _check;\n    private readonly IOperation _operation;\n    internal IRing Next { private get; set; }\n\n    public OperationRing(Check check, IOperation operation)\n    {\n        _check = check;\n        _operation = operation;\n    }\n\n    public HResult Execute()\n    {\n        var operationResult = _operation.DoJob();\n\n        if (_check.Succeeded(operationResult))\n            return Next.Execute();\n\n        return _operation.ErrorCode;\n    }\n}\n```\n\nThis class is responsible to execute an operation and to handle the execution to the next ring if it succeeded, or to interrupt the chain returning the right error code.\n\nThe chain will be terminated by a never-failing element:\n\n```csharp\ninternal class AlwaysSucceeds : IRing\n{\n    public HResult Execute() => HResult.Ok;\n}\n```\n\nOur original class reduces to:\n\n```csharp\ninternal class SomeClass\n{\n    private readonly Check _check;\n    private readonly List<IOperation> _operations;\n\n    public SomeClass(Check check, List<IOperation> operations)\n    {\n        _check = check;\n        _operations = operations;\n    }\n\n    internal HResult SomeFunction()\n    {\n        return _operations.ChainTogether(_check).Execute();\n    }\n}\n```\n\nIn this case, `ChainTogether()` is a function implemented as an extension of `List<IOperation>`, as I don't believe that the chaining logic is responsibility of our class.\n\n\n## That's not the *right* answer\n\nIt's absolutely debatable that the responsibilities have been separated to the most appropriate classes. For example: \n\n* is chaining operations a task of our function? Or should it directly receive the chained structure? \n* why the use of an enumerable? As Robert Martin wrote in \"Refactoring: Improving the Design of Existing Code\": enums are code smells and should be refactored to polymorphic classes;\n* how much is too much? Is the resulting design too complex? Does the complexity of the whole application need this level of modularisation?\n\nTherefore, I'm sure there are several other ways to refactor the original function.\n\n\n  [1]: https://stackoverflow.com/users/125816\n  [2]: https://en.wikipedia.org/wiki/SOLID\n  [3]: https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle\n  [4]: https://en.wikipedia.org/wiki/Single_responsibility_principle\n  [5]: https://en.wikipedia.org/wiki/Dependency_inversion_principle\n  [6]: https://en.wikipedia.org/wiki/Cyclomatic_complexity\n  [7]: https://en.wikipedia.org/wiki/Cohesion_(computer_science)\n  [8]: https://en.wikipedia.org/wiki/Chain-of-responsibility_pattern\n  [9]: https://en.wikipedia.org/wiki/Dependency_injection\n  [10]: https://refactoring.guru/smells/primitive-obsession\n"
  }
]