# Good taste coding These days, we have lots of frameworks, libraries and languages and everybody can code, but not everybody has a taste for it. Just look on Stack Overflow and you can see a huge amount of really bad code.

The worst thing is that sometimes coders think they are professional software engineers, when in fact, they just copy paste bad code into their projects making the code base utterly difficult to maintain. The concept of good taste code is not something I invented. I heard the term from Linus at his TED talk at 14:24. I don’t even think that we can establish precisely what is good taste, but we definitely can tell what’s bad. For me, it’s bad to write incorrect, unmaintainable, redundant, slow code. Exactly in this order.

For example, below is an algorithm to initialize the points along the edge of a grid, which is represented as a multidimensional array: grid[GRID_SIZE][GRID_SIZE].

```for (i = 0; i < GRID_SIZE; ++i) {
for (j = 0; j < GRID_SIZE; ++j) {
// top edge
if (i == 0) {
grid[i][j] = 0;
}

// left edge
if (j == 0) {
grid[i][j] = 0;
}

// right edge
if (j == GRID_SIZE - 1) {
grid[i][j] = 0;
}

// bottom edge
if (i == GRID_SIZE - 1) {
grid[i][j] = 0;
}
}
}
```

The bad things about this code are the two loops and the if statements. It is bad taste code not because it’s incorrect, but because it has a lot of unnecessary conditionals and loops. We can rewrite the code as follows:

```for (i = 0; i < GRID_SIZE; ++i) {
// top edge
grid[i] = 0;

// bottom edge
grid[GRID_SIZE - 1][i] = 0;

// left edge
grid[i] = 0;

// right edge
grid[i][GRID_SIZE - 1] = 0;
}
```

You see? The code is faster, we don’t have conditionals, it is easier to read and to maintain, but the code requires a little bit more thinking ahead before writing it.  Let’s take another example:

```ArrayList<String> arrayList = new ArrayList<String>();
```return Arrays.asList("weekly", "monthly", "yearly")