# Blending data and logic

(two-different-programming-styles)=
## Two different programming styles
<!--separation of data and program logic (control flow)-->

Imagine you want to write an application that checks if the entered food is one of the following vegetables or not:
- carrot
- beetroot
- cabbage
::::{grid} 2
:::{grid-item-card} Take 1
```cs
Console.Write(
    """
    I can help you with your diet.
    Enter the food: 
    """);
var line = Console.ReadLine();

if (line == "carrot"
    || line == "beetroot"
    || line == "cabbage")
    Console.WriteLine("✅ this is a vegetable.");
else
    Console.WriteLine("❌ I don't know what this is.");
```
:::

:::{grid-item-card} Take 2
```cs
const string WelcomeMessage =
    """
    I can help you with your diet.
    Enter the food: 
    """;
const string YesMessage = "✅ this is a vegetable.";
const string NoMessage = "❌ I don't know what this is.";
string[] knownVegetables =
[
    "carrot",
    "beetroot",
    "cabbage"
];

Console.Write(WelcomeMessage);
var line = Console.ReadLine();

if (knownVegetables.Contains(line))
    Console.WriteLine(YesMessage);
else
    Console.WriteLine(NoMessage);
```
:::
::::

- `string[]` means a collection of many `string`s. We will introduce this.

:::{activity}
:label: data-logic-separation
1. Which differences do you notice regarding:
   - readability
   - structure, e.g., where which components of code is located
1. How could this difference affect the programming experience?

Steps:
1. 1 min think individually.
1. 4 min discuss with your partner.
:::