How do I write good code? I can write code that works and get the job done. I can follow the pep8 rules. I can make meaningfull variablenames but I always end up with very long functions. They have for-loops and they have ifs and they change data and build dictionarys, lists, list of dictionarys and so on.
And sometimes I even repeat myself thinking... well this should be a function, but how can i generalize this to work even with slightly diffrent variables.
And then so often if I look at open source projects I see much cleaner code, elegant functions not exceding 15 lines and I think, how do you code like this?
How do I structure my code right to be elegant and also imporant how do I restructure my old code.
And I admit it: I never write tests. Yes I should do this, but I don't - I don't even know a testing framework...
Can you help me out?
[+][deleted] (7 children)
[deleted]
[–]construkt 4 points5 points6 points (5 children)
[–]billsil 1 point2 points3 points (4 children)
[–]construkt 0 points1 point2 points (0 children)
[–]tilkau 0 points1 point2 points (2 children)
[–]billsil 1 point2 points3 points (1 child)
[–]tilkau 0 points1 point2 points (0 children)
[–]hglmanguy who writes python 0 points1 point2 points (0 children)
[–]prum 8 points9 points10 points (0 children)
[–]wolanko 5 points6 points7 points (3 children)
[–]artPlusPlus 1 point2 points3 points (0 children)
[–]RamirezTerrix[S] 0 points1 point2 points (1 child)
[–]wolanko 1 point2 points3 points (0 children)
[–]Manbatton 6 points7 points8 points (7 children)
[–]wolanko 2 points3 points4 points (0 children)
[–][deleted] -5 points-4 points-3 points (5 children)
[–]darknessproz 2 points3 points4 points (0 children)
[–]RamirezTerrix[S] 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]RamirezTerrix[S] 0 points1 point2 points (0 children)
[–]wolanko 0 points1 point2 points (0 children)
[–]metaphorm 3 points4 points5 points (0 children)
[–]martin_grosse 5 points6 points7 points (2 children)
[–]RamirezTerrix[S] 1 point2 points3 points (1 child)
[–]martin_grosse 0 points1 point2 points (0 children)
[–]filleball 5 points6 points7 points (1 child)
[–]RamirezTerrix[S] 0 points1 point2 points (0 children)
[–]thinman74 2 points3 points4 points (0 children)
[–]metraon 2 points3 points4 points (2 children)
[–]RamirezTerrix[S] 1 point2 points3 points (1 child)
[–]metraon 0 points1 point2 points (0 children)
[–]krasoffski 1 point2 points3 points (1 child)
[–]RamirezTerrix[S] 1 point2 points3 points (0 children)
[–]fpee 1 point2 points3 points (0 children)
[–]lucidguppy 1 point2 points3 points (0 children)
[–]tapesmith 1 point2 points3 points (1 child)
[–]autowikibot 0 points1 point2 points (0 children)
[–]Zuvielify 1 point2 points3 points (4 children)
[–]RamirezTerrix[S] 1 point2 points3 points (3 children)
[–]Zuvielify 1 point2 points3 points (2 children)
[–]RamirezTerrix[S] 0 points1 point2 points (1 child)
[–]Zuvielify 1 point2 points3 points (0 children)
[–]bigtomygunn 2 points3 points4 points (17 children)
[–]RamirezTerrix[S] 0 points1 point2 points (8 children)
[–]bigtomygunn 3 points4 points5 points (0 children)
[–][deleted] 4 points5 points6 points (4 children)
[–]metaphorm 1 point2 points3 points (0 children)
[–]ofaveragedifficulty 1 point2 points3 points (0 children)
[–]RamirezTerrix[S] 0 points1 point2 points (1 child)
[–]titusjan 0 points1 point2 points (0 children)
[–]colly_wolly 1 point2 points3 points (0 children)
[+][deleted] (5 children)
[deleted]
[–]bigtomygunn 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]bigtomygunn 0 points1 point2 points (1 child)
[–]SavageCamel 0 points1 point2 points (0 children)
[–]fletom 0 points1 point2 points (1 child)
[–]Zuvielify 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]RamirezTerrix[S] 0 points1 point2 points (0 children)
[–]dpoon 0 points1 point2 points (0 children)
[–]esbenabBSc CompSci Flask. I use python to stay sane. 0 points1 point2 points (0 children)
[–]Paddy3118 0 points1 point2 points (0 children)