Timeline for Trying to follow Single Responsibility Principle with download and show progress
Current License: CC BY-SA 4.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Mar 9, 2022 at 11:18 | vote | accept | CommunityBot | ||
Mar 6, 2022 at 22:00 | comment | added | user197941 | So if i'm to show progress a function won't cut it, i might as well write a download class with a progress event that i can subscribe to which is basically equivalent to passing a callback to a function might be more cleaner that way. | |
Mar 6, 2022 at 21:49 | comment | added | hfontanez | @ZohirSalak this should answer your question or get you REALLY close: usefulangle.com/post/68/javascript-ajax-download-file | |
Mar 6, 2022 at 16:17 | answer | added | hfontanez | timeline score: 2 | |
Mar 6, 2022 at 16:03 | comment | added | hfontanez | You could design the download function to return a file and then call a save file function if you want to. It might be a cleaner solution that way. But, if the general expectation is that every downloaded file must be saved, then you could argue that the implementation does obey SRP. So, in this case, it is a matter of code reusability. If you find yourself copying the same "save" functionality in other parts of the code, then you have a refactoring opportunity. To obey Open/Close principle, typically what I do is to create a new version of a function, so that the legacy code remains intact. | |
Mar 6, 2022 at 14:53 | comment | added | user197941 | @hfontanez Yes i just wasn't sure about it so i decided to ask while i'm at it, thanks for the feedback. | |
Mar 6, 2022 at 14:53 | history | edited | user197941 | CC BY-SA 4.0 |
added 4 characters in body
|
Mar 6, 2022 at 14:41 | comment | added | hfontanez |
Perhaps your understanding of SRP is a little misguided. The first version of downloadFile.js seems fine to me.
|
|
Mar 6, 2022 at 14:05 | comment | added | pacmaninbw♦ |
You have already made most of the observations anyone could make about the code. Please note I did provide an answer as well. I did not down vote the question or vote to close it. Please read the How do I ask a good question? link so your questions are a better fit in the future. How to questions are off-topic on Code Review.
|
|
Mar 6, 2022 at 14:03 | comment | added | user197941 | @pacmaninbw How is this asking to write code ? I've already provided everything and only asking how i can refactor it to maintain a rule of clean code while having the same functionality. If this isn't what Code Review Community is about, Could you point me to which of the stackexchange communities that are appropriate for such question. | |
Mar 6, 2022 at 13:55 | comment | added | pacmaninbw♦ | Welcome to the Code Review Community. While your concerns about the code are valid, our goal here is to help you improve your coding skills by providing insightful observations about working code from your projects. We don't help write the code. Please read Where can I get help? and How do I ask a good question?. | |
Mar 6, 2022 at 5:53 | history | edited | 200_success |
edited tags
|
|
S Mar 6, 2022 at 0:39 | review | First questions | |||
Mar 6, 2022 at 13:56 | |||||
S Mar 6, 2022 at 0:39 | history | asked | user197941 | CC BY-SA 4.0 |