Naming convention for procedural elements (internal procedur

Posted by Nick Vancauwenberghe on 11-May-2017 09:40

What naming convention do you prefer for internal procedure and UDF names?

Currently we go for:

  1. Explanatory names
  2. Only alphanumeric chars
  3. lowerCamelCasing

Examples:

procedure internalProcedure private:

function functionExample returns integer private

Posted by gus bjorklund on 11-May-2017 17:54

procedures should be named for what they do:

deleteOrder()

printStatus()

functions should be named for what they return:

LoanInterestRate()

OrderTotal()

PollenCount()

and so on.

All Replies

Posted by Matt Baker on 11-May-2017 10:00

Robert martin wrote a whole book and runs a blog.  With topics that cover this.  I find his advice very good and he makes it a point to address a lot of the points and styles with DOs and DONTs.

http://blog.cleancoder.com/

Suggest you read the book if only just for the one section on naming.  The rest of the book is great too.

www.amazon.com/.../0132350882

Posted by gus bjorklund on 11-May-2017 17:54

procedures should be named for what they do:

deleteOrder()

printStatus()

functions should be named for what they return:

LoanInterestRate()

OrderTotal()

PollenCount()

and so on.

Posted by Nick Vancauwenberghe on 12-May-2017 03:25

Gus,

Thanks! Nice and simple guideline.

About the casing, you do this on purpose?

  • internal procedures: lowerCamelCasing
  • UDF: UpperCamelCasing

Posted by Patrick Tingen on 12-May-2017 04:28

I try to convince my fellow developers here as well that they should follow the rules Gus mentioned, but some folks simply cannot understand that I have difficulty grasping what a procedure does when it is named "orders".

I do believe that a good naming convention enforces better code quality. If you have a procedure that collects orders, recalculates discounts and then exports them to whatever, how on earth are you going to come up with a decent name for that. The answer is: you don't. You end up with a name like "orders". But in fact it tells you that your code block is way too large and that you should have split it up in at least 3 subprocedures: collectOrders, recalculateDiscounts and exportOrders.

Posted by onnodehaan on 12-May-2017 05:40

Amen, Patrick! Amen!

You are absolutely right. I have the exact same discussions .

Posted by bronco on 12-May-2017 06:25

It's always difficult to come up with a name which covers 3000+ lines of code. LOL.

Posted by ChUIMonster on 12-May-2017 09:00

Gus' suggested convention is excellent.

Posted by Peter Judge on 12-May-2017 10:18

What’s the guidance on class methods?
 
Should you _really_ be naming things based on the type of thing they are? Function v procedure?
 
 
 
 
 
And yes yes yes I know I use a leading I for interface types and a trailing Enum for enum types. But what’s a good Friday Flamwar ™ © wihtoyut a healthy dose of hypocrisy? ;)

Posted by Peter Judge on 17-May-2017 08:45

Since no-one was in the mood for a flamewar :) here's a serious comment ...

This post on StackOverflow has a good set of approaches for naming logical methods and proeprties: softwareengineering.stackexchange.com/.../naming-of-bool-methods-is-vs-can-vs

Posted by onnodehaan on 17-May-2017 09:05

Great post, Peter!

Posted by gus bjorklund on 24-May-2017 07:24

yes, good post, peter.

the important thing with any naming convention and the names created when using it is the effect its has on the mind of the /reader/. does it move him along on the path to understanding or does it lead him down the garden path? will it make him smarter or dumber?=

Posted by cverbiest on 24-May-2017 09:12

The Common Component Specification also has some coding conventions but I can't find a public link at the moment.and I get 404 on github.

It's written with OOABL classes in mind but I think some of it could be applied to procedural as well.

Maybe Peter has a link.

Posted by Mike Fechner on 24-May-2017 09:30
This thread is closed