(Single source of truth)
Gerard J. Holzmann
“A man with a watch knows what time it is. A man with two watches is never sure.”
Segal's law
POURQUOI?
Une montre => une valeur de référence
2 montres => 2 valeurs... Laquelle choisir?!
<!-- Page une -->
<html>
<head>
<link href="style.css">
</head>
<body>
<header class="navbar">
<!-- NAVBAR HERE -->
</header>
<h1>Page une</h1>
<footer>
<!-- FOOTER HERE -->
</footer>
</body>
</html>
Mauvais exemple
<!-- Page deux -->
<html>
<head>
<link href="style.css">
</head>
<body>
<header class="navbar">
<!-- NAVBAR HERE -->
</header>
<h1>Page deux</h1>
<footer>
<!-- FOOTER HERE -->
</footer>
</body>
</html>
Bon exemple
<!-- Page une -->
<?php include 'header.php'; ?>
<h1>Page une</h1>
<?php include 'footer.php'; ?>
<!-- Page deux -->
<?php include 'header.php'; ?>
<h1>Page deux</h1>
<?php include 'footer.php'; ?>
<!-- Page footer de reference (footer.php) -->
<footer>
<!-- FOOTER HERE -->
</footer>
</body>
</html>
<!-- Page header de reference (header.php) -->
<html>
<head>
<link href="style.css">
</head>
<body>
<header class="navbar">
<!-- NAVBAR HERE -->
</header>
AVANTAGES
1- Lisibilité
2- DRY (Don't repeat yourself)
3- Gain de temps
4- Maintenabilité