Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Get a devDuck
Rubber duck debugging has never been so cute! Get your favorite coding language devDuckBuy Now
Search - "refactor"
- Sleep 7h+ each night (you think you don't need it - but you do!)
- drink NO coffee (you've slept enough!)
- pair-up (you're not as good as you think)
- get a grasp on the problem (it's time will spent!)
- communicate constantly (you're not alonw especially)
- refactor just as much
- learn from you partner
- celebrate even small accomplishments (you need success!)
- go home and do something else (your pet project does not need more than 5hrs per week!)
- repeat (because repetition makes perfection!)20
Immortalised this actual legacy code for our Senior Devs leaving present (we all inherited this) with his last task being to refactor it, may he never have to work with code like this again.14
Senior: Why did you refactor those ten files?
Junior: There was a method copy-pasted in every one of them, so I moved it to a utils class.
Senior: Don't you know we will have to test all of those changed classes again? Please, rollback!
... two days later ...
Senior: Why did you just copy-paste that method? Don't you know it's bad practice?10
Dev: boss, there are some abnormalities and confusion in the client's specifications.
Dev: Shouldn't we get clear about them and then start coding?
Boss: No need. We assume and code. Then show them to our clients and then ask for their opinions. We will change again according to their opinion.
A few months later....
Dev: *seeing so many specifications change and realizing now have to refactor a lot of codes* , FML.16
After finishing up 70% of a feature,
Brain: "there's a better way to do it"
Me: "ok ill just change a bit of code here and there.."
-- 2 hours later --
swimming in spaghetti code..7
Boss: please refactor this js 2k lines spaghetti code class and use it in our reactive functional app
Me: it will take like 1 week to refactor and plug this
Boss: but it's almost the time I needed to write it!
YOU DON'T SAY? MAYBE FIRST LEARN HOW TO WRITE DECENT CODE. ffs.2
Day 2 of refactoring the mess my "senior" ex colleague left behind completed.
So far removed 3837 lines of code (from 17468 total).
Removed around 230 unused/duplicated assets.
Cut down the total apk size from 214mb to 163mb.
On average frames render about 3ms faster.
Fixed 2 "unfixable" bugs he'd ignored for over half a year.
And the code is actually becoming readable, and far from done yet.
It feels so good to not be obstructed anymore by an ignorant "senior" dev7
"Can you work on this ticket? It's kind of urgent."
"And could you please not refactor? Just get this done."
-- "Why? What's the issue?"
"The logic is complex. We should not break it."
-- "Erm, that's what the tests are for. So yes, if the need arises, I'll refactor. The tests are my guidelines if the logic breaks or not."
There's a reason we create tests. So let's not hinder code base improvements by some random fear that stuff might break.
If breaks due to refactoring, we'll fix it by adding a valid test case during and then fixing the bug.
If my refactoring does not break the tests, I'll assume the code base is stable.
If your code is untested, then we have a complete different problem.3
The moment when you reopen a project from 4 months ago and you can't believe that you wrote that code1
This is a fucking mess!!!
File > New Project
Yeah, fuck it. It'd be easier to just start over.9
Do NOT build something as fast as possible. You are going to end up spending more time trying to refactor the mess than youd have spent drawing a class diagram.7
Just spent the whole day rewriting a 5,000 line function with variables like num55 or num287. These variables constantly get re-used for different purposes and overwritten at will.
Everything is now broken. Including my spirit.5
Boss: ehi I was checking out our latest product (made in vuejs) it's blazing fast and responsive.
Me : shiny eyes "... Can I refactor our biggest project from angular 1.5 to vuejs?"
Boss: "mmh what can you save from the old code base? "
Me: "mmh.. A lot.. Mmh like.. The CSS!"
Boss : "no"
Boss: Have you finished that feature?
Me: Almost there, i'm refactoring some classes...
Boss: What? Refactor? But thisnis a new feature, it does not need refactor! We don't have time for this!
This is what happen when you care about code quality.5
Me (refactoring bosses code):
Is this worth it?
let me work it...
I'll put this thing down, flip it, and reverse it
did you just Missy Eliot my code?
Ti esrever dna ti pilf nwod gniht ym tup I1
Ok so the good news is. My vacation is in 2 weeks. And also just got Hired, and handed a big project with big money
The bad news is They need to refactor and document their legacy code from last dev partner. And this is the commit history
OH MY FUCKING GOD KILL ME NOW!19
So, should I refactor this into a .greatGreatGrandParent() method, or should I just go hang myself?
(Thanks former colleague for this gem)10
1. Refactor shitty code because it is hard to maintain
2. Rant about how can someone write a code like that
3. Check commit log to see who is the person to blame
4. Found out that's me2
Just got a merge request to review. It's TERRIBLE
- 93 changes
- 23 commits
- includes multiple features
- includes new project configs
- includes refactoring
NO. Please don't do that.
Do smaller commits. One feature per MR. It will help you and the reviewer :D6
That feeling when you refactor that spaghetti mess into clean beautiful code that passes all tests flawlessly4
I was given a work to refactor one of my colleagues code and found that there was a variable named 'anal'. I was quite surprised seeing it as the colleague was a soft spoken and well behaved guy in office. After scratching my head for 15mins I came to know that he was storing analytics data in that variable. Hence the name! :-D9
One big file with a lot of variables in the window scope.
Because she was in “charge” of the frontenders because she works there a bit longer then me I never checked the frontend code.
I said I wont/cant help unless I see better code. I explained to a trainee what could be done to change it and Im impressed that the trainee did a better job then the employee and quick as well.
Got the whole code in seperate files with each part of the code in seperate scopes within 2 hours.
What Im saying here is that even as student, intern or trainee you can know things better thsn someone with experience, dont be afraid to speak up. Because everyone can learn from eachother.7
Me : *wants to refactor a variable*
Visual Studio : Ok! Type the new name of the variable
Me : *backspace one time to remove a char*
VS : *erases ALL the name of the variable and ALL the usages of the variable, and no possibility to undo*
Me : ..... that was a dick move you know.10
I finally ended my first side project ever. I challenged myself to write a Tetris game in vanilla JS (with the less possible lines of code), some algorithm was tougher than I expected (2d array hell) but I made it ! 500 lines of JS code, I feel I could refactor some stuffs now...4
This is why development with Node.Js is tiresome...
The story is always the same. After several weeks, you finally understand that new fancy concept and you enjoy it...
Only to find that 8 month from now, it is going to be deprecated...
You need to refactor your code for the sake of future generations. Otherwise, your code will looks like a pathetic dying dinosaur...9
You refactor after there's code. You can't have clean code if there isn't code to be cleaned to begin with. Code first. Think of perfection later.5
Just spent 10+ hours refactoring a code, and at the end I've figure it out a one line fix to the problem... just wasted 10 hours of my life.. :)8
manager: Just create that new feature real quick... We'll refactor and make it a good feature in a couple months...
me: *see image*2
I always wonder why people complain about php being horrible, then I actually see the code they write.
It's like complaining "I can't believe I have to use such a horrible desk" when it's littered with empty coffee cups and yesterday's lunch.4
It definitely helps to not be proud, especially to talk to people.
I was about to refactor something someone did, without understanding their intentions and because I thought it was incorrect.
Thank God I got off my high horse to talk to them first!
If you are shy or bad at approaching people (like me), just force yourself and try.. You will eventually learn to be less hesitant.1
# ok since we are removing master/slave
# terminology, let's refactor our code to this
# jesus.py formerly master_machine.py
# formerly slave-machine.py
from jesus import owned_hashtable as the_word
from follower import listener as you
# let's see if this still piss them off.4
Boss: Can you refactor some of the code [dev who recently quit] wrote? Y'know, improve the readability a little bit.
Me: Sure thing. *opens project*
Project: *has 76 variables named var2 through var78*11
a little confession: i've rarely used test suites in my projects (due to laziness and lack of time).
i've started a new project and now i HAD to write tests in order to make my PM happy.
Then i had to refactor a lot of code.
IT WAS SO EASY WITH TESTS.
I WAS A FOOL.
STUPID PAST ME, STUPID!6
You know you learned a lot in the last year when you try to change something on a website you made 1 year ago and it is almost impossible.
The code is not well structured. PHP mixed with HTML, functions that should be organized as a class etc.
I really, really, need to refactor the entire site!4
Chrome is making me refactor my js every once in a while!
She comes up with new ways to show me my errors4
At my current project we use SVN, but today I noticed a colleague of mine uses another version of version control as well.
Every singletime Ive to remove 40 lines of comments before Im able to follow the code and refactor it.3
Boss: -We're firing one of our freelancers and you are taking over one of his projects.
Me: -OK, what is it?
Boss: Old POS project written in Java.
Me: -But I'm C# developer. I haven't touched Java in years!
Boss: -You'll manage...
FML I've managed to finish and fully refactor this piece of shit project.13
gotta love them comments:
#TODO: move this,
#TODO: fix this,
#TODO: DON'T DO THIS,
#TODO: CHANGE THIS
I shit you not8
1. Identify the problem
2. Come up with a clever solution
3. Refactor half of your code
4. Watch it fail horribly because you're such an idiot it's a bloody miracle you keep breathing on your own
1. If you dont know, say: Let me check that and get back to you.
2. ALWAYS use legit test-data and test-images.
3. Never argue ten minutes about something you can fix in ten minutes.
4. Fuck blame or glory. Just refactor and commit and feel proud about youself.1
You spend months coding an app, you refactor and restructure multiple times, you apply all sorts of smart patterns and algorithms you learned over all those years, you go back to the books even, you spend money on a ton of assets, localization, marketing, you spend time contacting hundreds of people that could boost your app in the ocean of apps. And once your app hits the store, people complain that $0.99 is too much.6
Programmer: We really have to refactor the codebase!
Director: That's not important. Do you think our customer would care what it looks like under the hood if we are selling cars?
One year after...
VP: We need to build a new platform for flexibility!
Director: Let's rewrite!1
I once made a .less files of 400 lines and today I redid it completely,
The file is now only 40 lines long and readable again1
Has anyone used PHP unit with Selenium before?
I have a.. well words can’t explain it nice enough but, beyond a joke, not even funny, spaghetti code base I’ve come to inherit recently, which god help me, doesn’t follow any design patterns at all, it’s just a stamp this here, staple this down over here and throw paint at the wall and hope it sticks.
It’s a mixture of procedural and functional with the rare class kind of mess.
So attempting to refactor by any means is not a real possibility without some kind of behavioural testing in place first otherwise I know I’m going to end up breaking something somewhere and not even know it.
Also if anyone has had the privilege of such code bases, tips to dealing with the mess are appreciated.
Oh and no, I can’t rm -rf or start again.😭5
When you look at a layout and consider the hour it will take to refactor and clean stuff out to remove built functionality.
Nah fuck it - display: none !important;2
I think I have a programming disease: Premature refactoring. Sometimes I refactor the refactor that I'm doing.1
What do you do when another dev overwrites/changes your working code without telling you, only because s/he cannot understand how your code works?
And your code was working fine, mind you, no bugs or anything, and is following recommended guidelines/standards. It's just that this other dev has a different coding style and prefers to rewrite everything his/her way even if it means breaking up otherwise sound logic.7
I spent 4 hours finding a good way to instanciate golang structures. Came up with a function that returned a value or pointer and I just kept reusing the nomenclature for an entire project. Then my buddy looks over and goes, "Ethan, you're a f****** idiot", and shows me the standard nomenclature. Now I have to refactor my entire project. FML.
When your brain comes up with "You can refactor this later,too!" Slap yourself in the face as hard as you can1
Figuring out where to put my devRant stickers is like picking variable names.
Except you can't refactor stickers...
So hello guys, I just published my first article, it might not be that good or good at all, but heck it feels great.
Anyway, see ya :p3
Blood, sweat and tears went into this because I wrote my code extremely bad so it became a huge clutter.
Will refactor some day, but I'm happy with the result!11
When your pm forces you to push new features out too quickly and you're slowly digging yourself into a messy hell, knowing you have to one day refactor thousands of lines of code.5
My coworker "fixed" a bug. Then an issue was reported to me. He refactored something that we both used(And my code was already working right). I asked him about it. He didn't care about it and also was upset about my question. A question that I didn't ask in a "rude" way.. The worst: the refactor only required 30 seconds to do!!!
Please guys if you refactor do it right or don't do it at all. Have a nice day9
Me and my team has been creating React components for the last two months. Today we realized that not a single component is done the Redux way (as pure functions), which means we have to refactor every component and the tests.
That's what you get for trying out new technology..3
React developers, What do you think about the new hooks api?
Will you refactor your codebases to use functional components or just stick with classes (even though the react community is moving towards removing classes completely)?
I think its awesome as it reduces the bundle sizes if you use function components though. I have been working on an awesome project for a while and I'm being tempted to refactor the whole codebase to use functions instead of classes. What do you think?22
To refactor code into a state much worse than when you started. It is often accompanied by files containing many lines of code, usually with an obscene amount of nesting.4
Just spent the entire day of which should have been the start of vacation fighting off a second wave of ransomware on one of our production servers. Gandcrab 5.2 anyone?
Turns out an exploit in our MySQL daemon allowed some fucking Chinese hackermonkey to upload a trojan and remote execute it. Thousands of angry customers, me the only one available and able to fix shit and patch up firewalls and system.
And now I get the pleasure of working on what I should have been doing today, another fire that MUST be put out today.
Fuck you deadlines. Fuck you Chinese hackers. In fact, FML.3
started converting VB code to JS.
* lets refactor it when we are on it *
After 3 hours, with refactored code not working, uses the old logic.3
1. Plans to reactor some code
2. Formats SQL nicely
3. Entire software stops working
4. After almost an hour finds string.replace() called on the SQL query matching exactly one space
First rant (well, first on devRant anyway)! So, I'm working on a project to refactor a decade old codebase so that all references to ip addresses are in config. It sucks. But I did find an ascii art fish in an old cron script, so that's something.9
I have a lab at uni where my lab group have to refactor some code from an open source project. We got assigned some Apache project and jfc that code is a mess. Little to no documentation, hard to navigate, tests that you have no idea what it's testing, and so on. On top of that the teacher expects us to spend more time than we have on it. I'll be glad when this course is over :))5
Today we'll refactor the API.
Tomorrow we'll celebrate.
My Future Self need never know how bad it once was.
That feeling when you've done a major refactor on you project and it's going to run for the first time... Then you hope it will have no problems/bugs/crashs but you already know it will1
when you're at a job interview, the interviewer shows you some code to give you a taste and the first thing that comes to mind is, "how long is it gonna take to refactor and is it worth it..."
then proceeds on to show a database diagram and its an unholy cluttered spaghetti soup that even a purple octopus would feel a cold shiver from..
then the interviewer mentions the previous dev left suddenly and the deadline is very soon(TM?)..3
Quick backstory. I've negotiated with our customers to drop IE11 support (happiest day of my life) and decided to also refactor and update our webpack configuration. I asked a bunch of questions about a few exclusions we had for JS processing and received a reply of: I don't know if we need these anymore. Queue a snippet of my response in a meme format on how I wish to proceed with the change done by our tech lead.
osu-web devs: we use PHP because it just works *stabs in vagrant*
My webdev friend + my crazy ASP.NET Friend: hold my beer
*proceeds to refactor everything to ASP.NET and stabs in Docker*
welp, thats enough social interaction for today
New dev hired to assist me told the boss that he was going to refactor the code to improve stability.
He converted all my fragments into activities. Because he didn't understand working with the back stack. Now everyone is asking me what happened.3
Typical code life?
1. Write rough comments
2. Write more detailed comments
3. Write pseudo code
4. Write semi-working but definitely ugly code
5. Write working but very ugly code
6. Refactor the code to be nicer, check for patterns, bottlenecks and other bits and pieces
7. Push to git the "final" code
8. After few months blame whoever wrote the code
9. Refactor all the things!
This happened in my career more than once and still - it seems like the best option out there to get things done. What do you guys think? Should something be added/removed from this? Is this over-complicated or what?2
I was looking at some poorly written code today in a project and I was curious to see who wrote it. I blamed it and found I had wrote it 6 months ago! smh Well... at least I know I'm getting better! I ended up refactoring it to use better code patterns.2
Typescript seems like such overkill, but then you need to refactor your code and hit a bunch of issues in production. I don't think I'll ever go without typescript again. Fuck dynamic typing, it doesn't scale8
I just found a 980 line long method in one of our legacy code bases.... And I need to add to it. There are no unit tests and I desperately want to refactor that shit....4
That feeling when you saw your code and says "I can certainly code better". Took the day to refactor and felt satisfied with the code now. I feel awesome muahahah
Small refactor. Which resulted in the confident removal of a comment that said:
// will this fail?
Ah. Like a breath of fresh air.
"'This is just a temporary fix, I'll refactor it into something great and modular later" thought I as I continued to sin for the umpteenth time.
Recently, I had to make a minor modification to some Node.js code a coworker wrote a year ago which buffers stringified JSON into Kinesis. I just needed to add a new key to the input object, it took minutes to make the change, but hours to make sense out the absolute trash spaghetti code this guy wrote. After spending half a day trying to make his code readable, I just got so pissed off. I replaced his 15 files/+1,500 lines of uncommented code, filled with classes, factory functions, poorly named functions and vars, and so, so many spelling mistakes.
We now have a single, well commented, 300 line file that does the same thing.
Get that shit code out of here.
ask about his game code logic he will rage, ask about how his front end code doing he will rage, talk to him about my server so that his front end code can follow he will rage.. and the end of final project which I merge my code and his code (I need to refactor nearly everything) he said you are very hard communicate. _. fml2
After doing crazy SCSS nesting for around 800 lines split between 8 partial imports, I just found out about the ampersand operator. Time to refactor I guess.
Coworker: "I'll just refactor this one messy piece of code and catch up with you later"
Me to another coworker: "We will not see him anytime soon..."
!rant this is just a shoutout, how fucking happy I am. Clean code valued over fast but hacky push of features!
Backstory. I work for a startup. Long story short a guy with an idea needed a developer. I've worked for about a year without pay but now since we're live I get paid. Recently a new field of bussiness came up. I told tge guy with the idea (a.k.a. my boss) that we either could just "hack" the current code to just make it "fit" well kind of... Or refactor our main code base, as requirements where changing at least monthly and we just built on top of the monolith.
Don't get me wrong. It still isn't perfect. However I was able to refactor the main business logic for the last few days, as he understood, it's an investment into the future.
P.S. On another note: happiness or happyness? :O1
They say 'code drunk, refactor sober' but they fail to mention the sober refactoring dude won't have a CLUE what the drunk coder was even thinking.
Such is my life.
When you finally get around to actually rewriting a save routine to use a new data structure instead of frankensteining the changes into it
Fellow devranter detected?
I can hardly count how many times I've used profanities for variable names or placeholder text. But, unlike this landing page for the Norwegian company 1881's API they never see the light of day. At least I hope so...
Made my giggle out loud at least, 1881 is a well known and respectable (I guess) company over here. Hello world! :-D5
Several days ago, I rant about how I stupidly "refactor" my code.
Now, it's solved. The code is now much cleaner and more maintainable...
The unit test works again. Perfectly...
I'm really happy for this, but I can't just tell it to my friends without explaining "what git and unittest is"1
That moment when, after you've spent days trying to refactor your code to be clean and readable, you look at what you've made and you honestly feel like you actually made things worse than before.1
Started to refactor a class. An hour later -
"hmmm this little bit of code that uses the new refactored class could do with a bit of work". An hour later
"hmmm this little bit of code that uses the new refactored class could do with a bit of work" Eight hours later
"Shit, I've almost rewritten the damn application" !!!
Fuck backward compatibility
Because IOS 9 and Android 4.4 doesn't support arrow functions, I have to refactor almost 90% of the code4
Best comment of the day! Found on one of our clients code. (eCommerce)
// If you are full time then please don't refactor this code.
// if you are consultant then charge triple!
I am slowly beginning to realize that my boss/manager doesn't care about refactoring at all. He cares about features and resolved tickets and thats why the code is a pile of spaghetti filled with hacks to fit every clients desires.
Also all of my coworkers work for themselves, ticket by ticket, either because they just don't care or because they are so frustrated that they don't care anymore. And here I am, an intern, and they expect me to cope with this deformed clutter of legacy designs, buried under hacks and workarounds, while implementing some new feature which in the end I have to put on top of everything else because nothing of that codebase can be reused. Fucking shit, fucking irresponsible managers who dont think about the quality of their product.
Time for a full refactor. Everyone can go home for three days while I unfuck every page and pattern.
Note to self: if you have a tight deadline and need to rush a website / web app, use SASS because you're going to end up with 800+ lines of CSS because you suck at your job and you keep telling yourself you'll refactor everything but never get around it.
Today i had to revisit my code to change some functionality for an application i made 3 years back.
I wish i could go back in time, refactor the code and write Unit tests.1
Embarrassment: when you ask a new hire to refactor some poorly written code, and he runs 'git blame' to find out that you were the OC. Cummon, that was more than an year back!
So I wanted to merge some variables that actually had the same roles.
So I did the Replace in all files (why I didn't refactor, I dunno).
Expected 10 changements, got 234.
Working in a messy and fragile codebase full of anti patterns really sucks the life out of me. It gets to a point where to fix a single bug I could either refactor a bunch of stuff to make it right, or get on board with the filth and do it the wrong way. I'm convinced this shit is making me worse as a developer. And most of the time because of deadlines, I have to do it the wrong way.5
36 hrs !
Just reopened my first android app project and was truly disgusted by the code.
So thought I should refactor it and publish a new update 😐
The update is still due and I am banging my head on the wall1
When a code sample is so obfuscated that it's almost better to leave it alone that to properly refactor it.5
Yea sure, I'd like to refactor your fucking 1000 loc spagetti code "module" with no documentation at all...3
That glorious feeling when you finally refactor a really esoteric function, and it's shorter and much more readable without comments.1
Famous developer sentences #1:
"I leave it like that for now and refactor it later"
It will definitely never going to happen! ;)3
Oh! no There is more than 10 level of nesting conditions in if else statements. I can not refactor it but It needs to add more nest there. I will only add switch statements or ternary operator for the deeper nesting conditions.4
git commit -am 'needs refactor'
// months go by
git commit -am 'hotfix, also needs refactor'
// ... repeat
"The MVC framework is just a hype, we dont need to refactor our ASP.NET webshop" - former CTO
Dudeee, its a pattern not a framework, ever heard of 'single responsibily' instead of these monolithic 8000 line helper classes!3
Just came across a function with a typo (this is in TypeScript) - let's call the function slightlyComplicaedName - see the typo? t is missing. Wanted to refactor the function name to fix the typo. Next thing I know, the project doesn't compile anymore. There was already a function called slightlyComplicatedName in that file and it was doing something completely different.
I get that naming is hard, but using typos to differentiate between functions seems too much :)2
Why did you have a problem with reinventing a wheel?
How can you be so sure that the wheels that been invented are perfects?8
I can't make progress on my private project.
I just started and already refactoring my code.
Yesterday I started to refactor my tests -.-'
I'm sure I will lose the interest in this project because I start a new one I can refactor to death.10
That awkward decision making process when there's good cases for refactoring, but there's equally as many cases for a full rewrite...
Hmm what do4
I hope one day i will stop writing dirty code to achieve a task, forget to refactor it and then struggle to use correct names for variables and methods when i need to move on other tasks.
Programming is like climbing a giant mountain covered with other smaller mountains. You conquer one small mountain (i.e. bugs, refactor, etc) just to realize there are many more mountains ahead before you get anywhere near the final summit.
Today I deleted a lot of stuff
Fields, methods, classes, files, even database tables
And for a change, it was all on purpose 😁
Feels good to refactor stuff and clear out the cruft!3
Typical Git work flow on a feature branch:
Commit#1 : The silly feature itself that took 10 minutes to code
Commit#2 : Added unsaved files
Commit#3 : Fix unit tests
Commit#4 : Fix
Commit#5 : Fix
Commit#6 : Fix
Commit#7 : Various Fix
Commit#8 : Added unsaved files
Commit#9 : Merge
Commit#10 : Fixed unit tests
Commit#11 : Code Review tasks
Commit#12 : Revert- Code Review tasks
Commit#13: Refactor part 1
Commit#14: Refactor part 2
Commit#15: Deleted unit tests
Commit#16: Added checking for null
Commit#17: Completely different feature's bugfix
Commit#18: Code review spacing corrections
Trying to merge, then merge conflicts.....2
Learn to refactor your code constantly. You are not writing code for yourself. Think about the next person who has to look at your code.1
So, I like refactoring old shits.
Now I want to exterminate this over thousand lines of code class. I have to be witty about it and do it within couple of PR, or they will find out I'm not doing anything productive but making their code cute again!4
Worst practice -- our application isn't built to properly handle threads and I just added a Sleep statement to wait for the backend process to replicate its data. I feel so guilty and dirty.
so I was given this old flask project, around 3k lines written in py2, the code is simply old and not refactored. So, it's pile of shit. Migrations completely botched as the original author created reference to live data in models.
Very strict line formatting resulting in backslashed ternary conditions.
Even saw manually formatted json responses... _line by line_.
My job is to clean this mess and eventually do as much as possible to freshen the whole project.
Currently just refucktoring the code as it's the only easy thing to do out of everything that could be done (it's still slow process).
Any tricks and tips? currently considering to try upgrading it to py3 but it feels like throwing gunpowder into already burning house.4
That emotional rollercoaster when you refactor a huge mess and finally there are no more compile errors in it. But there are still endless broken tests to fix :(
When I was creating pixel art creator program and each pixel was an separated object, performance was horrible, and after 2 days of intensive thinking I figured it out. I made working canvas. Ram usage dropped by 1800% and speed increased by 40000%. My satisfaction was unimaginable.3
Me: Ok, we'll implement that message tech. But since the clients are servers in that architecture and can't speak IPv6 we've to use a dedicated VPN so the endpoint is able to connect to the servers (clients). Since we have limited network resources we should use VPN cert-encryption and send the actual data plain to save at least some overhead.
Boss: Ok! Let's do it!
Boss: Hey! I talked to a guy from that message tech. Their encryption is certified. We should use that instead and get rid of the VPN to save the overhead!
Me: *unable to say a word*
What in "VPN in that architecture is mandatory" is unclear?
Well, I assume we'll kill the architecture then... Fun Time!
When you upgrade to awesome 4.1 and have to weed through and refactor 863 lines of Lua (not including theme file) -_- i3 is looking pretty good right about now3
Day 1 of migrating the entire companies infrastructure to GCE...
Thought It wouldn't be too difficult migrating the db until I found out the 480 triggers and 42 stored procedures are a no go.
I mean I know they right and the db layer should be about storage only - I even remember thinking "This is a bad idea" when I wrote most of them but fuuuck it's going to take weeks to refactor this. :'(
Spent the whole day trying to refactor a program that consumes an API and didn’t work out. Now we have one less day to try to improve the product.
I think the fault was that we were aiming too high by looking at other libraries and we ended up over-complicating it.
So... I decided to refactor some of my old code that I wrote exactly 11 months ago, which was one month after starting work..
My first reaction was: "Was I so stupid?"
Second reaction: "why the fuck my supposed 'mentor' allowed me to write this bullshit?"3
From the book
Turning Bad Code into Good Code
HOW CONVERSATIONS ABOUT REFACTORING SHOULD GO UNTIL TESTS ARE WRITTEN
“I refactored login to take email address and username.” “No, you didn’t.”
“I’m refactoring the code to ____”
“No, you aren’t.”
“Before we can add tests, we need to refactor.” “No.”
To be honest - task distraction
1. Starting a task, you need to do
2. finding old code you want to refactor
2. Doing some improvements
3.Fixing the bugs created by prev actions
Task not finished
But that's kind of fun. Livin' on the edge2
What's some valuable things you've learned this year?
Always ask myself, if I can elaborate on any given statement, otherwise just keep shut.
Always ask yourself before writing any code, if it's gonna be easy to modify later on, if not, take a step back and evaluate the bigger picture.
Don't bother with writing things clean in the first go.
It'll be much easier to refactor later on and take less total time.3
Try to avoid writing code that just works because one day some of your colleagues will have to refactor all of it and changing 70 files aint something someone would enjoy doing.1
Instead of ranting I thought it would be nicer to ask for opinions/solutions: How to cope with a collegue that keeps producing trainwrecks of code which you have to first refactor to make it work in a more logical/structured way? Yes, his initial solution works (in a way), but it's just not how 99% of the other developers would solve it. And yes, we've shown him quite a few times how it should/could be (in a positive and constructing manner)5
At last, after a year and a half working with legacy codebase, I got the greenlight from the seniors to refactor my team's app to modern front end technologies. You know, webpack, unit tests, component based architecture and shit.. I really love it!
My PM doesn't look as enthusiastic though...1
Man... I hate refactoring. After I had finished up an issue this morning, I had to refactor old sql queries and the parsing to the views.
I've worked on it all day and I still haven't finished! Still loving my job, tasks like these are unavoidable but they drain the life out of me.3
Just found a crystal subreport with 33 shared variables. For those who don't know what that is (lucky), they're super global variables that exist everywhere.
Please send help. I'm supposed to refactor this...20
My road trip still lasts for another 5 hours and my laptop does not have power anymore 😧😧😧
I could refactor or comment so much code. Maybe add even more loggings and unit tests, but noooo 😔4
I'm on leave but my brain won't stop thinking about ways to refactor that one js module I was working on yesterday into a functional one.
The fuck, brain?? I'm doing you a favor here by letting you take a day off!
So I had to refactor some code that looks like it was written by someone who was getting paid for the number of lines of code.
waking up at 11 o'clock... feeling like a lazy fuck. But then doing the math thing and end up with 5 hours sleep. dont know how to feel about it :D code wont refactor itself
That moment when your task is to refactor a Web site and you discover that every element is positioned absolute and all responsiveness is done by callbacks attached to window resize event2
I have a confession: I produced a shit ton of wacky code...
The business guy in my team is super fucking bitchy about deploying to prod, while my codebase is a total mess. I could refactor it to use a much cleaner module, but I had to do it because we're running out of time. I spent half a day trying to refactor while failing miserably.
//FIXME: I will come back... or not.1
The feeling after you refactor 4000+ lines of ugly legacy code into 2000 lines of code placed in a framework ...these 4000 lines also all one document
Going for a run but still thinking about how I can refactor the code I just wrote. Can't stop thinking about it. Is it just me?4
I’m curious, how do you guys explain something technical to non-technical person? Especially stuff with some degree of technical complexity, this is what happened for me
Me: so last week I paired and helped M with her task to build bla bla, and I had to refactor the component to make it work
SM: wait, why the refactor?
Me: because it won’t work otherwise, the previous code doesn’t leave any room for improvements
SM: the code? How so?
Me: it would take greater effort to add the feature with their approach, it’s bad practice and it won’t do us well in the long term
SM: how long until it’s finished?
Me: should be this afternoon, today at the most
SM: eh, ok
The PO doesn’t look happy, the non technical guys always get triggered easily over some words especially “refactor”, probably overused to cover someone’s mistakes (an ex colleague of mine did this all the time)10
How do you switch from testing while debugging (functional) to TDD unit tests?
Usually I test while coding by just running the use case and making sure while coding, bad inputs are caught/handled.
But most times I start with a general idea of the structure and what the about should be (which essentially would be the functional test case?)
I don't think about how you can break each part or the functions I need until I need them. Then usually start simple and then refactor. And until I'm sure each time I refactor would require changing the tests?4
Created new configs, entities, services, controllers, endpoints, views and all the relevant JS for a new section of a system.
Tested it out, all working like a charm, very happy, Then realise I've named them all incorrectly.
When your senior says he may as well stops working as I'm always refactoring his code...
Same sentence says I copy what you've done in other places so I don't see why it isn't good enough. By copy he leaves redundant code in there too.
Am I a being a douche is he just being over the top?
- He writes code and expects it to live for a long time.
- I write code and will go home and refactor my own code.2
Ordered to implement Old functionality in New system, not allowed to fix it, refactor or change the underlaying mess.
Wrap old system in a wcf, hardcoded some values, done.
3 weeks estimated so I feel ahead and got more time to look for a New job.
Going through my old code because i changed a small thing which will help me immensely and oh god.
I think a refactor/rewrite is coming.
We were building a website using angular 1. We were collaborating with some devs from outside our firm. At some point one of the devs(which was supposed to be a front end expert) had the brilliant idea to migrate to a never version of angular. He made the changes and fucked up all the controllers and functionalities and then he just disappeared. My team worked for 2 weeks to fix his mess.
Dude do you even know the definition of refactoring? 😤4
Sometimes i like to break my code on purpose, to force me to refactor those parts and rewrite them more efficiently.
I find it hard to improve existing, working code, because it limits me and it does not inspire me to come up with something better
I totally want to refactor my project's code, but I don't have any time for it and now it's a working piece of spaghetti-ish 😭
I'm just praying I'll get to do it once it's actually finished, so I don't have to work with it again in like a year and want to travel back in time and murder myself.13
Also once project gets to a certain level, it's practically impossible to revisit and refactor old codes in front-end languages which kills the maintainability. Views?4
When you advise your PM that it would probably be wise to make some time to refactor and learn the 10 year old system you got stuck working on.
'I wouldn't worry about that just yet'
Yep! you said that last time and look where it got us... -_-2
TMW you want to introduce a big feature that will require you to refactor the existing code, but you don't have to worry about breaking the latter since you have tons of unit tests backing you up.2
2 years huh. well...
1.Have a side business
2.Build an IoT project for home.
3.Refactor my code (Im not saying I'm a bad coder but, if some of you saw my code, you'd probably want to strangle me to death in my sleep, so....)
4. And finally, maybe post a rant/reply with no spelling mistakes so that I don't have to edit that shit every fricking time after I post something.
I don't always wreck the production environment, but when I do it's because I'm trying to refactor a piece of code with a "// this is here for reasons, don't change this" comment above it.
How can code refactor be so stressfull that even doin' it on YOUR OWN CODE looks like taking a slow walk over broken glass? More than never: GOD BLESS THOSE WHO DAILY DEAL WITH LEGACY CODE
Me: If I am going to refactor this code I should use test driven design
*Reads SO answer about TDD*
SO: you know ahead of time what each part of the program must achieve
Me: Well that was a pleasant thought.
*hides under my desk in depression*
What baffles me is how despite being on version 3 of Swift, Apple still havent updated Xcodes refactoring tools to support it. All I want to do is rename a variable or function but oh no. "Xcode can only refactor C or Objective-C code". Yet they are plowing on with new features in other areas like the interface builder but completely ignoring the tools that make IDEs useful.
The evolution of code, in Python:
-Refactor common functions into a Utility class
-Make the scripts into classes/methods with a "static main"
-Create a super script to run them all
I'd provide a screen shot of the last but to much propriety info... But yes it looks short and simple 😄😊
God dammit, I hate my bloody coworker sometimes. He's doing a huge refactor, and committing... which is fine, but he's clearly NEVER run the fucking test suite. I didn't write that much coverage so you could commit something that breaks the build and then fuck off to lunch.
Not only has he not run the test suite, I don't think he's run his changes AT ALL. The bloody modules don't even import the way he's written it now.2
Dude i asked you to review my pull request because i thought we were cool. The code change is about a simple rename, SO FUCK OFF WITH THE REFACTOR SUGGESTIONS. STOP DOING THAT TO MY CODE REVIEWS2
PhaserJS + Webpack = hours of misery and frustration. :P
Time to single-page this and refactor to Webpack later.
My approach to writing C++:
1. Write a test
2. If I don't understand the compiler errors, give up.
3. Run the test.
4. If it segfaults and I can't work out why in gdb, give up.
5. Make the test pass.
6. If the result is ugly and it breaks when I refactor, write a different test
7. Anything that makes it this far can be shipped.
The code I am supposed to refactor only builds if mounted on/as drive s:\.
Sure worked for the previous dev.
First thing to do: new makefile. And git init.
I started a months ago in a new company and I grab a horrible legacy system and what makes me more angry is they know the code isn't code and isn't fit our new reality but they don't want to refactor the same.
So which more features we produce more bugs comes along because the legacy code bugs still on there.4
got back from a week long (mountain/snowboard) trip, disconnected from anything that means work, just to found out the team decided to do a huge refactor of the whole app! now i have to 2x work to catch up. i need another vacation 😩!
ps: at least they were nice enough to not break me the news while i was gone and enjoy my time 😅1
Client: After two weeks of silence. "Are we ready to launch?"
Me: "Yeah, sure!" Forgetting there's a half-finished refactor from two weeks ago.
*spends an hour cowboy coding php in Plesk editor before IT guy updates DNS*
Junior dev is refactoring yet again instead of doing the work he is supposed to be doing ...... Feels he has to refactor everything to fit in with his floored idea of the way the system should work ...... Going to be having words with him soon :-(2
Asked to add a "simple" feature on the project. Realised it was imposible without a refactor. Ended up refactoring about 70% of the app to put in the feature. Boss complains I only have left 4 days to finish it. QA complains there is a small bug and I can't merge.2
Legacy code was so bad that it created the existence of my team to do a refactor and rewrite.
(Outsource to in house)
has anyone here done a proper refactoring? i mean, documenting, following some rules, etc.
i need to know the process and guidelines for refactoring, what & how to document, where to start, etc.
i am assigned to a project for a short term and my job is to do refactoring of Reactjs code. and i need to do it in a really good way.
any help would be highly appreciated.
Why do I always have to refactor bad written code ? Is this some kind of karma ?
Undocumented, written by a senior but looks like it was a junior, no unit tests, variables with meaningless names, duplicated code and every possible thing you can find in that kind of code.3
i finally get rid off that over-the-top dependency on Zend\Config in upwork/phystrix
The Pull-Request is on it's way:
After 4 years of "this will take minutes to refactor" and "yeah. I totally agree. Replace Zend\Config with Array Interfaces", someone (in this case me) took finally care of this easy to solve issue :)
I hope it will be merged soon into the master branch
Six months ago, I architected a solution that I thought was pretty darn good. Of course my boss didn't agree and basically twisted my arm until I agreed to go along with his approach. Today, he's walking back on it.. and telling us we can refactor the solution if it doesn't make sense anymore.. so back to my original solution?
If only he listened in the first place..
The worst is having to rewrite/refactor another person's implementation either due to not follow the requirements or specifications and having made something completely different or useless.
But recently is having to re-explain what needs to be done or what the requirements are.2
Last week I had two days training about how to code modern with the language I use.
Now I wanna refactor every single line of code I ever wrote :D3
I recently performed a huge refactoring effort on a Java project converting both the persistence and utility layers to Kotlin. Gotta say, I think I'm starting to fall in love with programming again!
Putting aside how pretty it is now, I've reduced those two layers by over 2400 lines of code
Ah, I haven't touched VB.Net for about three months and I was let down by excessive verbosity again.
Next task: Refactor VB.net modules into C# libraries one by one...
Just by refactoring to use the correct data types to skip all checking and conversions and also use data bindings, the performance increased several folds.
Why take the time to refactor? It would probably take longer to implement the new features if I did not.
Have you ever hit Ballmers Peak, only to fly past it but still keep coding? Sometimes it's an adventure looking at the code the next day. Three steps forward, one step back I say!2
Tried to change a overriding method in my C++ class to override another method using "refactor - rename" from my IDE, ended up changing the header of the parent class which is not even in my source tree.
I know I should check the value first before pop the element from the array, check it, and push it back...
Gonna fix this later, but still wanna put it here for future reference...
Working, but stupid, but working, but stupid, but working....13
Update to my last rant*:
I got to know what my colleague did as he "rewrote" my code:
He just searched some GitHub-Projects and used the good old copy+paste method.
Awesome bro, "rewriting" code until nobody's understanding it is the best method to improve code.
- Dealing only with your own code
- Having enough time to improve and refactor your code whenever you want
- Bug reports are detailed af and not just like "doesn't work"
- Choosing the IDE (and OS maybe, too) by yourself
- Having enough time for bugfixes, implementations
- Software is ready, when you want it, not anyone else.
- Visiting trainings or seminars to improve your skills whenever you want
Yeah, that would be pretty awesome.3
My most recent workaround occurred last week.
We have a demo very soon and I had to change our iOS app to use a new Web API endpoint for uploading content.
Long story short: The existing code is so awful and rigid and dependant on Core Data that I ended up having to completely bypass the service layer of the app and implement the new endpoint as a raw HTTP request. Its gonna take a long time to refactor the existing service layer. All because the new endpoint has a different content type.
Need to refactor the code base, and when looked at it, we don't have single UnitTest.... F*** them all1
Oh noooo! During the last retrospectives we, as a team, decided to not refactor things to make it nicer, better or even more loosely coupled, as existing mechanisms are working properly and as such the refactoring is not absolutely necessary. But now someone in our team suggests to refactor something that is ready for deployment. Just because it will make the code better and more maintainable. Yay! Lets add another 2 days of work just to refactor out 3 lines of code.
The more I refactor a codebase that I have started for 2+ years ago the dumber I feel I have been.
There are too many things that are done completely wrong or in a stupid way.
Currently adding comments like in the picture...1
Few days ago PM said that all of our grids should load all the data at once and just display it, and now today he says he likes paging more. So many files to refactor :////
BTW: every grid has to be set up individually :(((1
Things could be soo much better if I could just refactor this code to accommodate more than one web service... #soapmessages #devwoes
Rarely refactor my code: sometimes there are completely same parts of code which I am too lazy to move to a separate function)))
Today I try to refactor my personal project. It contains a very huge file named "core.js". It become so monolithic so that I'm too afraid to open it again.
So, I decide to face my darkest nightmare by refactor that "core.js" into several files based on it's context.
Now, I'm in the middle of the task, and unable to figure out, which one of these code is cleaner:
let function = util.function;
The first one let me informed about the "namespace" without any need to scroll up and look for the declaration.
The second one is shorter, and I don't need to change everything so much.3
I cannot write my shopping list on paper anymore. I'm unable to sort it alphabetically, refactor it, group the items by theme...
The more code I write the worse I feel as a programmer. Just me?
An 80's programmer once said to her son, my friend a writer, "Don't be self deprecating".
Time to refactor my thoughts.
Refactor our front end from a blend of Classic ASP and Classic ASP hosting React Components to React. I doubt it'll ever happen, but a dev can dream right?1
When you have to refactor the whole microservice to fix package structuring so it can be modular...why can't people do it correctly the first time?
Perfectionism... I often refactor my code because I always see something that could be "done better" in my own work, which can slow me down if I'm not paying attention to my main task.
If I could stop time I would perfect my code all day, but that isn't realistic. 😂
Doesn't apply to dev work only, I've had to learn the art of not giving a shit about every single detail in many other disciplines. I just love getting things done really well.
So today I learnt that babel/runtime-corejs2 is a lib which makes babel more optimised by refactoring most of its function calls. So I need to import a library..... to gain more performance out of an existing library.... I mean you could literally refactor babel instead of asking people to import another package in your project 🤦♂️6
Le dev and le me (continued)
So le manager decides to talk to both le me and le dev so we can sort things out.
Le dev than says: "I think we shouldn't refactor things just to make them prettier." (Very passive-aggressively talking about me.)
Then goes on and implements a custom permission handler that performs several queries to the database to determine if a user should be able to change an object.
And all le me wanted was to use groups...
Collect project specifications & details.
- order by relevance.
List & install dependencies (possibly spin up a vm).
Bootstrap skeleton & scaffold.
- ensure functional base.
Iterate specs list & create test case(s) one at a time, going: test => minimal to pass => refactor => next(repeat_cycle)1
Also the designer: lets change every basic style this site has. Refactor the fonts, the colors and all sections.
Sure, great idea to totally fuck up this site!
When you wait for your project's third-party dependencies to upgrade to the newest version, in order to upgrade to the newest version too;
but the upgrades never comes so you start considering if it's worth a whole refactor or just more waiting time.
I think my worst habit is that I create too much DRY code. Sometimes code gets repeated when I'm just too focused on getting a feature to work and makes it hard to refactor later :/1
“Whenever I have to think to understand what the code is doing, I ask myself if I can refactor the code to make that understanding more immediately apparent.” - Martin Fowler
I hate to see when my code is touched by co worker and after then it looks like shit... mäh... added a task to refactor it by myself just to set a statement
"Anyways trust code that you wrote before but... never rely on that!"
I wrote some code mounts ago, now when I want to refactor it see a bunch of shit, I delete them all and after hours write exactly the previous code!!! just because i don't put some STUPID comments... 😑1
Got a ton of work? naaah let me completely refactor my dotfiles and vimrc https://github.com/cousine/dotfiles
Weekend ruined supporting legacy and poorly designed services coupled with poor architecture.
But "no project bandwidth" to refactor said services.
5 hours of data loss should now hopefully inspire a backlog re-shuffle.
I wrote a function a few months ago that made 10 http calls for the same data... had to refactor it because users were saying it was broken. FML but I've learned my lesson.
JUST ONE CALL.
Since we are sharing some of our more interesting commits, what do people think of these commits?
General: pro.user update
Refactor: Hide and show Spin Boxes on Normalization
Refactor: Dynamic resizing refactoring
Refactor: Dynamic resizing across any screen
GUI: Measure screen size and assume the proper size.
Fix: guitest.cpp has been reafactored
Dir: Clean unused directory
GUI: Hide and show Spin Boxes on Normalization
Commits on Jun 28, 2016
GUI: Make boxes more bolded
General Commit: 11:03 PM 6/28/2016
Del: build from previous commit
Fix: Guitest's compiled code was broken
GUI: Make window scrollable.
Adjust; Changing directory tree
Find out both are the same, but parentNode works everywhere with any element and parentElement doesn't. Let's refactor then.4
Have you already met the code that you have no idea how to refactor?
In five years I met those twice and I'm still puzzled with one of them. (I don't mean just a spaghetti or too long code)
Well here i thought i would have done work...and pooof its time to go home
All i did was refactor with and make PR...
I guess today was one of those days where little work was done
Me: Look boss i refactor application, now it is way faster then previous one.
Boss: Cool, but who wrote the previous code?
Me: OH! well me.
read and get a basic understanding ->
create using simpleton syntax until confident ->
read a bit more ->
refactor with a more advanced approach
-> repeat until GODMODE
-> sad panda if the next version is completely different (Angular 2.0)
-> flex your muscles
-> buy some swag
-> happy panda
Spent 4 days to refactor the most used word in the system. And that moment, when techlead asked to stop refactoring and keep as it is. 😖😖😖
new Confession(new Rant()).admit("My kludge bit me in the ass. But If I make a series of classes that encapsulate (hide) the awful hacks, one day I can replace the hacks with nice code. This is why I say I love refactoring. But right now, procrastination looks ugly.").asRant()1
TFW your collegues rename and refactor everything, don't comment on their commits and then break EVERYTHING when you merge their changes into your branch. FFS.
Usually if theres a tough problem I just start to scribble code one piece at a time, then refactor, then refactor, then refactor... Until I get it and write it again from scratch 😀 Usually this involves lots of coffee and cigarette
Okay i should done this code tomorrow
Watching youtube till evening
Thinking about annoying senior who tried to refactor everythign
What i have done,
Ugh trying to refactor a Node.js MUD codebase to use mongodb. It currently accesses/stores it's data in json files via synchronous FS operations. Callback and/or .then hell, here I come!
Also the designer: lets change every basic style this site has. Refactor the fonts, the colors and all sections.
Sure, great idea to totally fuck up this site!
Best part of being a dev: seeing my code grow, take shape and become robust, line after line, refactor after refactor.
Have to refactor one Big shitty class with thousands of lines of code... Thanks to Bachelor thesis1
Frustration is starting a very large data object with multiple child objects while a project wide refactor is underway changing the MVC architecture and introducing serialization.
Worked around a major blocker using iframes inside modals. The 8 hours saved will become 8 days extra in Web Developer Hell when I have to refactor it fully!
Pray for me :/
When it comes to work, I wouldn't say that I get low motivation. In every single job that I have been in I have seen some terrible coding, or when I review my previous stuff I find it was also terrible. Always wanting to improve/refactor stuff is always a motivation as it'll in turn make me a better programmer. Also I hold that belief that you have to do the shit out of your job since you can be replaced!
Any one else dissapointed in what direction Play (scala) is going? Jesus christ i cant even mock my authentication anymore without a shit ton of refactor...
When they hits the sign where everyone knows they should split the core and refactor their API, Apollo chose to merge everything.
Great engineering management there.