5 Tips to Become a Recognized Software Developer

Software developers are the unsung heroes of the industry. They toil tirelessly performing crucial digital duties behind the scenes, but are rarely acknowledged for their contributions to the success of the venture, at least publicly.

As with any field, however, there’s always the possibility of garnering some well-deserved acclaim—provided you do outstanding work and are willing to devote time to polishing your professional image.

Code blocks, but better

Pedro Duarte made a wishlist for styled code blocks in blog posts and documentation, then hand-rolls a perfect solution for that wishlist. For example, a feature to be able to highlight certain lines or words within the code block. The line highlighter is unique in that it only syntax highlights the highlighted lines, leaving the rest gray, which is a neat way to draw focus. And the word highlighter works via a RegEx. Pedro notes this isn’t a tutorial, it’s just a showcase of all the features that were stitched together using an existing combination of custom code and existing libraries. It’s pretty specific to React + Next.js + MDX, but apparently the core of it is based on rehype, which is new to me.

The results are pretty darn nice, modern-looking code blocks if you ask me! At the same time, I think it’s equally notable what’s not there as opposed to what is. I’ve seen (and tried) really featured-packed code blocks in the past, with features like a copy to clipboard button, a view raw code button, and export to whatever services. Pedro’s code blocks don’t even have an option to show the language in use.

Everybody’s wishlist is different. One thing that isn’t on Pedro’s wishlist is server-side rendering, but you can see on the blog post itself that it totally works with that (it’s presumably just Next.js at work). I’m pretty envious of that. Even though we’re ultimately both using Prism.js as the syntax highlighter, I’m only using it client-side. It occurs to me now that I could perhaps pull all this off in a Cloudflare Worker by using the HTMLRewriter — meaning it would essentially look like it’s done server-side and I could rip off the client-side copy of Prism. Maybe even more ideally, though, is that I’d do it as a WordPress plugin. Basically a PHP port of Prism, which seems like a tall order.

My wishlist for code block plugin…

  • Syntax highlighting (both on the rendered site and while authoring)
  • Server-side rendered <span class="token-foo"> stuff for syntax highlighting
  • Works nicely with the native WordPress block editor code blocks (```). For example, pasting in a code block auto-detects and uses the correct block. Easy to convert code to and from this kind of block.
  • Optional line highlighter
  • Optional line numbers
  • Optional word highlighter
  • Optional language display (and the ability to override that label)
  • Copy and paste very cleanly
  • No need to escape code while authoring
  • Freedom to style however on the front end (for modes, themes, custom scrollbars, etc). Styling code blocks has a million things to consider, so smart defaults should probably come with the plugin, but easy to override.
  • Stretch goal: can it somehow help with inline code as well?

Direct Link to ArticlePermalink


The post Code blocks, but better appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

The Engineer’s Complete Guide to Code Quality

You might not realize it, but you probably know when you see bad quality code. It might be written in a way that doesn't make sense, be full of errors, excessively verbose, or highly inconsistent in its use of terminology and naming conventions. Fortunately, there are lots of ways you can improve your code quality, make it easier to review and test and reduce the pain later of having to fix all of the errors. Let's take a look.

The Basics of Code Quality

Code quality refers to the attributes and characteristics of your code. These may differ according to your organization's specific business focus and the particular needs of your team. While there's no definitive checklist, there are broadly several things that separate good quality code from poor quality.

How to Maintain a Healthy Codebase While Shipping Fast

One of my greatest privileges building Stepsize has been hearing from hundreds of the best engineering teams in the world about how they ship software at pace while maintaining a healthy codebase.

That's right, these teams go faster because they manage technical debt properly. We're so used to the quality vs. cost trade-off that this statement sounds like a lie—you can't both be fast and maintain a healthy codebase.

Get a Jump Into GitHub Actions

On January 27, 2021, Angie Jones of Applitools hosted Brian Douglas, aka "bdougie", a Staff Developer Advocate at GitHub, for a webinar to help you jump into GitHub Actions. You can watch the entire webinar on YouTube. This article goes through the highlights for you.

Introduction

Brian Douglas and Angie Jones infographic.

Angie Jones serves as Senior Director of Test Automation University and as Principal Developer Advocate at Applitools. She tweets at @techgirl1908, and her website here

WCAG 1.3: Adaptable

The third WCAG Guideline, Adaptable, is part of the Perceivable principle and covers adapting to the different needs of users by allowing content to be received in multiple ways. WCAG 1.3: Use Semantic HTML One of the most important ways...

The post WCAG 1.3: Adaptable appeared first on Treehouse Blog.

Learning Vim for Beginners

Vim, or Vi Improved, is a powerful text editor that lets you do almost everything using keyboard shortcuts. You can replace text in a document, move or delete lines, automate edit actions, and more, without ever reaching for the mouse. Vim is the favorite source code editor of programmers but there’s no reason why you cannot use this editor for writing documents or composing long emails.

Vim can be confusing for people who are used to working inside visual editors like Microsoft Word or Google Docs but spend some time with Vim and it will be difficult for you to go back. Entire books have been devoted to teaching Vim but if you can manage to learn the basic commands, you’ll find yourself more efficient and productive.

Vim Logo

How to Learn Vi

Here’s a list of online tutorials and other helpful resources to help you learn Vim.

1. OpenVim - An interactive tutorial for learning the basics of Vim. Switch to the Practice page to test your existing Vim skills.

2. Vim Adventures - An online puzzle game for learning and memorizing Vim commands. You play the character of a blinking cursor that has to navigate the maze with the letter keys. If you are stuck, you can always type :help for a hint.

3. Vim Genius - This a flashcard style game to help you learn the basics of Vim. There are dedicated lessons for learning the motion keys (h,j,k,l) and for mastering copy-paste in vim.

4. Learn to Love Vim - The Linux Voice magazine has put together a quick video tutorial to get you started with Vim.

5. Vim Basics - Derek Wyatt has produced a bunch of video tutorials (screencasts) around teaching Vim. A good resource for novice users who prefer learning Vim by watching than reading.

6. Learning Vim - Mike Coutermarsh covers getting up and running, and eventually productive with Vim.

7. Vim - Precision Editing - Drew Neil, author of the popular Practical Vim title and Vimcasts.org, walks you through Vim and how the text editor is optimized for mouseless operations.

8. Vim Tutorial - The official Vim documentation is excellent and includes a step-by-step tutorial. You can also access this tutorial inside the Vim program through the :vimtutor command.

9. Vim Cheat Sheet - Print this because you’ll need it later.

10. Vim Masterclass - This Udemy course will help you master all the concepts of Vim and how to ‘think’ in Vim.

If you spend a lot of time typing text, learning Vim will be totally worth the effort. I wrote this article inside Visual Studio Code with Vim key bindings.

Styling Code In and Out of Blocks

We’ll get to that, but first, a long-winded introduction.

I’m still not in a confident place knowing a good time to use native web components. The templating isn’t particularly robust, so that doesn’t draw me in. There is no state management, and I like having standard ways of handling that. If I’m using another library for components anyway, seems like I would just stick with that. So, at the moment, my checklist is something like:

  • Not using any other JavaScript framework that has components
  • Templating needs aren’t particularly complex
  • Don’t need particularly performant re-rendering
  • Don’t need state management

I’m sure there is tooling that helps with these things and more (the devMode episode with some folks from Stencil was good), but if I’m going to get into tooling-land, I’d be extra tempted to go with a framework, and probably not framework plus another thing with a lot of overlap.

The reasons I am tempted to go with native web components are:

  • They are native. No downloads of frameworks.
  • The Shadow DOM is a true encapsulation in a way a framework can’t really do.
  • I get to build my own HTML element that I use in HTML, with my own API design.

It sorta seems like the sweet spot for native web components is design system components. You build out your own little API for the components in your system, and people can use them in a way that is a lot safer than just copy and paste this chunk of HTML. And I suppose if consumers of the system wanted to BYO framework, they could.

So you can use like <our-tabs active-tab="3"> rather than <div class="tabs"> ... <a href="#3" class="tab-is-active">. Refactoring the components certainly gets a lot easier as changes percolate everywhere.

I’ve used them here on CSS-Tricks for our <circle-text> component. It takes the radius as a parameter and the content via, uh, content, and outputs an <svg> that does the trick. It gave us a nice API for authoring that abstracted away the complexity.

So!

It occurred to me a “code block” might be a nice use-case for a web component.

  • The API would be nice for it, as you could have attributes control useful things, and the code itself as the content (which is a great fallback).
  • It doesn’t really need state.
  • Syntax highlighting is a big gnarly block of CSS, so it would be kinda cool to isolate that away in the Shadow DOM.
  • It could have useful functionality like a “click to copy” button that people might enjoy having.

Altogether, it might feel like a yeah, I could use this kinda component.

This probably isn’t really production ready (for one thing, it’s not on npm or anything yet), but here’s where I am so far:

Here’s a thought dump!

  • What do you do when a component depends on a third-party lib? The syntax highlighting here is done with Prism.js. To make it more isolated, I suppose you could copy and paste the whole lib in there somewhere, but that seems silly. Maybe you just document it?
  • Styling web components doesn’t feel like it has a great story yet, despite the fact that Shadow DOM is cool and useful.
  • Yanking in pre-formatted text to use in a template is super weird. I’m sure it’s possible to do without needing a <pre> tag inside the custom element, but it’s clearly much easier if you grab the content from the <pre>. Makes the API here just a smidge less friendly (because I’d prefer to use the <code-block> alone).
  • I wonder what a good practice is for passing along attributes that another library needs. Like is data-lang="CSS" OK to use (feels nicer), and then convert it to class="language-css" in the template because that’s what Prism wants? Or is it better practice to just pass along attributes as they are? (I went with the latter.)
  • People complain that there aren’t really “lifecycle methods” in native web components, but at least you have one: when the thing renders: connectedCallback. So, I suppose you should do all the manipulation of HTML and such before you do that final shadowRoot.appendChild(node);. I’m not doing that here, and instead am running Prism over the whole shadowRoot after it’s been appended. Just seemed to work that way. I imagine it’s probably better, and possible, to do it ahead of time rather than allow all the repainting caused by injecting spans and such.
  • The whole point of this is a nice API. Seems to me thing would be nicer if it was possible to drop un-escaped HTML in there to highlight and it could escape it for you. But that makes the fallback actually render that HTML which could be bad (or even theoretically insecure). What’s a good story for that? Maybe put the HTML in HTML comments and test if <!-- is the start of the content and handle that as a special situation?

Anyway, if you wanna fork it or do anything fancier with it, lemme know. Maybe we can eventually put it on npm or whatever. We’ll have to see how useful people think it could be.


The post Styling Code In and Out of Blocks appeared first on CSS-Tricks.

You can support CSS-Tricks by being an MVP Supporter.

3 Hardest Python Code Challenges and How To Overcome Them

Python as a programming language is used for developing desktop and web-based applications. It is an open-source, high-level programming language that is versatile and can be used for different purposes but is used mainly for data analysis, back-end website development, and artificial intelligence. Python is regarded as one of the easiest programming languages to learn and also very user-friendly.

However, for first-time users, beginners, and learners, they could encounter different Python challenges, which could discourage them. Before discussing what these challenges are in Python, it’s essential to learn one or two things about Python first.