Methodology

Norme Epitech

Table of contents

Project structure

Git workflow

C

Headers

#define HELP "USAGE..."
...
printf(HELP); // OK

printf("USAGE..."); // NOT OK
void my_useless_function(void);
void get_and_display_map(const char *filename); // NOT OK

char **get_map(const char *filename);
void display_map(const char **map); // OK

Sources

size_t length = strlen(str); // OK
size_t l = strlen(s); // NOT OK

C++

Headers

class IMyInterface
{
...
int _privateAttribut;
const MyClass &myNonModifierPublicMethod() const;
MyClass &myPublicMethod();
MyClass(MyClass &&) noexcept = default;
MyClass(const MyClass &copy) = delete;
~MyClass() = default;
[[nodiscard]] int getValue() const; // OK
int Value() const; // NOT OK
MyClass &setValue(int value); // OK
MyClass &Value(int value); // NOT OK
bool isActive() const;
void func([[maybe_unused]int]);

Complete example:

#ifndef MY_FILE_HPP
# define MY_FILE_HPP

# include <string> // NOT OK
# include "MyBase.hpp"

namespace example
{

constexpr double GLOBAL_CONSTANT = 3.14159265359;

class MyClass : public MyBase
{
// ATTIRBUTS
  private:
        int _myPrivateAttribut;

  public:

// METHOD
  public: // CONSTRUCTORS
        MyClass() = default;
        ~MyClass() override = default;
        MyClass(const MyClass &copy) = delete;
         MyClass(MyClass &&) noexcept = default;

   public: // OPERATORS
         MyClass &operator=(const MyClass &other) = default;
         MyClass &operator=(MyClass &&other) = default;

   public:
         MyClass &myPublicMethod();
         const MyClass &myNonModifierPublicMethod() const;

   private:
         void myPrivateMethod();

  };

}

#endif /* !MY_FILE_HPP */

Sources

auto player = std::make_unique<Player>(); // OK
auto i = int64_t{ 0 }; // OK
std::function func = [](){ return 42; };  // NOT OK
auto player = std::make_unique<Player>(); // OK
auto *player = new Player; // NOT OK

Complete example:

#include "MyClass.hpp"

namespace example
{

  MyClass MyClass::&myPublicMethod()
  {
   ...
   return *this;
  }

}

Python

mylist = [1, 2, 3]

mysum = 0
for i in mylist: # NOT OK
    mysum += i

sum(mylist) # OK

Javascript