DEV Community

Cover image for Our way: Naming
Robson TenĂłrio
Robson TenĂłrio

Posted on

Our way: Naming

👉 Go to Summary

There is no wrong or right way, there is our way.

-- Someone

.
.
.

Naming is hard #1

WTF!?


$value = $this->getLoggedUser();

// ... after 50 lines of code you forget what `$value` is.

Enter fullscreen mode Exit fullscreen mode

Nice!

$user = $this->getLoggedUser();

// Ok, got it. It is `$user`
Enter fullscreen mode Exit fullscreen mode

.
.
.

Naming is hard #2

WTF!?

$user1 = User::where('name', 'Mary')->first();
$user2 = User::where('name', 'Joe')->first();

// 50 lines of code here ...

if ($user1->age > $user2->age) {

    // WTF are $user1 and $user2 ?
}


Enter fullscreen mode Exit fullscreen mode

Nice!

$mary = User::where('name', 'Mary')->first();
$joe = User::where('name', 'Joe')->first();

... // 50 lines of code here

if ($mary->age > $joe->age) {

    // Ok, Mary is older than Joe
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)

Qodo Takeover

Introducing Qodo Gen 1.0: Transform Your Workflow with Agentic AI

Rather than just generating snippets, our agents understand your entire project context, can make decisions, use tools, and carry out tasks autonomously.

Read full post

đź‘‹ Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay