Artwork

Content provided by Allen Underwood, Michael Outlaw, and Joseph Zack. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Allen Underwood, Michael Outlaw, and Joseph Zack or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.
Player FM - Podcast App
Go offline with the Player FM app!

Clean Code - Writing Meaningful Names

1:51:36
 
Share
 

Manage episode 161519108 series 27319
Content provided by Allen Underwood, Michael Outlaw, and Joseph Zack. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Allen Underwood, Michael Outlaw, and Joseph Zack or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

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

  continue reading

241 episodes

Artwork

Clean Code - Writing Meaningful Names

Coding Blocks

2,229 subscribers

published

iconShare
 
Manage episode 161519108 series 27319
Content provided by Allen Underwood, Michael Outlaw, and Joseph Zack. All podcast content including episodes, graphics, and podcast descriptions are uploaded and provided directly by Allen Underwood, Michael Outlaw, and Joseph Zack or their podcast platform partner. If you believe someone is using your copyrighted work without your permission, you can follow the process outlined here https://player.fm/legal.

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

  continue reading

241 episodes

All episodes

×
 
Loading …

Welcome to Player FM!

Player FM is scanning the web for high-quality podcasts for you to enjoy right now. It's the best podcast app and works on Android, iPhone, and the web. Signup to sync subscriptions across devices.

 

Quick Reference Guide