Coding Standards

  Home  Applications Programs  Coding Standards


“Coding standards/conventions Interview Questions and Answers will guide you that Coding standards are a set of guidelines for a specific programming language that recommend programming style, practices and methods for each aspect of a piece program written in this language. These conventions usually cover file organization, so learn coding standards and conventions with this Coding standards/conventions Interview Questions with Answers guide”



26 Coding Standards Questions And Answers

1⟩ From where CamelCase gained popularity?

The coding standard CamelCase gained popularity as a convention with WikiWiki (pronounced wikee wikee; wiki means "quick" in Hawaiian) software, which automatically creates and identifies hypertext links in Web pages and is used in Wikipedia, the user-contributed encyclopedia. CamelCase is now used in a number of World Wide Web Consortium-recommended protocols, such as the Simple Object Access Protocol (SOAP), Synchronized Multimedia Integration Language (SMIL), and Extensible Markup Language (XML).

 222 views

2⟩ Size of Scripts and libraries?

Main script section ("Sub Main .. End Sub) and function bodies should fit within an A4-page (approx. two monitor-pages). If the code doesn't fit it is a candidate to do more decoupling to separate small functions. The bigger a function body the harder to read and maintain.

 232 views

3⟩ Documentation Introduction

Documentation is done to provide others with information and ease maintenance. The best documentation is done in the headers (function and scripts) and directly in the code. Any useful thoughts ie a chosen algorithm or a solution to a specific problem should be documented in order to help others understand the script(s) and/or function(s).

 258 views

4⟩ How to deal both scripts and libs in Scripts and libraries?

Although it is possible to chain scripts by using the “CallScript” command it is not recommended to use it (or even exhaust) too much unless successful script execution of the called script does not depend on the prior executed script or if the chain is not too long and if a script is preceded by an initiating script followed by a script that brings the AUT back into a defined state.

Functionality or a business-case that is used very often such as the login-operation should not be placed in a script but in a function library because scripts don’t allow for parameter passing, ie. a login-script is unable to be reused with different usernames and passwords.

All functions within libraries and/or scripts need explanatory headers where one describes the purpose of the function.

 225 views

5⟩ Explain Documentation Libraries?

The documentation rules are almost exactly the same as for Scripts "Documenting scripts". Although from a technical point of view it is feasible to place procedures in libraries it is not common to do that. Functions are a better alternative as they accept parameter passing.

 221 views

6⟩ Explain Functions Introduction?

Common used functions are placed within libraries in the SQABasic directory. Files ending with “.SBH” contain the public interface they provide to other libraries and scripts. Files ending with “SBL” contain the implementation of the public interface and private functions.

You use them by including them in your testscript or in another library. However, never ever include a .SBL-file into your script or library, instead include the header file only (.SBH) otherwise you run into cyclic redundancy problems and the compiled SBX file growths for nothing.

Example

GOOD:

'$include "axCommon.sbh"

FORBIDDEN:

'$include "axCommon.sbl"

 221 views

7⟩ Explain Naming Convention Verification points?

Description

In functional testing, you need to verify that the objects in the application-under-test look and work as designed from build to build. To accomplish this, you can establish verification points also known as checkpoints or the objects. Because verification points are not very flexible when it comes to changes in the AUT it is wise to prefer Robot's

SQAGetProperty...- commands to verify whether expected behavior is met or not.

Syntax

[vp]+[FEATURE]+ [FUNCTION]

Examples

· vpAURA_ImageUploaded

· vpAURA_CaseInserted

 225 views

8⟩ Explain Naming Convention Libraries?

Description

Common used functions are placed in libraries. These are located in the SQABas32 subdirectory of the Robot working directory. A library is divided into three files, a header (.SBH), an implementation file (.SBL) and the compiled version (.SBX). Libraries are not necessarily bound to an AUT or feature.

Syntax for implementation file

[ax]+[ShortName]+"sbl"

Syntax for header file

[ax]+[ShortName]+"sbh"

Examples

· axCommonUtilities.sbl

· axDBAccess.sbh

· axGuiMapper.sbl

 241 views

9⟩ Explain Scripts and libraries Introduction?

Scripts

A script within Rational Robot is a file that contains a sequence of SQABasic code. The extension of the file is always “.REC”. Typically the script contains an automated testcase and contains the business-logic and also the testdata. Although it is generally recommended to shift testcase-logic and especially testdata to external sources such as CSV or Excel it is NOT designed to do so today because this technique requires an underlying sophisticated automated test framework that we do not have implemented at this level of automation yet.

Libraries

Common used functions are placed in libraries. These are located in the SQABas32 subdirectory of the Robot working directory. A library is divided into three files, a header (.SBH), an implementation file (.SBL) and the compiled version (.SBX). Libraries are not necessarily bound to an AUT or feature.

 238 views

10⟩ Explain Naming Convention Scripts?

Description

A script within Rational Robot is a file that contains a sequence of SQABasic code. The extension of the file is always “.REC”.

Syntax

[FEATURE] + "_" + [FUNCTION] + "_" + {optional}

[FEATURE] is a capital letter string denoting the feature name [FUNCTION] is a capital letter string denoting the function {optional} means that the remaining characters preceded by an underscore will be optional and left to each person to define a sensible name which clearly identifies each of the test scripts

Example · BILL_REP_Outputformat (refers to script Billing feature with report function)

· PART_INS_Assesor

· PART_UPD_Assessor

 225 views

12⟩ Explain Functions Size?

A function body should fit within an A4-page (approx. two monitor-pages). If the code does not fit it is a candidate for more decoupling to smaller functions. The larger a function body the harder to read and maintain.

 226 views

13⟩ What are the conditions of CamelCase coding standard?

☆ The first letter is capitalized.

☆ One or more letters in that word are also capitalised.

☆ The word does not end on a capitalized letter: CamelCasE

☆ No two capitalised letters shall follow directly each other: CamelCAse

☆ No number in that word at any place: CamelCase1more

☆ No dot(.), under_score or dash (-) within the word, only letters: Camel_Case

 230 views

14⟩ What is the structure of Coding Standard?

☆ Add a single space after each comma delimiter;

☆ Add a single space around binary operators (==, &&, ...), with the exception of the concatenation (.) operator;

☆ Place unary operators (!, --, ...) adjacent to the affected variable;

☆ Add a comma after each array item in a multi-line array, even after the last one;

☆ Add a blank line before return statements, unless the return is alone inside a statement-group (like an if statement);

☆ Use braces to indicate control structure body regardless of the number of statements it contains;

☆ Define one class per file - this does not apply to private helper classes that are not intended to be instantiated from the outside and thus are not concerned by the PSR-0 standard;

☆ Declare class properties before methods;

☆ Declare public methods first, then protected ones and finally private ones. The exceptions to this rule are the class constructor and the setUp and tearDown methods of PHPUnit tests, which should always be the first methods to increase readability;

☆ Use parentheses when instantiating classes regardless of the number of arguments the constructor has;

☆ Exception message strings should be concatenated using sprintf.

 240 views

15⟩ List the naming conventions in Coding Standards?

☆ Use camelCase, not underscores, for variable, function and method names, arguments;

☆ Use underscores for option names and parameter names;

☆ Use namespaces for all classes;

☆ Prefix abstract classes with Abstract. Please note some early Symfony classes do not follow this convention and have not been renamed for backward compatibility reasons. However all new abstract classes must follow this naming convention;

☆ Suffix interfaces with Interface;

☆ Suffix traits with Trait;

☆ Suffix exceptions with Exception;

☆ Use alphanumeric characters and underscores for file names;

☆ For type-hinting in PHPDocs and casting, use bool (instead of boolean or Boolean), int (instead of integer), float (instead of double or real);

☆ Don't forget to look at the more verbose Conventions document for more subjective naming considerations.

 231 views

18⟩ What is CamelCase Coding Standard?

CamelCase is a naming convention in which a name is formed of multiple words that are joined together as a single word with the first letter of each of the multiple words capitalized so that each word that makes up the name can easily be read.

 251 views

19⟩ What are the advantage of CamelCase?

The advantage of CamelCase is that in any computer system where the letters in a name have to be contiguous (no spaces), a more meaningful name can be created using a descriptive sequence of words without violating the naming limitation.

 243 views

20⟩ Explain Naming Convention Globals?

Description

The values of global variables can be used and changed all over the project within all scripts and libraries. Though it is highly recommended to keep the number of global variables small. If global variables tend to be used in a specific project only it is advisable to keep those values in either a project specific library header or in a separate configuration file.

Syntax

"g" + [Prefix]+[ShortDescription]

Letter “g” indicates that the scope of the variable is global. [Prefix] is a lowercase letter that represents the type of the global variable. The rules for [Prefix] are the same as for “Local scope variables”.

Examples

· gnNumOfPersons

· gsPersonLastname

 227 views