Contact us

Guideline General Programming

Guideline General Programming

There are 2 very important principles that we want to use here in Uniweb.

DRY: DON’T REPEAT YOURSELF’t_repeat_yourself


Those ideas are fundamental to provide quality and reliability into all our projects.
We never work alone on a project so it’s very important to keep those concepts in mind to help your coworkers to understand your code.
And it’s better for yourself because it will help you to update your own code later.
It’s always important to think about the project in global, not only about your current task.
Try to anticipate and to make your project grows up carefully.

We don’t just want you to finish the work. We also want the works to be well done. There is nothing more annoying that to have to update the code of a lazy developer who just did his work and nothing more. Do not forget many of our customer are web companies, they know how to work and they will check our codes.
More important some companies hire external experts in order to verify our works and to process security checkings.

Remember good programming is not about speed. It’s about efficiency and durability.
Do not just make it works. Make it ALWAYS works whatever the context (user capacities, browser, OS, language, …)
In one word: Anticipate

Here is some guidelines to help you to reach this goal.


Always structure your methods and functions step by step.
It should be CLEAN and easy to understand.
The classic way to do 90% of the works is a 4 steps architecture:

  • Get the values
  • Format the values
  • Send the values
  • Return an answer

We need to see those steps clearly with the code formatting and the comments:

// My step 1
$id = 1;
$name = "test";

// My step 2
$name = ucfirst($name);
$name = ucfirst($name);
$name = ucfirst($name);

// My step 3

Same ideas with the class. We need to clearly understand the various methods.
If you have a method that you have to scroll through the 500 rows to read it, maybe there is a problem.
You probably need to restructure your method and cut it into smaller steps.
And even if you only use one time a method (for now!) it doesn’t mean it’s useless.
It improve the readability and it’s ready to be reused later.

Name conventions:

Try to be consistent when you choose attributes, methods and functions name.
Keep it clear and simple like:
delete[Object Name], update[Object Name]

Always use camelCase for methods and functions
And always use the following standard:

function addUser()
    $code = "clean";

Logical operators

Try to make them simple, avoid complex operators and multi rows unless the speed is a priority for the action.
Understand how to choose between && and || in order to make the operator faster.

Always use the following standard:

if ($test == "operator") {
    $test = "clean";
} elseif ($test == "ok") {
    $test = "easy";
} else {
    $test = "simple";

foreach ($test as $key => $value) {


Please note the spaces between the key words and use the same format.

Always use && – || and don’t use AND – OR
Don’t forget to use the identical operator (=== instead of ==). It could be good to check the type in some cases.
Use the ternary operator as much as possible:


if ($test == "easy") {
    $test = "simple";
} else {
    $test = "clean";


$test = ($test == "easy") ? "simple" : "clean";

Please note the spaces between the key words and use the same notations.
Readability is the key. Sometimes ternary is not a good idea:


$test = $test == ("This is obviously a bad idea when the checking is very long" && "I will have difficulties to understand by code Monday morning") ? "bad" : "It was totally useless " . ($check ? " to do that" : " to do that again");

If you use PHP > 5.3 you can even use the following assignment:

$test = $name ?: 'Error';

Instead of:

$test = isset($test) ? $test : 'Error';

And in JavaScript :

var test = test || 'Error';

What’s next

If you have some free times please take a look to:
Django (Python framework)
AngularJS (JS framework)
SASS (CSS3 extension)

Which are the tools we use to build our web applications.
Of course they will never replace Magento or WordPress which are great tools for specific needs.