Why every developer should read Plato

88
Why every developer should read Plato

Transcript of Why every developer should read Plato

Why every developer should read Plato

@OmarReissCTO at Yoast

Philosopher

Developer

Platomar

26%

What makes WordPress a superhero?

WordPress makes users awesome!Source: useronboard.com

What makes WordPress a superhero?

How does WordPress turn users into superheroes?

We can build almost anything using WordPress

47,260 plugins

You can write a WordPress plugin with 0 lines of code.

What makes WordPress so easy to plugin to?

Filters! (and actions)

APIadd_filter

remove_filter

apply_filters

Filters

A filter is a function

A filter is a function

Timing

The plugins are loaded

WordPress is initialised

The head is rendered

The content is rendered

After

After

do_action(‘plugins_loaded’)

do_action(‘init’)

do_action(‘wp_head’)

apply_filters(‘the content’)

Before

Before

What should we use filters for?

“As a site owner, I want Yoast SEO to use the excerpt as a meta description.”

Usecase

“As a custom fields plugin builder, I want Yoast SEO to use a custom field as a meta description.”

Usecase

“As a {ROLE}, I want Yoast SEO to use {FIELD} as a meta description.”

Usecase

How does this translate to WordPress?

“As a {ROLE}, I want to be able to filter the meta description that Yoast SEO outputs.”

Usecase

Example

Example

What is a meta description?

Filter the output

Filter the data

Filtering the output

Filtering the data

Data typesString -> “hello”

Integer -> 123

Array -> [$a, $b, $c]

etc.

What is data?

Is “<html><body>Hello world</body></html>” a string?

V = f( M )

View = function( Model )

Filter data, not representation

Filter the data

Filtering the data

Can I safely filter data?

Type juggling

#YOLO

Notice: Array to string conversion…

Type checking madness

Never trust filtered data

Because #YOLO

Hey! But wasn’t this supposed to be easy?

And what does this have to do with Plato?

- Maieutike

- Irony

- Anamnesis

26%

What makes WordPress a superhero?

WordPress makes users awesome!Source: useronboard.com

What makes WordPress a superhero?

How does WordPress turn users into superheroes?

We can build almost anything using WordPress

47,260 plugins

You can write a WordPress plugin with 0 lines of code.

What makes WordPress so easy to plugin to?

Filters! (and actions)

APIadd_filter

remove_filter

apply_filters

Filters

A filter is a function

What is a filter?

A filter is a function

Timing

The plugins are loaded

WordPress is initialised

The head is rendered

The content is rendered

After

After

do_action(‘plugins_loaded’)

do_action(‘init’)

do_action(‘wp_head’)

apply_filters(‘the content’)

Before

Before

What should we use filters for?

“As a site owner, I want Yoast SEO to use the excerpt as a meta description.”

Usecase

“As a custom fields plugin builder, I want Yoast SEO to use a custom field as a meta description.”

Usecase

“As a {ROLE}, I want Yoast SEO to use {FIELD} as a meta description.”

Usecase

How does this translate to WordPress?

“As a {ROLE}, I want to be able to filter the meta description that Yoast SEO outputs.”

Usecase

Example

Example

What is a meta description?

Filter the output

Filter the data

Filtering the output

Filtering the data

Data typesString -> “hello”

Integer -> 123

Array -> [$a, $b, $c]

etc.

What is data?

Is “<html><body>Hello world</body></html>” a string?

V = f( M )

View = function( Model )

Filter data, not representation

Filter the data

Filtering the data

Can I safely filter data?

Type juggling

#YOLO

Notice: Array to string conversion…

Type checking madness

Never trust filtered data

Because #YOLO

But wasn’t this supposed to be easy?

Issues with filtersIn WordPress it’s hard to distinguish representation from raw data, because of reasons.

In WordPress it’s not possible to trust filtered data, because of reasons.

In WordPress it’s not possible to know when a filter was applied, because of reasons.

Conclusion

And what does this have to do with Plato?

Why every developer should read Plato

Plato working on his art

To learn about Socrates

To learn about Plato

To practice inquiry

Thank you!

@OmarReiss