Eco-design in code

The developer's levers for lean code, in four groups (processing, data, network, display), what gets measured and the guidelines that help.

  • 21 cards
  • 5 topics
  • Free

The outline, topic by topic

Each topic is weighted the way the exam weighs it.

  1. Concepts
  2. Questions
  3. Sort and link
  4. Scenarios
  5. Understand

A few cards from the deck

  • Eco-design of a digital service: what is it?

    Show the answer

    An approach that reduces, from the design stage, the environmental impacts of a service over its whole life cycle: device manufacturing, servers, network, use.

    For a web service, the manufacturing of devices often weighs more than the electricity used: extending the life of devices matters as much as the code.

  • A page shows 20 rows of a table that holds 50,000. Which version is the leanest?

    • Paginate in the SQL query, which returns only the 20 rows shown
    • Send the 50,000 rows to the browser, which shows only 20
    • Read the 50,000 rows on the server and send only the 20 needed
    • Compress the response that carries the 50,000 rows
    Show the answer

    Paginate in the SQL query, which returns only the 20 rows shown

    Pagination is done in the query (LIMIT 20 OFFSET …), closest to the data: what is not displayed is neither read nor transferred. Compressing a useless transfer shrinks it but does not remove it.

  • The developer's levers fall into four families: …, stored and transferred …, network exchanges and display.

    Show the answer

    The developer's levers fall into four families: processing, stored and transferred data, network exchanges and display.

    This grid helps not to forget anything: fast code that downloads the same image ten times is still greedy.

  • Green coding: what is it?

    Show the answer

    The set of writing practices that limit the resources a program consumes: computation, memory, storage, transfers.

    It overlaps with performance (less computation means less energy) but goes further: do not store, transfer or display what is useless.

  • An 8 MB home page contains a decorative video that starts by itself in the background. What first?

    • Ask whether it is useful, then remove or defer it
    • Re-encode it at a lower resolution and keep it on autoplay
    • Serve it from a delivery network closer to visitors
    • Host it with a provider running on renewable energy
    Show the answer

    Ask whether it is useful, then remove or defer it

    The best byte is the one you do not transfer. Optimising a useless resource is less effective than removing it; sobriety comes before optimisation.