X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=docs%2Fcoding-convention.html;h=b6d48d859ca2d44781751c3c57bd09defb9b1591;hb=c8885de47e3bd416d70b824f336b69ec05464fb7;hp=1acc2f175715898df3cca52b9c326e0adea5fadc;hpb=1494fe758d3e47ae30ac6eb09f3f52c5c596e55e;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/docs/coding-convention.html b/docs/coding-convention.html index 1acc2f1..b6d48d8 100644 --- a/docs/coding-convention.html +++ b/docs/coding-convention.html @@ -325,7 +325,7 @@ function toggleVisibility( button, obj )

auto keyword should only be used where it improves the readability of the code and does not lead to ambiguities. - never use auto in a line where multiple different types occur as part of expressions like additions, subtracts, multiplies as whe conversion ordering rules are not always obvious. + never use auto in a line where multiple different types occur as part of expressions like additions, subtracts, multiplies as the conversion ordering rules are not always obvious. @@ -368,6 +368,70 @@ function toggleVisibility( button, obj )

+

Class Inheritance

+

Overriding

+
+

+ + When using inheritance, any methods in the base class that can be overridden MUST be marked as virtual. + In deriving classes, when a virtual method is overridden, then only use the override keyword. + If a method should not be overridden further, then use the final keyword alone. + + + + // Good: + class Base + { + public: + virtual void Print() const; + virtual void SetPrintSpeed( float speed ); + }; + + class Derived : public Base + { + public: + void Print() const override; + void SetPrintSpeed( float speed ) final; + }; + +

+

+ If a class should not be overridden then use the final keyword on the class itself. + This should also be done for a derived class that should not to be overridden further as well. + Overridden methods within that class can be marked as final or override. + + + + class Derived final : public Base + { + public: + void Print() const override; + void SetPrintSpeed( float speed ) final; + }; + +

+

Overloading

+

+ Overloading of Base class methods SHOULD be avoided but if it's required, then use the using keyword. + + + + class Derived : public Base + { + public: + void Print( float number ) const; // overloaded member + using Base::Print; // Make the Base class' Print method visible here as well. + }; + +

+

+ If we do not add the using line, then we can only use the overloaded Print method for a Derived object (unless we cast to the Base class). + Attempting to use the base class' Print() method on a Derived object would result in a compilation error. +

+

+

+
+

General design priciples

Here's a few pragmatic programmer guidelines to follow (Web version)