oliverdavies.uk/content/node.79ac611e-17a9-4c36-b6cb-0f5c525cd665.json
2025-05-11 20:02:12 +01:00

100 lines
No EOL
4.9 KiB
JSON

{
"uuid": [
{
"value": "79ac611e-17a9-4c36-b6cb-0f5c525cd665"
}
],
"langcode": [
{
"value": "en"
}
],
"type": [
{
"target_id": "daily_email",
"target_type": "node_type",
"target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7"
}
],
"revision_timestamp": [
{
"value": "2025-04-16T14:13:05+00:00"
}
],
"revision_uid": [
{
"target_type": "user",
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
}
],
"revision_log": [],
"status": [
{
"value": true
}
],
"uid": [
{
"target_type": "user",
"target_uuid": "b8966985-d4b2-42a7-a319-2e94ccfbb849"
}
],
"title": [
{
"value": "Writing readable code\n"
}
],
"created": [
{
"value": "2022-12-01T00:00:00+00:00"
}
],
"changed": [
{
"value": "2025-04-16T14:13:05+00:00"
}
],
"promote": [
{
"value": false
}
],
"sticky": [
{
"value": false
}
],
"default_langcode": [
{
"value": true
}
],
"revision_translation_affected": [
{
"value": true
}
],
"path": [
{
"alias": "\/daily\/2022\/12\/01\/writing-readable-code",
"langcode": "en"
}
],
"body": [
{
"value": "\n <p>This week, I needed to investigate and fix a bug within some existing code.<\/p>\n\n<p>It's code written some time ago and not by anyone working on the team.<\/p>\n\n<p>The code wasn't very readable, so before I could fix the bug, I needed to figure out what the code was supposed to be doing.<\/p>\n\n<p>I started to write a list of things that would make the code easier to read and understand - no single-letter variable names, reduced levels of indentation and splitting some nested ternary operators to use separate return statements.<\/p>\n\n<p>I also watched a video of a conference talk titled \"Writing code you won't hate tomorrow\", which re-introduced me to Object Callisthenics.<\/p>\n\n<p>They are from \"The ThoughtWorks Anthology\" book and are some steps that include some of the points that I had written:<\/p>\n\n<ol>\n<li>Use only one level of indentation per method.<\/li>\n<li>Don\u2019t use the else keyword.<\/li>\n<li>Wrap all primitives and strings.<\/li>\n<li>Use only one dot per line.<\/li>\n<li>Don\u2019t abbreviate.<\/li>\n<li>Keep all entities small.<\/li>\n<li>Don\u2019t use any classes with more than two instance variables.<\/li>\n<li>Use first-class collections.<\/li>\n<li>Don\u2019t use any getters\/setters\/properties<\/li>\n<\/ol>\n\n<p>As well as the original book, there are numerous blog posts and videos on this topic.<\/p>\n\n<p>Why try some of them on the next code you write and see if it's easier to read and understand?<\/p>\n\n ",
"format": "full_html",
"processed": "\n <p>This week, I needed to investigate and fix a bug within some existing code.<\/p>\n\n<p>It's code written some time ago and not by anyone working on the team.<\/p>\n\n<p>The code wasn't very readable, so before I could fix the bug, I needed to figure out what the code was supposed to be doing.<\/p>\n\n<p>I started to write a list of things that would make the code easier to read and understand - no single-letter variable names, reduced levels of indentation and splitting some nested ternary operators to use separate return statements.<\/p>\n\n<p>I also watched a video of a conference talk titled \"Writing code you won't hate tomorrow\", which re-introduced me to Object Callisthenics.<\/p>\n\n<p>They are from \"The ThoughtWorks Anthology\" book and are some steps that include some of the points that I had written:<\/p>\n\n<ol>\n<li>Use only one level of indentation per method.<\/li>\n<li>Don\u2019t use the else keyword.<\/li>\n<li>Wrap all primitives and strings.<\/li>\n<li>Use only one dot per line.<\/li>\n<li>Don\u2019t abbreviate.<\/li>\n<li>Keep all entities small.<\/li>\n<li>Don\u2019t use any classes with more than two instance variables.<\/li>\n<li>Use first-class collections.<\/li>\n<li>Don\u2019t use any getters\/setters\/properties<\/li>\n<\/ol>\n\n<p>As well as the original book, there are numerous blog posts and videos on this topic.<\/p>\n\n<p>Why try some of them on the next code you write and see if it's easier to read and understand?<\/p>\n\n ",
"summary": null
}
],
"feeds_item": [
{
"imported": "2025-04-16T14:13:05+00:00",
"guid": null,
"hash": "2753953e3bfd1a1568643626ad56e3cf",
"target_type": "feeds_feed",
"target_uuid": "90c85284-7ca8-4074-9178-97ff8384fe76"
}
]
}