Rename renderLink() method for better DX

Created on 27 September 2013, about 11 years ago
Updated 18 December 2024, 5 days ago

Updated: Comment #0

Problem/Motivation

In a lot of views' field plugins a method renderLink() is used to set up the advanced render options for the views field rendering. As the method does not really render anything, "renderLink" is an inappropriate name.
Motivation: Correct method naming provides better DX.

Proposed resolution

A method name like "buildLink" or "prepareLink" would fit better, as proposed by @damiankloip in IRC.

Remaining tasks

  • Consider core naming conventions (for method naming)

User interface changes

-

API changes

-

Related Issues

-

📌 Task
Status

Active

Version

11.0 🔥

Component

views.module

Created by

🇩🇪Germany derhasi

Live updates comments and jobs are added and updated live.
  • VDC

    Related to the Views in Drupal Core initiative.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇳🇱Netherlands Lendude Amsterdam

    Going through (really) old issues to clean up the queue.

    While I agree renderLink is indeed not great, buildLink still doesn't tell me what this method does, so to me that isn't worth changing this over. To me, the problem is that this method does two things. It updates settings to make sure we are going to be rendering a link and then returns a string to use in the link. So, to me, we should either split this up into two methods or make sure the name represents what it does: setRenderAsLinkAndGetLinkText() which feels very verbose but at least tells you what it does ¯\_(ツ)_/¯

Production build 0.71.5 2024