Coding Style question

generic
Member Posts: 511
Hello I’m wondering why some people write if statement the following way.
Which one is easier to read? The second one is probably some millisecond faster or maybe the compiler is smart enough to remove the unnecessary " = TRUE" part.
Thanks.
IF Record."Some Boolean field" = TRUE then begin end;
IF Record."Some Boolean field" then begin end;
Which one is easier to read? The second one is probably some millisecond faster or maybe the compiler is smart enough to remove the unnecessary " = TRUE" part.
Thanks.
0
Comments
-
Personal preference, I personally like the first one, and I would even put parentheses around the expression. Neither one is faster than the other, not even a millisecond.0
-
I think - second is more standard, I use same. But definitely no difference for compiler0
-
I prefer the first one. That clearly indicates to me that the programmer really intended this code.
And I also like the parentheses especially when there are multiple conditions in the if statement.Fostering a homeless, abused child is the hardest yet most rewarding thing I have ever done.0 -
The second one is standard NAV way of coding.
Using the standard way makes it easier for everyone in the community.
It is also mandatory to use for the current CfMD certification for NAV2013...0 -
Mark Brummel wrote:The second one is standard NAV way of coding.
Using the standard way makes it easier for everyone in the community.
It is also mandatory to use for the current CfMD certification for NAV2013...
I do not agree that this is easier for all, because to me, the first way of writing the code is easier to read. Overall I agree that adhering to a standard makes things easier, but to me that applies to naming conventions more than whether you use literal values in expressions, or whether you use BEGIN and END for single line statements.
It might be mandatory, but I seriously doubt that there is a team of people that actually checks each line of code to make sure you don't evaluate boolean types against literal values.0 -
You do not need people or that, they have automated tools... :-)0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions