Ben Frain — Enduring CSS and Self-Publishing

Ben Frain is a senior front-end developer at bet365 and the author of Enduring CSS. In a previous life he was a TV actor and technology journalist. In this interview with Len Epp, he talks about his circuitous path into web development, the challenges of building betting interfaces at scale, the CSS architecture methodology behind his book, and his experience self-publishing on Leanpub.

Len Epp: I usually like to start these interviews by asking people for their origin story. I know from an interview I read about you that in your case, the path to where you are now is perhaps a little more circuitous than it is for most people.

Ben Frain: Obviously I’m primarily a software developer now, and the closest I got to software development in my younger years was when we had a BBC Model B computer when I was a young boy. We used to get computer magazines here in the UK that contained a program which you could spend four or five days of your life typing out and then hit go, and they never worked. So that was my initial foray into programming.

I always wanted to be a film director, so from young teens that was where my head was. I did film directing at university and tried desperately to get into that career, which where I live in the UK isn’t exactly a hotbed for the film industry. But off the back of that I used to do a lot of acting as well, got an agent, and did about five years of TV acting here in the UK, none of which set the silver screen alight, but soaps that are well known over here like Coronation Street and the like. The frustration with that career was that I was imagining myself getting alongside Bobby De Niro, and I was actually getting 10 lines on a not so great soap opera, and so my idea of where I wanted to be and reality weren’t measuring up.

I’d started to write my own stuff, and I’d written a screenplay and I wanted to try and get that off the ground. I’d done short films before, and at the same time is when I started to dovetail it in with the beginnings of web design. This was about 98, 99, and like a lot of people do websites for the band, my first website was one for a short film that I’d made. So these two lives started to develop, one where I was furthering my web development skills and the other where I was trying to get this film career going. The reality was that on a long enough timeline what I wanted to do didn’t pan out and what I never planned on doing did.

I tried to get films off the ground myself, tried to get them financed. It was very tough and I basically failed. The screenplays made no money, but I was writing for technology magazines here in the UK and abroad. So that was where I was making my money, making websites for other people and writing for magazines, and trying to get these screenplays off the ground that never saw the light of day. Eventually it just came to the point where I was so much better at the web development, that was taking off, that’s the path that I followed.

That brings us up to about 2011. I’d been doing web development freelance for quite some time and decided to try my hand at a book. So I did a couple of books with Packt Publishing, and I have always enjoyed the writing process, because I feel like I probably learn as much by writing something for other people as I do just trying to learn for myself. There were good things about writing for a publisher and there were lots of bad things, and I know we’ll get to the bad things later on maybe. But that gives you the abridged versions of my torrid career path, I guess.

Len: I have a question specifically about the process of getting a screenplay funded. Maybe like some other listeners, I’ve written a couple myself, totally amateurishly, and entered them in screenplay contests or passed them around to friends. When you say you tried to get them off the ground, what does that mean? Approaching producers you’ve been introduced to, or trying to get introductions to people with money who are interested in producing a film?

Ben: It was a bit of both. I’d done a bit of screenwriting and I managed to get a literary agent off the back of that. Much like my acting ideals didn’t match up with the reality of what agents wanted me to do, it was the same case with the screenwriting. They wanted me to be writing episodes of soap operas and I wanted to be writing blockbuster films. But it was basically any producers that would let you bend their ear, and there were production companies as well. You probably had a very similar experience, you get a lot of responses from people that sound quite promising but ultimately end up in nothing. When you’re in the beginning of that journey you always feel like you’re on the cusp of something happening, and for me at least it never actually did.

The one that I was going to try and make myself, what I planned to do was find a thousand people to each put in a thousand pounds, so everyone would have an equal share in this million pound low budget film. But I just didn’t anticipate what a skill producing is, and how difficult it is to actually go out and get money out of people. I spent all the time on the script and the director and the cinematography and storyboarding, and I thought of course people would want to put only a thousand pounds to be part of a film. I just thought that would be a given, and nobody did. So it didn’t pan out that well.

Len: It sounds like having a screenplay and trying to get it produced is a little bit like being a startup and approaching venture capitalists, almost none of whom will ever give you an outright no. That’s interesting, the crowdfunding model that you’re describing. Have you ever thought about using Kickstarter or something like that?

Ben: There was a thing a while back when I was last seriously dabbling, called Trigger Street, which I don’t know if it’s still going. I think it was something that Kevin Spacey had set up, and that was quite interesting because you put your screenplay in and it was voted on by other members of the site, and the highest ones each month got put before a panel. The truth of the matter is I’ve moved past it mentally. I’ve got two young sons now and I think the one remaining thing that I’d like to do for them is to try and write a novel for them, as my belief that I could get one of these screenplays sold is fading with every day, sadly.

Len: Speaking of moving on, you’ve written about the change from being kind of a lone wolf working for yourself to being an employee for a company. How did that affect you, and what have you lost and gained?

Ben: For about 10 years I worked just for myself, freelance, essentially a sole worker, and that was all absolutely fine. The rub of that is that what you actually like doing is just one portion of your day-to-day. You’ve got to chase jobs coming in, you’ve got to chase payment, which generally people in the freelance trade don’t like, and I certainly didn’t either. The good part about freelancing is that once you know how to put structure into your day, there’s a leeway that if at four o’clock one day you just know your brain’s not working very well, you can go out and get a cup of coffee or whatever. That feeling of being what you imagine an adult to be, where you’re in charge of your own destiny day to day, that’s what’s really nice about it.

The flip side of it, I was approached to join bet365 by a recruitment agency in the UK. When you’re a freelancer doing public-ish work on the web, recruiters are contacting you quite a lot of the time, so that was no surprise. But the thing that they described to me was quite interesting, and it was fairly close to where I live. They didn’t say specifically who it was at the time, but they said it was a large company, and there’s only two really big companies near to where I live, one of which is bet365 and the other is JCB. It wasn’t JCB because I’d already been and spoken to them, so it turned out to be bet365.

I joined them fully believing that I would be there maybe a couple of weeks, and somebody telling me what to do every day would very quickly wear thin. There’s a quote that I heard from somebody, and they said, “people don’t leave jobs, they leave bosses,” and I always think that’s quite interesting, because the guy who took me on is still my boss. He’s just a really good guy and I get on with him very well and I enjoy working with him. That’s the part of working for a company that I’d missed but didn’t realise I missed. I’m working with two or three people pretty closely every day and I enjoy it.

It must be like people who are in a band, being able to bounce ideas off people, which is what you miss when you’re working for yourself. It’s nice if you’re doing anything creative to be able to stop and sit around a table and put some sketches down and go, “this is what we’re thinking of doing,” being able to bash that stuff back and forth. That’s the stuff that I actually enjoy doing the most. That’s the real buzz of it, when the ideas bounce back and forth and you come up with something that no one person would have come up with all by themselves.

Len: Speaking about buzz, I’m not sure if everyone listening knows this, but in England it’s more or less legal to bet on anything. I actually lived over there for nine years, and I’m familiar with the sight of the odds makers. I was wondering if there is any special buzz around working for a betting company. Is there an extra kind of pressure or constraint on you?

Ben: The funny thing is I was never somebody who ever bet on anything. I was never brought up with betting in our family at all, and I can remember distinctly thinking, I don’t know if I’m comfortable with a betting company, it felt slightly weird to me, almost like a tobacco company or something like that. But the reality is that it’s very much a cultural thing, and it’s just not a big deal here. It’s not considered weird in any way, in much the same respect as people would go out and have a drink in a bar and 99% of people are absolutely fine. You occasionally get people that don’t respond well, when you get alcoholism and all that sort of stuff, and by the same token you get the odd people in terms of gambling that go the same way and they get addicted to it. So it’s a really difficult subject to really feel out the edges of.

But in terms of what I do day to day, which is build the interfaces for these things, there are very few applications on the web which are by necessity as complicated as a betting application needs to be. So that does present some unique challenges which are pretty exciting to try and solve and architect. From my point of view it’s a good thing, because other than that I’d be doing the same brochure sites and magazine sites that are much more common.

Len: It just sounds exciting to me. I’ve met a couple of people who worked doing the odds, and it could be literally anything, right? Like when will Charles and Camilla get divorced? The idea of just putting odds on that, and the user’s interaction with something like that, must be particularly tense.

Ben: The thing I’m most involved in is called the Sports Book, which is betting on live sporting events around the world, and it was unbelievable to me when I got there and saw the scale of what they do. As an example, right now you might go onto the site and there’s maybe 18 live soccer games happening, and we let you choose any one of those games, and we’ll either have a live video feed of that event, or we’ll give you an animated interactive computer version of it showing you what’s happening right now. At all these events around the world there’s guys and girls feeding back exactly what’s happening at this game at this point in time, and based upon that the odds are updating, which lets users choose which opportunities they want to bet on second to second. That’s a level and scale of interactivity that you just really can’t find in many other areas.

Len: I’m looking at it right now, actually. It looks really good. I see there are esports as well. Are you a part of that?

Ben: Yeah, all that sort of stuff. If you go to mobile.bet365.com on your phone, what you see there is the stuff that our team prototypes, builds up, and then we have another team of devs that take it and mesh it in with all the live data. We’re just constantly putting new things in there. Just when you think, right, we’ve thought of everything, there’s another whole set of features we want to add in. So it certainly moves very quickly. It’s a competitive market to be in, and it gets me out of bed every day. If it keeps your brain challenged and keeps you solving problems, that generally makes me quite happy.

Len: I kind of have to ask the obligatory Brexit question. But I guess it’s a reverse Brexit question, which is, as far as you know, did the EU ever try to put limitations on the British cultural practice of betting?

Ben: Funnily enough, it’s pretty across the whole of Europe. There isn’t really anywhere that doesn’t allow betting. I think if anything, America and Canada is kind of unique. China tries to say it doesn’t allow betting, but China has always been massively into gambling and betting culturally. There’s occasionally bits of legislation that are particular to different areas, like Italy has a certain set of specific requirements for in-play bets, but by and large they were at it.

Len: One more question about the switch from working on your own to working for a company. I made this switch about a year ago from working remotely to working in an office, and you’ve written about how much you enjoy being able to set up your own physical environment. Are there one or two pro tips you can give for setting up a physical environment?

Ben: The main thing is to try and get people to understand your ways, particularly if you’ve worked for yourself for a long period of time. You do have to have things the way that you want them. I’ve got to be honest, there aren’t many things that I’ve wanted at my current place of work that they haven’t accommodated in some way. The key difference for me is, if I was working for a company and it was a crummy, horrible monitor to sit in front of and they weren’t prepared to buy a new, better monitor, I would quite happily buy my own monitor and bring it in if they would allow me to, because I’d rather do that and have a nice working environment than use crummy tools. You sit in front of these things every day and that’s how you apply your craft. Whether they should or shouldn’t buy something better for you is a different question, but I’d rather just buy the things that I want to use to do my job and accept that as part of my professional outgoings. If we think about people in other trades and what they have to pay for the tools that they need, the absolute creme de la creme of kit you can get, top of the line MacBook Pro for a few thousand dollars, massive cinema displays, same sort of money, in the scheme of things compared to other professions it’s not a great deal of money.

Len: That’s very true. Your book Enduring CSS is about a method, I suppose you could call it, you’ve developed for organizing and doing CSS architecture on big projects. Could you explain a little bit about how you came to develop the approach and what the approach is?

Ben: CSS and HTML has been the core of what I’ve done over the years. Whilst I’ve dabbled in other technologies, of the three tiers of the front end stack, being JavaScript, CSS and HTML, I have specialised in the CSS, particularly in the HTML. What happens when you move to something of size with a lot of people all working on that code base, historically you’re always told to lean on the cascade in CSS. You make some styles and you inherit from those styles as much as you can. You try and write as little CSS as you can, and when you want to change something across the whole site, the thought being that you go back to that one thing that everything inherits from and you make those changes, which is all well and good.

But what I found once I started on these sizable projects with many different visual components was that often these things that started life looking quite similar often needed to transgress as time went on, and develop their own life and identity. You would make a change to one thing and it would end up inadvertently changing something somewhere else, which on something of scale is really problematic, because you need to be quite confident when you’re committing into a large code base that the changes you make are going to make just those changes, they’re not going to start visually changing things in other areas.

There’s been a few methodologies over the years like BEM, which is block element and modifier, and then there’s been things like OOCSS. The two main ways of approaching CSS at scale are, you either go for an atomic approach, where you make a little class for every single permutation of CSS, so at some point your CSS can’t get any bigger, but the downside is that you have to write 10 or 20 classes on every single node in the DOM to get it to appear the way that you want. The flip side of that is you try and contain styles, and by doing that you put one particular class on each node in the DOM, and then every single thing that’s needed to isolate and contain and render that thing perfectly is put on that class. You’re going to get a little bit more repetition, maybe a lot of repetition, because you’re going to be declaring things like the display type, colours, background colours, lots and lots, but things like gzip when it’s all smashed together nullify a great deal of that. So the ECSS methodology is based around the idea of isolation and containment. The principle being that by isolating these things with a namespace and various other characteristics, there’s no danger of styles leaking out from one component into another.

Len: You also talk about style sheet entropy. Is that something in what you just described, or is that something else?

Ben: I’m unsure of the exact context of where I’ve said that, it sounds like the sort of thing I would say. It’s the place where I came to look at the styles on a big site, whereby over months and years people have been working on a CSS code base, and it grows because nobody has the confidence. It’s back to that thing I was saying before, people are too afraid to make changes to existing CSS because they don’t know what it’s going to affect. Nobody seems to know what changing a class 200 lines above is actually going to do. So they use a very specific syntax and they write some more CSS, and you end up with this situation where the CSS only ever grows because nobody has the confidence to fully understand what the existing code is doing. Once you develop a very clear set of guidelines and principles for how you’re going to architect this stuff, it becomes very simple and manageable to deal with those styles, update them, remove them, knowing full well you’re not going to destroy everything.

Len: So I imagine the target audience for your book is people who are either on large-scale projects that have suffered from this kind of entropy, or people who are scaling up and want to adopt a best practice before they proceed.

Ben: Absolutely, and I think with all these things there’s trade-offs, there’s no right way to do anything. There’s just a set of problems and a solution that fits those problems. So I’m quite clear and quite vocal about saying, before you do anything you need to understand the problems you actually have. Don’t go and pick a methodology, whether it’s mine or anybody else’s, and just think, well that sounds pretty good, and slap that into your situation. You need to know exactly what the problems are that you’re trying to solve before you try and fit something to them.

Len: You’ve got a section where you talk about, and forgive me if I pronounce this wrongly, Pin Cing Do, which translates roughly as the way of pragmatic coding, and it means more or less solving the problems you actually have. But you immediately then go on to say, but the problems you have might not be the problems I have.

Ben: It’s a bit of a bugbear of mine, but we tend to be a bit like lemmings in web development, and we just follow what somebody decides is the next hot thing, without actually stopping and deciding if it’s the right thing for us. That’s part of what the whole Pin Cing Do thing is about. Having the confidence and developing the confidence to know what suits your particular circumstances, and knowing what things to concentrate on. Some of that takes time, but some of it also requires conscious effort, and not just getting carried away on the latest hot technology.

Len: On the subject of writing and publishing, you’ve written previously two books for what we might call a conventional publisher, and you decided to switch to self-publishing. Before I ask you specifically about Leanpub, why did you decide to make that switch, at least for this book?

Ben: The thing that’s good about a traditional publisher is obviously that they’ve got the scope and the avenues to get your book out in all the right places, which if you’ve never written books before, there’s some advantage to. The disadvantage is it’ll take a massive chunk of your royalty. You have to use horrible tools generally to write the books, you’re working in Word templates and the like, and you’re also stuck to a contract which means you’ve got to do stuff to a certain timeline. That can be a good and a bad thing. In fairness, I don’t think I would have written my first book if I hadn’t signed a contract, because that motivated me to write it. Sometimes not having the things that you’ve got to hit means that you never actually end up doing anything, so having something in place is good.

For me it was perfect to move to Leanpub, because having done that a couple of times I understood how to structure stuff and get stuff done, whilst at the same time I could move at my own pace because I didn’t have a contract to worry about. That’s the other big thing that’s a real annoyance with typical published books, no matter how fastidious you are with the detail, once that thing is published and you find those little four or five things which are wrong or need fixing, you’re done, they’re going to stay there and irritate you and everybody else forever. What’s lovely about Leanpub is a reader can email me, and have done, and within 10 minutes I can have the revised version up and live for people to re-download. That’s a lovely thing that feels like how it should be in this day and age.

Len: I couldn’t agree more. You made a comment about Word, so I imagine that you wrote your book in plain text using our Leanpub-Flavored Markdown syntax.

Ben: Yeah, I use Sublime Text. That’s where I spend like 95% of my working day, writing code, so it’s very easy for me to just flick open a new tab, put it in Markdown syntax, and away I go. Anything that I write starts out as Markdown, whether it’s a blog post or a book or a bit of documentation for work. The only time I got, well not even frustrated because it was a thing above and beyond, I wanted to have an online version of the book as well, at ecss.io, and what I wanted to do is use that same Markdown text to generate the HTML, so that I only ever had to update in one place. There’s just a couple of things which I wanted to be able to do in terms of putting classes on things, which I couldn’t do in the Markdown once it had run through the converter. These are minor things.

By and large it’s just been incredible. I think I started it off saying it was like 70% complete or something like that, so I kept chipping away at it until I got it to a point that I was happy with. Once it had run on Leanpub in a finished stage for a while, it’s easy to then go and stick it on Amazon or stick it on the iBookstore, literally within an hour you can have generated the right files and the right stuff that they need to get it out there. It’s just incredibly liberating when you’re used to dealing with the massive machinery of a big publisher.

Len: That was actually going to be my next question, did you publish it in progress? A lot of self-published authors talk about how they like the freedom, but sometimes you can miss the pressure because it helps you get motivated to finish. One thing we’ve tried to do is replace that with the concept of in-progress publishing. You publish something that’s 70% finished, and then you maybe start getting readers before you’re done, and the fact that your book is out there provides you with some motivation to finish it.

Ben: It definitely did for me, Len, because I’ve got a weird thing where it only had to be one person buying that book at the 70% stage and I felt a debt of honour to finish that thing for that person. The more people that buy it along the way obviously just adds the weight, and they become like the contract.

Len: I know your book is on Amazon as well as available in the Leanpub bookstore, and I can see that the pricing is different. Leanpub has variable pricing, you can set a minimum and a suggested price and people can choose to pay anything above the minimum. But on Amazon, your book is set at $9.99. I imagine that’s partly because Amazon starts to punish you if you make your book worth more than $9.99. What’s that like for you as an author, to have your book available in two different places?

Ben: The reality is it probably won’t be on Amazon for much longer, because it only went on about 10 days ago and I didn’t really realise at the time that that would be the case. It’s incredibly frustrating because obviously it’s taken a massive chunk of the money anyway, and they kind of strong-armed me into setting it at a certain price.

Len: As I understand it, there are all sorts of complications to Amazon’s royalty structure, but one of the main divisions is that you can earn up to, I think, a 70 percent royalty on a sale if your book is priced up to $9.99. After $9.99, it goes down to 30 percent. So if you price a book at eleven dollars, you can make less money than you would at $9.99. This is a particular issue for people who are writing technical books, or books that have a higher inherent value to the reader than other types of books. Because if it’s for your work, for your career, to solve a problem that can make an entire organization more efficient, then that book might be worth a thousand dollars, not $9.99, and Amazon is inherently structured to not be friendly to books of that kind.

Ben: It’s something that I wanted to get on there for an experiment, to see whether it would sell substantially more units that way. But it’s been on there about 10 days and it’s not sold any more than I have on Leanpub, and obviously it’s a much more frustrating process. Whether in time, once there’s reviews and stuff like that, that makes a difference, I’d be keen to know, but that’s something I’m saving up to talk to you about in a minute.

Len: Before we jump to that, you’ve mentioned making corrections and you’ve published in progress. Is engaging with readers something that’s been important to you throughout this process?

Ben: It is, and definitely with the subject of this book particularly, because it’s not like a simple do these things and there’s the answer and it can only be one answer. It is the sort of book where if you’re a CSS developer starting down this road, you’re going to have a lot of questions even after reading that book. So being able to have back and forth with people, you basically have to meet people on whatever medium they want. Whether you ask for it or not, some people are going to email you, some people are going to reach out to you on Twitter, and some people are going to put a comment on the site’s page. So you just have to be as vigilant as you can, to meet people wherever they are.

The other thing I would say that I found incredible was the variable pricing. I remember seeing that and thinking, well, that’s ridiculous, nobody’s ever going to pay more. And all the time people do, and bless them for doing it, because it’s just lovely. Literally I’d say every one in three is probably somebody who puts a little bit more than you’ve even asked for. From an author’s point of view, that’s obviously fantastic, and I never would have imagined that in a million years.

Len: We also get people who have bought a book and then read it and then approach us saying, “hey, can I now pay more?” So it’s essentially a kind of tip afterwards. Because since people can choose, it creates a very different commercial relationship between the customer and the thing they’ve bought and the people who produced it, because it introduces choice on their part about value. And that can be different from what yours is as an author, and it can actually change after they’ve had an experience reading the book.

Ben: That’s fantastic. I don’t care how famous people are, it’s always nice to get an email from somebody saying, “thanks for that, good job,” or “really enjoyed it,” or whatever. It makes your day. If anything makes that easier to do, it’s fantastic to open that dialogue with people.

Len: So moving on to the final part of the podcast. What is it that we can do for you that we haven’t done that you think would be a good addition to the process?

Ben: I think just reviews are the main thing for me. I know so many people that when they look at something, particularly books without any kind of testimonials and reviews, it just makes it more likely they’ll go away and think about it. I’m sure you must have thought about it a hundred times.

Len: We have thought about it. The only reason reviews don’t exist yet on Leanpub is because we’re a small team and we’re bootstrapped and there’s just always an endless number of things to do, but definitely reviews, and more broadly reader-author and reader-reader interaction, is a big part of Leanpub’s future. Currently the substitutes for reviews are reader testimonials that authors can add, which are obviously all going to be positive, but it puts a face and a name to a claim about the book. We also make it possible for people to download a sample of the book and have a look, the equivalent of being in an old-timey paper bookstore and taking some books off the shelf and having a flick through. And the last thing is that we have our 100% happiness guarantee, which means that with a couple of clicks people can get a refund within 45 days of purchase. People who know about that understand that buying the book is actually risk-free, so they might be more likely to buy a book without a recommendation. But reviews are definitely something that we need to add.

Ben: Other than that, the only thing that I can really think of is maybe more possibilities for extending the Markdown output, but that’s really niche, because I don’t think most people will be making an online version of the book. The book’s enough. That’s certainly not something I worry too much about, because I’d put that at the bottom of the stack if I was on the other end.

Len: It sort of is in a way for us as well. There’s a bit of a theoretical reason around that, around this concept of lean publishing, which is that 99% of one’s work as a writer ought to be going into writing. Especially before a book is finished, formatting ought to be an afterthought, because if you’re doing too much formatting while you’re writing, what you’re probably doing is procrastinating. But that being said, of course, we want to have an awesome online reading experience, so when authors come to us with a suggestion, it’s something we think seriously about.

Ben: By and large, I’ve got to say, not just saying it because I’m on the podcast, but it’s just been incredible. Anybody listening who’s thinking about doing one with Leanpub, I would encourage them to do so. There’s very, very little negative I could say about the whole experience.

Len: Thanks very much for that. I actually have one last question, which is you have an awesome book cover. How did you get that?

Ben: Funnily enough, the boss I mentioned earlier, he designed it for me. He’s just one of these irritating people that can do everything really well. When I said I was going to do this self-published book and I didn’t know what to do for a cover, we had a couple of iterations of it. The first one he did had sort of isobars, like you would look at a map and see isobars, hinting towards that idea of terrain and topology, but ultimately we felt that was maybe a bit of a vague notion and people would think it was just squiggly lines. So the new one, the landscape hopefully attests to the notion of you want to be writing your CSS code that’s going to last as long as the hills, which obviously not quite, but hopefully you get the notion.

Len: It’s a great idea for a cover and it just looks awesome. So thanks to your boss as well for me, I suppose.