Keeping things in sync: derive vs test
Lukeplant.me.uk » Web Development
by Luke Plant
4M ago
An extremely common problem in programming is that multiple parts of a program need to be kept in sync – they need to do exactly the same thing or behave in a consistent way. It is in response to this problem that we have mantras like “DRY” (Don’t Repeat Yourself), or, as I prefer it, OAOO, “Each and every declaration of behaviour should appear Once And Only Once”. For both of these mantras, if you are faced with possible duplication of any kind, the answer is simply “just say no”. However, since programming mantras are to be understood as proverbs, not absolute laws, there are times that obey ..read more
Visit website
Enforcing conventions in Django projects with introspection
Lukeplant.me.uk » Web Development
by Luke Plant
8M ago
Naming conventions can make a big difference to maintenance issues in software projects. This post is about how we can use the great introspection capabilities in Python to help enforce naming conventions in Django projects. Contents The problem: DateField and DateTimeField confusion The tools Introspection Django app and model introspection Django checks framework The solution Output Conclusion Links Let’s start with an example problem and the naming convention we’re going to use to solve it. There are many other applications of the techniques here, but it helps to have ..read more
Visit website
Super-fast Sphinx docs, and SNOB driven development
Lukeplant.me.uk » Web Development
by Luke Plant
1y ago
If you are using static HTML files for your docs, such as with Sphinx or many other doc generators, here is a chunk of code that will speed up loading of pages after the first one. If you’re using some other docs generator, the instructions will probably work with minimal adaptation. Create a custom.js file inside your _static directory, with the following contents: var script = document.createElement('script'); script.src = "https://unpkg.com/htmx.org@1.9.5" script.integrity = "sha384-xcuj3WpfgjlKF+FXhSQFQ0ZNr39ln+hwjN3npfM9VBnUskLolQAcN80McRIVOPuO"; script.crossOrigin = 'anonymous'; scri ..read more
Visit website
No-one actually wants simplicity
Lukeplant.me.uk » Web Development
by Luke Plant
1y ago
The reason that modern web development is swamped with complexity is that no one really wants things to be simple. We just think we do, while our choices prove otherwise. A lot of developers want simplicity in the same way that a lot of clients claim they want a fast website. You respond “OK, so we can remove some of these 17 Javascript trackers and other bloat that’s making your website horribly slow?” – no, apparently those are all critical business functionality. In other words, they prioritise everything over speed. And then they wonder why using their website is like rowing a boat through ..read more
Visit website
Announcement: Django Views - The Right Way
Lukeplant.me.uk » Web Development
by Luke Plant
1y ago
I announced this a few days back on Twitter, this is just a quick additional blog post to announce Django Views - The Right Way. It's an opinionated guide to writing views in Django that I've been working on for a few months. This project turned out to be much bigger than I expected. And in the end, more about general programming and Python principles than just Django – so you may enjoy it even if you're not into Django ..read more
Visit website
Why I'm leaving Elm
Lukeplant.me.uk » Web Development
by Luke Plant
1y ago
Over the past year or so, I've reluctantly come to the conclusion I need to leave Elm and migrate to some other language (most likely Bucklescript via philip2), and I definitely cannot recommend it to anyone else. This post is about my reasons for that, which are mostly about the way in which the leadership behave. I'm not going to talk about the good points of Elm as a technology. You can read them other places, and they will probably be true. Elm (up to version 0.18, at least) has been a joy to work with, and it will be hard to replace. I should also note “Your Mileage May Vary” etc. It woul ..read more
Visit website
You can stop using user-scalable=no and maximum-scale=1 in viewport meta tags now
Lukeplant.me.uk » Web Development
by Luke Plant
1y ago
Many websites are still using a viewport meta tag like one of the following: <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"> These days, you can almost certainly remove the maximum-scale or user-scalable properties, to leave: <meta name="viewport" content="width=device-width, initial-scale=1"> This is the same as suggested by HTML5 boilerplate, so it should be a pretty good default for most people. Why should you remove these properties? Becaus ..read more
Visit website
Re-using CSS for the wrong HTML with Sass
Lukeplant.me.uk » Web Development
by Luke Plant
1y ago
Recently, while writing up some examples and pattern for using htmx with Django for form validation, I discovered a new trick for using externally defined CSS without having to change the HTML you are working with. To make it concrete, an example might be that you are using some CSS from a CSS library or framework that requires your HTML to look a certain way. In the Bulma framework, for instance, you have to add the right class attribute directly on an element that needs styling. At the same time, you might be working with another system that is generating the HTML for you, and modifying that ..read more
Visit website
Two experiences with Elm
Lukeplant.me.uk » Web Development
by Luke Plant
1y ago
This is a post about two experiences I had using Elm. It is quite long, written primarily for the sake of other people who might be considering using Elm – the things that might trip you up etc. I have put quite a lot of content into footnotes for the sake of brevity, so you are advised not to read footnotes unless you want the gory details. At the very end, however, it gets derailed as I attempt to address what I see as a potential critical weakness in Elm or the Elm community, triggered by some recent events. I tried to separate out these two things into separate posts, but realised that the ..read more
Visit website
Django and Sass/SCSS without Node.js or a build step
Lukeplant.me.uk » Web Development
by Luke Plant
1y ago
Although they are less necessary than in the past, I like to use a CSS pre-processor when doing web development. I used to use LessCSS, but recently I’ve found that I can use Sass without needing either a separate build step, or a package that requires Node.js and npm to install it. The heart of the functionality is provided by libsass, an implementation of Sass as a C++ library. On Linux systems, this can be installed as a package libsass or similar, but even better is that you can pip install it as a Python package, libsass. When it comes to using it from a Django project, the first step is ..read more
Visit website

Follow Lukeplant.me.uk » Web Development on FeedSpot

Continue with Google
Continue with Apple
OR