Ask coding questions

← Back to all posts
Which of these code styles looks better / is more common?
h
SixBeeps (5629)

Howdy.

I'm making a vector library for myself that currently looks something like this:

But since I've been using it, I'm tempted to make a few changes that will leave the code looking like this:

Does this transition make any sense? I kinda like what I have right now, but wouldn't mind making these changes if it makes more sense.

Comments
hotnewtop
ch1ck3n (2882)

screw everyone else's opinion

#2 gang

Highwayman (1537)

I agree that vec1.dot() looks nicer, but I fell like..- static operations like number two seems like it more closely adheres to...like...gah- best practices? maintainability? like not depending on inner workings? 🤷‍♂️ something??

I'm...gonna stop talking now.

Coder100 (19280)

personally i like number 1 because it is more mathematically correct, but you could probably use operator overloads instead

ez: