Review – Scalable and Modular Architecture for CSS by Jonathan Snook

Over the last year I’ve become increasingly frustrated with CSS. I used to be its champion; when people moaned about how touchy and picky CSS is, I told them “It’s really not that hard! You probably have a specificity problem, let’s take a look”

Since increasing my knowledge of basic programming principles, though, and diving into Ruby and Javascript, I’ve been loathe to spend time on CSS. Every time I touch it I feel frustrated, and this joke hits far too close to home:

“Two CSS properties walk into a bar. A barstool in a completely different bar falls over”

 

Ugh.

I’m annoyed at my frustration, and I want to get back my love of CSS — this time, by increasing my knowledge of CSS and related tools like Sass. I want to dive deeper and take as much pride and joy in my CSS as I do in my Ruby.

To that end, I finally picked up Scalable and Modular Architecture for CSS by Jonathan Snook (known as SMACSS, and pronounced ‘smacks’) and read it through. SMACSS is a great primer on organising your CSS. It’s particularly useful for CSS beginners, as following SMACSS style will get you into some good habits and leave you feeling less overwhelmed by the hodgepodge of rules, selectors, and properties that can build up the first few times you seriously try to style something. It’s also great for people like me, whose knowledge of CSS built haphazardly over the years — I know how to do some cool things with CSS, but my organisational style left a lot to be desired.

Snook suggests categorising your CSS into a few different groups:

  • Base, which contains all the default rules. There should be no use of class or ID selectors here, only single element selectors
  • Layout, which as the name suggests, specifies how the elements should be laid out on the page.
  • Modules, where the meat of our styling lives. In here you will mostly be using class selectors to apply rules.
  • State, which contains rules that describe how our modules look in different states — selected, active, hidden, highlighted, featured, what-have-you.
  • Themes, for when multiple different ‘skins’ may need to be employed (e.g. a ‘light’ theme and a ‘dark’ theme).

 

The rationale here is that by categorising CSS this way, you can avoid repetition and keep your CSS DRY.

SMACSS contains lots of relevant examples that show exactly how such organisation can result in more sensible CSS. Unfortunately, if you’re reading on an e-reader, the code examples can look a bit out-of-whack (I’ve found this for all programming books, though).

My read-thorough of SMACSS was pretty gratifying. As it turns out, the way I’ve been writing CSS, particularly over the last six months, has been pretty close to SMACSS style anyway. You may find this too, particularly if you’re familiar with CSS libraries such as Bootstrap and Pure, which mostly encourage SMACSS style. Reading the book gave me a bit more context as to the why of doing it the SMACSS way, rather than just the how.

My understanding of the organisational structure is much better, and I’ve identified lots of areas where I can improve. In particular, my state rules have mostly been contained in my modules. From now on I’ll start separating them out. I’ll also admit that my organisation of CSS properties is very spotty. Though I’ve been aware of the suggested structure of box, border, background, text, other, my adherence to it has been on a when I remember and can be bothered looking up the order basis, which hardly leads to consistent code. Here’s an example that follows the property order suggested by Snook:

p.featured-text {
  position: relative;
  top: 20px;
  display: block;
  width: 80%;
  padding: 10px 20px;
  border: 2px solid #efefef;
  border-raidus: 6px;
  background: #fff;
  font-family: Gotham, Arial, Helvetica, sans-serif;
  line-height: 2;
}

Some of the examples in the book are, of course, out-of-date. The author takes care to mention IE6 support, but only a really sadistic client would force a developer to support IE6 these days. There’s also a lot of guff about vendor prefixes which we are privileged enough to ignore now thanks to tools such as Bourbon.

If you’re into LESS, you’re out of luck when it comes to the pre-processors section of the book. Snook gives examples exclusively in Sass. It’s not hard to translate to LESS, but let’s face it — Sass seems to be winning the pre-processor game. Notably, Bootstrap 4 will support Sass rather than LESS, and if you’re a Rails developer, you’re probably using Sass exclusively too.

SMACSS is a quick and painless read. There’s no crazy jargon and if you have a passing familiarity with HTML and CSS, you’ll keep up with no trouble. I recommend reading it if you’re just getting into CSS, or you’re looking to optimise and improve your CSS organisation.

Book Review: 10% Happier by Dan Harris

I’ve been under a fair bit of stress lately. Nearly a year into self-employment, work has become steadier, sometimes more than steady. Although I love it, I’ve finally come to understand why people yearn to meditate. With my mind racing with mostly unproductive worries and nags, I’ve been thinking that I should try mediation to calm the tumult and find ‘flow’ again.

The problem has been finding a guide to meditation that isn’t complete granola claptrap. I loaded Eckhart Tolle’s The Power of Now onto my Kindle but gave up almost immediately. His meanings were almost completely opaque to me, and I didn’t have to fortitude to stick through it. So when Dan Harris popped up on The Colbert Report (where he was a more eloquent guest than most on the show) to promote his book 10% Happier, I figured I’d give it a try.

Writing the above paragraphs, I’ve come to appreciate Dan Harris’ book a little bit more. It’s hard to write about mediation without sounding like a complete asshole. Dan gave it a fair shot, and his book was useful, though I never felt entirely compelled by his voice.

Preci

Journalist/News Anchor, extrovert, and work-a-holic Dan Harris becomes intrigued by meditation, and seeks to cut through the hippy-dippy bullshit in search of something more practical that he can apply to his daily life. He journeys, he stumbles, but eventually manages to create a mediation practice that fits within, and enhances his life. He says it makes him ‘about 10% happier’.

What I liked

This isn’t a life-hacking book. I was afraid that I was in for another Tim Ferris wank-fest, but I was pleasantly surprised by Harris’ respect for the subject matter. Although Harris doesn’t become a Buddhist, he explores Buddhism, and the role of meditation therein with care, and ultimately decides that while the spiritual aspect of Buddhism isn’t for him, the mechanics of mediation are useful to him. From what I know of Buddhism as a whole, this is absolutely kosher (though correct me if I’m wrong).

I like that Harris clung to his misgivings about Eckhart Tolle (whom he  finds a bit too whack-a-doodle) and Deepak Chopra (whom he considers to be insincere), and sought meditation practitioners and teachers whose practise is more deeply rooted in ‘the real world’. In his words:

“After months of swimming against the riptide of bathos and bullshit peddled by the self-help subculture, it was phenomenally refreshing to see the ego depicted with wry wit.”

Amen, brother.

He frequently mentions that meditation has a terrible marketing issue in that its most vocal advocates are a bit too crunchy and/or otherworldly for the mainstream. He suggests several works for further reading which are rooted in science rather than mysticism, for folks who would prefer to read about meditation from that viewpoint.

I also found the chapter on ‘hiding the zen’ to be useful. Although I’m blogging about it, one’s self-help forays aren’t always what you’d like discussed in the public sphere. It’s nice to be able to slip under the radar as a meditator without showing your ‘woo woo-ness’ in public.

What I didn’t like

I’ll be honest, Harris is not someone I’d like to hang out with. While I enjoyed his journey from bro-ish asshole to a more self-aware being, I couldn’t really relate on a personal level. Honestly, even a redeemed Harris seems like a bit of an asshole to me.

I also wasn’t too interested in the extensive personal narrative. While I appreciate it was important to illustrate his journey, I believe it could have been edited more thoroughly. As a non-USA reader, I had never heard of the guy, and don’t really care about the internal politics of USA news networks.

Moreover, Harris’ writing is serviceable, but his forays into poetic description most often fall flat. Take this one, for example:

“With the Klonopin on board you could have marched an army of crazed chimps armed with nunchucks and ninja stars into my apartment and I would have remained calm.”

His asides often devolve to a Barney Stinson meets College Bro level of sophistication

“The real mindfuck, though, was this: almost as soon as he said something brilliant, he would say something else that was totally ridiculous”

While other paragraphs head almost into (the much maligned) Eckhart Tolle territory — behold:

“Failure to recognize thoughts for what they are — quantum bursts of psychic energy that exist solely in your head — is primordial human error”

Observations

Harris is very much an extrovert. Throughout the book I found myself thinking that although I have never really meditated, I have already mastered some of the techniques he mentions. I think it comes down to the fact that I am an introvert and am very comfortable within my own mind — I know how to observe my thoughts and emotions and ‘lean in’ to them, responding rather than reacting. I get the sense that for an extrovert, the inner mind can be a scary and alien landscape, and that a large part of Harris’ journey is simply getting to know his inner mind.

Verdict

Overall, this book was a useful start for my foray into meditation, though I’ll need to do a lot more reading, I think. This is the book for the everyman, and I’d like to gain a more academic insight.

While the tone was a bit too alpha-male and bro-ish for me, I appreciated the practical look at meditation.

Bonus points for a relatively obscure Simpsons reference.

3/5

{image credit}

Book Review — How to Read a Book

I confess that, after skimming the preface of How to Read a Book by Mortimer J. Adler and Charles Van Doren, I set my Kindle aside, cracked open my laptop and Googled ‘how to read a book key points’.

You see, I’m a lazy reader. I simply have not developed the fortitude to plough through a book that isn’t particularly interesting to me on a very superficial level. If it’s boring, I’m out. If it’s too complex and I can’t speed-read it as I usually do, I’m out. How to Read a Book is one of those books. It is bland and boring, soporific and tedious. Hell, even the book’s Wikipedia page was too long-of-wind for me. Take this for example:

There are three types of knowledge: practical, informational, and comprehensive. He discusses the methods of acquiring knowledge, concluding that practical knowledge, though teachable, cannot be truly mastered without experience; that only informational knowledge can be gained by one whose understanding equals the author’s; that comprehension (insight) is best learned from who first achieved said understanding — an “original communication” [Wikipedia]

Yikes.

I’m not entirely sure how I made it through an academic degree, considering my lazy reading habits. Oh wait–I know. I skimmed, I scanned, I read the introduction, the headings and the conclusions, and I always made sure I had a few morsels to contribute during tutorials. As a whole, I find non-fiction easier to read. Except essays by Griselda Pollock, I’m yet to make head or tail of her work. Blessedly, I know that I am personally not cut out for education beyond my Bachelor’s degree and that’s probably the most demanding reading load that will ever be expected of me. I can now choose to wallow in contemporary literature, essays, pop-science, and science fiction novels of dubious calibre. Hooray.

The thing is, though, I feel a bit of pressure (and maybe it’s imagined but nevertheless it presses me), to fully earn my status as a culturally-aware, educated, middle-class woman by reading books that are…challenging. The Classics, you know, The Great Books. I have read a few (and even liked a few)! But there are still others that I avoid because I know, I just know that I’ll struggle my way through them, probably miss the point and themes and what-have-you, and have nothing interesting to say about them. How embarrassing. It would seem that I am exactly the sort of person who would benefit from reading How to Read a Book. So I decided to read the damn thing–maybe it would do me some good.

After perusing the relevant Wikipedia page, I decided to skip Part I entirely. This is probably not how you’re meant to read a book. But really, the chapter summary made it seem like Some Old Guy ranting about the Shitty State of the Education System. Behold:

He takes time to tell the reader about how he believes that the educational system has failed to teach students the arts of reading well, up to and including undergraduate university-level institutions. He concludes that, due to these shortcomings in formal education, it falls upon the individuals to cultivate these abilities in themselves. Throughout this section, he relates anecdotes and summaries of his experience in education as support for these assertions.

While that’s all very nice, I really don’t care that much. Just tell me how I’m supposed to read the book, please. Alright. Here’s what Wikipedia had to say about Part II:

The first stage of the third level of reading is concerned with understanding the structure and purpose of the book. It begins with determining the basic topic and type of the book being read, so as to better anticipate the contents and comprehend the book from the very beginning.

Ah! Great! I understand this. During teacher training, this was referred to as the top-down approach–mentally gathering information you already know and applying that knowledge to the topic. Great. This chapter concerns non-fiction, though. Look, honestly, non-fiction I’m fine with. I can read non-fiction, extract the themes and discuss them intelligently. I have a piece of paper from Victoria University that endorses this ability. What about fiction? Oh. That’s addressed in Part III.

Part III. The author immediately describes me:

People deceive themselves about their ability to read novels intelligently. From our teaching experience, we know how tongue-tied people become when asked to say what they liked about a novel. That they enjoyed it is perfectly clear to them, but they cannot give much of an account of their enjoyment or tell what the book contained that caused them pleasure.

Touché.

I flicked through a few pages. What did I learn?

  • Read your fiction book quickly, to get a sense of the whole story.

Good. I do this. I read FAST.

  • When faced with a metric shit-ton of characters, don’t give up. Try and learn their names and who they are, just like you would when meeting people at a new job. 

Okay. Seems sensible. I’ll do it.

And then I gave up reading. I failed to read How to Read a Book, and I don’t think I’ll ever pick it up again. I’d much rather have started a Dickens novel, really. A quick scan of Goodreads shows that I’m not alone. Many others found the book long-winded and not extremely useful, particularly for fiction. Ultimately, the book wasn’t for me, but that doesn’t mean that my quest for a more meaningful reading experience is ended; I still want to learn to read more critically, but I’ll pursue it in my own way. After all, I want to be able to say something intelligent and compelling at my next book club meet-up. I certainly won’t be recommending How to Read a Book, though.