Clean Code: 5 Tips for Best Practices

Last week, another developer from Hyland and I had the opportunity to go out and give a talk to computer science students at Bowling Green State University, courtesy of the university’s Women in Computing club.  They were kind enough to let us choose our own topic, and after tossing out our first 50 ideas, we decided to talk about how to write clean code.

Both Rebecca and I are second-career developers, and the two of us are called on to give the “second-career-woman-in-tech” talk fairly often, so we wanted to talk about something technical!  Besides which, university comp sci majors are probably not a group that needs a “second career” talk.  We headed out to Bowling Green after work on aWednesday, had a lovely drive out, and spent a few hours giving the presentation and chatting with the students.

I don’t want to dump the entire presentation here, but I did want share some of our key points.  Also, if you have an organization that’d be interested in hearing the talk, drop me a line and one/both of us can make arrangements to come give it!

Point #1: Coding is a social activity.  Programmers spend more time reading code than we do writing it!  The ratio on reading to writing code when it comes to development is something like 60:40.  This is because programming languages don’t exist for computers.  Think about it!  All the computer cares about are ones and zeros; the switch is either on or off.  We have high-level programming languages because programmers have made them for other programmers.  Languages are a tool that lets us share ideas with each other and communicate what we’re trying to achieve with our code–which is why you should always write clean code.  Pretend that the next developer to touch your code is a psychotic serial killer who knows where you live; you don’t want to make them angry.

Point #2: The two hardest things in computer programming are cache invalidation and naming things.  (Admission: I stole this saying from my dude Dave Goerlich).  You want to make sure that your names for things convey your intent!  Follow common conventions for whatever language you’re using, use one word per concept (i.e. don’t use “get”, “fetch”, and “retrieve” if they all mean the same thing), and avoid one-letter variable names (unless it’s a short scope or you’re naming an iterator variable).  Variables (customerAccountNumber) and classes (customerAccount) are nouns, booleans are yes/no answers (isValidAccount, isNotFlagged), functions are verbs (getCustomerAccountNumbers).  You also don’t want to mislead your reader–so don’t name an array of Customer objects a “customerList”.  Names should also be pronounceable and understandable–don’t make weird acronyms, or use nonsense words that have no meaning outside of very specific knowledge set.

Point #3: Classes and functions/methods should be small!  Very small!  Very, very small!  They should also obey the SRP (Single Responsibility Principle).  Functions should do one thing and do it well; classes should only have one reason to change.  For functions, the ideal number of arguments is nil–then one, then two, perhaps, three, but after that, many input arguments are a bad smell and indicate that the function is probably not adhering to the SRP.  Stay away from output arguments if at all possible–we’re far more used to seeing input arguments, and output args can lead to confusion.

Point #4: Keep it DRY.  Don’t Repeat Yourself!  This argument may have been done to death a thousand times before, but it’s worth repeating in every talk about clean coding practices.  We can also talk about organization here: try listing your functions ordered by level of abstraction.  One function should call those functions directly beneath it, although there are (of course) exceptions to this rule (I had one in my example code!).  Try making your code as easy to read as possible so that they next developer doesn’t have to keep scrolling up and down lines, looking for the next function call.

Point #5: Comments can be evil.  It’s very, very tempting to comment away badly-written code, but that’s a cardinal sin of clean coding.  Comments are not an excuse for skipping refactoring–if you think developers are bad at maintaining clean code, imagine how bad we can be about keeping comments up-to-date!  Comments that are redundant, misleading, or arbitrarily-required need to go, as do large block of commented-out code.  End-of-block comments are a smell that your code block is too long and refactoring is needed, and log comments on every file aren’t needed with any good modern version-control system.  Documentation comments, TODO comments, legal disclaimers, and short informative or clarifying comments can be good, but these all still run the risk of becoming outdated, and care should be taken to update them along with the surrounding code.

That’s not the entirely of the presentation, but those five tips are our key points for code cleanliness.  Also, if you’d like to see our slide deck, you can see it here!

 

Ela Conf 2016

So, I went to Ela Conf in Philadelphia, PA this past weekend, and, like, I don’t even know.  I don’t even know what happened.  I’m going to try and write a blog post, but I’m also sure there’s no way to put the experience into words that properly express how amazing the weekend was.

First, some disclosure.  I knew I wanted to go to a conference, but every time I heard about one I could even think of going to, it was impossible–either registration had closed, or going would have cost me a thousand dollars, or both (usually both).  Even though I make sweet, sweet developer money now, I’m still a single mom with bills and a crapload of debt, so let’s be real: if it’s gonna cost more than a few hundred bucks to go to something, I’m not going.  I’ve heard from other people that a $400 conference ticket is “so cheap”, that the associated $800+ hotel stay is “reasonable for the venue”, and it’s totally okay to do things like fly across the country and eat $100 hotel-restaurant meals in the name of networking.  Maybe that’s true for people who aren’t nine months into their first real jobs and don’t have hundreds of thousands of dollars of debt, but for me?  Networking doesn’t keep my lights on and my kid fed.  (I guess I could set all the business cards I’d collect on fire for warmth, but that seems impractical.)

Here’s the first amazing thing about Ela: through sponsorship, they were able to pay stipends for speaker travel and childcare, and provide grants for ticket cost to any woman who applied.  In case you can’t figure out where this is going, my broke self got a ticket grant, which left me enough money to book a motel in New Jersey and buy gasoline to drive back and forth from Cleveland.

Takeaway: if a small, second-year conference in Philadelphia can get sponsorship enough to do this, why the hell can’t conferences with much more name recognition and/or budget do it, too?

Read more

Recent Engagements

I am so, so pleased to tell you, readers, that this past Saturday, I was on a panel of women answering attendee questions about their careers during Hyland’s first Women in Tech conference! Here’s the official press release blurb:

“Hyland will host the Women in Tech Conference on Saturday, October 8 at its headquarters in Westlake, Ohio. Working with close partners the Ohio Collaboration of Women in Computing (OCWiC) and We Can Code It, the half-day conference aims to inform women about the career opportunities within computer science and information technology (IT) professions.

Attendees will hear from female software developers, quality assurance (QA) specialists and senior IT managers who will provide insight into their technology backgrounds, what interested them about their chosen fields and the roles and responsibilities for their positions.”

Source: http://www.prweb.com/releases/2016/10/prweb13733094.htm

Feedback for the event has been overwhelmingly positive. It was a great day at Hyland for those of us who were speaking, and I’m really glad to hear that it was a great day for our attendees, too! There was a lot of good energy in the room that came from over fifty women in one place with one goal: to represent and increase the presence and visibility of women in technology. The conference opened with a talk by Brenda Kirk, Hyland’s Senior Vice President of Product & Strategry (and my big boss!), followed by a presentation by two of our developers, the Q&A panel where attendees asked us about our career paths and opportunities at Hyland, a talk by my frentor (that’s friend + mentor, for those unaware) Mel McGee of We Can Code IT, and a presentation by volunteers and attendees of the Ohio Celebration of Women in Computing (OCWiC).

For more information on Hyland, We Can Code IT and OCWiC, check out:

I was also asked to speak at a recent We Can Code IT commencement, but that’s its own blog post, and it hasn’t been written yet! I’ve been keeping busy lately and am looking forward to finally being able to give updates on all the projects I have going on, including a new website (here’s a hint: I now own http://www.mylittlecoding.com) and a new meetup group. Stay tuned. 🙂

 

Engineers Week: Girl Day

A couple weeks ago, out of the blue, I received an e-mail from the Molly Bukowski, Director of Special Projects at Teza Technologies.  Turns out that people actually do read my blog!  She inquired as to whether I’d be interested in writing an entry for Girl Day, a day set aside during Engineers Week to show girls the creative side of engineering and encourage them to explore STEM careers.

Of course I said yes, not only because I was immensely flattered that someone read my blog, but also because I have a lot to say about encouraging girls to go ahead and push themselves to be whatever the heck they want.  I don’t see any problem with a girl deciding to be an engineer or an art teacher (or both!), but an oft-discussed problem with girls disregarding potential STEM careers is that they “can’t be what they can’t see,” and it’s hard for a girl to push herself to be an engineer if she doesn’t have readily-available female engineer role models.  On the flip side, I know plenty of amazing female art teachers.

It still feels a little odd to reply to “so what do you do?” with, “I’m a software developer”.  I’m sure that I have taken the most convoluted, expensive, roundabout path to software development possible, but now that I am a Bonafide Female Software Developer (TM), one of my goals is to be a readily-available female role model for girls.  Molly invited me to share my personal thoughts and experience for this entry, so I want to share my (very unique) path to software development.  So, kids, read on:

I was in junior high school when I first started making websites (about 1997).  Right now, if you want to learn how to make a website, you just Google “how to make a website” and can find zillions of tutorials for HTML and CSS (the code used to make websites).  When I started out, though, there were very few references for HTML available, almost none for CSS (it was very, very new), and Google hadn’t been invented yet. We did, however, have a program on the family computer called Microsoft FrontPage, where you could build a website by clicking on things and arranging them on the screen.  FrontPage would then let you switch over to see the code it generated for the website, and I was slowly able to figure out the code for things like text, images and buttons.

Know I could type some code and have it magically turn into a website was pretty much the most exciting thing ever.  As the Web really started taking off, I would re-write my websites over and over.  Each time, I’d try pushing just a little bit further, to make my site that much cooler.  In high school, my parents let me drill holes in the ceiling so that I could run a line from the cable modem in dad’s office to my computer in my bedroom.  I routinely stayed up way past my bedtime re-doing my websites and chatting with friends on AIM (which was like Facebook Messenger, except way more anonymous and easy to use).  My junior year, my web development hobby actually got me a boyfriend!  I’m not kidding–I entered my website in a contest for high school web designers and won first place in my category.  To find out whether or not I won the big prize, I had to go to an awards ceremony at the local community college, which is where I met a boy who won first place in another category, and we dated for like, six whole months.  (For the record, I did not win the big prize.  The big prize was an iPod and it was won by a team of six boys who all worked on the winning website together.  No idea how they split it up.  Also, last I heard, the boy I dated is also working in software development.)

Naturally, all of this obsession with making websites and understanding how the web worked meant that I went to a really awesome technical college, majored in computer science, and… wait, wait… that’s not the story at all.  I didn’t do any of that.  Instead, I went to art school, transferred to a liberal arts school, majored in art education, then art, then art history, transferred to state school, graduated with a BA in art history, went to London, earned a MA in art history…

So what caused me to close my editor at age 19 and walk away from building websites for ten years?

Part of it was that I couldn’t be what I couldn’t see.  I knew that college-level computer science required a lot of advanced math, which I’m really terrible at.  Another part of it was that the only real programming I’d done was some BASIC as a little kid and a few attempts at JavaScript in the early 2000’s.  HTML and CSS are markup languages–they’re used to display data, not manipulate it.  I was good at drawing, interpreting poems, and remembering random historical facts, and so I was advised to go into something more suitable to my existing skills than to try and fit my bad-at-math, no-programming-experience self into ‘real’ computer science.  All the comp sci students I knew were super into computer hardware, had tons of programming experience already, and were dangerously good at math–and, except for one, they were all guys.  It was really intimidating, so I played down how cool I think computers are and became a really good sport about people asking me what kind of job I thought I’d be able get with an art history degree.

Turns out, I’m a software developer with an art history degree.  I love drawing and writing and taking photographs, but I also really love to code.  After I decided not to pursue a PhD, a friend of mine suggested I go back to making websites.  He sent me a couple e-books to get me caught up to the new developments with HTML5 and CSS3 and gave me a some challenges to try and recreate things with my new-old skills.  It felt really, really good to get back into it, and I knew I was on the right path.  Just re-learning HTML and CSS wasn’t enough to get me a job, though–I knew I had to at least tackle JavaScript again to be a web developer, so I decided to go to a programming bootcamp… and this Monday, I started my first software development job.

I’m really glad I went to bootcamp.  We Can Code IT is focused on getting women and minorities into computer science, and even though the program has only been around for a year, it’s already seems to be paying off for the Cleveland tech community.  I’m really excited to see where it goes–so excited that I’ve contracted with WCCI to teach programming workshops for kids in addition to my full-time development job.

If you’re looking to get started learning code, I’ve included some links here that might help, as well as a special infographic from Teza about women in STEM degree programs and careers.

Happy coding, ladies! 😉

 

Suggested resources:

Scratch: a fun, free creative learning community based around an easy-to-learn, easy-to-use visual programming language.  Great for kids and those just starting out with code.

Codecademy: learn to code interactively, for free.  Includes lessons on HTML, CSS, JavaScript, Python, Ruby, and more.

Khan Academy: a free education site with computer science lessons including how to code with HTML, CSS, JavaScript, and SQL.  Good for math, science and art history lessons, too!

w3 Schools: a developer site with tutorials and reference for web languages including HTML, CSS, PHP and jQuery.

We Can Code IT: offers full-time and part-time .NET programming bootcamps in Cleveland, Ohio as well as children’s camps and workshops.  Diversity focus.

Software Guild: a 12-week, full-time Java/.NET programming bootcamp in Akron, Ohio.

Engineers Week_Girl Day

Promo Video Answer Fumble (or, I Am Not Developer Barbie)

This morning, I got an e-mail from my coding bootcamp asking if I would like to be part of a promotional video.  Since I didn’t have any grandiose plans for the afternoon, I said yes, and headed out to catch the 2:30 train to downtown.

It turned out to be one of those deals where you sit in a chair and answer questions interview-style, which I didn’t mind.  There was a brief moment of concern when the lighting setup resulted in a shiny spot on my forehead, which the videographer insisted be dealt with.  Initially I had thought he was talking about my cheeks, which were dusted with glitter thanks to my severe underestimation of both the amount of shimmer in my eyeshadow and the amount of powder fallout it would have–not having had enough time to re-do my whole face, I went with it and declared glitter cheeks to be very “in” and “now”.  But no, it was my forehead, in a tiny spot I’d missed with my setting powder.  Oops.  Blotting papers were found and we were good to go, anyway.

Remember this aside about my makeup.  I’ll get back to it later, I promise.

The bootcamp I went to, We Can Code IT, has a focus on improving diversity in the tech community.   I don’t remember all of the questions for the interview, but they were along the lines of things like, “what made you decide to try bootcamp” and “how did you feel about your career before bootcamp and how do you feel about it now”.  Pretty standard stuff, but I was invited to share how I felt about these things “as a woman”.

I’m sure some of you reading this are already scoffing at that.  Truthfully, my immediate reaction was also “how about I just answer the questions, I don’t really need to point out how female I am.”  After the first few questions, though, I thought about it again, and realized that being a woman has impacted how I feel about some things.  My first year at Cleveland State, in German class, my friend Lizz and I were chatting when our instructor, Carol, came over.  We all got to talking, when all of a sudden, Carol looked at us, and dropped this bomb:

“You know, you two are very pretty.  I’m glad you’re smart.”

There was a pause, and Carol tried to clarify what she’d just said.  “What I mean is–both of you are very striking.  You’re good-looking.  But you’re also not afraid to be smart.  When you don’t know something, or when you get something wrong, you admit it, and when you do know something, you speak up.  You’re both smart enough to know that you’re pretty, too, but you know your looks are a bonus, not a crutch.  I’ve been teaching for a long time, and there are so many girls who won’t raise their hand in class, and there are so many girls who act cute and ditzy to try and play down when they don’t know an answer, or say ‘oh well, at least I’m pretty’ when they get something wrong–it makes me sad.  Because they’re all smart girls, too, but they think they can’t be smart in public.”

That moment has stuck with me.  It’s stuck with me because as a kid, I was bullied for being an awkward, shy, poorly-dressed smart girl with terrible skin, bitten-down nails and a bad haircut.  (Honestly, being smart was probably the least of my worries, but the meanies toned it down a bit if I didn’t draw attention to myself in class.)  In ninth grade, I transferred to a private high school with uniforms, got a haircut, saw a dermatologist and grew into my own brand of “pretty” as I re-learned how to raise my hand in class.  That experience has stuck with me, too–as an adult, I am very conscious of how I present myself to the world, and I’ve developed a pretty feminine look.  I wear a lot of black, yes, but I usually wear makeup, I (try to) take care of my hair, and I make sure my clothing is in good repair.  What’s more–I am okay with this.  Being concerned with my appearance in no way effects my intelligence or ability.  I am 100% sure that I can be pretty and smart.

Back to the video and the interview questions.  Thinking about what it mean to answer “as a woman”, I thought about my makeup and the amount of serum in my hair, which I had pulled back because it still wasn’t really cooperating.  I also thought about the other side of my wearing lipstick and slicking down my hair, which is that sometimes, it feels like a liability.  I have a few “masculine” hobbies: firearms, cars–and, yes, computers.  Sometimes, being female makes it seem like those hobbies aren’t really for me.  I don’t like walking into the auto parts store alone because the teenage boy behind the counter is so quick to assume I need help, and I usually have to ask for the ammunition case at Wal-Mart to be unlocked, even when the associate is standing two feet away from me and it is obvious I want to make a purchase.  The kicker?  Even using an alias that starts with the words “Queen Of”, people constantly assume I’m a guy on the internet.  I’m aware that my femininity can get me disregarded in some circles, and technology seems to be one of them.  It sometimes seem as though the message is this: as a woman, I must be too emotional and too easily distracted to solve complex problems.  My drive to nurture friendships and soothe over conflict must mean I lack the logic necessary for computer science.  Caring about my appearance means that I am incapable of looking past the surface of things.  My femininity is a barrier to the mindset needed for programming, and it must be overcome.  Maybe it would be easier to accept me if I could frump down my look a little?  Just to prove I’m serious about the whole thing.

Look.  I am not, nor do I want to be, Developer Barbie.  I just want to write good code and rock winged eyeliner.  At the same time.  Because one does not negate the other.

“So,” asks my interviewer.  “What advice would you give to women who are thinking about bootcamp?”

It takes me a couple of takes to get the answer out, and I’m still not satisfied with it.  I was supposed to give short answers, and I think everyone can agree this blog is anything but short.  I wish I could have said it better, but what I finally got out was something like this:

“There’s this idea out there that you can only do this if you’re really, really smart, or if you’re really good at math.  That it’s all logic, and there’s not room for emotion–but there totally is.  If you’re thinking about learning to code, jump in.  Try it out.  You’ll be surprised what you’re capable of.”

It’s not the best answer.  It’s not the most in-depth answer.  The thought was there, but I needed time to fully develop it. If I could do it over again, this is how I’d say it:

“There’s this idea out there that you can only do this if you’re really, really smart, or if you’re really good at math.  There’s this idea that it’s all logic, and that there’s no room for emotion–but there totally is.  It doesn’t matter how feminine you are or what background you come from; trust yourself and trust that you’re capable of making space for yourself at the table.  If you’re thinking about learning to code, jump in.  Try it out.  You’ll be surprised what you’re capable of.”

It’s too bad that ideas like the smart/pretty dichotomy seem to be persistant.  Traditionally feminine appearance and/or behavior has no bearing on competency–and, for that matter, traditionally unfeminine appearance and behavior has no bearing on it, either.  I would never suggest that all women wear makeup and heels.  What I am hoping to suggest, though, is that  it’s worth encouraging women to take a shot at anything they may have an interest in, even if (especially if?) they’ve somehow been made to feel as though it “isn’t for them”.  There’s a sense of power in carving out a space for yourself, and it’d be a real shame if we didn’t encourage women to try.

Girls in STEM (Sursum Corda)

I graduated from Saint Joseph Academy–a Catholic, all-girls high school–eleven years ago.  I’ve also never understood the popular inclination to hate on your high school.  Now, it’s not that I peaked at seventeen and long to return to St. Joe’s and attend classes–my affection for the school isn’t that based in nostalgia–but I honestly love SJA and I’ll readily tell anyone that it’s an excellent place and that they should have no hesitations about sending their daughters there.

Until today.

Today, my love of Joe’s is based in nostalgia, and I totally want to be fourteen again and go back to high school.  Why?

Let’s start with some backstory:  I was a really nerdy kid.  I was into computers and books and sci-fi and a lot of really, really nerdy stuff.  Part of the reason I ended up at St. Joe’s was because I was the perfect bully target at public school.  I had wanted to go into some sort of computer  career when I was a kid and my life journey took me farther and farther away from that as an adult, until I decided that was nonsense, pulled a 180 and enrolled in coding bootcamp.

Keep that in mind as I tell you about how this is reunion weekend, and every fall during reunion weekend, SJA has an Open House.  I’ve been meaning to go and see the improvements they’ve made to the campus (including a new dining hall and outdoor spaces), plus the alumnae window cling in my car went missing awhile back, so I figured I’d go to the Open House, poke around, and buy a new window cling.

I took a friend with me and we went up to the third floor to look at my mother’s old Spanish classroom, which is now an engineering classroom.  Okay, fine.  The surprise was a few feet down the hall, where a classroom door had been propped open so that that a strangely alluring humming noise and the scent of melted plastic could drift out.

We had inadvertently found the “maker room”, where four out of the school’s six 3D printers were busy making what looked like Christmas ornaments.  Further along the wall, a laser printer was busy etching a chess board into a piece of wood.  A few students were drafting out designs for the 3D printers while my old chemistry teacher was showing off the school’s drone.

MY HIGH SCHOOL HAS A DRONE NOW.  WHAT IN THE BLASTED HECK, GUYS.

Mr. Weiss, if you’re reading this… I’m sorry I didn’t get a chance to talk to you about the drone today, but please know that if we’d had a drone in 2003, I really, really would’ve paid more attention in class.

I’m totally jealous of all this stuff.  We let one of the students show us the equipment and explain how it worked, and I was insanely jealous of a fifteen-year-old taking Intro to Pre-Engineering, because back in my day the closest you could’ve gotten to that was, I don’t know, maybe calculus?  I’m not sure I have the capacity for calculus as an adult–as an easily-distracted seventeen-year-old girl with dyscalculia and a serious literary crush on Discworld‘s Ponder Stibbons, I never could’ve hacked it, even if my crush was because Ponder is the Disc’s ~science wizard~.  If there had been 3D printers and Lego robots and a freakin’ drone, I would have been all over my math textbooks in high school.  I would have overcome my learning disorder immediately, beaten down the educational psychologist’s door, anything to get my hands on that stuff.  These girls get to take an honors class in computer programming, which I would have been all about had it been an option.

I got to putz around with JavaScript until the wee hours of the morning without any direction when I was sixteen.  I learned it out of a book I checked out from the local library and when I pulled into the parking lot each morning, it was time for other things because no one had even heard of JavaScript at school.  I was also pretty good at drawing and playing the cello and interpreting poems in English class, though, and shuffled into a file labeled “going to be a success case in the humanities” pretty early on.  For a long time, I was kind of ambivalent about STEM education because most of my nerdy friends went on to be software developers and data analysts, while I racked up a ton of debt writing very long papers about Nazi propaganda and postmodern elements in Blade Runner*.  Animosity and dismissiveness towards STEM activities kind of became a coping mechanism for me because I wasn’t getting to do the cool stuff I had originally wanted to do, either because I “wasn’t good at it” (which I now know to be absolute rubbish) or because I was “just so good at other things” (also rubbish, because it’s not like interpreting poetry is not compatible with science).  That said…

…good on SJA! I may be insanely jealous that this stuff wasn’t around when I was a student, but let’s be honest, half this stuff just didn’t exist in 2003, let alone exist in consume products that schools could easily purchase.  We’re living in the future, and the future is totally rad.  I’m super proud of my high school for encouraging girls to pursue STEM and giving them the tools they need to learn and prepare themselves for college and future careers.  I should also point out that SJA has expanded its curriculum for the visual and performing arts from the time I graduated and not only boasts a really impressive class list in the humanities, but also a specialty program track for students interested in going into healthcare careers.

Basically, my high school is really cool, and I think it’s totally amazing that girls are getting STEM education at St Joe’s.  Also, all the alumni gear in the bookstore was 25% off, so I got a good deal on this really sweet hoodie to go with my window cling:

wearing my totally rad SJA hoodie

Sursum Corda! 🙂

 

 

 

*If you want to read the Blade Runner paper, it’s on this site.  Just click on “writing” in the top menu.