Ue4 encoding Specification

Source: Internet
Author: User
Tags coding standards

The original translation is the official version of unreal! I summarized it myself, not necessarily every article can be matched. For more information, see!

Original article address: Unreal codingstandard


Ue4 encoding Specification
In epic, there are several simple coding standards:

L The 80% time of code life lies in Service

L no software is maintained by the original author throughout the process

L coding specifications provide software readability, allowing new users to quickly and thoroughly understand the code. The new engineer will create a new project to modify the code.

L if the source code is released to community developers, the code is easy to understand.

L cross-compilation is required.


Naming rules

L uppercase letters without underscores

L The first letter is of the variable type.

The module prefix is T.

Inherit uobject prefix u

The prefix of aactor is.

Inherit swidget prefix s

Inherit abstract interface prefix is I

Most of the other prefixes are f, and some subclasses use other letters.

L type and variable are nouns

L The name of a method action is a verb, describing the action of a method, or returning a value.

Variables and methods. The class name must be clear to avoid over-abbreviations.

Only one variable can be declared at a time. Annotations can be used normally. They are required for the javadocs type. You can annotate multiple lines or single lines.

The function must return the bool type. The prefix of the bool variable is B.

No return value function. objects must be added after the verb. Name to avoid ambiguity

 

Basic C ++ object type

Do not use bool

Tchar, no need to use char

Uint8

Int8

Uint16

Int16

Uint32

Int32

Uint64

Int64

Float, single-precision floating point

Double, double-precision floating point number

Ptrint, an integer with a pointer

 

Note

Comments are communication, and communication is critical. Print comments to your mind. (Kernighan & Pike the practice of programming)

 

Ue4 uses javadoc to automatically parse code comments and compile and generate documents. Note the format of the comment.


C ++ 11 new features

Currently, auto, for loop, and lambda expressions are supported. Sometimes we just fold it with the macro definition.

L auto

Use auto to bind the variable type during compilation. If you hover your mouse over the vs variable, the actual type of the auto variable is displayed.

L for Loop

The code is simpler and easier to maintain.

L Lambda expresses anonymous Functions

Lambda is available, but currently we are very cautious about using it.


Third-party code encoding format

{} Another line is required.

If-Else, brackets should be used for any use. Multiple rows can be used to put else-if on one row.

Switch, there must be a default.


Namespace

L use your own namespace. Do not use the same name as a third-party database.

L do not use using in the global scope, or even in CPP.

L using a namespace in a namespace or using a namespace in a function is okay.

L use the namespace to confirm consistency.

L The type of Forward Declaration must be carried out in their separate namespaces.

L if a large number of classes or types are declared in a namespace, use the expenditure namespace that needs to be specified globally.

L using. It is best not to use aliases.

L The Enumeration type is declared in the namespace to prevent global visibility.


Physical independence

All compilers support # pragma once.

Do not use the header file directly.

Do not worry about the pre-compiled header settings of the header file. unrealbuild is better than what you do.


Common formats

L variables are defined in the most recent usage.

L separate as many methods as possible.

L function declaration or call. Do not place spaces before the function name.

L add a line of space at the end of the. h and CPP files, as required by GCC compilation.

L do not convert floating point float to int implicitly, because it is not possible for the compiler to compile. Use apptrunc () for conversion.

L it is not an interface. Use the private type to protect data.

L do not write variables in the interface class. The interface class allows non-pure virtual functions, non-virtual functions, or static functions.

L use const more.

L separate multiple expressions to make the code easy to understand. Simplify complex expressions with intermediate variables.



const bool bIsLegalWindow = Blah->BlahP->WindowExists->Etc && Stuff; const bool bIsPlayerDead = bPlayerExists && bGameStarted && bPlayerStillHasPawn && IsTuesday(); if (bIsLegalWindow && !bIsPlayerDead){DoSomething(); }



L use override for virtual functions

L The * Number of the pointer, which is placed near the object to facilitate searching for a certain type of pointer class object.

 

----------------------

If you have any questions, feel free to contact us!


Ue4 encoding Specification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.