DEV Community

Cover image for I'm Sandi Metz, Ask Me Anything! [Finished]
Sandi Metz
Sandi Metz

Posted on

I'm Sandi Metz, Ask Me Anything! [Finished]

Hi, I'm Sandi Metz, author of Practical Object-Oriented Design in Ruby and 99 Bottles of OOP, and I believe in simple code and straightforward explanations. I prefer working software, practical solutions and lengthy bicycle trips (not necessarily in that order) and I write, consult, and teach about object-oriented design.

Ask me anything!

Top comments (63)

Collapse
 
annarankin profile image
Anna Rankin

Hello again! A question I forgot - shortly before I joined my current engineering team, they'd spent a few days doing a workshop with you (they called it "Sandifest" πŸ˜‚). What sort of things do you do when you spend time with a development team? How do you determine what subject matter to focus on?

Again, thanks a million :D

Collapse
 
sandimetz profile image
Sandi Metz

Hey, Anna, I teach a 3-day OO course, and that may be what your folks are talking about. The course gets tuned to the group, but contains a set of foundation OO ideas that I cover for every class. It's really about how to think in OO.

Collapse
 
annarankin profile image
Anna Rankin

Awesome! Thanks :D

Collapse
 
jgregor5 profile image
jgregor5

How do I explain OOP to young students that don't know any other programming paradigms? Because classes are just representations, not the real world. Why do we need OOP?

Collapse
 
restoreddev profile image
Andrew Davis

Hi Sandi, thanks for doing this AMA. When you code, do you follow TDD religiously? I like to write tests, but have a hard time writing tests before functionality, so I tend to write tests after the fact. What downsides do you see to writing tests second?

Collapse
 
sandimetz profile image
Sandi Metz • Edited

Andrew, this is my pleasure.
Ah, TDD. I find my code turns out better if I write tests first, but I am deeply sympathetic about how hard that can be. Writing tests first can help drive you to create decoupled code. If you write tests 2nd, and then find that the tests have complicated setup, this suggests that your code is too tightly coupled together. If you write tests first, and insist on having simple setup, you'll naturally end up with nicely decoupled code.

Collapse
 
restoreddev profile image
Andrew Davis

That makes sense, thanks!

Collapse
 
maestromac profile image
Mac Siri

Would you advise your career path to other developers?

Collapse
 
kristinmars profile image
Kristin V Marsicano • Edited

Hi Sandi! Thank you for investing the time to do this AMA. I admire your work, especially your approachability as a teacher and your ability to make concepts accessible to different audiences. My question for today, however, centers around something I am currently grappling with...

How often do you context switch between writing, consulting, and teaching? Do you have any tips for streamlining this process? In particular, I find switching between writing and other non-writing tasks within a day to be somewhat challenging (some days more than others). Also, how do you avoid burn out? So basically...how do you do it all? :-)

P.s. I "met" you when someone sent me a link to one of your conference talks. I loved it so much that I read POODR (even though I did not know Ruby). I learned a lot about OO (and also about Ruby). So thank you!

Collapse
 
sandimetz profile image
Sandi Metz

Kristen, I fear that I'm terrible at context switching. I do best when I can bury myself in one thing and ignore everything else. This often means that I neglect the small things (arg, email) in order to work on big things (a book chapter, or a talk).

I'm reconciled to this quality of myself, and just have basically arranged my life so that I can work like this.

The one thing I've found is that I do my best writing early in the day. I can write prose in the morning, take a break, and then write code in the afternoon, for example. Writing prose is super painful for me, and code is always a joy, so I tend to reward myself with code, once other writing is done.

Collapse
 
ben profile image
Ben Halpern

I think I work in similar patterns, any advice on the specifics of arranging your life to fit your work style?

Collapse
 
kristinmars profile image
Kristin V Marsicano • Edited

Thank you so much for your candid response!

"I do best when I can bury myself in one thing and ignore everything else" --> your point about accepting this quality and arranging things so you can work the way that is most natural to you is super helpful! I have the same quality (I prefer to bury myself in one thing) but have been resisting accepting it. So now I am going to try to rework things so I can work the way I work best, instead of trying to convince myself I can be or have to be a context-switching-super-star.

I am also going to try your approach to writing in the morning. Typically I fill my morning with other things in effort to "get them out of the way so I can write". I'm going to flip that and write first thing in the morning so I can get to the other things in the afternoon.

Collapse
 
hanmaslah profile image
Hannah Masila

When you are dealing with optimization, which do you give more preference/weight in terms of performance. Is it time complexity or memory consumption. And how do you decide which data structure to use?

Collapse
 
ben profile image
Ben Halpern

How do you feel about static analysis tools for code coverage, code quality, styling etc.

Collapse
 
sandimetz profile image
Sandi Metz

I love them, in their place, and taken with a grain of salt. Static analysis tools can't get everything right, but they can supply an unbiased, reproducible overview of the state of code.

Like, for example:
Is it getting worse or getting better?
What parts of the code hold the most danger for someone who doesn't know the app?

I don't want to be pushed around by metrics, but I do want the insights they can give me.

Collapse
 
ben profile image
Ben Halpern

Got a list of tools you'd recommend?

Collapse
 
jgaskins profile image
Jamie Gaskins

You've mentioned Smalltalk a bit in your presentations and podcast appearances. Do you still do any Smalltalk programming?

Collapse
 
sandimetz profile image
Sandi Metz

Nope, but if I had the free time, I certainly would. Squeak looks interesting. My go-to dynamically typed OO language these days is still Ruby.

Collapse
 
lightalloy profile image
Anna Buianova

Hi, Sandi!
Thank you for your books, they are great :)
A couple of questions:

  • What do you think about Domain Driven Design, do you use it?
  • Do you have plans on writing more books?
Collapse
 
jess profile image
Jess Lee

What was it like collaborating on your newest book with Katrina, versus being the only author? How did that impact your process?

Collapse
 
sandimetz profile image
Sandi Metz

Collaborating with Katrina was equal parts delightful and a cause of great head-banging, as you'd likely expect. Let me be clear--Katrina is wonderful, it's just that the very process of collaboration requires compromise, and blending disparate ideas. This was good for the resulting book, but not necessarily welcomed in the moment.

Collapse
 
jess profile image
Jess Lee

Any memorable conflicts that you're both laughing about now?!

Thread Thread
 
sandimetz profile image
Sandi Metz

Too many, really, to pick one. Katrina and I as very different. The core lesson for me was that while it's easy to pair with someone who is like you, it's better, if you can stand it, to pair with someone who is different.

Being forced to resolve our differences improved our understanding of the material, and vastly improved that book. This only worked because, despite our head-banging, we respected one another's ideas, and believed that if we stayed at a discussion (read, argument) long enough, we would find that we actually agreed.

Collapse
 
fnh profile image
Fabian Holzer

Hi Sandi,

thank you for doing this AMA - I really enjoyed POODR, I learned a lot from it and that is although I have never written any major Ruby code before or after it ;)

I'd be really curious about your thoughts on the value of type systems, especially since you have very strong roots in Smalltalk and Ruby.

I've "grown up" mostly on statically typed languages (Pascal, Java, Haskell), but I've learned to appreciate dynamically typed languages a lot in the last 4 years (especially Javascript and Clojure). Working in a Java shop that is short of being considered a heretic. In your experience, do you see a middle ground?

Collapse
 
sandimetz profile image
Sandi Metz • Edited

Fabian, first let me confess that I'm an outlier in that most of my OO experience is in dynamically typed languages, and that in my code, I don't get run-time type errors. Because my experience is that dynamic typing is perfectly safe, I find myself resenting having to enter type annotations when I work in statically typed languages. While I appreciate the fact that static typing means that I don't have to write some tests, I hate having to add this extra code.

Having said that, I realize that many folks have had different experiences with dynamic typing. I write trustworthy code where objects behave like you'd expect. This means that I can trust that any object with which I'm interacting just works. This, in turn, means that I don't have to check if objects behave the right way. Sadly, I've seen many OO applications where these things were not true. Folks fall into the trap of writing code that's not trustworthy. Because they can't trust message sends to return objects that behave correctly, they have to check the type of the return of messages sends. This leads to a descending spiral of manually adding type checking, and code which ultimately breaks in confusing and painful ways.

Here's the deal. The power of dynamically typed OO languages is attained only when you write trustworthy objects that use duck-typing and polymorphism, and then trust them to behave correctly. If for some reason (inclination or background) you can't prevent the creation of untrustworthy objects, it's probably better to use static typing.

These styles of programming are different, and combining them leads to the worst of both worlds.

Collapse
 
jgaskins profile image
Jamie Gaskins

How did you get into conference speaking?

Collapse
 
sandimetz profile image
Sandi Metz • Edited

Completely by accident. Someone pushed me into it, pretty much against my wishes. I was terrified at first, but have grown to really enjoy it. This, of course, means that everyone else should and could speak at conferences too. :-)

Collapse
 
jess profile image
Jess Lee

How do you prepare for your talks? Do you have any specific rituals you go through before stepping in front of an audience?

Thread Thread
 
sandimetz profile image
Sandi Metz

I'm a scripter and practicer as opposed to an, err, wing-it-er. Once I sort out the point of the talk and put together a slide deck, I figure out what I plan to say on every slide, and between which words I plan to change slides, and then I rehearse until I feel confident that I can appear unrehearsed. My rule-of-thumb is that I have to give the entire completed talk to my empty office 10 times before I'm ready go on stage.
I once read a recommendation that said a speaker should multiply the number of folks in the audience by their hourly rate in order to decide how much effort should be put into a talk. By that math, the bar for being prepared feels very high.

Thread Thread
 
jess profile image
Jess Lee • Edited

Ah! That is so nice to hear. I've met a lot of wing-it-ers recently and it's honestly made me feel quite self conscious about how much I need to rehearse.

Collapse
 
peter profile image
Peter Kim Frank

Hi Sandi, thanks for doing this AMA!

What are your thoughts on functional programming?

Collapse
 
sandimetz profile image
Sandi Metz

I only have a small bit of experience with functional languages, so I don't get to have much of an opinion. I can say, however, that immutability and no side-effects are great ideas, and that I've borrowed them for my OO.

My initial goal for every new object I write is that it not change, and that it not have side effects. This obviously can't suit every object, but I've been pleasantly surprised about how much can be done under these constraints, and how much the constraints simplify code.

Collapse
 
liana profile image
Liana Felt (she/her)

Hey Sandi! Thanks for doing this! How often do you write code these days?

Collapse
 
sandimetz profile image
Sandi Metz

Liana, I never get to write enough code. Sigh. Most of the code I write these days is for my own apps.

After many years of working of big apps every day, I had a secret fear that, if I stopped doing that full-time, that I'd forget how. It turns out not. The time I've had over the last few years to think about code has really improved my understanding about what code means, and how best to write it. This has been an unexpected pleasure.

Collapse
 
lucerosalazar26 profile image
Lucero Salazar

I've moved recently from .NET to Ruby on Rails and it had been quite difficult for me to understand how yo write beautiful and meaningful code, 'till I started reading your books. I love the simple way you explain everything in it. I think that I've improved a lot since my first lines of Ruby and now I can think about improving even more. I'm willing to meet you in Seattle in a few months. Thanks for your sharing!

Collapse
 
sandimetz profile image
Sandi Metz

And thanks for thanking. :-)