Code Formatting - Functions with long Parameter Names, or many Parameters

robbonickrobbonick Member Posts: 40
Hi,

I am just wondering what the best practice is for formatting of code, I have tried to search the coding guidelines for this, but found nothing.
My question is, say I have a function called "SomeVeryVeryVeryLongFunctionName", which returns a boolean.

This then has 4 parameters, which are populated by values from a record.

So the code would look like this...

Variant 1
IF SomeVeryVeryVeryLongFunctionName(ItemLedgerEntry."Posting Date", ItemLedgerEntry."Entry Type", ItemLedgerEntry."Document Type", ItemLedgerEntry."SourceNo") THEN BEGIN
  DoSomething();
END;

What are the guidelines for separating this function on to two lines, or more?
Or is it all a matter of opinion?

For instance should it be something like this...

Variant 2
IF SomeVeryVeryVeryLongFunctionName(
  ItemLedgerEntry."Posting Date", 
  ItemLedgerEntry."Entry Type", 
  ItemLedgerEntry."Document Type",
  ItemLedgerEntry."SourceNo") THEN BEGIN
    DoSomething();
END;

or this...

Variant 3
IF SomeVeryVeryVeryLongFunctionName(ItemLedgerEntry."Posting Date", ItemLedgerEntry."Entry Type", 
  ItemLedgerEntry."Document Type", ItemLedgerEntry."SourceNo") THEN BEGIN
    DoSomething();
END;


Best Answers

Answers

  • JuhlJuhl Member Posts: 724
    You could look at NAV standard.
    Variant 3 is the most used.
    Follow me on my blog juhl.blog
  • robbonickrobbonick Member Posts: 40
    Yeah I have looked in standard, and it varies between them all to be honest
Sign In or Register to comment.