# Sebastian Dörner

Published articles for Sebastian Dörner.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Arrange Your Code to Communicate Data Flow

DevFeed: [Arrange Your Code to Communicate Data Flow](<https://devfeed.tech/articles/arrange-your-code-to-communicate-data-flow-23863.md>)

Original publisher: [Read original article](<http://testing.googleblog.com/2025/01/arrange-your-code-to-communicate-data.html>)

Author: Google Testing Bloggers (noreply@blogger.com)

Published: 2025-01-07T13:59:00Z

Content type: tutorial

Language: en

Sources: [Google Testing Blog](<https://devfeed.tech/sources/google-testing-blog.md>)

Topics: [Code](<https://devfeed.tech/topics/code.md>)

Tags: [article](<https://devfeed.tech/tags/article.md>), [code](<https://devfeed.tech/tags/code.md>), [code-health](<https://devfeed.tech/tags/code-health.md>), [cognitive-load](<https://devfeed.tech/tags/cognitive-load.md>), [readability](<https://devfeed.tech/tags/readability.md>), [sebastian-dorner](<https://devfeed.tech/tags/sebastian-dorner.md>), [tott](<https://devfeed.tech/tags/tott.md>)

### AI overview

The article explains how arranging adjacent lines of code to follow data flow can improve readability and reduce cognitive load. It uses sandwich-making examples to show grouping related operations, adding blank lines between code blocks, and handling values reused for logging.

### Source excerpt

This article was adapted from a Google Tech on the Toilet (TotT) episode. You can download a printer-friendly version of this TotT episode and post it in your office. By Sebastian Dörner We often read code linearly, from one line to the next. To make code easier to understand and to reduce cognitive load for your readers, make sure that adjacent lines of code are coherent. One way to achieve this is to order your lines of code to match the data flow inside your method: fun getSandwich( bread: Bread, pasture: Pasture ): Sandwich { // This alternates between milk- // bread-related code. val cow = pasture.getCow() val slicedBread = bread.slice() val milk = cow.getMilk() val toast = toastBread(slicedBread) val cheese = makeCheese(milk) return Sandwich(cheese, toast) } fun getSandwich( bread: Bread, pasture: Pasture ): Sandwich { // Linear flow from cow to milk // to cheese. val cow = pasture.getCow() val milk = cow.getMilk() val cheese = makeCheese(milk) // Linear flow from bread to slicedBread // to toast. val slicedBread = bread.slice() val toast = toastBread(slicedBread) return Sandwich(cheese, toast) } To visually emphasize the grouping of related lines, you can add a blank line between each code block. Often you can further improve readability by extracting a method, e.g., by extracting the first 3 lines of the function on the above right into a getCheese method. However, in some scenarios, extracting a method isn't possible or helpful, e.g., if data is used a second time for logging. If you order the lines to match the data flow, you can still increase code clarity: fun getSandwich(bread: Bread, pasture: Pasture): Sandwich { // Both milk and cheese are used below, so this can't easily be extracted into // a method. val cow = pasture.getCow() val milk = cow.getMilk() reportFatContentToStreamz(cow.age, milk) val cheese = makeCheese(milk) val slicedBread = bread.slice() val toast = toastBread(slicedBread) logWarningIfAnyExpired(bread, toast, milk, cheese) return Sand