> 2021年09月06日信息消化 ### Signs That You Are a Bad Programmer origin: [Signs That You Are a Bad Programmer](https://javascript.plainenglish.io/signs-that-you-are-a-bad-programmer-dc1c647827d6) Most of the time, we know what we should do, but we don’t do it. We think we can do it later or correct it later. But “later” never comes. This is a common sign of a lazy programmer and the first step towards being a bad programmer. ##### Don’t understand the goal of the code Before writing the code, you have to know the purposes of the code, what your code will do. It’s like running the code in your head. ###### Symptoms 1. Keeping variables that are never used. 2. Producing irrelevant output. 3. Calling functions that are irrelevant to the goal. 4. Executing idempotent functions, like save() multiple times, just to be sure. 5. Fixing bugs by writing some codes that overwrite the buggy code. 6. Unnecessary value converting. Like first converting a decimal into a string and then again convert the string into decimal. ###### Remedies 1. Use the IDE’s own debugger as an aide. 2. Inspect the value of the variables before and after they change. ##### Poor understanding of language’s architecture Object-oriented programming is a programming model, so is Functional or Declarative programming. They are different from procedural or Declarative programming. Programmers became confused when they moved from one architecture to another, and it’s normal. But with time, you have to have a better understanding of that architecture. ###### Symptoms 1. Not following standard OOP. 2. (OOP) Calling non-static functions/variables in uninstantiated classes. 3. (OOP) Writing lots of “XXXXManager” classes with all the methods for manipulating the fields of objects with a little method or no method of their own. 4. Treating a relational database as an object-store. 5. Performing all joins and relation enforcement in client code. 6. Creating multiple versions of the same algorithm to handle different types. 7. Setting individual values( in imperative codes) rather than using data binding. ##### Distrust your own code When your logic is poor, you will have confusion and will distrust your own codes. ###### Symptoms 1. Writing IsNull() or IsNotNull(), or IsTrue(bool) or IsFalse(bool) functions unnecessarily. 2. Checking to see if a boolean-typed variable is something other than true or false. 3. Calling the same functions multiple times to confirm that it executes. ###### Remedies 1. Don’t carry unnecessary old habits from a language with a weak type system. 2. Be confident about your logic. If there are problems with the logic, try new logic. ##### Falling into a recursion trap The idea of recursion is tricky but not so hard. But many programmers fear recursion like ghosts. Recursion will make code cleaner and efficient. Recursion is like a ladder. you just have to picture “where you are” and “where is the base” and how you will step up or step down. ###### Symptoms 1. Complex iterative algorithms for problems that can be solved recursively. Like traversing a filesystem tree. 2. Checking base condition both before and after the recursive call. 3. Recursive functions that don’t test for a base condition. 4. Recursive subroutines that concatenate/sum to a global variable or a carry-along output variable. ###### Remedies 1. Run the code in several steps to understand the flow. It might occur some stack overflows. But don’t worry. 2. Change the base condition to see the outputs. 3. Your goal is to have confidence and a complete sense of where you are and what you are doing. ##### Deficient research skill ###### Symptoms 1. Re-inventing without basic mechanisms that are built into the language, such as events-and-handlers or regular expressions. 2. Re-inventing classes and functions that are built into the framework. 3. Rather than searching, “Email me the code, plz” messages posted to help forums by them. 4. Persistently using old-fashioned techniques even when new techniques are better in those situations. 5. Rather than searching for a straight solution, make it complex by writing “Roundabout code” that accomplishes what could be done with fewer codes in many steps. ###### Remedies 1. This skill takes time to build. So don’t rush. 2. Don’t go to a programmer or copy-paste code directly when you are stuck in a problem. Take time. Read the documentation. ##### Poor understanding of pointers If you don’t understand the concept of pointers, then it will be very hard for you to write complex data structures and efficient APIs. You will generate poor data structure design and bugs. ###### Symptoms 1. Lack of knowledge to differentiate between pass-by-value and pass-by-reference in method calls. 2. Failure to implement linked lists. 3. Failure to find or fix bugs occurred by mistakenly performing arithmetic on pointers. 4. Inability to write code that inserts/deletes nodes from a linked list or tree without losing or deleting data. 5. Making a copy of a pointer, changing the dereferenced value via the copy, then thinking that the original pointer still points to the old value. ###### Remedies 1. Pointer is very easy to understand but often misunderstood because of lack of practice. ### What We Learned from 200,000 OpenAPI Files origin: [What We Learned from 200,000 OpenAPI Files](https://blog.postman.com/what-we-learned-from-200000-openapi-files/) ##### Our key discoveries Here are Postman’s key discoveries after analyzing nearly 200,000 OpenAPI files: 1. Most OpenAPI documents don’t include license information, but when they do, the most common licenses, listed in order, are: Apache 2.0, AGPL 3, Creative Commons Attribution 3.0 and the BSD license. 2. 79% of the API definitions were valid according to `oas-validator`. 3. API enthusiasts aren’t spammers. Otherwise I’d get far more junk email from being the second-most commonly included contact email address, after [email@google.com](mailto:email@google.com). 4. Just over 6% of the APIs include a logo URL in the `x-logo` extension property, as popularized by ReDoc and APIs.guru. 5. Approximately 2% of APIs have a publicly available `/status` endpoint. 6. Nearly 4% have a `/healthcheck` or `/ready` endpoint, likely related to this IETF [Internet Draft](https://tools.ietf.org/html/draft-inadarei-api-health-check-05). 7. Although it may seem like it’s more, only 2% of OpenAPI definitions in the wild are PetStore related. 8. Each API has, on average, 37 paths. 9. Each API has, on average, 51 endpoints (or 1.4 methods per path item). 10. Each API has, on average, 38 distinct query parameters across all operations. 11. Each API has, on average, 33 schemas defined, or 0.65 schemas per operation. 12. 1,485 APIs, or 0.8%, use the `discriminator` keyword. 13. 3,253 APIs, or 1.7%, use the `xml` keyword. 14. The combination of `basic` and/or `apiKey` security is most common, followed by no security, `apiKey` solo, `basic`, `oauth2`, `oauth2` and/or `apiKey`, and other `http` mechanisms. 15. Just three APIs used the new `callbacks` feature of OpenAPI 3.0—though this low figure is probably due to the sample’s limited inclusion of v3.0 definitions. 16. We could not find any APIs using the new ‘links’ feature of OpenAPI 3.0—though this may have been limited by the sample’s focus. 17. Despite looking for the `x-webhooks` extension used by ReDoc, we found no APIs using the new `webhooks` feature of OpenAPI 3.1, but adoption of this very new version of the specification would be expected due to its infancy. ### This Is the Number 1 Sign of High Intelligence, According to Steve Jobs origin: [This Is the Number 1 Sign of High Intelligence, According to Steve Jobs](https://entrylevelrebel.medium.com/this-is-the-number-1-sign-of-high-intelligence-according-to-steve-jobs-e76d0a628174) School smart and real-world smart are, as we all know, not the same thing. It’s perfectly possible to ace every test in college and struggle in life after you graduate. So if academic grades aren’t enough to prove a person is smart, how do the world’s most successful people spot the [truly, practically intelligent](https://www.inc.com/jessica-stillman/don-moore-intelligence-question.html)? [Jeff Bezos](https://www.inc.com/jessica-stillman/this-is-number-1-sign-of-high-intelligence-according-to-jeff-bezos.html) looks for the ability to change your mind frequently. [Elon Musk is all about examining skills over credentials](https://www.inc.com/jessica-stillman/why-elon-musk-doesnt-care-about-college-degrees.html). Steve Jobs, however, took another approach. The legendary Apple co-founder laid out how he defines real intelligence in [a talk to the Academy of Achievement](https://www.fastcompany.com/3015391/seven-rare-steve-jobs-videos-that-show-how-to-think-different) way back in 1982 (hat tip to [Alan Trapulionis](https://entrepreneurshandbook.co/steve-jobss-definition-of-smart-will-make-you-rethink-your-actions-6b1d7873fd46)). According to Jobs, the key to being truly smart isn’t deep expertise in one field, but instead the ability to make unexpected connections between fields. ##### Breadth beats depth. “A lot of [what it means to be smart] is the ability to zoom out, like you’re in a city and you could look at the whole thing from the 80th floor down at the city. And while other people are trying to figure out how to get from point A to point B reading these stupid little maps, you could just see it in front of you. You can see the whole thing,” Jobs says in the talk. "很多[智能的含义]是放大的能力,比如你在一个城市,你可以从80楼往下看整个城市的情况。而当其他人正试图找出如何从A点到B点,阅读这些愚蠢的小地图时,你可以只看到它在你面前。你可以看到整个事情,"乔布斯在演讲中说。 That’s a fascinating conception of smarts, but it raises an inevitable question: How do you develop the ability to get a bird’s eye view of a situation in this way? The answer, Jobs goes on to say, is to be an **intellectual omnivore**, exploring the world in unique and unexpected ways. 这是一个迷人的智能概念,但它提出了一个不可避免的问题。你是如何培养出以这种方式鸟瞰全局的能力的?乔布斯接着说,答案是成为一个智力杂食者,以独特和意想不到的方式探索世界。 “You have to not have the same bag of experiences as everyone else does, or else you’re gonna make the same connections and you won’t be innovative. […] You might want to think about going to Paris and being a poet for a few years. Or you might want to go to a third-world country — I’d highly advise that. Falling in love with two people at once. Walt Disney took LSD,” he says. "你必须不拥有与其他人相同的经验包,否则你就会建立相同的联系,你就不会有创新。[你可能想去巴黎,做几年诗人。或者你可能想去一个第三世界国家--我强烈建议这样做。同时爱上两个人。沃尔特-迪斯尼吃过迷幻药,"他说。 While doomed love and psychedelics may not be your bag, the principle stands whatever your intellectual tastes. The point isn’t that any particular interest is exceptionally valuable, but that combining unrelated (and relatively rare) areas of expertise can give you a broader view of problems and unique insights into solving them. Jobs famously took inspiration for Apple’s typography from [a college course on calligraphy](https://www.inc.com/rohini-venkatraman/how-steve-jobs-and-mark-zuckerberg-came-up-with-th.html#:~:text=Steve Jobs audited a calligraphy,looking back 10 years later.) he took, for instance. 虽然注定的爱情和迷幻药可能不是你的囊中之物,但无论你的智力品味如何,这个原则是成立的。问题的关键不在于任何特定的兴趣是特别有价值的,而在于将不相关的(相对罕见的)专业领域结合起来,可以使你对问题有更广泛的看法,并对解决这些问题有独特见解。例如,著名的乔布斯从他所学的大学书法课程中获得了苹果公司字体设计的灵感。 ##### Science agrees with Jobs. If you think about it, this is a fairly common sense insight. You’re unlikely to bring fresh perspectives to your work if you have the same interests as everyone else around you. But many of us miss this truth in practice, fretting so much about building up our abilities in our primary area of expertise that we tell ourselves we have no time for “pointless” exploration or random detours. 如果你仔细想想,这是一个相当常识性的见解。如果你的兴趣和你周围的人一样,你就不可能为你的工作带来新的观点。但我们中的许多人在实践中错过了这一真理,他们为在自己的主要专业领域培养能力而烦恼,以至于告诉自己没有时间进行 "无意义的 "探索或随机绕道。 Science agrees with Jobs that such single-mindedness can limit your intelligence and your creativity. Repeated studies show a close link between the personality trait psychologists call openness and truly great brains. 科学界同意乔布斯的观点,即这种一心一意的做法会限制你的智力和创造力。反复的研究表明,心理学家称之为开放性的人格特质与真正伟大的大脑之间存在着密切的联系。 Back in the 1960s, when scientists stuck a bunch of geniuses in a house and observed them to try to figure out what qualities they all shared, they discovered that, from poets to entrepreneurs to scientists, every super achiever in the group was extremely open to new ideas and experiences. Another more recent study showed that not only is a high appetite for new ideas and experiences highly correlated with intelligence among the young, staying open to new ideas as you grow older helps fight mental decline. Focus, as Steve Jobs himself knew, is essential when you’re trying to execute on a good idea you’ve already had. But don’t rush to put blinkers on your curiosity. If you want to be smart enough to come up with a good idea in the first place, it’s essential to cultivate intellectual openness and diverse interests. It’s only by being initially distractible that you’ll end up with something worth focusing on. ### Misc - [React vs. Vue: A Modern Comparison](https://draft.dev/learn/react-vs-vue-a-modern-comparison?utm_campaign=Portable%2BCTO&utm_medium=email&utm_source=Portable_CTO_11) - React: JSX, large-scale - Vue: HTML Template, small/middle-scale - [Why APIs need zero-trust security](https://launchany.us2.list-manage.com/track/click?u=5005148108dfbac726f74e31e&id=4874a50ab4&e=be39bd5b43) - API insecurity.