{ "uuid": [ { "value": "9d63cfe9-dd20-4e58-955f-bd42a5026c8a" } ], "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:00+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": "Don't repeat yourself" } ], "created": [ { "value": "2025-03-26T00:00:00+00:00" } ], "changed": [ { "value": "2025-05-11T09:00:00+00:00" } ], "promote": [ { "value": false } ], "sticky": [ { "value": false } ], "default_langcode": [ { "value": true } ], "revision_translation_affected": [ { "value": true } ], "path": [ { "alias": "\/daily\/2025\/03\/26\/repeat", "langcode": "en" } ], "body": [ { "value": "\n

When most people think of \"Don't repeat yourself\" or DRY, they probably think about not duplicating logic in code.<\/p>\n\n

If you've written some functionality once, you should avoid writing it again.<\/p>\n\n

I was recently browsing the code for an open source package and saw this:<\/p>\n\n

\/**\n * Flush everything.\n *\/\npublic function flush(): void;\n\n\/**\n * Sets the formatter.\n *\/\npublic function setFormatter(FormatterInterface $formatter): void;\n\n\/**\n * Gets the formatter.\n *\/\npublic function getFormatter(): FormatterInterface;\n<\/code><\/pre>\n\n

This is another instance of repetition.<\/p>\n\n

The docblocks are just repeating what the code already tells me.<\/p>\n\n

I can understand from the method names what each function does, and I can see what parameters they have and their types.<\/p>\n\n

I can see if each method returns anything and, if so, what type it returns - e.g. getFormatter<\/code> returns a FormatterInterface<\/code>.<\/p>\n\n

I think these docblocks aren't needed and in my projects, would suggest they be removed.<\/p>\n\n

Unless they're adding more information, such as PHPStan PHPDoc types<\/a>, there's no need to repeat what the code already says.<\/p>\n\n ", "format": "full_html", "processed": "\n

When most people think of \"Don't repeat yourself\" or DRY, they probably think about not duplicating logic in code.<\/p>\n\n

If you've written some functionality once, you should avoid writing it again.<\/p>\n\n

I was recently browsing the code for an open source package and saw this:<\/p>\n\n

\/**\n * Flush everything.\n *\/\npublic function flush(): void;\n\n\/**\n * Sets the formatter.\n *\/\npublic function setFormatter(FormatterInterface $formatter): void;\n\n\/**\n * Gets the formatter.\n *\/\npublic function getFormatter(): FormatterInterface;\n<\/code><\/pre>\n\n

This is another instance of repetition.<\/p>\n\n

The docblocks are just repeating what the code already tells me.<\/p>\n\n

I can understand from the method names what each function does, and I can see what parameters they have and their types.<\/p>\n\n

I can see if each method returns anything and, if so, what type it returns - e.g. getFormatter<\/code> returns a FormatterInterface<\/code>.<\/p>\n\n

I think these docblocks aren't needed and in my projects, would suggest they be removed.<\/p>\n\n

Unless they're adding more information, such as PHPStan PHPDoc types<\/a>, there's no need to repeat what the code already says.<\/p>\n\n ", "summary": null } ] }