{ "uuid": [ { "value": "4297cfc8-623f-4d32-b353-5a441c2c632f" } ], "langcode": [ { "value": "en" } ], "type": [ { "target_id": "daily_email", "target_type": "node_type", "target_uuid": "8bde1f2f-eef9-4f2d-ae9c-96921f8193d7" } ], "revision_timestamp": [ { "value": "2025-05-11T09:00:51+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-05-11T09:00:51+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

This week, I needed to investigate and fix a bug within some existing code.<\/p>\n\n

It's code written some time ago and not by anyone working on the team.<\/p>\n\n

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

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

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

They are from \"The ThoughtWorks Anthology\" book and are some steps that include some of the points that I had written:<\/p>\n\n

    \n
  1. Use only one level of indentation per method.<\/li>\n
  2. Don\u2019t use the else keyword.<\/li>\n
  3. Wrap all primitives and strings.<\/li>\n
  4. Use only one dot per line.<\/li>\n
  5. Don\u2019t abbreviate.<\/li>\n
  6. Keep all entities small.<\/li>\n
  7. Don\u2019t use any classes with more than two instance variables.<\/li>\n
  8. Use first-class collections.<\/li>\n
  9. Don\u2019t use any getters\/setters\/properties<\/li>\n<\/ol>\n\n

    As well as the original book, there are numerous blog posts and videos on this topic.<\/p>\n\n

    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

    This week, I needed to investigate and fix a bug within some existing code.<\/p>\n\n

    It's code written some time ago and not by anyone working on the team.<\/p>\n\n

    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

    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

    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

    They are from \"The ThoughtWorks Anthology\" book and are some steps that include some of the points that I had written:<\/p>\n\n

      \n
    1. Use only one level of indentation per method.<\/li>\n
    2. Don\u2019t use the else keyword.<\/li>\n
    3. Wrap all primitives and strings.<\/li>\n
    4. Use only one dot per line.<\/li>\n
    5. Don\u2019t abbreviate.<\/li>\n
    6. Keep all entities small.<\/li>\n
    7. Don\u2019t use any classes with more than two instance variables.<\/li>\n
    8. Use first-class collections.<\/li>\n
    9. Don\u2019t use any getters\/setters\/properties<\/li>\n<\/ol>\n\n

      As well as the original book, there are numerous blog posts and videos on this topic.<\/p>\n\n

      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 } ] }