Timeline for How to balance 'efficient' vs 'clean' code? [closed]
Current License: CC BY-SA 4.0
21 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 30, 2021 at 10:14 | comment | added | Doc Brown | @S.Robins: in case of reopening, we can also vote for closing with "needs more focus" or "educational advice", if you prefer this. | |
| Jul 30, 2021 at 10:10 | comment | added | S.Robins | @NewCoder18, It's not really a good question in the sense that it doesn't really clarify what you are asking for, which is to understand how to write better code up front. I'll answer the question though: you are trying to run before you can crawl. Even after 30+ years of software development, I still look at old code and realise I could have done something better. If you want to master programming, you practice it constantly, and learn from others, as well as from your own mistakes. You rarely get it right first go, so you test, refactor, and improve incrementally. | |
| Jul 30, 2021 at 9:57 | comment | added | S.Robins | The problem with the question as written, is it's too loosely defined. By what standard is 'efficiency' measured? By which paradigm is the OP programming that is 'familiar'? @DocBrown I see the questions as fundamentally different. The other question asks when to break "the rules". In this case, the OP seeks guidance about whether it's better to just throw any old code together to make something work, or whether to fine tune it from the start. If the question is written in this context, it would be easy to cite several Agile sources as to why it's OK to do anything first, then improve. | |
| Jul 29, 2021 at 19:55 | comment | added | alilland | Whenever I've built anything - you get it working first, even if its slow - then you refactor as you learn more. Write, Refactor, Release is the never ending development cycle. | |
| Jul 29, 2021 at 10:06 | comment | added | gnasher729 | In practice code is often slow because you did something stupid, and not doing the stupid thing is enough to make it fast. | |
| Jul 29, 2021 at 10:05 | comment | added | gnasher729 | If you have written some code, making it easier, more straightforward, less complicated will often tend to make it faster. Unnecessarily complex is often unnecessarily slow. The next step is to extract the unreadable bits into one function with a clean , well defined interface. Keeping 99,9% of your code readable, and 0.1% as fast as possible. | |
| Jul 29, 2021 at 7:47 | comment | added | Doc Brown | I changed the title to make it match the question body. But if the question gets reopened, I would vote to close it as a dupe of this older one: Clean readable code vs fast hard to read code. When to cross the line? | |
| Jul 29, 2021 at 7:46 | review | Reopen votes | |||
| Jul 30, 2021 at 10:10 | |||||
| Jul 29, 2021 at 7:42 | history | edited | Doc Brown | CC BY-SA 4.0 |
Made title meet the question
|
| Jul 29, 2021 at 4:46 | history | closed |
Robert Harvey Greg Burghardt gnat |
Opinion-based | |
| Jul 29, 2021 at 4:00 | vote | accept | NewCoder18 | ||
| Jul 29, 2021 at 0:14 | answer | added | candied_orange | timeline score: 10 | |
| Jul 28, 2021 at 23:17 | review | Close votes | |||
| Jul 29, 2021 at 4:50 | |||||
| Jul 28, 2021 at 23:08 | comment | added | NewCoder18 | That is a great answer, I had not thought of it from a goal-oriented perspective. I have been working to achieve my goals with the software I am creating, but I am unsure at times the way real programmers look at problems or techniques they use. I know I could learn a thing or two from all of you and your experience. Thank you for your view! | |
| Jul 28, 2021 at 23:07 | comment | added | Robert Harvey | So none of us can categorically say that we always strive to produce the most efficient code, because efficiency is not always the most important goal we're trying to achieve. | |
| Jul 28, 2021 at 23:05 | history | edited | NewCoder18 | CC BY-SA 4.0 |
deleted 93 characters in body
|
| Jul 28, 2021 at 23:05 | comment | added | Robert Harvey | There are many goals in software development, some of which compete with each other. You have to decide which goals are the most important to you, and favor those. For example, do you prefer high performance, or code that is the most readable and clear? You can't always have both. Software developers are always under time pressure to produce, and sometimes perfection is sacrificed so that a product can ship. | |
| Jul 28, 2021 at 23:00 | history | edited | NewCoder18 | CC BY-SA 4.0 |
deleted 93 characters in body
|
| Jul 28, 2021 at 22:57 | comment | added | Robert Harvey | "Does it bother you" is not a useful question. It's tantamount to asking "Are you a lazy person who doesn't care about their work?" | |
| Jul 28, 2021 at 22:55 | review | First posts | |||
| Jul 29, 2021 at 0:05 | |||||
| Jul 28, 2021 at 22:51 | history | asked | NewCoder18 | CC BY-SA 4.0 |