未加星标

Doing things wrong

字体大小 | |
[前端(javascript) 所属分类 前端(javascript) | 发布者 店小二03 | 时间 2017 | 作者 红领巾 ] 0人收藏点击收藏

I wrote a blog post last week and bits of it were wrong. This is not a retraction of that blog post, I just wanted to share the feedback that I got, the things I changed and some lessons that I learned.

Inconsistency sucks

The first feedback I received was from posting the article on /r/javascript . The comment is deleted now so I can’t credit the author, but they pointed out a few things:

Code styles between my two examples were different Two semicolons were missing It was better to format chains of Promises by placing the .then on the following line and indenting

I knew that the style of the two snippets was different as one had been written a year ago for the 12 Devs of Christmas blog and I had opted to retain the original code. But, mixing code styles in a project is unforgivable so why should a blog post be any different?

The formatting issues were also obvious once they had been pointed out to me. So, I went back to the post, improved the Promise formatting and fixed both the semicolons and the code style .

Over promising under delivers

The second piece of feedback came over Twitter, firstly in a direct message from Masse Fierro and then in a mention from James DiGioia . I’d gotten paranoid with my Promises and written one or two too many. I just needed to return the final data and not resolve another Promise.

const punkAPIPromise = fetch(punkAPIUrl) .then(res => res.json()) - .then(data => Promise.resolve(data[0])); + .then(data => data[0]);

Thanks to Masse and James I fixed that too .

Accessibility matters

The last thing to be pointed out, and probably the most important, was not about the content of the blog post but the accessibility of my site in general. Charlotte Spencer pointed out that my site failed colour contrast tests for both the code samples and links on the site. The tests they referred to are the Web Content Accessibility Guidelines on colour contrast which recommend a contrast ratio of at least 4.5:1 for regular body text. I learned some interesting things trying to fix this:

tota11y , by the Khan Academy , is a really awesome tool I learned about it from the link Charlotte shared with me It suggests colours that are similar to the existing colour that would pass the test It also has other plugins that visualise things like out of order heading usage, poor link text, missing alt attributes and a few more, helping you to ensure your site is as accessible as possible Syntax highlighting themes are really bad at accessible contrast levels I was using a version of Solarized Dark which failed in a number of places I couldn’t find any syntax highlighting theme that had decent contrast for all elements out of the box Using syntax highlighting in your editor is one thing, you can use whichever contrast levels you are comfortable with, but on the web anyone could be reading it

Eventually I chose to use the suggestions from tota11y to fix the four colours in Solarized Dark that were too low contrast . I also fixed my link text colour.

I was a little embarrassed about this because, as I said in a tweet , I thought I used to be good at this sort of thing. So much so that almost 10 years ago I wrote a blog post on the very matter of colour in web accessibility . This just goes to show that not only do we learn new things every day in web development, retaining old things is just as important.

Always be improving

I want to thank Masse, James, Charlotte and the now mystery Redditor for giving me the feedback that helped to improve both my blog post and my site. If you see anything on this site that could be improved I welcome the feedback. I learned that I should keep my eye on the formatting and consistency of my code, not to over promise and to pay closer attention to accessibility concerns.

Overall I learned that in order to always be improving―my code, my site, myself―sometimes I need to do things wrong.

本文前端(javascript)相关术语:javascript是什么意思 javascript下载 javascript权威指南 javascript基础教程 javascript 正则表达式 javascript设计模式 javascript高级程序设计 精通javascript javascript教程

主题: Twitter
分页:12
转载请注明
本文标题:Doing things wrong
本站链接:http://www.codesec.net/view/532871.html
分享请点击:


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 前端(javascript) | 评论(0) | 阅读(25)