31
Programming / Re: How to be a horrible programmer: OpenXcom coding guidelines
« on: September 25, 2013, 12:58:01 am »
I've read the document, and here are my comments:
"ALL" - this isn't ok. boost has it's noncopyable class for a reason, and this reason is that so much classes weren't meant to be copied at all.
Quote
C++ Guideline 3.1.13 Verify that all classes provide a minimal standard interface against a checklist comprising: a default constructor; a copy constructor; a copy assignment operator and a destructor.
"ALL" - this isn't ok. boost has it's noncopyable class for a reason, and this reason is that so much classes weren't meant to be copied at all.
Quote
C++ Guideline 3.2.4 An abstract class shall have no public constructors.this is a purely useless rule.
Quote
Use public derivation only.disables you from layering code common for each object instantiated for a template, which makes your compile generate tons of redundant code.
Quote
C++ Rule 3.3.5 Override all overloads of a base class virtual function.if you really need to do this because of "safety", then your classes need a redesign.
Quote
Rule 3.4.5 When publicly deriving from a base class, the base class should be abstract.in such cases it's always a composition vs inheritance issue to talk through in the team and evaluate the profit of each solution, sometimes inheritance wins, so the rule isn't always viable, and by that shouldn't be called a rule.
Quote
Rule 3.5.4 Make binary operators non-members to allow implicit conversions of the left hand operand.not always what you'd like to have actually...
Quote
Rule 5.2 For boolean expressions ('if', 'for', 'while', 'do' and the first operand of the ternary operator '?:') involving non-boolean values, always use an explicit test of equality or non-equality.in case of 'if' and 'while' this is actually a very redundant rule.
Quote
C++ Rule 7.1 Always use casting forms: 'static_cast', 'const_cast', 'dynamic_cast' and 'reinterpret_cast' or explicit constructor call. Do not use any other form.this is actually CRAZY IMPORTANT. using these guys is not only safer and nicer, but it's a nice and free tool to make first general verification on the code quality.
Quote
C++ Guideline 10.6 When comparing variables and constants for equality always place the constant on the left hand side.bad guideline, already explained why.
Quote
C++ Rule 12.7 Document that operator new and operator delete are static by declaring them static.this is just silly...
Quote
Rule 15.1 Do not use variant structures (unions).they are required to make a nice memory pool, and not die in the process but in general I agree with this.
Quote
Rule 16.3 Only instantiate templates with template arguments which fulfill the interface requirements of the 'template'.disagree - if all you need from a template is the part of functionality that your object fulfills, then it's better to use it that way, than to write code without reason.
Quote
Guideline 16.4 Only use templates when the behaviour of the class or function template is completely independent of the type of object to which it is applied.true, but only in cases when the template is for everyone to use. making private template methods that will handle a handful of types, to save a lot of code is ok, and it IS a way to go, rather than to duplicate the code.
Quote
Rule 17.8 Never create containers of auto_ptrs.CRAZY IMPORTANT