• 开源镜像
  • 开源沙龙
  • 媛宝
  • 猿帅
  • 注册
  • 登录
  • 息壤开源生活方式平台
  • 加入我们

开源日报

  • 开源日报第950期:《Clean-code-javascript》

    15 11 月, 2020
    开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
    今日推荐开源项目:《Clean-code-javascript》
    今日推荐英文原文:《KISS in Practice》

    今日推荐开源项目:《Clean-code-javascript》传送门:项目链接
    推荐理由:该项目介绍了 Robert C.Martin 的著作《Clean Code》(中文名:《代码整洁之道》)对JavaScript代码编写的建议,并附有样例。和文章一样,代码整洁是编写过程中不可忽视的一环。变量名 currentDate 显然比 yyyymmdstr 好得多不是吗?
    今日推荐英文原文:《KISS in Practice》作者:Wojciech Kasperczyk
    原文链接:https://medium.com/swlh/kiss-or-not-to-kiss-1f5bc28e7610
    推荐理由:本文也是关于代码编写原则和思想上的建议。标题“KISS”是软件工程中的一个常用概念,即“Keep It Simple, Stupid”,不应将事情过于复杂化。

    KISS in Practice

    KISS is a common method used in software development. It stands for Keep It Simple, Stupid. What does it mean, how would you use it and when simple is not necessarily better?

    What does it actually mean?

    KISS simply put is a mindset — you should not complicate things more than necessary. It finds perfect place in software development as this is a domain that is very prone to overcomplication. There is almost infinite number of possible solutions to every problem, but many of them are just too complex.

    Young software engineers are so eager to present all their knowledge, apply everything they learned in real life but fail to understand one thing — in business, what matters is the end result not the way of achieving it. Don’t get me wrong, there are still unethical ways of achieving your goals and even though they are simpler you shouldn’t take that road. Here I’m focusing on your workshop as a professional.

    Constrains should drive your solution.

    Following KISS principle seems rather simple. You just don’t complicate your code and you should be fine, right? Well, not exactly. Usually your solution does not have only one dimension. It is not enough to just solve the issue business is presenting to you. Your manager may want to achieve some goal, but your job as an engineer is to ensure that this goal is not only reached but is also within certain constrains.

    What are those constrains? They could be anything really. It usually depends on your project, but there are some common ones that you should take into account.

    When time is key.

    First thing you should take into account when developing new feature is time. There are many aspects to which time could be applied.

    On most basic level time complexity is the thing that most engineers think when they are speaking of time. Time complexity is crucial when working in games industry. It is even more important in real time applications, the ones that are overseeing sensitive operations and should quickly react to changes. When designing your solution you should strive for it to work as fast as possible. Usually this means less abstraction, less layers of code indirectly passing messages around. You should have a clean, straight path between input and output. No unnecessary allocations, calling virtual methods that could be overridden in subclass. It should be… well, simple.

    When maintainability is key.

    That speed of work comes with a cost. That cost is also connected to time but in a different way. It is the speed of development. When you create a pice of code, usually that code lands in some kind of repository, so that other developers could pick up what you did and expand on it or fix any mistakes you’ve made. Problem with code that is very efficient in getting the job done is that it is more prone for side effects caused by small changes in the code. There is usually no way of modifying the code to be customizable. Customization requires at least lookup for parameters and usually it involves some kind of abstraction and indirection.

    To sum it up — when writing business applications that could be maintained for years by multiple developers you should take into consideration the time other developers will spend fixing your code. In that sense modifying your code should be simple.

    When versatility is key.

    Last thing I would advise you should consider is how versatile your code should be. You might think that the best way is to cover all cases how your code could be used. Lets say you are developing a library that would be used by other developers to create their products. Key here is to know when to stop. At some point your code is covering 90% of your users’ needs. You should ask yourself if it is enough. Answer to that will be crucial.

    Users, both developers and end users, always want more. More features, more ways of interacting with your software, you name it. If you have access to your users — talk to them. Ask what is the most important feature and focus on that. If they like it there will be time to expand on it. If they don’t like it, you lost minimal amount of time possible to verify it.

    Thinking about every possible feature your software might have is very important and shouldn’t be overlooked, but you don’t have to implement everything at once. Again, we come back to the KISS principle — you shouldn’t complicate your code in the name of future work or unnecessary functionality. Abstract what you can, so that later you won’t have problems with adding new things.

    Putting it all together.

    We’ve look at three things you should take into account when designing your solution: time of execution, maintainability and versatility. There are many more things you might consider, but those three are a starting point and you should always take them into account. Everything is connected and you should find balance among all aspects. That balance would greatly depend on the specifics of the project you are working on. There is no perfect solution, if there was one we wouldn’t have jobs. Look at your problem from many angles and remember: whatever is the most important part — keep it simple.


    下载开源日报APP:https://opensourcedaily.org/2579/
    加入我们:https://opensourcedaily.org/about/join/
    关注我们:https://opensourcedaily.org/about/love/
  • 开源日报第949期:《InfoSpider》

    14 11 月, 2020
    开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
    今日推荐开源项目:《InfoSpider》
    今日推荐英文原文:《Rules for strong passwords don’t work, researchers find. Here’s what does》

    今日推荐开源项目:《InfoSpider》传送门:项目链接
    推荐理由:InfoSpider 是一个集众多数据源于一身的爬虫工具箱,旨在安全快捷的帮助用户拿回自己的数据,工具代码开源,流程透明。并提供数据分析功能,基于用户数据生成图表文件,使得用户更直观、深入了解自己的信息。 目前支持数据源包括GitHub、QQ邮箱、网易邮箱、阿里邮箱、新浪邮箱、Hotmail邮箱、Outlook邮箱、京东、淘宝、支付宝、中国移动、中国联通、中国电信、知乎、哔哩哔哩、网易云音乐、QQ好友、QQ群、生成朋友圈相册、浏览器浏览历史、12306、博客园、CSDN博客、开源中国博客、简书。
    今日推荐英文原文:《Rules for strong passwords don’t work, researchers find. Here’s what does》作者:Laura Hautala
    原文链接:https://www.cnet.com/news/rules-for-strong-passwords-dont-work-researchers-find-heres-what-does/
    推荐理由:在人均网络冲浪的今天, 我们面对海量app, 也在这些app上创建了无数的账号, 人们也开始更加关注自己的账号安全. 这篇文章将提供一些实用的tips来提升你的密码可靠度.

    Rules for strong passwords don’t work, researchers find. Here’s what does

    When you create a password for yet another new account, you’ll probably encounter familiar rules designed to make it harder for hackers to get in: Use capitals letters, numbers and special characters. However, researchers at Carnegie Mellon University say these requirements don’t make your password stronger.

    Lorrie Cranor, director of the CyLab Usable Security and Privacy Laboratory at CMU, says her team has a better way, a meter that websites can use to prompt you to create more-secure passwords. After a user has created a password of at least 10 characters, the meter will start giving suggestions, such as breaking up common words with slashes or random letters, to make your password stronger.

    The suggestions set the password strength meter apart from other meters that provide an estimated password strength, often using colors. The suggestions come from common pitfalls Cranor’s team has seen people make when they set up passwords during experiments run by the lab.

    One of the problems with many passwords is that they tick all the security checks but are still easy to guess, because most of us follow the same patterns, the lab found. Numbers? You’ll likely add a “1” at the end. Capital letters? You’ll probably make it the first one in the password. And special characters? Frequently exclamation marks.

    CMU’s password meter will offer advice for strengthening a password like “ILoveYou2!” — which meets the standard requirements. The meter also offers other advice based on what you type in, such as reminding you not to use a name or suggesting you put special characters in the middle of your password.

    “It’s relevant to what you’re doing, rather than some random tip,” Cranor said.

    In an experiment, users created passwords on a system that simply required them to enter 10 characters. Then the system rated the passwords with the lab’s password strength meter and gave tailored suggestions for stronger passwords. Test subjects were able to come up with secure passwords that they could recall up to five days later. It worked better than showing users preset lists of rules or simply banning known bad passwords (I’m looking at you “StarWars”).

    Cranor and co-authors Joshua Tan, Lujo Bauer and Nicolas Christin will present their latest password findings on Thursday at the ACM Conference on Computer and Communications Security, which is being held virtually. The team hopes its tools will be adopted by website makers in the future.

    In the meantime, Cranor says the best way to create and remember secure passwords is to use a password manager. Those aren’t widely adopted, and they come with some trade-offs. Nonetheless, they allow you to create a random, unique password for each account, and they remember your passwords for you.
    下载开源日报APP:https://opensourcedaily.org/2579/
    加入我们:https://opensourcedaily.org/about/join/
    关注我们:https://opensourcedaily.org/about/love/
  • 开源日报第948期:《之前 timeago.js》

    13 11 月, 2020
    开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
    今日推荐开源项目:《之前 timeago.js》
    今日推荐英文原文:《JavaScript Tooling to the Rescue》

    今日推荐开源项目:《之前 timeago.js》传送门:项目链接
    推荐理由:这个 JS 库项目可以用于解决一个常见的问题:计算出某个过去的时间是在多久以前。这个项目不仅支持多种语言,而且除了默认的数据处理方式外,它也提供了让开发者自定义输出语言及格式的功能,可以轻松适应需要特殊语言风格的页面。
    今日推荐英文原文:《JavaScript Tooling to the Rescue》作者:Juan Cruz Martinez
    原文链接:https://medium.com/better-programming/javascript-tooling-to-the-rescue-2279742a8d1e
    推荐理由:介绍 JS 中常用的几个工具

    JavaScript Tooling to the Rescue

    The benefits of Webpack, Babel, ESLint, and Prettier

    Today there are a number of development tools available for JavaScript developers to make our job easier. These tools let us stop worrying about the mundane tasks related to application development and focus on the really important part, coding.

    In this article, I am presenting a few of the most popular JavaScript tools among developers: Webpack, Babel, ESLint, and Prettier. If you haven’t used even one of them in your projects, trust me, you are missing out. Definitely give them a try on your next project.

    Webpack

    Webpack is a popular module bundler among JavaScript developers. It takes the large collection of JavaScript modules in your application as input and bundles them into one or several JS files that you can easily include in an HTML document.

    A modern-day web application contains a considerably high number of JS files because of our tendency to use more and more dynamic features in the application. While the added features are great for the users, managing these modules along with other third-party dependencies used in the application without additional support could become quite a headache for developers.

    For example, you’ll have to manually control the order in which each script is executed on the browser. Loading many files could also affect the performance of your application.

    With the use of Webpack, you can stop worrying about these issues. Webpack easily and efficiently takes care of this business for you. It analyzes the JS modules of the application starting from an entry point, and constructs a dependency graph. With the help of loaders and plugins, it then handles tasks like dealing with dependencies, deciding load priorities, and resolving paths.

    It’s not just for JavaScript. You can also use Webpack’s css-loader to manage the CSS files.

    Webpack allows you to define split points in the code so that the output is bundled to several JS files instead of a single long file. It gives you the freedom to load parts of code only when they are needed.

    This on-demand, lazy loading could be used efficiently to increase the performance of your application. You load the new code blocks only when the user has done something to require their functionality.

    Especially if you are working with frameworks like React, the functions provided by Webpack — splitting and bundling code, dealing with dependency modules — will save you a lot of the hassle of managing them by yourself.

    Babel

    Babel is the most popular transpiler for JavaScript. It converts ES6 JavaScript code into ES5 JavaScript so that the code can run in even old browser versions.

    Transpilers are tools that take the code written in one language as input and convert it to another language. In Babel’s case, it mainly takes ES6 code and outputs ES5 code.

    Take the following code snippet written using newly introduced classes in ES6.
    class Person {
    
      constructor(name){
        this.name = name;
      }
    }
    let person = new Person("Mark");
    
    Babel will convert it into ES5 like this.
    "use strict";
    function _instanceof(left, right) { 
       if (right != null && typeof Symbol !== "undefined" &&      right[Symbol.hasInstance]) { 
           return !!right[Symbol.hasInstance](left); 
       } else { 
            return left instanceof right; 
       } 
    }
    function _classCallCheck(instance, Constructor) { 
        if (!_instanceof(instance, Constructor)) { 
            throw new TypeError("Cannot call a class as a function"); 
        } 
    }
    var Person = function Person(name) {
      _classCallCheck(this, Person);
      this.name = name;
    };
    var person = new Person("Mark");
    
    If that’s all Babel does, why should you use Babel in your project? Though developers embraced new ES6 features introduced to JavaScript, some browsers are yet to catch up with ES6 support.

    If the users of your web application are using one of these browsers, or simply using older browser versions, they won’t be able to take advantage of all the great features you have added to the application. To make sure your app is accessible to everyone, Babel steps in and transpiles your code to ES5, which is supported by all the browsers.

    Should you stop using Babel after all the browsers start supporting ES6? The answer is no. Even though the focus is currently on ES6, ECMA releases new JavaScript updates yearly. It’ll always take browsers some time to catch up with the newest standards.

    But with the support of Babel, which adopts the newest standards much sooner, you won’t have to worry about transitioning to use new JavaScript features when developing your applications.

    If you are a React developer who wants to use ES6 features or JSX in your code, letting Babel help you with transpiling the code to ES5 is the wise choice to make. Also, you can use Babel with Angular to write ES6 code.

    In addition to ES6, Babel can transpile TypeScript to ES5 as well.

    ESLint

    ESLint is the default linter of most JavaScript developers. It helps you write cleaner code and adhere to the coding conventions you follow.

    The task of a linter is to analyze your code and flag programming and style errors in it. With ESLint, you have complete control over which errors should be flagged and what their error level is. You can define the error levels of a rule as error, warning, or disabled.

    ESLint is quite useful to spot errors like an undeclared variable assignment and issues related to variable scope.

    You can also use rules to enforce certain coding conventions in your code. For example, you can define rules to disallow the use of await inside loops or disallow the use of console.

    If the project you are involved in follows a specific style guide and coding convention, you can define ESLint rules to help you stay consistent with them. If the style guide you follow has a limit on continuous empty lines, you can specify this in the rules. Then, whenever you mistakenly leave too many empty lines, ESLint shows an error in your code.

    Prettier

    Prettier is a code formatter. You can use it to automatically format your code without having to manually check for style errors.

    Though it comes with a set of rules for its preferred style, you can set up your own rules to reflect the style guide you follow. Then all you have to do is save the source file for Prettier to format your code to suit the defined rules.

    Similar to ESLint, Prettier helps you write cleaner code that conforms to a style guide of your choice. The difference between ESLint and Prettier when it comes to enforcing style is that ESLint only shows you errors on what you are doing wrong, but Prettier does the formatting by itself.

    But it’s important to understand that they are not interchangeable. ESLint offers more use cases than checking style errors.

    Conclusion

    The JavaScript ecosystem relies on tools that help developers to resolve problems and build amazing apps. These tools provide support for clean code, compatibility issues, and performance.

    It is thanks to these tools that frameworks like React are possible and that JavaScript can be present in much more than just the web.

    It is also true that some of these tools are here just to fix the “mess” that JavaScript legacy left us.

    Thanks for reading!
    下载开源日报APP:https://opensourcedaily.org/2579/
    加入我们:https://opensourcedaily.org/about/join/
    关注我们:https://opensourcedaily.org/about/love/
  • 开源日报第947期:《铜豌豆 Linux》

    12 11 月, 2020
    开源日报 每天推荐一个 GitHub 优质开源项目和一篇精选英文科技或编程文章原文,坚持阅读《开源日报》,保持每日学习的好习惯。
    今日推荐开源项目:《铜豌豆 Linux》
    今日推荐英文原文:《Our Obsession With ‘Expertise’ Is Holding Us Back》

    今日推荐开源项目:《铜豌豆 Linux》传送门:项目链接
    推荐理由:Debian 是一款由来已久,完全开源的 Linux 发行版,优点是极其稳定且快速。但是但由于版权限制等多方面的原因,默认安装缺少中文桌面用户常用的软件。 而《铜豌豆 Linux》操作系统在 Debian 基础上,简化安装步骤,收集整理制作中文常用软件、一键安装脚本,搭建软件源,一次性安装完成常用中文应用,做到“开箱即用”。
    今日推荐英文原文:《Our Obsession With ‘Expertise’ Is Holding Us Back》作者:Seth Godin
    原文链接:https://forge.medium.com/our-obsession-with-expertise-is-holding-us-back-4c7cebd8a392
    推荐理由:只有我们自己心里清楚最后拿到的那张文凭里面到底有什么。

    Our Obsession With ‘Expertise’ Is Holding Us Back

    You don’t need a credential to create useful work

    There are many instances where a credential — like a certificate, a license, or a degree — is essential. Nobody wants a knee surgeon who learned the craft by watching YouTube videos. But you don’t need a permit to speak up, to solve an interesting problem, or to lead. You don’t need a degree to write a lyric, or take responsibility, either.

    You don’t need “expertise” to create useful work.

    The modern credentialing system was designed to maintain the consistency of our industrial output. But over time, that system has expanded to create a roadblock. By relying on certificates and degrees to confer expertise, we slow down people who would otherwise make change happen by trying things out.

    Think about the leaders you most respect, in any field. Find out what got them where they are. Was it a degree? Or did they get things done by simply doing the work?

    There’s a myth that a “famous college” is the same thing as a “good college.” But there’s no evidence that the quality of an education depends on whether or not an institution is well-known.

    Famous colleges rely on a perception of scarcity. We think “it’s hard to get into those schools,” and therefore value their credentials more. Our cooperation and belief is what builds their reputation. In exchange, we can see a degree from a famous school as a status symbol. They’re only famous because we want them to be famous. We want them to be famous because our society places greater value on credentials than ability.

    From an early age, high achievers are taught to sacrifice independent thought for a good grade. We’re taught that compliance will be rewarded by “being picked.” And the biggest pick for many kids is the approval that comes from gaining admission into a famous college.

    Our credential-obsessed society teaches high achievers to equate success with approval from an external authority. Unfortunately, this outlook undermines your ability to trust yourself.

    It is a convenient place to hide from our own potential.

    After all, if you haven’t “been picked,” you’re off the hook. And if you don’t have the means to apply or pay for the credential, you don’t even have to bother getting rejected, because you’ve already rejected yourself.

    A better way to think about credentials

    In the Wizard of Oz, when the Wizard gave the Scarecrow his diploma, he didn’t give him anything that he didn’t already have. The paper was unnecessary external validation that helped the Scarecrow find the trust he probably could have captured on his own. The Scarecrow already had what he needed.

    Rejecting the trap of credentialing opens the door to fake experts. If no credential is needed — if everyone is qualified, leveraged, and able to do this job — aren’t we inviting hacks and charlatans in to do important work?

    I think the opposite is true. Credentialing lulled us into false confidence about who was actually an expert. The fact that you have a degree doesn’t mean you have insight, experience, or concern. You’ve acquired a piece of paper, but that doesn’t mean you care.

    Actions matter more today than ever before. We can see your work, hear your words, and understand your intent.

    Today, we can go beyond the credential and actually see your impact. We can create a body of work and a community that understands the impact we’re capable of.

    I’m not provoking you to become a charlatan (or to follow one). But we should all take the opportunity that’s available to engage in the long process of earning genuine expertise, in service of making a change.


    下载开源日报APP:https://opensourcedaily.org/2579/
    加入我们:https://opensourcedaily.org/about/join/
    关注我们:https://opensourcedaily.org/about/love/
←上一页
1 … 21 22 23 24 25 … 262
下一页→

Proudly powered by WordPress