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
-
Awlex177457yHad to couple it like this, because otherwise, it would not be that performant.
I think I have to rethink some aspects anyway. I just realized, I messed up -
sinisas3237yWhy not just adding a comment block above function name, that lists what it does, and just use simple name?
-
// getRefreshedPath gets required paths and clears all other files.
fun getRefreshedPaths() {
getSongPath();
getBackgroundPath();
cleanUp();
} -
Depends on how big your system is? In future if you can have more things to clean up, e.g song lyricist, composer, lyricist info path and related paths with lyrics and some other paths, you will know where to go. Keeping everything in main may be a good idea if you don't have to maintain/modify the code much.
-
If it is performant to do everything in one step, how about a holder class with an initialisation methode that is gathering all the things needed and two other methods to get them in the format you want to (deleting other files is not needed because it is done in initialisation).
On this way you even could add new things and types for file handling very easily in the future. -
This clearly violates SRP. Like others said split it up in more functions. It'll be easier to name those functions and I'll bet you can make them perform good too if you take some time for proper design.
-
Just do as my colleagues do.
Name it Gablork();
And make sure you delete all comments. -
xalez19377yhow about theDescriptiveNameWasTooLongSoPleaseCheckTheCodeToUnderstandWhatTheFunctionDoes()?
-
Awlex177457yAfter getting so much constructive criticism I ended up with this:
getSong(file, [fileText])
getBackground(file, [fileText])
deleteFiles(folder, preserveList)
getPairedSongsAndBackgrounds(folder)
The last function exists, because one song and one background path are written inside the same (immutable) file and should be grouped.
Also the same song can have multiple backgrounds, so I needed a function that returned a 1:n mapping between them.
getSong and getBackground get the file as parameter because the paths are written relatively to the file. The optional parameter fileText exists to avoid reading the file multiple times.
Thank you!
Related Rants
-
makwayne30So, this random teen on subway asked me if it was 9GAG I was scrolling [i was on this app ofc]. I said it's be...
-
Anu-cool-00714*listens to music using Samsung earphones* Person next to me: Nice song Neighbor: Nice song Aliens: Nice song
-
linuxxx30A client asked if we could change their nameservers to wix's ones. "we want to move to wix because one of my...
Toughest about this function was (obviously) naming.
Suggestions are (highly) appreciated
undefined
¯\_(ツ)_/¯
send help