Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
iAmNaN71317yWrite elegant code that is both easy to understand, and is optimized and efficient. They are not mutually exclusive.
-
Depends on what you're writing.
A trading platform needs to go for as efficient code as possible, no matter how ugly it looks.
A report builder needs to be more maintainable, and a tiny bit of extra processing time is worth it for the ease of changing a report later. -
Kyliroth2307yKeep it clear until you hit a bottleneck: Then optimise it if needs be.
But clear code can still be optimal. Don't assume that if it's easy to read that it's slow.. -
plumbus11947yWrite the simple code. Time it, profile it. Optimize if slow. Complexity can be worth it but i like to prove its worth it.
Usually i stop at "write the simple code" because when i dont and a bug appears, i have to write the simple code again anyway to figure out what i did wrong. -
iAmNaN71317y@Fiftyseven welcome to devRant! Have your first ++. It is Very possible to write elegant, efficient code. Anything else is just being sloppy. 😉
-
First write clear and simple code. It's simpler to test it with unit tests.
Then optimize it till you can still read it.
If it is a must to be efficient more than readable and extensible, then write documentation. Really really good.
Hypothetical Question:
Write a complex code to make it efficient Or
Write a simple code so that the next developer who works on it understands the code easily.
undefined
#hypothetical
#lost