Coding Blocks

Clean Code - Writing Meaningful Names


Listen Later

In this episode, we take our first dive into the book Clean Code by Robert Martin and specifically we talk about writing meaningful names for all things code related.  You'll be amazed at how following some decent rules that you can start naming things that will help you and fellow coders understand your code at a glance.

You can see the original show notes and put your own stamp on our survey here:
http://www.codingblocks.net/episode47

News

Samsung 960 Pro
http://www.anandtech.com/show/10698/samsung-announces-960-pro-and-960-evo-m2-pcie-ssds

SQL Server 2016 Columnstore for real time operational analytics
https://msdn.microsoft.com/en-us/library/dn817827.aspx

Krebs site taken off Akamai
http://www.zdnet.com/article/krebs-on-security-booted-off-akamai-network-after-ddos-attack-proves-pricey/

The best Android distribution is iOS?
Outlaw’s thoughts on various phone OS’s

Survey

[yop_poll id="23"]

Meaningful Names - Clean Code Chapter 2

“If a name requires a comment, then the name does not reveal its intent”

  • Write explicit code - naming variables and methods can reveal the entire intent of the code
  • Avoid using words that would be confusing like “List” as they refer to programming types and could be misleading : accountList should be accounts
  • Avoid using characters that look like numbers i and L or capital o
  • disinformative vs noninformative
    • noise words “data” “info” - noninformative
  • Types should almost never be in a name “table” “string” “object”
  • Names should be distinguished so a user can look at them and understand the differences
  • Use pronounceable names
  • Use searcheable names - longer names trump shorter names
  • Author’s pref - single letter names should only be used as local variables inside small methods - length of the name should correspond to the size of its scope
  • Avoid encoding names
  • Avoid Hungarian Notation with typing as part of the variable name - simply not needed nowadays
  • Stop prefixing member (instance) variables with m_ or _
  • Decorating Interfaces vs Classes with a prefix / suffix - opinion - he prefers
    • ClassImp or vs IType
  • Don’t force someone to map variable names in their mind - n = username…smart programmer vs professional programmer - clarity is king
  • Class names should be nouns - English 101 - NOT VERBS
  • Method names should be verbs
  • Use get, set, is - javabean standard
  • When constructors are overloaded, use static factory methods with explicit names - liked this one, possibly make the constructors private
  • Don’t get cute with naming by means of jokes (inside or well known)
  • Use consistent naming - Get, Set, Controller - makes it easier to understand and code various parts of an application
  • Avoid puns - add for a collection vs add for setting a value - two different meanings with the same name
  • Use technical names such as pattern names or CS terms in your names - other programmers will understand them better than the problem domain in some cases
  • Fall back to the problem domain for a name if there is no suitable technical name
  • Adding context to naming can clarify their use - prefixes can work but putting variables into classes may work out better

“Hardest thing about choosing good names is that it requires good descriptive skills and a shared cultural background”

Renaming things that don’t make sense as you work in code is a good thing.

Resources we Like

Clean Code

Clean Code by Robert C. Martin

Even though we’re giving our thoughts on the various ideas throughout the book, Clean Code has tons of excellent sample code that really helps drive the points home. We can’t recommend it enough - it’s probably one of the few books EVERY developer should read and revisit from time to time.
http://amzn.to/2cryvJR

Tip of the Week

Allen: Implementing OAuth in ASP.NET for a number of providers
http://www.oauthforaspnet.com/

Michael: Get out there! Go to conferences, meetups, do it all!
http://www.connect.tech/
https://www.atlantacodecamp.com/2016

...more
View all episodesView all episodes
Download on the App Store

Coding BlocksBy Allen Underwood, Michael Outlaw, Joe Zack

  • 4.9
  • 4.9
  • 4.9
  • 4.9
  • 4.9

4.9

931 ratings


More shows like Coding Blocks

View all
Hanselminutes with Scott Hanselman by Scott Hanselman

Hanselminutes with Scott Hanselman

377 Listeners

Software Engineering Radio - the podcast for professional software developers by se-radio@computer.org

Software Engineering Radio - the podcast for professional software developers

272 Listeners

.NET Rocks! by Carl Franklin and Richard Campbell

.NET Rocks!

246 Listeners

The Changelog: Software Development, Open Source by Changelog Media

The Changelog: Software Development, Open Source

282 Listeners

The Vergecast by The Verge

The Vergecast

3,660 Listeners

Talk Python To Me by Michael Kennedy

Talk Python To Me

590 Listeners

Software Engineering Daily by Software Engineering Daily

Software Engineering Daily

626 Listeners

Soft Skills Engineering by Jamison Dance and Dave Smith

Soft Skills Engineering

271 Listeners

AWS Podcast by Amazon Web Services

AWS Podcast

203 Listeners

Syntax - Tasty Web Development Treats by Wes Bos & Scott Tolinski - Full Stack JavaScript Web Developers

Syntax - Tasty Web Development Treats

984 Listeners

Darknet Diaries by Jack Rhysider

Darknet Diaries

7,875 Listeners

CoRecursive: Coding Stories by Adam Gordon Bell - Software Developer

CoRecursive: Coding Stories

189 Listeners

Hacking Humans by N2K Networks

Hacking Humans

314 Listeners

Practical AI by Practical AI LLC

Practical AI

189 Listeners

The Stack Overflow Podcast by The Stack Overflow Podcast

The Stack Overflow Podcast

64 Listeners