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
Search - "code refactor"
-
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
-
Omfg this fucking guy!!!!
Context:
We are going through a major refactor of some of our backend components. I was tasked with cleaning up our ML code while another guy was tasked with cleaning up the general CRUD side of the backend, let's call him DA for "dumb ass".
** At 11pm
DA: I am getting a strange error from your backend. Look:
"Invalid call: method=PUT expected=[POST]"
Me: you need to send a post request not a put request
DM: no, it's not that. I am sending the right thing
Me: ... Let me see...
* 15min ish of testing *
No, it works fine on my version, 1.1.0 what's your version?
DM: I'm on 1.1.0.
Me: send me code?
DM: *send
"request.put(..."
Me: you are sending a PUT... It's literally in the screenshot. Send a Post
DM: I am
Me: no, send a Post
DM: I don't understand, I am sending the request
Me: it's a post not a put
DM: but...
Me: it's a post not a put
Me: good night!!!!!!12 -
Dev: boss, there are some abnormalities and confusion in the client's specifications.
Boss: So?
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.
Dev: ..
A few months later....
Dev: *seeing so many specifications change and realizing now have to refactor a lot of codes* , FML.15 -
Today was my last day of work, tomorrow i have officially left that place. It's a weird feeling because i'm not certain about the future.
The job was certainly not bad, and after all i read on devrant i'm beginning to believe it was one of the better ones. A nice boss, always something to eat/drink nearby, a relaxed atmosphere, a tolerance for my occasionally odd behaviour and the chance to suggest frameworks. Why i would leave that place, you ask? Because of the thing not on the list, the code, that is the thing i work with all the time.
Most of the time i only had to make things work, testing/refactoring/etc. was cut because we had other things to do. You could argue that we had more time if we did refactor, and i suggested that, but the decision to do so was delayed because we didn't have enough time.
The first project i had to work on had around 100 files with nearly the same code, everything copy-pasted and changed slightly. Half of the files used format a and the other half used the newer format b. B used a function that concatenated strings to produce html. I made some suggestions on how to change this, but they got denied because they would take up too much time. Aat that point i started to understand the position my boss was in and how i had to word things in order to get my point across. This project never got changed and holds hundreds of sql- and xss-injection-vulnerabilities and misses access control up to today. But at least the new project is better, it's tomcat and hibernate on the backend and react in the frontend, communicating via rest. It took a few years to get there, but we made it.
To get back to code quality, it's not there. Some projects had 1000 LOC files that were only touched to add features, we wrote horrible hacks to work with the reactabular-module and duplicate code everywhere. I already ranted about my boss' use of ctrl-c&v and i think it is the biggest threat to code quality. That and the juniors who worked on a real project for the first time. And the fact that i was the only one who really knew git. At some point i had enough of working on those projects and quit.
I don't have much experience, but i'm certain my next job has a better workflow and i hope i don't have to fix that much bugs anymore.
In the end my experience was mostly positive though. I had nice coworkers, was often free to do things my way, got really into linux, all in all a good workplace if there wasn't work.
Now they dont have their js-expert anymore, with that i'm excited to see how the new project evolves. It's still a weird thing to know you won't go back to a place you've been for several years. But i still have my backdoor, but maybe not. :P16 -
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 -
After our Head Of Software has terminated.
I started to take control over our development crew. And in this year I did more then the old head in the last 6 years.
- Swapped from plain old SVN to Gitlab.
- Build a complete autonomous deployment with Gitlab.
- Introduced code reviews.
- Started to refactor the legacy product with 500.000 lines of code...
- learned how to use confluent apache kafka and kubernetes to split the legacy project in many small and maintainable one.(not done yet)
- Last 3 weeks I learned how to use elasticstack with kibana and co. That we aren't blind anymore. Big dashboards are now shown in the middle of the room :) and maybe convinced my coworker that we use unity3d for our business application cause of support for all devices and same design on them. And offline capabilities. (Don't know if this was my best idea)
When I look back, I'm proud to did that much in one year alone. And my coworkers are happy too that they have less work with deployments and everything.
But I can't decide what's the title for this. System or Software Architect cause I litterallity did both :/7 -
"Can you work on this ticket? It's kind of urgent."
-- "OK"
"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 -
THIS is why unit testing is important, I often see newbs scour at the idea of debugging or testing:
My high school cs project, i made a 2d game in c++. A generic top down tank game. Being my FIRST project and knowing nothing about debugging or testing and just straight up kept at it for 3 months. Used everything c++ and OOP had to offer, thinking "It works now, sure will work later"
Fast forward evaluation day i had over 5k lines of code here, and not a day of testing; ALL the bugs thought to themselves- "YOU KNOW WHAT LETS GUT THIS KID "
Now I did see some minor infractions several times but nothing too serious to make me refactor my code. But here goes
I started my game on a different system, with a low end processor about 1/4 the power of mine( fair assumption). The game crashed in loading screen. Okay lets do that again. Finally starts and tanks are going off screen, dead tanks are not being de-spawned and ended up crashing game again. Wow okay again! Backround image didn't load, can only see black background. Again! Crashed when i used a special ability. Went on for some time and i gave up.
Prof saw the pain, he'd probably seen dis shit a million times, saw all the hard work and i got a good grade anyways. But god that was embarrassing, entire class saw that and I cringe at the thought of it.
I never looked at testing the same way again.6 -
Interviewed a dev for a junior role earlier this week...my first question:
const numbers = [0.1, 0.2, 0.3];
let sum = 0;
for (i = 0; i < numbers.length; ++i) {
setTimeout(() => {
sum += numbers[i];
}, 0);
}
// Refactor the preceding code so that the following returns true.
console.log(sum === 0.6);
---
He had no idea where to even start, so I asked him to walk through the code with me line by line, he couldn't get past line 1 - literally didn't know what an array was... I walked through the code with him and he just started to look more and more lost.
I didn't even bother with the rest of my questions on OOP, FP, etc...
Am I really expecting too much of somebody that claims to have 2 years practical experience in JavaScript, jQuery, Angular, and PHP?
Do you think this is a problem a junior dev should be able to solve...even if it takes some hand-holding?57 -
Never have I been so furious whilst at work as yesterday, I am still super pissed about going back today but knowing it's only for another few weeks makes it baerable.
I have been the lead developer on a project for the last 3~ months and our CTO is the product owner. So every now and then he decides to just work on a feature he is interested in- fair enough I guess. But everything I have to go and clean up his horrendous code. Everything he writes is an absolute joke, it's like he is constantly in Hackathon mode "let's just copy and paste some code here, hardcoded shit there and forgot about separation of code- it all goes in 1 file".
So yesterday he added a application to the project and instead of reusing a shared data access layer he added an entirely new ORM, which is near identical to the existing ORM in use, for this one application.
Being anal about these things, the first thing I did was delete his shit and simply reference the shared library then refactor a little code to make it compatible.
WELL!! I certainly hit a nerve, he went crazy spamming messages on Slack demanding I revert as it broke ONE SINGLE QUERY that he hadn't checked in (he does 1 huge commit for 10 of everyone else's). I stuck to my principals and explained both ORM's are similar and that we only needed one, the second would cause a fragmented codebase for no benefit whatsoever.
The lead Dev was then forced to come and convince me to revert, again I refused and called out the shit quality of their code. The battle raged on via the public slack group and I could hear colleagues enjoying the heated debate, new users even started joining the group just to get in on mine and the cto's difference of opinion.
I even offered to fix his code for him if he were to commit it, obviously that was not taken well ;).
Once I finally got a luck at the cluster fuck of shit he had written it took me around 5 minutes to fix and I ever improved performance. Regardless he was having none of it. Still the demands to revert continued.
I left the office steaming after long discussions with the lead Dev caught in the middle.
Fortunately my day was salvages with a positive technical discussion that evening at a company with whome I had a job offer from.
I really hate burning bridges and have never left a company under bad terms but this dictator is making me look forward to breaking the news today I will be gone in 4 weeks.4 -
Attack problems you've never solved.
Don't fear projects which you're not familiar with the technology.
Read books, blogs, and code.
Refactor every opportunity you have.
Don't always be the smartest developer in the room.
Be flexible. Tools are tools, don't fall in love with any one till and neglect others. -
!rant
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"
I hoped!5 -
Every time I do a dirty fix and someone in my MR comments "have you investigated the root cause" I wanna kill myself.
No bro, I havent investigated the root cause because this ticket is 3 months old and was passed around like a hot potato from team to team until it got assigned to me.
If you want I can add a comment to refactor this in the future. As far as Im concerned any refactors are out of scope, also I atleast came up with some kind of solution that noone else was able to in 3 months. So im not gonna waste my time on refactoring this piece of shit code under immense pressure from management who thinks it was me who dragged this ticket for 3 months.
Its working, it doesnt cause any side effects, we all gonna die soon and nothing really matters, so fuck off.9 -
Insecure... My laptop disk is encrypted, but I'm using a fairly weak password. 🤔
Oh, you mean psychological.
Working at a startup in crisis time. Might lose my job if the company goes under.
I'm a Tech lead, Senior Backender, DB admin, Debugger, Solutions Architect, PR reviewer.
In practice, that means zero portfolio. Truth be told, I can sniff out issues with your code, but can't code features for shit. I really just don't have the patience to actually BUILD things.
I'm pretty much the town fool who angrily yells at managers for being dumb, rolls his eyes when he finds hacky code, then disappears into his cave to repair and refactor the mess other people made.
I totally suck at interviews, unless the interviewer really loves comparing Haskell's & Rust's type systems, or something equally useless.
I'm grumpy, hedonistic and brutally straight forward. Some coworkers call me "refreshing" and "direct but reasonable", others "barely tolerable" or even "fundamentally unlikable".
I'm not sure if they actually mean it, or are just messing with me, but by noon I'm either too deep into code, or too much under influence of cognac & LSD, wearing too little clothing, having interesting conversations WITH instead of AT the coffee machine, to still care about what other humans think.
There have been moments where I coded for 72 hours straight to fix a severe issue, and I would take a bullet to save this company from going under... But there have also been days where I called my boss a "A malicious tumor, slowly infecting all departments and draining the life out of the company with his cancerous ideas" — to his face.
I count myself lucky to still have a very well paying job, where many others are struggling to pay bills or have lost their income completely.
But I realize I'm really not that easy to work with... Over time, I've recruited a team of compatible psychopaths and misfits, from a Ukranian ex-military explosives expert & brilliant DB admin to a Nigerian crossfitting gay autist devops weeb, to a tiny alcoholic French machine learning fanatic, to the paranoid "how much keef is there in my beard" architecture lead who is convinced covid-19 is linked to the disappearance of MH370 and looks like he bathes in pig manure.
So... I would really hate to ever have to look for a new employer.
I would really hate to ever lose my protective human meat shield... I mean, my "team".
I feel like, despite having worked to get my Karma deep into the red by calling people all kinds of rude things, things are really quite sweet for me.
I'm fucking terrified that this peak could be temporary, that there's a giant ravine waiting for me, to remind me that life is a ruthless bitch and that all the good things were totally undeserved.
Ah well, might as well stay in character...
*taunts fate with a raised middlefinger*13 -
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!
Me: 😵🔫
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
Boss:
did you just Missy Eliot my code?
Me:
Ti esrever dna ti pilf nwod gniht ym tup I1 -
2 years into polytechnic I got my 1st big project as a subcontractor doing Symbian. No need to tell the company I presume.
Anyways, I was brought into the project just couple weeks before holiday season started. My Symbian programming experience was just the basics from school. 1st day I was crapping my pants out of anxiety. I pretty much didn't understand anything what my project manager or teammates were telling, so I just wrote EVERYTHING down on paper and recorded all the meetings to my laptop.
My job was to implement a very big end to end SDK feature. Basically from API through Symbian OS through HAL to other OS and into its subsystem. Nice job for a beginner :/
As the holidays were starting we had just drafted out the specification (I don't know how, because I didn't understand much of what was going on) and I got a clear mission from team lead. Make a working prototype of the feature during the time everybody else was on vacation.
"No problemos, I can do it" I BS'd myself and the team lead.
First 2 weeks I just read documentation, my notes and internal coding tutorials over and over again. I produced maybe couple of lines of usable code. I stayed at the office as late as I dared without seeming to obvious that I had no clue what I was doing. After the two weeks of staying late and seeing nightmares every night I had a sudden heureka moment. Code that I was reading started to make sense. Okay, still 2 weeks more until my teammates come back.
Next 2 weeks were furious coding and I got better every day. I even had time to refactor some of my earlier code so that quality was consistent.
Soooo, holidays are over and my team leader and collagues are very interested with my progress. "You did very well. Much better than expected. Prototype is working with main use case implemeted. You must have quite high competence to do this so well..."
"Well...I did have to refactor some stuff, so not 10/10"
I didn't say a word of my super late nights, anxiety and total n00biness.
Pretty much finished "like a boss". After that I was on the managers wanted list and they called me to ask if I had the time work on their projects.
Fake it, crap your pants, eat your crap and turn into diamonds and then you make it.
PS. After Symbian normal C++ and almost any other language has been a breeze to learn.2 -
In my current work, I have two systems to work on (let's name em Systems A and B). Both basically do the same thing; both allow users to book facilities available to them.
System A is already in production. My job is to fix any bugs that come up on said system. System B is an improved version that they wanted me to develop. This would follow a different framework etc. I am already halfway through this system.
Now, here's the fucked up part. The code for system A is a massive clusterfuck. It has unused commented code dated back to ancient times where men had the brain of an ape.
And don't get me started on the fucking logic. One part of the code was to retrieve and display the timeslots available for a chosen facility. The code to do that alone takes up 500++ fucking lines, filled with ajax commands, html manipulation and commented, unused codes..AND THAT'S JUST THE FRONTEND!
The fucking backend was not a problem of smelly code anymore. Nope. It was like a programmer had code diarrhea and shat his backend code all over the project. If I had a pin board, I would have made a crazy wall just to understand what some fucknut was trying to achieve.
Anyway, my supervisor told me to fix some bugs on System A. Knowing how the code was, I told her that I could refactor the code. Since I've already achieved that function on System B, with a shorter and cleaner code, I could just copy that and use on System A. But nope. She SPECIFICALLY told me to just "do whatever to fix the bugs. I don't want to waste time on System A." Okay. Makes sense to me. Whatever. I didn't wanna fuck my head up looking through that mess of a cesspool. So, I came up with a few hacks, not thinking of clean code and fixed whatever bugs there was. I then just pushed to the repo (after testing of course).
This bloody morning, supervisor came in and gave me more bugs to fix. When I thought she was done, she said "Hey. I saw the fix you made to the system. The bugs are fixed but the retrieval of the timeslots is now pretty slow. Could you see what is the problem?"
Slow.. She said that it was slow. And asked if I could fix it. I already told her what the problem was and she did not want me to waste time on it. But she wants me to fix it. WHAT THE FUCK IS WRONG IN HER BLOODY HEAD! I SWEAR TO GOD... UGHHHHH I swear I was already waterboarding her in my head. YOU WANT FAST?? How bout fucking allowing me to refactor the code?? Fucking shit head. I think I should take up yoga.1 -
Still trying to get good.
The requirements are forever shifting, and so do the applied paradigms.
I think the first layer is learning about each paradigm.
You learn 5-10 languages/technologies, get a feeling for procedural/functional/OOP programming. You mess around with some electronics engineering, write a bit of assembly. You write an ugly GTK program, an Android todo app, check how OpenGL works. You learn about relational models, about graph databases, time series storage and key value caches. You learn about networking and protocols. You void the warranty of all the devices in your house at some point. You develop preferences for languages and systems. For certain periods of time, you even become an insufferable fanboy who claims that all databases should be replaced by MongoDB, or all applications should be written in C# -- no exceptions in your mind are possible, because you found the Perfect Thing. Temporarily.
Eventually, you get to the second layer: Instead of being a champion for a single cause, you start to see patterns of applicability.
You might have grown to prefer serverless microservice architectures driven by pub/sub event busses, but realize that some MVC framework is probably more suitable for a 5-employee company. You realize that development is not just about picking the best language and best architecture -- It's about pros and cons for every situation. You start to value consistency over hard rules. You realize that even respected books about computer science can sometimes contain lies -- or represent solutions which are only applicable to "spherical cows in a vacuum".
Then you get to the third layer: Which is about orchestrating migrations between paradigms without creating a bigger mess.
Your company started with a tiny MVC webshop written in PHP. There are now 300 employees and a few million lines of code, the framework more often gets in the way than it helps, the database is terribly strained. Big rewrite? Gradual refactor? Introduce new languages within the company or stick with what people know? Educate people about paradigms which might be more suitable, but which will feel unfamiliar? What leads to a better product, someone who is experienced with PHP, or someone just learning to use Typescript?
All that theoretical knowledge about superior paradigms won't help you now -- No clean slates! You have to build a skyscraper city to replace a swamp village while keeping the economy running, together with builders who have no clue what concrete even looks like. You might think "I'll throw my superior engineering against this, no harm done if it doesn't stick", but 9 out of 10 times that will just end in a mix of concrete rubble, corpses and mud.
I think I'm somewhere between 2 and 3.
I think I have most of the important knowledge about a wide array of languages, technologies and architectures.
I think I know how to come to a conclusion about what to use in which scenario -- most of the time.
But dealing with a giant legacy mess, transforming things into something better, without creating an ugly amalgamation of old and new systems blended together into an even bigger abomination? Nah, I don't think I'm fully there yet.8 -
Worst of many. Had to work with someone who could be accurately described as a monkey in trousers with strategically cut fur.
Him: "I have refactored code now I have to refactor all your goddamn unit tests"
Me: "so?"
<silence>
<checks his commit>
Me: "why have you commented out every single line in all the unit tests?"
Him: "I DON'T BELIEVE WE SHOULD HAVE ANY UNIT TEST. THEY ADD TIME".
Me:"You cannot be serious. Apart from the obvious mistake in judgement why in the name of blue buggery fuck did you not delete the files? Have you not heard of source history?"
Him:"...."
I became his lead.
He left.5 -
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!10 -
Most satisfying bug I've fixed?
Fixed a n+1 issue with a web service retrieving price information. I initially wrote the service, but it was taken over by a couple of 'world class' monday-morning-quarterbacks.
The "Worst code I've ever seen" ... "I can't believe this crap compiles" types that never met anyone else's code that was any good.
After a few months (yes months) and heavy refactoring, the service still returned price information for a product. Pass the service a list of product numbers, service returns the price, availability, etc, that was it.
After a very proud and boisterous deployment, over the next couple of days the service seemed to get slower and slower. DBAs started to complain that the service was causing unusually high wait times, locks, and CPU spikes causing problems for other applications. The usual finger pointing began which ended up with "If PaperTrail had written the service 'correctly' the first time, we wouldn't be in this mess."
Only mattered that I initially wrote the service and no one seemed to care about the two geniuses that took months changing the code.
The dev manager was able to justify a complete re-write of the service using 'proper development methodologies' including budgeting devs, DBAs, server resources, etc..etc. with a projected year+ completion date.
My 'BS Meter' goes off, so I open up the code, maybe 5 minutes...tada...found it. The corresponding stored procedure accepts a list of product numbers and a price type (1=Retail, 2=Dealer, and so on). If you pass 0, the stored procedure returns all the prices.
Code basically looked like this..
public List<Prices> GetPrices(List<Product> products, int priceTypeId)
{
foreach (var item in products)
{
List<int> productIdsParameter = new List<int>();
productIdsParameter.Add(item.ProductID);
List<Price> prices = dataProvider.GetPrices(productIdsParameter, 0);
foreach (var price in prices)
{
if (price.PriceTypeID == priceTypeId)
{
prices = dataProvider.GetPrices(productIdsParameter, price.PriceTypeID);
return prices;
}
* Omitting the other 'WTF?' code to handle the zero price type
}
}
}
I removed the double stored procedure call, updated the method signature to only accept the list of product numbers (which it was before the 'major refactor'), deployed the service to dev (the issue was reproducible in our dev environment) and had the DBA monitor.
The two devs and the manager are grumbling and mocking the changes (they never looked, they assumed I wrote some threading monstrosity) then the DBA walks up..
DBA: "We're good. You hit the database pretty hard and the CPU never moved. Execution plans, locks, all good to go."
<dba starts to walk away>
DevMgr: "No fucking way! Putting that code in a thread wouldn't have fix it"
Me: "Um, I didn't use threads"
Dev1: "You had to. There was no way you made that code run faster without threads"
Dev2: "It runs fine in dev, but there is no way that level of threading will work in production with thousands of requests. I've got unit tests that prove our design is perfect."
Me: "I looked at what the code was doing and removed what it shouldn't be doing. That's it."
DBA: "If the database is happy with the changes, I'm happy. Good job. Get that service deployed tomorrow and lets move on"
Me: "You'll remove the recommendation for a complete re-write of the service?"
DevMgr: "Hell no! The re-write moves forward. This, whatever you did, changes nothing."
DBA: "Hell yes it does!! I've got too much on my plate already to play babysitter with you assholes. I'm done and no one on my team will waste any more time on this. Am I clear?"
Seeing the dev manager face turn red and the other two devs look completely dumbfounded was the most satisfying bug I've fixed.5 -
Ticket: Add <feature> to <thing>. It works in <other things> so just copy it over. Easy.
Thing: tangled, over-complicated mess.
Feature: tangled and broken, and winds much too deep to refactor. Gets an almost-right answer by doing lots of things that shouldn't work but somehow manage to.
I write a quick patch that avoids the decent into madness and duplicates the broken behavior in a simple way for consistency and ease of fixing later. I inform my boss of my findings and push the code.
He gets angry and mildly chews me out for it. During the code review, he calls my patch naive, and says the original feature is obviously not broken or convoluted. During the course of proving me wrong, he has trouble following it, and eventually finds out that it really is broken -- and refuses to admit i was right about any of it. I'm still in trouble for taking too long, doing it naively, and not doing it correctly.
He schedules a meeting with product to see if we should do it correctly. He tells product to say no. Product says no. He then tells me to duplicate the broken behavior. ... which I already did.
At this point I'm in trouble for:
1) Taking too long copying a simple feature over.
2) Showing said feature is not simple, but convoluted and broken.
3) Reimplementing the broken feature in a simpler way.
4) Not making my new implementation correct despite it not working anywhere else, and despite how that would be inconsistent.
Did everything right, still in the wrong.
Also, they decided I'm not allowed to fix the original, that it should stay broken, and that I should make sure it's broken here, too.
You just have to admire the sound reasoning and mutual respect on display. Best in class.19 -
I was only seventeen back then and I was a Java Developer Intern, not knowing much about enterprise oriented coding.
The project leader in our dev team saw a lot of potential and passion in my work, but was convinced I wasn't taught enough to do the right thing.
I was mainly doing shitty mappers and services back then, which were somewhat used but never lasted long and were ditched a few months later, which always bummed me out. I wanted to make an impact on REAL projects that would deploy into production.
So Mister Mentor (GDPR forbid to use the actual name), who was always first to come and last to leave the office, taught me what it means to code for real.
We stayed after 5pm until 7-8pm multiple times a week and he taught me in a deeply understanding and calm way how to:
- Git (SVN)
- Refactor
- SOA
- Annotate
- Deploy
- Unit Test
And most importantly:
- How to debug like an absolute BOSS
(We even debugged native Java Libraries just for fun to see if we could break them)
Fast-forward a month later and little intern me made his first commit on production.
Without Mister Mentor, I wouldn't be half as good of a developer as I am today.3 -
We were still using python 2.7 waaay into 2020 - It had been heralding the impending doom since 2018 and finally end-of-lifed in 2020.
That's when I finally managed to be the loudest asshole in the room and allocate a team (myself included) to refactor shit up to 3.6 (then somewhat more modern) for a month or so.
COVID the destroyer may have helped by wrecking havoc on our client's demands pipelines.
It was the third week into "the red sprint" when my entire team (myself included) were beheaded out of the company since we had "not delivered ANYTHING in weeks!" (emphasis in the original).
Frankly, being laid off was by a large margin the best thing that company ever did for me.
I heard from a poor schmuck who stayed behind that they were still using the shitty spaghetti code from before our refactoring - in freaking November 2021 - and that our entire last effort was thrown out because "nobody knows how to use it".
There is tech debt and there is tech bankruptcy.
I may have a lot of tech schadenfreude now :)13 -
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 -
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! :-D8
-
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 me1 -
That feeling when you refactor that spaghetti mess into clean beautiful code that passes all tests flawlessly4
-
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
-
Don't you just love it when upper Management people that never wrote a line of code in their life tell you, the software engineer peasant, to refactor all of your projects with Inclusive Terminology?
I mean I'll do it, the company is just protecting their image and money... But I blame the sick mind that came up with this in the first place.... It's implying that all sofware engineers are somehow racist and sexist and I'm somewhat offended by that notion. Whoever started this trend should seriously burn in hell.
P. S.
Apparently "the elderly" is also non-inclusive and should be referred to as "older adult"... What the fuck?
Do you not realize that you're just disassembling words and nothing else? Also "AIDS patient" should be referred to as "person living with AIDS"... Ok? Same fucking thing? If not even worse? At least "patient" kinda invokes that professional help is given... A person living with AIDS just implies you're infected and seeking no help...
You help no one with this non-issue bullshit. All your replacements will be deemed outdated and non-inclusive in the next 5 years again... Fucking hell... Waste of time and money19 -
I’m adding some fucking commas.
It should be trivial, right?
They’re fucking commas. Displayed on a fucking webpage. So fucking hard.
What the fuck is this even? Specifically, what fucking looney morons can write something so fucking complicated it requires following the code path through ten fucking files to see where something gets fucking defined!?
There are seriously so fucking many layers of abstraction that I can’t even tell where the bloody fucking amount transforms from a currency into a string. I’m digging so deep in the codebase now that any change here will break countless other areas. There’s no excuse for this shit.
I have two options:
A) I convert the resulting magically conjured string into a currency again (and of course lose the actual currency, e.g. usd, peso, etc.), or
B) Refactor the code to actually pass around the currency like it’s fucking intended to be, and convert to a string only when displaying. Like it’s fucking intended to be.
Impossible decision here.
If I pick (A) I get yelled at because it’s bloody wrong. “it’s already for display” they’ll say. Except it isn’t. And on top of that, the “legendary” devs who wrote this monstrosity just assumed the currency will always be in USD. If I’m the last person to touch this, I take the blame. Doesn’t matter that “legendary Mr. Apple dev” wrote it this way. (How do I know? It’s not the first time this shit has happened.) So invariably it’ll be up to me to fix anyway.
But if I pick (B) and fix it now, I’ll get yelled at for refactoring their wonderful code, for making this into too big of a problem (again), and for taking on something that’s “just too much for me.” Assholes. My après Taco Bell bathroom experiences look and smell better than this codebase. But seriously, only those two “legendary” devs get to do any real refactoring or make any architecture decisions — despite many of them being horribly flawed. No one else is even close to qualified… and “qualified” apparently means circle jerking it in Silicon Valley with the other better-than-everyone snobs, bragging about themselves and about one another. MojoJojo. “It was terrible, but it fucking worked! It fucking worked!” And “I can’t believe <blah> wanted to fix that thing. No way, this is a piece of history!” Go fuck yourselves.
So sorry I don’t fit in your stupid club.
Oh, and as an pointed, close-at-hand example of their wonderful code? This API call I’m adding commas to (it’s only used by the frontend) uses a json instance variable to store the total, errors, displayed versions of fees/charges (yes they differ because of course they do), etc. … except that variable isn’t even defined anywhere in the class. It’s defined three. fucking. abstraction. layers. in. THREE! AND. That wonderful piece of smelly garbage they’re so proud of can situationally modify all of the other related instance variables like the various charges and fees, so I can’t just keep the original currency around, or even expect the types to remain the same. It’s global variable hell all over again.
Such fucking wonderful code.
I fucking hate this codebase and I hate this fucking company. And I fucking. hate. them.7 -
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.4
-
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 -
Ok so this happend in the last 3 days, I didn't post it till now because I had to seriously take a rest with all the bullshit and stress that came with it...
(Legacy project I have the lead in called: "Foo")
Monday:
Management decided it would be effective to add a senior and a junior to Foo, which would make (together with me) to be 2 juniors and one senior developer
Well I've spend most of that day helping both the junior and the senior to setup "Foo" on their local development machines... So I could not do any programming myself
tuesday:
The senior wanted to refactor EVERYTHING... and I had to stop him multiple times because we simply do not have the time to do that...
The junior tried to work on other things as much as he could, and after he had run out of things to do, asked me for EVERYTHING... EVEN WHERE TO FUCKING CHANGE SOME GOD DAMN STRINGS!....
Also he did in total 3 commits, two of which existed of my code (because I had to "help" him
wednesday:
Both the junior and senior were removed from the project and I got another senior.. who fucking deleted the production database on accident
god damn rough few days man...7 -
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.. :)7
-
So a company I'm working at has this internal product. I just got employed and was put into that team.
"First task: refactor some of the code"
Alright, I start refactoring. Oh I may need to write a small class for this one. And then rewrite this a bit. And then rewrite that a bit. And then rewrite everything.
"Why are you rewriting most of my code?"
oh i would not have needed to do so if your code was not COMING OUT OF YOUR ASS and if all the teams had FREAKING PROPER API DOCUMENTATION9 -
I have to refactor code from an intern. He's VERY lucky that he already left the company.
If I'd say he programms like the first human that would be very insulting to that first human.
It looks like code at first sight, but when you try to understand what he was doing to achieve his goal you get a brainfuck. Duplicate code, unused code, dumb variable names like blRszN.
He wrote unittests like "expects Exception to be thrown or Server returns Statuscode 500".
Yes, Exception, the generic one.
THESE FUCKING TESTS ARE GREEN BECAUSE YOU DID NOT ACTUALLY TEST SOMETHING.
GREEN IN THIS CONTEXT MEANS: YOUR PRODUCTION CODE IS A BIG PILE OF SHIT.
I already removed 2 bugs in a test which caused another exception than the "expected" one and the test does still not reach the actual method under test.
Dumb fucktard.
The sad thing: The fuckers who did the code reviews and let this shit pass are still here writing code.4 -
001 REM Code review
010 PRINT "Nitpick nitpick nitpick nitpick nitpick"
011 GOSUB REFACTOR
020 PRINT "This function is too complicated, break it up"
021 GOSUB REFACTOR
030 PRINT "Why do you have three methods for this? Put all the logic in one method."
031 GOSUB REFACTOR
040 GOTO 020
041 REM ARGH
998 PRINT "Looks good."
999 STOP8 -
"I'm almost done, I'll just need to add tests!"
Booom! You did it, that was a nuke going off in my head.
No, you shouldn't just need to add tests. The tests should have been written from the get go! You most likely won't cover all the cases. You won't know if adding the tests will break your feature, as you had none, as you refactor your untested mess in order to make your code testable.
When reading your mess of a test case and the painful mocking process you went through, I silently cry out into the void: "Why oh why!? All of this suffering could have been avoided!"
Since most of the time, your mocking pain boils down to not understanding what your "unit" in your "unit test" should be.
So let it be said:
- If you want to build a parser for an XML file, then just write a function / class whose *only* purpose is: parse the XML file, return a value object. That's it. Nothing more, nothing less.
- If you want to build a parser for an XML file, it MUST NOT: download a zip, extract that zip, merge all those files to one big file, parse that big file, talk to some other random APIs as a side-effect, and then return a value object.
Because then you suddenly have to mock away a http service and deal with zip files in your test cases.
The http util of your programming language will most likely work. Your unzip library will most likely work. So just assume it working. There are valid use cases where you want to make sure you acutally send a request and get a response, yet I am talking unit test here only.
In the scope of a class, keep the public methods to a reasonable minimum. As for each public method you shall at least create one test case. If you ever have the feeling "I want to test that private method" replace that statement in your head with: "I should extract that functionality to a new class where that method public. I then can create a unit test case a for that." That new service then becomes a dependency in your current service. Problem solved.
Also, mocking away dependencies should a simple process. If your mocking process fills half the screen, your test setup is overly complicated and your class is doing too much.
That's why I currently dig functional programming so much. When you build pure functions without side effects, unit tests are easy to write. Yet you can apply pure functions to OOP as well (to a degree). Embrace immutability.
Sidenote:
It's really not helpful that a lot of developers don't understand the difference between unit, functional acceptance, integration testing. Then they wonder why they can't test something easily, write overly complex test cases, until someone points out to them: No, in the scope of unit tests, we don't need to test our persistance layer. We just assume that it works. We should only test our businsess logic. You know: "Assuming that I get that response from the database, I expect that to happen." You don't need a test db, make a real query against that, in order to test that. (That still is a valid thing to do. Yet not in the scope of unit tests.)rant developer unit test test testing fp oop writing tests get your shit together unit testing unit tests8 -
# main.py
# 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 -
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!5 -
Hey I got reminded of a funny story.
A friend of mine and me were in internships in the same company. The company was specialized in territory resources management (managing water for agriculture, money to build industrial zones...). He got the interesting internship (water predictory modeling) and I got... The repairs of a reference sheet manager that never happened to work. It was in C# and ASP.NET and I was in second year of CS. I expected the code to be nice and clear since it was made by a just graduated engineer with +5years of studies.
I was very wrong.
This guy may never have touched a web server in his life, used static variables to keep sessions instead of... well... sessions, did code everything in the pages event handlers (even LinQ stuff et al) and I was told to make it maintainable, efficient and functional in 2 months. There were files with +32k LoC.
After 1week of immense despair, I decided I will refactor all the code. Make nice classes, mapping layer, something close to a MVC... So I lost time and got scoled for not being able to make all the modifications as fast as in a cleanly designed code...
After 4 weeks, everything was refactored and I got to wait for the design sheets to change some crystal report views.
At this moment I began to understand were was the problem in this company.
My friend next door got asked to stop his modeling stuff for an emergency project. He had to make an XML converter for our clients to be able to send decentralized electrics bills, and if it was not completed within a week, they would no longer be able to pay until it is done.
This XML converter was a project scheduled 5 years before that. Nobody wanted to do it.
At the same time, I was waiting for the Com Department to give me the design views.
I never saw the design views. Spent one month implementing a golden ratio calculator with arbitrary precision because they ain't give me anything to do until the design were implemented.
Ended with a poor grade because "the work wasn't finished".2 -
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 -
Dev: Ok refactor this following block of code to make it more readable/maintainable while still ensuring the tests pass
*** Block is an absolute mess of nested ternaries, poorly named functions, single letter variables and outdated comments. An underhand pitch if there ever was one ***
Interview Candidate: Why would you refactor code if the tests are already passing?
Dev: …… NEXT.7 -
This is something I'll never forget.
I'm a senior UI engineer. I was working at a digital agency at the time and got tasked with refactoring and improving an existing interface from a well known delivery company.
I open the code and what do I find? Indentation. But not in the normal sense. The indentation only went forward, randomly returning a bunch of tabs back in the middle of the file a few times, but never returning to its initial level after closing a tag or function, both on HTML and JS.
Let that sink in for a minute and try to imagine what it does to your editor with word wrapping (1 letter columns), and without (absurd horizontal scrolling).
Using Sublime at the time, ctrl+shift+P, reindent. Everything magically falls beautifully into place. Refactor the application, clean up the code, document it, package it and send it back (zip files as they didn't want to provide version control access, yay).
The next day, we get a very angry call from the client saying that their team is completely lost. I prove to the project manager that my code is up to scratch, running fine, no errors, tested, good performance. He returns to the client and proves that it's all correct (good PM with decent tech knowledge).
The client responds with "Yeah, the code is running, but our team uses tabs for version control and now we lost all versioning!".
Bear in mind this was in 2012, git was around for 7 years then, and SVN and Mercury much longer.
I then finally understood the randomness of the tabs. The code would go a bunch of tabs back when it went back to a previous version, everything above were additions or modifications that joined seamlessly with the previous version before, with no way to know when and so on.
I immediately told the PM that was absurd, he agreed, and told the client we wouldn't be reindenting everything back for them according to the original file.
All in all, it wasn't a bad experience due to a competent PM, but it left a bad taste in my mouth to know companies have teams that are that incompetent, and that no one thought to stop and say "hey, this may cause issues down the line".4 -
I'm coming off a lengthy staff augmentation assignment awful enough that I feel like I need to be rehabilitated to convince myself that I even want to be a software developer.
They needed someone who does .NET. It turns out what they meant was someone to copy and paste massive amounts of code that their EA calls a "framework." Just copy and paste this entire repo, make a whole ton of tweaks that for whatever reason never make their way back into the "template," and then make a few edits for some specific functionality. And then repeat. And repeat. Over a dozen times.
The code is unbelievable. Everything is stacked into giant classes that inherit from each other. There's no dependency inversion. The classes have default constructors with a comment "for unit testing" and then the "real" code uses a different one.
It's full of projects, classes, and methods with weird names that don't do anything. The class and method names sound like they mean something but don't. So after a dozen times I tried to refactor, and the EA threw a hissy fit. Deleting dead code, reducing three levels of inheritance to a simple class, and renaming stuff to indicate what it does are all violations of "standards." I had to go back to the template and start over.
This guy actually recorded a video of himself giving developers instructions on how to copy and paste his awful code.
Then he randomly invents new "standards." A class that reads messages from a queue and processes them shouldn't process them anymore. It should read them and put them in another queue, and then we add more complication by reading from that queue. The reason? We might want to use the original queue for something else one day. I'm pretty sure rewriting working code to meet requirements no one has is as close as you can get to the opposite of Agile.
I fixed some major bugs during my refactor, and missed one the second time after I started over. So stuff actually broke in production because I took points off the board and "fixed" what worked to add back in dead code, variables that aren't used, etc.
In the process, I asked the EA how he wanted me to do this stuff, because I know that he makes up "standards" on the fly and whatever I do may or may not be what he was imagining. We had a tight deadline and I didn't really have time to guess, read his mind, get it wrong, and start over. So we scheduled an hour for him to show me what he wanted.
He said it would take fifteen minutes. He used the first fifteen insisting that he would not explain what he wanted, and besides he didn't remember how all of the code he wrote worked anyway so I would just have to spend more time studying his masterpiece and stepping through it in the debugger.
Being accountable to my team, I insisted that we needed to spend the scheduled hour on him actually explaining what he wanted. He started yelling and hung up. I had to explain to management that I could figure out how to make his "framework" work, but it would take longer and there was no guarantee that when it was done it would magically converge on whatever he was imagining. We totally blew that deadline.
When the .NET work was done, I got sucked into another part of the same project where they were writing massive 500 line SQL stored procedures that no one could understand. They would write a dozen before sending any to QA, then find out that there was a scenario or two not accounted for, and rewrite them all. And repeat. And repeat. Eventually it consisted of, one again, copying and pasting existing procedures into new ones.
At one point one dev asked me to help him test his procedure. I said sure, tell me the scenarios for which I needed to test. He didn't know. My question was the equivalent of asking, "Tell me what you think your code does," and he couldn't answer it. If the guy who wrote it doesn't know what it does right after he wrote it and you certainly can't tell by reading it, and there's dozens of these procedures, all the same but slightly different, how is anyone ever going to read them in a month or a year? What happens when someone needs to change them? What happens when someone finds another defect, and there are going to be a ton of them?
It's a nightmare. Why interview me with all sorts of questions about my dev skills if the plan is to have me copy and paste stuff and carefully avoid applying anything that I know?
The people are all nice except for their evil XEB (Xenophobe Expert Beginner) EA who has no business writing a line of code, ever, and certainly shouldn't be reviewing it.
I've tried to keep my sanity by answering stackoverflow questions once in a while and sometimes turning evil things I was forced to do into constructive blog posts to which I cannot link to preserve my anonymity. I feel like I've taken a six-month detour from software development to shovel crap. Never again. Lesson learned. Next time they're not interviewing me. I'm interviewing them. I'm a professional.9 -
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 -
FML, I hate projects where managers (and other developers, too!) irrationally think that the only thing to do in the codebase is delivering new features and fulfilling change requests.
After 5 years of such approach, the code is bloated, and has hack-on-hack done against the original architecture, and management complains on the time to delivery a change, however asking them to get some time to "refactor" meets a deny every single fucking time because "we don't have budget".
Decided to leave the team. Any reason to stay there longer?7 -
Sometimes I really fucking hate this company
The code is an absolute shitshow filled with static classes, untestable and duplicate code, on top of that my boss doesn’t like open source
Yeah so i’m not allowed to use a mapping library or something because “Uhhh like uhh we don’t have a contract with the company so who knows what’ll happen when the maintainers leave the project”
I understand his reasoning but it’s an absolutely retarded reasoning especially considering most of the .NET platform is open source nowadays
Writing a webapp from scratch now as well and I HAVE to use vanilla javascript and AngularJS 1.5 even though all the developers here told me they would like to upgrade to Typescript and Angular 2+ but it’s never gonna happen I suppose
Oh and he doesn’t like TDD and our only product is SAAS so imagine the amount of bugs being pushed simply because we don’t have time to write tests or even manually test, let alone refactor our horseshit codebase
AND i have to pay for gas myself which takes 200€ out of my bank account a month just for driving to work whilst I’m only getting a mediocre pay
Have a job interview tomorrow and another one on tuesday4 -
Anyone else work in a codebase that is so deeply convoluted, that the only way to make new features work is to write new code in a similarly convoluted way?
Everyone wants to refactor our system, but we're a small shop with an insane amount of technical debt, so it likely won't happen for a long time. Any suggestions in the meantime? I feel like I'm spending more time figuring out how to make something work in our system then learning actual good practices.6 -
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
5. Repeat2 -
At my current project we use SVN, but today I noticed a colleague of mine uses another version of version control as well.
Example:
V1:
console.log('Hello, world!');
V2:
//console.log('Hello, world!');
document.write('Hello, World!');
V3:
//console.log('Hello, world!');
window.alert('Hello, world!');
//document.write('Hello, World!');
Every singletime Ive to remove 40 lines of comments before Im able to follow the code and refactor it.2 -
I’ve become the person who I said I’d never be. Writing spaghetti code in spaghetti project instead of trying to refactor methods and classes where I’m adding new features.
Welp. They want it “yesterday” , they’ll have it yesterday.
But hey, the money’s good.8 -
!rant
Just started working for a new company. Super cool. Just like the last one (as far as perks), except they actually trust their devs.
Old company: Make sure your code is extensible
Devs at old company: You know it's not written in stone right?
Old company: Does that mean you can make it do this?
Devs at old company: No. That's the wrong code base
New company: I need a feature. Get it done when you can
New company devs: Well, guess I'll take some time to refactor all this stuff while I'm at it
~Some time later~
New company: Thanks, that feature works great!
No staring over shoulders, asking when it will be done. No asking why we want to refactor something. As long as work continues to flow, there are no issues. It's great!
Also, if we want to try a new tech, we just have to put together a short paper explaining why it will work better in that situation than the tech that's already in place. -
I've been so pissed off so many times, I thought I should divide them into categories.
- Pissed off at a fellow dev: I told him to use a constant instead of a hardcoded number.
He changed this: obj.method(3);
to this:
public static final int three = 3;
obj.method(three);
- Pissed off at management: I once got a $10 yearly raise.
- Pissed off at a client: They rejected our design proposal because the text was in spanish and they didn't speak spanish. It was lorem ipsum text.
- Pissed off at code: I once had to refactor a 500 line legacy jsp script with HTML, CSS, JS and Java completely intertwined.
- Pissed off at Twitter: They changed their API the day of our go-live, breaking all of their widgets, forcing us to move the go-live date and making me work an additional 8 hours after a week with almost no breaks.
- Pissed off at travel and logistics: They sent me to a hotel in Mexico City 2.5 hours away from the client's office.
Fun times...1 -
Did anyone of you worked for a company where:
- there was a financial success
- code was clean and was enabler for fast delivery
- tests were professional
- CI/CD pipeline was working as expected
- features were developed in small chunks (few PRs per day)
- managers were trustful and were solving real issues to help you
- refactor was part of the everyday development
Is it even possible? Is there at least one company who achieved success doing the above?13 -
Read the following in Morgan Freeman’s voice.
Okay everyone sit on down and get ready for story time. There once was a workspace that was a pain in the ass to setup. It often would take an entire day even for the most experienced devs on the team...for it was a workspace perched atop a swamp of shit that would require a whole year to refactor into something that isn’t shit.
It was inherited, passed down, stepped in and scrapped from the boot soles of every programmer that ever touched it. It was an amalgam of old, new, and third party components with a class path a mile long and no package management because the company although physically in the present, somehow maintained a temporal presence in the past. And there was nothing that the team hated more than setting that workspace. In short it was an unholy mess that made Satan cry and Dennis Ritchie spin in his grave so much that the state of California attached magnets and a coil to his body and casket to generate electricity.
Then one day the untalented clowns known as App Group decided that our IDE should be owned and configured strictly through them. They took poor Eclipse and mounted so much silly shit to it that it resembled a riding lawn mower with a fax machine and a blender duct taped to it. Eventually as everything the company touched did, it simply turned into a broken, shitty mess that not even Jesus Titty Fucking Christ could bring back the dead.
And then, every month or so the IDE would break in such a grand way that every developer had to rebuild their workspace...the very same Lovecraftian monster disguised as a code base. It was just too much to bear for old Deus. He was all out of fucks and there wasn’t enough alcohol in the world to quiet his injured soul. So he stood on a chair, carved his name in a rafter and tied a noose to it, put it around his neck and finally kicked the chair out from under himself. I am told he even pooped his pants and the post mortem shit in the seat of his pants was still better than the codebase at work. I’m Morgan Freeman. -
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 -
Wrote a feature that took a week plus to complete that was reviewed, approved, merged and already in production.
Guy who approved comes in and says to make changes now with 1 day to end of sprint saying to refactor stuff. It won't make a difference other than some logging changes but I found the effort to be large plus the QA would need to retest everything.
When I brought up my concern, he tells me it is very easy and to get it done.
Now am feeling so stuck rushing on this work cos he called it 'easy' and I don't want to look like a fool...
Why review and approve code only to come back last minute asking for changes.. Not the first time and always last minute followed by calling it easy. I am almost forming a phobia to merge approved code..4 -
Time to do a little bit of shaming:
I'm specialized in e-commerce applications, mostly based on Shopware, a german out-of-the-box online-shop. They essentially claim to be a better Magento. In December of last year I found a critical issue within the code. Products within the shop can be declared as digital wares. In that case the purchase of a product will unlock the possibility to download a designated file.
As a customer you can access your downloads within the account section. Now here's the problem: The query that fetches the unlocked downloads for a customer is hard-capped at 500 rows. So after your 500th purchase, you won't be able to access any further files you paid for. Essentially their developers thought that this limit would never be exceeded anyway and called it a day.
Personally I think this unacceptable. For the merchant this is a potential law-suit in the making. So I took the time to refactor the code and fix the issue. The corresponding pull-request was flagged as scheduled back in December. Since then there have been numerous releases and the issue is still present. Not only do I ask myself why I should ever put in time and effort to fix their code again, but I also can't believe that they just chose to ignore the issue completely. Also mind that this is not just a small or non-profit open-source project. The responsible company behind the software is a stock corporation that claims to be the market leader in Germany.5 -
Everyone is on their vacation and I am in good mood so time to refactor some 3 year old frontend, angular, javascript code. After 5 minutes of looking, some great quality of code snippet on the image below.10
-
Got a simple task
Decided to refactor some related shit so I don't have duplicated code
Get loads of problems with the shit I'm trying to refactor, now I'm late with the simple task13 -
God fucking dammit why are people so fucking lazy? A couple months ago I've had the intern refactor and organise this coworker's spaghetti code, and he did an excellent job, added type safety, etc.
I've took special care to explain it to this coworker that I understand he didn't have time to organise code and the intern took care of it, and to please keep it clean from now on.
Today I had to add a small feature to the same codebase, and every single thing that fucktard added from then on was crammed in the same file. And that guy's been here for 5 years already, I thought I don't have to triple check every single line he writes by now...5 -
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.4
-
Question time:
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.😭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 -
Why are people complaining about debugging?
Oooh it’s so hard.
It’s so boring.
Can someone do this for me?
I honestly enjoy debugging and you should too..
if it’s not your code, you’ll get to understand the code better than the actual author. You’ll notice design improvements and that some of the code is not even needed. YOU LEARN!
If it’s your own code (I especially enjoy debugging my own code): it forces you to look at the problem from a different perspective. It makes you aware of potential other bugs your current solution might cause. Again, it makes you aware of flaws in the design. YOU LEARN!
And in either case, if it’s a tricky case, you’ll most likely stop debugging at some point, refactor the shit out of some 50-100 line methods and modulize it because the original code was undebuggable (<- made up a new word there) and continue debugging after that.
So many things I know, I know only because I spend days, sometimes even weeks debugging a piece code to find the fucking problem.
My main language is java and i wouldn’t have believed anyone who told me there’s a memory leak in my code. I mean, it’s java, right? We refactored the code and everything worked fine again. But I debugged the old version anyway and found bugs in Java (java 6.xx I believe?) which made me aware of the fact that languages have flaws as well.. GC has its flaws as well. So does docker and any other software..
Stop complaining, get on your ass and debug the shit out of your bugs instead of just writing it in a different way and being glad that it fixed the issue..
My opinion.3 -
Some people refactor because feature updates need to be optimized throughout the code base.
I refactor because I am terrible at planning.3 -
Over the past week I've been working on a game written in JavaScript (in the browser) which can be played with hand gestures seen by a camera (wanted to use an IR camera but couldn't get one in the time I had). It is the well-know Shell Game!
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!4 -
re·fucked·or
[rəˈfəktˈôr]
VERB
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 -
I've started programming when I was 12. Right now I'm 25. I can clearly say that I'm passionate, I've touched I think almost every "type" of programming ever. From game development, through IoT and finished at eCommerce. I never stop learning.
My workmates are pissing me off. For code review sometimes I'm waiting even 3 days when I've changed like 5-6 files. They don't want to introduce "new" technologies (by new I mean who are existing at least 2-3 years, got stable community). They don't want to refactor some core of the application because it's working - they don't care about it as they can later say "legacy system so this basic feature took me a week".
Code quality means for them "use shorthand syntax, this code is ugly" - the basic shit which can do any linter
When I'm doing code review, I'm checking out to this branch, test it, check if the solution is scalable. Then I make my comments. I just hear "stop bitching about it just approve".
Thank God I've made through interview and I'm going to switch job in next week.7 -
Engineering managers will say things like -
- "I'll let the team decide what's best for them" & "code quality is our primary goal" -
but then they'll shoot down any & all requests to go back to some old piece of code and refactor/clean it, because of "deadlines".
Hypocrites, all of them.3 -
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!!!
What!!!
Please guys if you refactor do it right or don't do it at all. Have a nice day9 -
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
-
Our company is cheap, cheap as fuck. We have to use some third-party platforms and every year they choose something that is slightly cheaper than the other. (like a few $ per annual), they do not know that we have to refactor our code at the backend because the changes of the platform.
It doesn't end there, they even look for devs from third world countries to work for them remotely instead of hiring permanent staff (I understand it is cheaper because of currency difference and etc), but what about the training period or to let them become comfortable with the existing system, even when he/she is a genius... it takes time to be productive at work.
The worst part is they dont give a shit, they think devs can be replaced easily just like some construction workers carrying stuffs on site (no offence to them), management treating people like shit and doesn't care when they leave.2 -
I just installed Opera Mini on my PSP. That alone isn't very exciting on its own, although I am stoked that my website does in fact render on a device from 2009. With the helpful guidance of a laptop from 2004 that's doing the hotspot duties for this thing.
No, what really got me stoked is that Opera still supports these old platforms, and how small they managed to make it. The .jar file for Opera Mini 4.5 is ~800kB large. There's a .jad file as well but it's negligible in size and seems to be a signature of sorts.
Let that sink in for a moment. This entire web browser is 800kB. Firefox meanwhile consistently consumes 800 MEGABYTES.. in MEMORY. So then, I went to think for a moment, how on earth did they manage to cram an entire functioning web browser in 800kB? Hell, what makes up a web browser anyway?
The answer to that question I got to is as follows. You need an engine to render the web page you receive. You need a UI to make the browser look nice. And finally you need a certificate store to know which TLS certificates to trust. And while probably difficult to make, I think it should be possible to do in 800k. Seriously, think about it. How would you go *make* a web browser? Because I've already done that in the past.
Earlier I heard that you need graphics, audio, wasm, yada yada backends too.. no. Give your head a shake. Graphics are the responsibility of the graphics driver. A web browser shouldn't dabble with those at all. Audio, you connect to PulseAudio (in Linux at least) and you're done. Hell I don't even care about ALSA or OSS here. You just connect to the stuff that does that job for you. And WebAssembly.. God I could rant about that shit all day. How about making it a native application? Not like actual Assembly is used for BIOS and low-level drivers. And that we already have a better language for the more portable stuff called C.
Seriously, think about it. Opera - a reputable browser vendor - managed to do it in 800kB on a 12 year old device. Don't go full wank on your framework shit on the comments. And don't you fucking dare to tell me that there's more to it. They did it for crying out loud. Now you take a look at your shitpile for JS code and refactor that shit already. Thank you.21 -
I got a project to "refactor" some shitty site. It was written in nativ php. The guy who wrote this is a moron.
The site is so unsecure that my dog could broke into it while barking at cats.
It's sooo unreadable and illogical.
Every time i look at the code i get sadder and sadder. And now i understand why so many people hate php..
**Jump in time**
After i planned the new logic. My boss told me i can't do any of this. Because they only need a new user lever..
Now i just stare at this pile of horse sh*t and rant about it.4 -
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
-
Fucking people, why the hell are you reading into things instead of asking for clarification if something is unclear?
So much time, sweat and tears wasted on miscommunication.
When I said, "there might be a problem in the way component X method Y was implemented", i didnt mean go refactor the entire code of the component. Why waste 2 days of work on unnecessary refactor that nobody wanted and breaks changes + the bug is not fully fixed 😤13 -
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?)..1 -
Do you think refactoring code adds value?
Pick one:
1. Hard No (Only refactor when there is a dollar value associated with it, i.e new feature depends on it).
2. Somewhat Yes (Futureproof your code, anticipate easiness to build feature requested in future).
3. Yes (Developer happiness, retention and for point 2)27 -
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 -
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
-
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 -
My new co-worker is extremely stressing. I have to give small tasks so he won't forget to do anything. I also have to explain what he has to do in detail, give him the full solution, and show him exactly how he has to do it.
And he has no idea how to use git. He makes a feature branch and pushes all his various, half-finished features into it and makes a pull request.
And then I still have to refactor his crappy code everytime cause he uses variables like $data, $accA, $accB, $accZ and forgets to use the definied color variables in sass.
I literally have to do my work and his as well -_-6 -
Sorry, long since my last post...
I have quit my job recently at DERP & CO.. The level of anxiety was already somewhat of medical severity.
For months I had been in a project that not only did not progress, but that it was getting worst day by day.
A bit of Context
November: "Dev, junior anon needs you to help him on the SHIT project because they are running out of time, it is mainly doing unit tests."
Well, the code was a mess, there was a LOT of copy paste and it was all bad quality (we talk about methods with complexities between 80 and 120 according to SONAR QUBE).
Dev: "Anon, you know this is wrong, right?"
Anon: "Why? it works"
Dev: after long explanation.
Anon: "Oh well, yes, from now on I will take it into account." And he did it / try his best.
Dev does the unit tests and do extra work outside of the reach of the sprint (y than i mean work after hours, classic) and alerts the boss of the mess.
December: After a project of approximately 6 or 8 months of development, the boss discovers that the junior anon have been doing everything wrong and/or with poor quality (indicating that throughout the whole development the quality of the code was NEVER checked nor the functionality).
Boss: "This is a shit. Dev, you have to correct all the errors and warnings marked on sonar", which are around 1200 between smelling code, high risk errors, etc.
Dev fixes something like 900 bugs... lots of hours...
Boss: "This still is all wrong, we have to redo it. We will correct the errors leaving something stable and we will make a new repository with everything programmed as it should be, with quality and all"
- 900 corrections later, now are irrelevant -
Boss: "Dev, you will start to redo it, anon is out on other project. First you must leave the existing one working properly"
Dev: "ok ..."
January: How can I correct the mess if the client asks for more things. I am just fixing the mess, doing new functionalities, and when I have free time (outside the work) I try to advance the new repository, poorly I must say because burntout.
Boss: "Everything should be arranged at the end of January, so that you can redo everything well in February."
I can't handle everything, it starts to fall further behind. Junior Anon quits the job.
February: Big Bad Bugs in the code appear and practically monopolize the month (the code is very coupled with itself and touching in one place sometimes meant breaking other stuff).
Boss: "It can't be, you've been with this since January and you haven't even started correcting this mess in the new repo"
Dev: "It is that between the new things that are requested and the bugs I cannot put myself with that"
Boss: "Do not worry, you will be helped by random dev if you needed. SPOILER ALERT: random dev is allways bussy. Not made up bussy, He had a lot of work by itself, but it can't help me the way I need it.
High anxiety levels, using free time to try to reduce the work left and gradually losing the taste for develop.
March: So far, not only do they add new things day and day, but now they want to modify things that were already "ok", add new ones and refactor everything in a new repo. I just did not see an end of this nonsense.
Dev breaks, the doctor says it's anxiety, so I just know what I have to do.
Dev: "I quit my job"
Cool Manager: "Damn, why?"
Explain everithig
Cool Manager: "Do you want to try if I can change you to other project or anotjer scope on the same project?"
Dev: "Thanks, but no Thanks. I need to stop for a while".
End. sry for long sad post and maybe poor use of English (?) Not my native language.10 -
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 scale5
-
Einstein supposedly has a quote attributed to him: "Perfection isn't achieved when there is nothing left to add, but when there is nothing left to remove."
I find that I aggressively refactor code where I can to only what is absolutely required. It does also have the knock on effect of reducing scope of bugs, when the code is smaller there's only so many places bugs can be.
Tesla claimed to have the ability to create designs in his head and only built things once he was satisfied that it worked in theory first, now it's rare I can do that, but I will use a repl to prototype or test modules in isolation before just hacking on the actual code.
Jobs, I mean, I know he didn't code but he was always insisting on designs that looked good and was generally uncompromising in his design centric view.
My friend, she was my Starbucks barista for a while but I've slowly been teaching her code and she's taught me a lot about how to teach others to code, she also happens to be my favourite student.3 -
I am just sick of the things that's been going on.
Joined a mid level startup as full Stack developer working on angular and node js . Code base is too shit and application is full of bugs(100+ tickets are being raised for bugs)
Since the product owner(PO) wants to demo the application he is pushing for bug fixes.
UI code:
1. Application is not handled for responsiveness all these years, it is now being trying to address. Code base is very huge to address though .
2. The common reusable components of UI has business logic inside. Any small change in business logic we are forced to handle in common components which might break up on another components.
3. Styling in 40+ components are made global. Small css change in component A is breaking up in component B due to this
4. No time to refactor.
5. Application not at all tested properly all these years. PO wants a stable build.
6. More importantly most of developers have already left the company and we are left with 2 developers including me.
I am not in a position to switch due to other commitments adds up a lot to frustration11 -
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
-
My lessons both come from my current side project (I will share it with you in a week or two, the website isn't finished yet):
1. Every project comes to the point where it hurts to continue. Keep pushing, the result is worth it.
2. You aren't as good as you thought you were when you started, but you'll be better than you ever were when you finish.
3. Sometimes, there's more points to a list than you'd expect.
4. One hour per day is easier than five hours a week.
How?
Well. I started out my project knowing some C#, but Jack shit about unity. I know most of what I might build will end up being shit I'm gonna regret, refactor and recycle later. But I don't give a fuck. Doing it is better than planning it.
It sometimes hurts to get rid of a carefully planned algorithm that took hours to build because it fails in practice. But it's the right thing to do.
Never plan too much. If I'd have planned this project out, I wouldn't even have started with what I'm good at: write code, break shit and experiment.
It's easier to progress slowly but steady. Look at some awesome games that have been worked on for ages while the public had their say (RimWorld, Project Zomboid, Dwarf Fortress...) as opposed to those that are developed behind closed doors and rushed to the market before Christmas or some other major event (Mafia 3, Fallout 76, Fallout 4 VR...). Progress slowly, deploy early, push often. And the one hour per day approach is a good way to do this. -
Whelp. I started making a very simple website with a single-page design, which I intended to use for managing my own personal knowledge on a particular subject matter, with some basic categorization features and a simple rich text editor for entering data. Partly as an exercise in web development, and partly due to not being happy with existing options out there. All was going well...
...and then feature creep happened. Now I have implemented support for multiple users with different access levels; user profiles; encrypted login system (and encrypted cookies that contain no sensitive data lol) and session handling according to (perceived) best practices; secure password recovery; user-management interface for admins; public, private and group-based sections with multiple categories and posts in each category that can be sorted by sort order value or drag and drop; custom user-created groups where they can give other users access to their sections; notifications; context menus for everything; post & user flagging system, moderation queue and support system; post revisions with comparison between different revisions; support for mobile devices and touch/swipe gestures to open/close menus or navigate between posts; easily extendible css themes with two different dark themes and one ugly as heck light theme; lazy loading of images in posts that won't load until you actually open them; auto-saving of posts in case of browser crash or accidental navigation away from page; plus various other small stuff like syntax highlighting for code, internal post linking, favouriting of posts, free-text filter, no-javascript mode, invitation system, secure (yeah right) image uploading, post-locking...
On my TODO-list: Comment and/or upvote system, spoiler tag, GDPR compliance (if I ever launch it haha), data-limits, a simple user action log for admins/moderators, overall improved security measures, refactor various controllers, clean up the code...
It STILL uses a single-page design, and the amount of feature requests (and bugs) added to my Trello board increases exponentially with every passing week. No other living person has seen the website yet, and at the pace I'm going, humanity will have gone through at least one major extinction event before I consider it "done" enough to show anyone.
help4 -
Had to make a change in an ugly codebase. For this I had to change a config value which was duplicated three times in the code base. So I wanted to refactor the code so that the config was in one place.
I worked on this for two days and it was starting to look good. On the third day when I started to work on this I realized that I couldn't start the server anymore. Looking through version control I figure out that my co-worker had stayed till 3am last night to work on the change I was supposed to make.
I had to spend all morning undoing his commits. Once I was done refactoring the actual change took me ten minutes.
Why the fuck would you stay until the middle of the night to work on someone else's task?!
Could have just asked how it was coming along if I wasn't working fast enough for him.2 -
Ever been tasked with a modification, you see the code and think WTF??!!!??
Yes it was me who wrote it, what was I thinking? So I going to have to refactor this rubbish, so I set about tidying it up and realise that this is far more complex than I remember. When I finally get to grips with every aspect of it, I come to the conclusion that actually this is quite clever.
Straight up removed the changes, walked away from the original code and got on with what I was supposed to be doing to start with. Oh well, guess I got to grips with something I had forgotten.3 -
Todays story: conversation between me and my brain about a app that i have planned for a long while.
The application is just a huge, specyfic json editor/manager for a game that i like. The game uses json files to determine unit charactetistics. So in order to make modding easier i want to make a tool for that that is fancier and easier to use than a notepad.
Brain> Lets make a app that allows you to mod the game easier!
Me> Good idea. How would you want to make it?
Brain> Lets use C# cause you main that lang currently and you have experience with json parser lib.
Me> That is true. So what do you wanna implement first?
Brain> Oh. I have thought about it before! I want to implement: (10 000 features) and maybe few more later!
Me> It sounds like a infinity project, shouldnt you implement like 1 or 2 features at first and then jump to other ones?
Brain> Yes... but i dont wanna refactor those features latter so let just implement them all at once!
Me> Dammit brain! Let just implement just one feature now! Like a simple json editor. You can use inhieritance to reuse the code later.
Brain> Ok...
* Starts with that one feature but one day later starts coding 6 more *
* Cant publish the app yet, the code looks like shit, gui is unfinished because brain wanted only to test those 6 unfinished features without propely implementing them *
Me> Brain WTF! You said that you are going to focus on one feature at the time!
Brain> I got carried a bit...
Me> ...
Me> Ok. I understand. Let just refactor the code and clean the project out of those unfinished features.
Brain> No. I have a depression now...
Me> FUCK.
* 2 month passes by without any progress on ANY of my projects*
current day
Brain> I still have depression...
Me> Ok i dont care about that anymore! Tell me something that i dont know!
Brain> Oh I have good news as well!
Me> ???
Brain> What about the home server that is going to store all mods made by the users so they can share it? It would be a good practice with networking!
Me> * Gives up *1 -
Writing css is still better than having to refactor angular code.
aaaaarrrrrgggghhhhhhhhhh.
#whatamess6 -
!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.
Good guy!
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. -
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
-
In flutter , there’s something called TextButton.icon. Which render a button look like this :
(👍🏼 Like Button)
But there’s this tiny twat decided to use countless of nested column in a nested row and containers just to create a fucking button! This particular class contains 1438 lines of code! Most of the code are redundant and nested fucking shit.
I want to punch this guy so hard but I do not intend to start a ww3 with china.
That means I have no choice but refactor it as I implement a feature requested by the product team, every components break. It is like a land mine field here. One changes , the entire application crash.
So there are useless mother fucking Sherlock fucking holmes kept telling me that “don’t worry about refactoring now , just complete the task.” , like seriously “how in the name of mother fucking god of all arseholes can I complete my task when I can’t change even one component?”
These people are fucking genius. Their intelligence resurrected Einstein and made him die the second time.3 -
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
-
I am going to create a define in my code:
#define BIT_CH CHAR_BIT
Then do search replace of CHAR_BIT to "update" the code. Probably need to wait for a refactor. No idea if CHAR_BIT is even used in our code base. I just want to be a BIT_CH.
I was sitting here thinking what a valid use for an object called BitCh or BitChar. Still trying to come up with some valid reason to create such an object.
And people say programming as an art is dead.8 -
Fuck backward compatibility
Because IOS 9 and Android 4.4 doesn't support arrow functions, I have to refactor almost 90% of the code4 -
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. -
Oh great...
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. -
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" !!! -
Here we are, three years later. Our system breaks down at the slightest load. An architecture is hardly recognizable anymore. The code consists of methods that have been refactored beyond recognition. The so-called architects came and went, leaving behind an ever-growing fiasco. Wrong decisions are concealed, criticism of them dismissed as ignorance. Our clients are on the verge of having us all killed. Daily crisis meetings are the norm. The remaining developers skulk around the unmaintainable code like emaciated ghosts. Everyone who has even the slightest chance to escape takes a parachute. Our dailies are made up of lies to cover up yesterday's lies. Our Mondays have become days of dread, because that's when the weekend disaster news has to be analyzed. Yet there are still developers who turn a blind eye. Who recommend this and that workaround in a good-humored tone. The code consists only of workarounds. Sarcasm has replaced any normal discussion. Reasonable suggestions on how to basically refactor the whole thing are rejected for cost reasons. In the process, our entire budget is eaten up by maintenance costs. Middle management should be put up against the wall. Why am I still here? This deceptive feeling that one could still turn the tide. This is eating me up.2
-
While it's totally not without its valid use cases, I fucking hate pair programming.
Well, let me elaborate. I hate *remote* pair programming. It completely disrupts my flow and wastes so much time with additional water cooler nonsense, and pedantic argument for the sake of participation. Not to mention "oh hey let me see how you did this... Oh, you know what, I think it would be better to do it this way...". Ok, great, we weren't even discussing that, but sure, let's completely detail this session to refactor something that could have come up at a good transition point, like I dunno, say a code review?
Like I said, there are very good reasons to pair program, but I would much prefer rubber ducking wherever possible.2 -
Do not trust Unity Collab.
Been using unity collab as a VCS for months on a project, regularly saving the files, working well.
Today i decided to refactor some code but lost track of some things, so i reverted to a version i checked in 2h before.
Unity replaced my files with the stable build back then, except... half of the files were missing. of course no undo functionality.
months of work were simply not saved in collab. no version had these files, i did modify them regularly and they never caused collab issues.
how can a company not make the vcs they add for their main product work to its minimal requirements?!
Im not sure how i could motivate myself to fix this mess. fuck this trash company, cant have a single project without major issues.2 -
probably every time I see my tests failing.
Each time I am writing tests I'm convincing myself "it's an investment", "spend 2 hours now to save 2 days later", "unit-tests are good".
And each time I'm chasing away ideas like "perhaps they are right, perhaps writing unit tests is a waste of time..", "this code is simple, it should ever break - why test it??", "In the 2 hours I'll spend writing those UT I could build another feature"
Yes, it is terribly annoying to write tests, especially after writing the production code (code-first approach). Why test code that you know works, right?
But after a few weeks, months or years, when the time comes to change your feature: enhance it, refactor it, build an integration with/from it, etc, I feel like a child who found a forgotten favourite candy in his pocket when I see my tests failing.
It means I did a very good job writing them
It means it was not a waste of time
it means these tests will now save me hours or days of trial-and-error change→compile→deploy→test cycles.
So yeah, whenever I see my tests fail, I feel warm and fussy inside :)2 -
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! -
Oh, as a noob dev my team was using a dropdown library for our filters in the website. The code was messed up cause they kept changing the design halfway through dev and after releases and then finally after some releases, the client wanted multilevel options as a new requirement.
So I scrapped the whole thing and made my own multilevel dropdown component (there were no decent libraries then) and we used that from then on. It has many issues now that I look back (who cares about keyboard interaction right?). But that is a refactor for another day. -
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!
-
When a code sample is so obfuscated that it's almost better to leave it alone that to properly refactor it.5
-
Oh, gather 'round fellow wizards of the code realm! 🧙✨ Let me regale you with the epic tale of software sorcery and the comical misadventures that come with it! 🤪🎉
So there we are, facing the dreaded Internet Explorer dragon 🐉 - an ancient, stubborn beast from the era of dial-up connections and clipart-laden websites. It breathes fire on our carefully crafted layouts, turning them into a pixelated disaster! 🔥😱
And then, the grand quest of cross-browser testing begins! 🚀🌍 One moment, your website is a shining knight in Chrome's armor, and the next, it's a jester in Safari's court. A circus of compatibility struggles! 🎪🤹
CSS, the arcane art of cascading style sheets, is our magic wand. But oh, the incantations can be treacherous! A slight misstep and your buttons start disco dancing, and your text transforms into a microscopic mystery! 🕺👀
But fear not, brave developers! We wield the enchanted sword of Stack Overflow and the shield of Git version control. We shall slay bugs and refactor with valor! ⚔️🐞
In this enchanted land, documentation is the mystical parchment, often written in the cryptic dialect of ancient monks. "This function doeth stuff, thou knoweth what I meaneth." 📜😅
And meetings, oh the meetings! 🗣️🤯 It's like a conference of babbling brooks in the forest of Jargon. "Let us discuss the velocity of the backlog!" 🌿🐇
But amidst the chaos, we code on! Armed with our emojis and a bubbling cauldron of coffee, we persist. For we are the wizards and witches of the digital age, conjuring spells in Python and brewing potions in Java. 🐍☕
Onward, magical beings of code! 🚀 May your bugs be few, and your merges conflict-free! 🙌🎩3 -
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..." -
Took over a NodeJS/SailsJS project from a previous developer that is no longer working at the company. There's no documentation or requirement docs and the models need to be rewritten as some have up to 67 attributes in them.
Looked through the source code file by file to see how bad it was and it will more than likely be easier to start over then to try and refactor and cleanup the existing project into a usable state.
As bonus, I was given the option to switch the entire stack if needed as well.5 -
Does anyone else have experience on a team where everyone seems to be doing their own thing across the full stack/multiple systems/languages but then they're all stepping over each other, breaking other each other's code so ends up doing a lot of rework to update your code to someone else's change.
And also many wheels get reinvented in slightly different ways because no one is aware that something like ... Already exists and can be reused or refactor.... Or how to use it correctly.
Basically we're like all moving in different directions instead of in sync.
I feel maybe the team is too big and everyone is doing everything, wearing too many hats... and maybe should define roles and ownership better.4 -
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
-
I really really hope that no one post this,a friend texted it to me and I wanted to share it because made my day.
Idk where it comes, so feel free if know where this came from to post it:
//FUN PART HERE
# Do not refactor, it is a bad practice. YOLO
# Not understanding why or how something works is always good. YOLO
# Do not ever test your code yourself, just ask. YOLO
# No one is going to read your code, at any point don’t comment. YOLO
# Why do it the easy way when you can reinvent the wheel? Future-proofing is for pussies. YOLO
# Do not read the documentation. YOLO
# Do not waste time with gists. YOLO
# Do not write specs. YOLO also matches to YDD (YOLO DRIVEN DEVELOPMENT)
# Do not use naming conventions. YOLO
# Paying for online tutorials is always better than just searching and reading. YOLO
# You always use production as an environment. YOLO
# Don’t describe what you’re trying to do, just ask random questions on how to do it. YOLO
# Don’t indent. YOLO
# Version control systems are for wussies. YOLO
# Developing on a system similar to the deployment system is for wussies! YOLO
# I don’t always test my code, but when I do, I do it in production. YOLO
# Real men deploy with ftp. YOLO
So YOLO Driven Development isn’t your style? Okay, here are a few more hilarious IT methodologies to get on board with.
*The Pigeon Methodology*
Boss flies in, shits all over everything, then flies away.
*ADD (Asshole Driven Development)*
An old favourite, which outlines any team where the biggest jerk makes all the big decisions. Wisdom, process and logic are not the factory default.
*NDAD (No Developers Allowed in Decisions)*
Methodology Developers of all kinds are strictly forbidden when it comes to decisions regarding entire projects, from back end design to deadlines, because middle and top management know exactly what they want, how it should be done, and how long it will take.
*FDD (Fear Driven Development)*
The analysis paralysis that can slow an entire project down, with developments afraid to make mistakes, break the build, or cause bugs. The source of a developer’s anxiety could be attributed to a failure in sharing information, or by implicating that team members are replaceable.
*CYAE (Cover Your Ass Engineering)*
As Scott Berkun so eloquently put it, the driving force behind most individual efforts is making sure that when the shit hits the fan, you are not to blame.2 -
Yea sure, I'd like to refactor your fucking 1000 loc spagetti code "module" with no documentation at all...3
-
I'm considering quitting a job I started a few weeks ago. I'll probably try to find other work first I suppose.
I'm UK based and this is the 6th programming/DevOps role I've had and I've never seen a team that is so utterly opposed to change. This is the largest company I've worked for in a full time capacity so someone please tell me if I'm going to see the same things at other companies of similar sizes (1000 employees). Or even tell me if I'm just being too opinionated and that I simply have different priorities than others I'm working with. The only upside so far is that at least 90% of the people I've been speaking to are very friendly and aren't outwardly toxic.
My first week, I explained during the daily stand up how I had been updating the readmes of a couple of code bases as I set them up locally, updated docker files to fix a few issues, made missing env files, and I didn't mention that I had also started a soon to be very long list of major problems in the code bases. 30 minutes later I get a call from the team lead saying he'd had complaints from another dev about the changes I'd spoke about making to their work. I was told to stash my changes for a few weeks at least and not to bother committing them.
Since then I've found out that even if I had wanted to, I wouldn't have been allowed to merge in my changes. Sprints are 2 weeks long, and are planned several sprints ahead. Trying to get any tickets planned in so far has been a brick wall, and it's clear management only cares about features.
Weirdly enough but not unsurprisingly I've heard loads of complaints about the slow turn around of the dev team to get out anything, be it bug fixes or features. It's weird because when I pointed out that there's currently no centralised logging or an error management platform like bugsnag, there was zero interest. I wrote a 4 page report on the benefits and how it would help the dev team to get away from fire fighting and these hidden issues they keep running into. But I was told that it would have to be planned for next year's work, as this year everything is already planned and there's no space in the budget for the roughly $20 a month a standard bugsnag plan would take.
The reason I even had time to write up such a report is because I get given work that takes 30 minutes and I'm seemingly expected to take several days to do it. I tried asking for more work at the start but I could tell the lead was busy and was frankly just annoyed that he was having to find me work within the narrow confines of what's planned for the sprint.
So I tried to keep busy with a load of code reviews and writing reports on road mapping out how we could improve various things. It's still not much to do though. And hey when I brought up actually implementing psr12 coding standards, there currently aren't any standards and the code bases even use a mix of spaces and tab indentation in the same file, I seemingly got a positive impression at the only senior developer meeting I've been to so far. However when I wrote up a confluence doc on setting up psr12 code sniffing in the various IDEs everyone uses, and mentioned it in a daily stand up, I once again got kickback and a talking to.
It's pretty clear that they'd like me to sit down, do my assigned work, and otherwise try to look busy. While continuing with their terrible practices.
After today I think I'll have to stop trying to do code reviews too as it's clear they don't actually want code to be reviewed. A junior dev who only started writing code last year had written probably the single worst pull request I've ever seen. However it's still a perfectly reasonable thing, they're junior and that's what code reviews are for. So I went through file by file and gently suggested a cleaner or safer way to achieve things, or in a couple of the worst cases I suggested that they bring up a refactor ticket to be made as the code base was trapping them in shocking practices. I'm talking html in strings being concatenated in a class. Database migrations that use hard coded IDs from production data. Database queries that again quote arbitrary production IDs. A mix of tabs and spaces in the same file. Indentation being way off. Etc, the list goes on.
Well of course I get massive kickback from that too, not just from the team lead who they complained to but the junior was incredibly rude and basically told me to shut up because this was how it was done in this code base. For the last 2 days it's been a bit of a back and forth of me at least trying to get the guy to fix the formatting issues, and my lead has messaged me multiple times asking if it can go through code review to QA yet. I don't know why they even bother with code reviews at this point.18 -
So happy about being about to convince management that we needed a large refactor, due to requirements change, and since the code architecture from the beginning had boundaries built before knowing all the requirements...
pulled the shame on us, this is a learning lesson card.. blah blah blah
Also explained we need to implement an RTOS, and make the system event driven... which then a stupid programmer said you mean interrupt driven ... and management lost their minds... ( bad memories of poorly executed interrupts in the past).... had to bring everyone back down to earth.. explained yes it’s interrupt driven, but interrupt driven properly unlike in the past (prior to me)... the fuck didn’t properly prioritize the interrupts and did WAYYY too much in the interrupts.
Explained we will be implementing interrupts along side DMA, and literally no message could be lost in normal execution.. and explained polling the old way along side no RTOS, Wastes power, CPU resources and throws timing off.
Same fucker spoke up and said how the fuck You supposed to do timing, all the timing will be further off... I said wrong, in this system .. unlike yours, this is discreet timing potential and accurate as fuck... unlike your round robin while loop of death.
Anyway they gave me 3 weeks.. and the system out performs, and is more power efficient than the older model.
The interrupting developer, now gives me way more respect...4 -
A colleague is walking me trough some of the source code because we try to fix an issue.
colleague: Oh we don't use this anymore
Me: ...
LATER
colleague: This part we should refactor someday
Me: ...
LATER
colleague: Oh I think this is old code and does not exist anymore.
Me: .. .. ...
Great Colleague BTW :)
PS: fix will be posted Later.3 -
I have a friend which have a hoarding disorder when it comes to coding. Here are some of the things he does:
1: If he rewrites, remove, or in any other way refactor a function, then he keeps the old one in the file commented out.
2: If he deletes a class then he takes the code and paste it into a class that he have just for old code. AN ACTUAL CLASS! Not just some random text file somewhere. Even though it is commented out, he leaves it so that you can initiate his garbage.
3: In point 1, the code is not pasted on the end. It inside all the other actual code.
So if you try to help him with something, then you have to dig through a mountain of shit just to find some code.5 -
! Rant
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 -
I have a co-worker who won’t stop “refactoring” our codebase. He will go on a long tangent — under the guise of working on a proper story — and then reveal proudly after a few days that he now introduced a new middle-layer into the code which will help us such and such.
I have never seen any benefit from this. I think sometimes cleaning up variable names is nice, but a lot of the things just add noise and complexity. He’s a junior dev, I’m a senior dev. My progressional opinion is that he is doing a bad job. Management doesn’t know the full extent and the lead programmer scolds him every now and then but in the end let’s the code changes pass code review. “It has already been implemented so what’s the harm”.
Then the rest of us are stuck with horrible merge conflicts. I recently noticed that some new business-important unit tests that I wrote were mysteriously gone. Oops — lost in some misguided refactoring I guess. I’m assuming they were failing after the refactor, so clearly they had to go... Fortunately the underlying logic still works I think.
His main tactic in all of this seems to be to just use argumentative stamina. He will lose discussion after discussion but doesn’t seem to care. He’ll just talk and talk. And the in the end the lead tech gives in. And/or doesn’t have the energy to catch the error introduced.
I swear, the company would be better off without him. Maybe even better if we keep paying him but he just cleans the toilets instead. Sometimes I almost believes he gets up in the morning to come to work and just fuck with people all day.2 -
Today I finally experienced the power of something I learned in university: propositional and predicate logic.
Many developers I know think that such education is useless. Well, today I have proven that it is very useful. On a day to day basis, working on banking software, complexity in purely logic is very low. However, we have a screen that must show or hide elements based on some input values and conditions associated with certain elements. How hard can that be, right? Well, there are many variables to take into account and as such it's absolutely not trivial.
This screen didn't work properly and maintaining the code is hard as there is a lot of logic to show/hide, enable/disable things and so on. After quite some time and attempts by fellow developers, I decided to refactor the whole thing. I'm responsible for the quality of the software and it was quite degrading, so I had to do something.
In order to get things working properly, I defined collections of constants (ui elements) and predicates. Then, I defined for which element what predicates must be true, in order to hide/show, disable/enable etc. I then translated these predicates into code. And guess what? It works! Of course it works. It's logic. But I'm very pleased I finally could actually use some of all the math I studied!5 -
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
*Approved*
Trying to merge, then merge conflicts.....2 -
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.
-
I love git stash.
It's helps a lot for doing refactors to me. I guess it's not the most complex workflow, but it wasn't obvious to me when I started with git. Let me explain.
Refactors. As you start writing the first lines of a refactor, you start to notice something: you're changing too many things, your next commit is going to be huge.
That tends to be the very nature of refactors, they usually affect different parts of code.
So, there you are, with a shitload changes, and you figure "hey, I have a better idea, let me first do a smaller cohesive commit (let's call it subcommit) that changes a smaller specific thing, and then I'll continue with the upper parts of the refactor".
Good idea, but you have a shitload of changes nearly touching every file in your working copy, what do you do with these changes? You git stash them.
Let's say you stash and try to do that smaller "subcommit". What sometimes happens to me at this point is that I notice that I could do an even smaller change inside this current "subcommit". So I do the same thing, I git stash and I work on that even smaller thing.
At some point I end up `git stash pop`ing up all these levels. And it it shows that git stash is powerful for this.
* You never lose a single bit of work you did.
* Every commit is clean.
* After every commit you can run tests (automated or manual) to see shit is still working.
* If you don't like some changes that you had git stashed, you can just erase them with git reset --hard.
* If a change overlaps between a stash you're applying and the last "subcommit", then
if they differ, git shows conflicts on the files,
if they are identical, nothing happens.
with this workflow things just flow and you don't need to wipe out all your changes when doing simpler things,
and you don't need to go around creating new branches with temp commits (which results in bloated temp commits and the work of switching branches).
After you finish the refactor, you can decide to squash things with git rebase.
(Note: I don't use git stash pop, because it annoys the fuck out of me when I pop and you I get conflicts, I rather apply and drop)4 -
I'm in my first internship, they gave me their only company owned product. They always made interns work on that, and it's something I really appreciate (I like when people give to others any possible chance of learning)... But apparently they made a mistake: for the first year they never reviewed interns' code. And now that software is huge and full of bugs.
After two weeks working on that I said to the tech leader and to the PM that we should spent a couple of months rewriting more than half of the code, and surprisingly they listened and agreed (the TL already knew that, and the PM is not a dev and he listened to the TL).
After two days of code rewriting ("refactor" is a too weak word) the boss calls me and orders to stop, telling me basically "I agree on this decision, but not now; let's first make it work and then we make it great!".
Okay I respect that, but what he didn't understand is that the two things are strictly related!
Result: last week we had a first official release (with some client's testers, so they were expecting a few bugs) and nothing was working, so me and the tl started a really hard rewriting work (that didn't finish) and managed to release a very bade made software that works by chance.
After easter we'll keep working on this, and I think at the end it will be great.
First working experience, in two months I learned a lot (not only about code/tech).3 -
My co-worker had to add some small feature, and while at it, he thought it’s a good idea to “refactor” the entire repo.
Now the code is over-modularized and full of disconnected 100 line files, just for the sake of modularity.
Sometimes less is more9 -
What's some valuable things you've learned this year?
I'll start.
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 -
Ugh. That may have been a mistake.
I'm deep in a large effort to refactor my project. It's a one man deal and something I've been working on pretty much every day in some fashion for nearly 10 years (five years ago I started a scratch rewrite to move from a fully CGI server rendered application to a browser rendered asynchronous version built around JS) and that took me three years.
I started this refactor about 8 weeks ago. Turns out I've been tackling the largest modules and progress has been decent. So that's good.
But I got to wondering ... Just how much code is there?
So I whipped up a quick script to do some calculations. Read each file and get a line and word count, skipping empty lines.
In JS it turns out I have 83,973 lines and 467,683 words.
On the back end, 86,230 lines and 580,422 words.
Average publishing stats say the are about 250 words/printed page.
That means I'm confronting refactoring 1,870 pages of JS. That's the size of several decent sized novels. (I think I've done the equivalent of Maybe 400 at this point).
Makes me feel like the walls are creeping in to know how much is left to go ... -
I'm faszinated by some dev's ability to write legacy code.
Not maintaining but plainly creating code so horrible, that it can be considered legacy.
I wrote a new API for a silly Application because the old one had hardly anything to do with rest. At all. And despite the code being only 2 years old, it was still unmaintainable.
Now that I'm finish with this task, i got the next generation of the angular Frontend.
A guy wrote a completely new version of the frontend in angular5.
Only untyped variables, no documentation, no tests at all, no idea whats going on where,....
I thought my job was to adjust a few URL's and change some DTO's, but now i have to refactor everything again...
And the pain continues.....3 -
Fuck, I knew that my code for my thesis would at some point become bad and very unmaintainable. Workaround here and there, everything put together "to fix later", just to make it all work "for now". I know what my code does where and when but my tech debt has reached a critical point, where a new idea and new procedure cannot be simply be added. Well, time to refactor and modularize as much as possible😪
Wish me luck that the whole project doesn't brake. Oh and of course so many different changes that I don't know what to put in git and in which order to do so.12 -
I really resent people who reduce the occupation to tickets. Our world is just tickets, tickets all the way down.
"well the ticket just says this, but that's vague, so what should I do?"
You either ask for clarification, or you get creative with the blank canvas you were handed.
"well that edge case wasn't called out in the ticket's specs"
this is _why_ we do TDD - to design our code to be able to function as expected for ALL cases
"is there a ticket to refactor that?"
what?! no, it's your job to always leave code better than when you found it (within scope/reason of course)
FFS we are not hired to be code monkeys or glorified typists. There should be joy that comes from getting to be more clever than the average bear and to solve problems and improve things with your code and logic.
shit bums me out.7 -
Just launched a successful deployment today. Took 4 months to build everything. It's probably not a big deal but I'm just really happy today that everything worked right away, and almost no deployment hiccups at all.
Only one issue popped up, but come to find out it's a particular thing about the Prod environment and nothing to do with my code.
Gonna go celebrate now, before more work comes in. (hey, can you refactor this for me?)4 -
If you ever get a chance to refactor a 5/6 years old code , just do it .
Dont loose hope , you'll eventually have a great time .
Its totally worth the effort and time . I learnt so many things. (still in the proccess)5 -
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
-
ColdFusion and all ColdFusion devs should be executed. Its a god-awful software from the 90's and if you still use it you're either braindead or ignorant.
Shut up about legacy CF code too! No one cares whether or not your embeddable calendar would be hard to make in JS; fucking figure it out.
I realise that CF may make things easier in the short run, but in the long run you'll have introduced so much technical debt that you'll run crying back to JS anyways; CF is so hard to refactor and even to make flexible that you would spend less total time over an application lifecycle learning JS.11 -
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 -
I was asked to make proof of concept small frontend app with some simplified requirements, they asked me because it should be written in the stack I done most of my career work with. I do it in 3 days instead of 5, using those 2 days to optimise the app and explore different approaches. I noted down my findings, what to avoid and reasons and also what is good to use and reasons and shared with everyone.
We waited for the project to start, I started working on another project in the meantime and there was a big rush to make project go live etc., so I was consumed 100% on that new project.
So they put in charge backend php developer to do frontend js work. I said ok, do you need help in starting out? Nah, my proof of concept repo is enough.
4 days before that small project goes live they asked me to do code review. All things I noted down to avoid are in the codebase, few bad practices but everything is over-engineered (in a very bad way), some parts should be more flexible as current setup is very rigid, having almost all kinds of CSS, I saw SASS, CSS variables, 2 different CSS-in-JS tools with some additional libraries that is used to toggle classes.
I don't know how to approach this as I am not asshole as a person and I don't want to say to my colleague that his codebase is completely trash, but it is.
The worst parts: They called me to help finish the app and budget is almost spent!
I would rewrite the whole app as the state of the current app is unusable and everything is glued with bad Chinese ducktape that barely holds.
Additional points because it won't bundle as everything is f**ked.
I am seriously thinking of duplicating master branch and refactor the whole fricking app but won't do that as I am burning midnight oil on other two projects. Don't worry overtimes are paid.
I hate those shitty situations, this project was supposed to be tiny, sweet and example of decent project in this company but it is instead big fat franken-app that will be example how smart it is to avoid putting backend dev to do frontend work (I also agree for vice versa)! -
I'm finishing up the most depressing client engagement ever. Ultimately it all traces back to their worthless Expert Beginner EA who thinks he's a genius but can't write code. I don't mean that he's not great at it. It's some of the worst I've ever seen by a person in his position.
In the time I have left here I could do so much to help them clean this stuff up so that future developers could ramp up more easily and there wouldn't be tons of duplicate code.
But I've just given up. You can't help someone who thinks their code is perfect. I don't even bother suggesting stuff any more (like don't have two methods in a class - a "real" one and one for unit testing) because he gets mad or just says that's his "pattern."
If I have a useful improvement, first he'll want me to put all new code in some new library, which is fine as an end result but you don't start with putting single-use code in a library separate from where you're using it. You work with it for a while to see what's useful, what's not, and make changes. But, you see, he just loves making more libraries and calling them "frameworks."
He tells me what he wants me to name classes, and they have nothing to do with what the classes do. When you haven't done any development yet you don't even know what classes you're going to create. You start with something but you refactor and rename. It takes a special breed of stupid to think that you start with a name.
I've even caught the dude taking classes I've committed and copying and pasting them into their own library - a library with one class.
The last time we had to figure out how to do something new I told everyone up front: Don't waste time trying to figure out how you want to solve the problem. Just ask the EA what he wants you to do. Because whatever you come up with, he's going to reject it and come up with something stupid that revolves around adding stuff to his genius framework. And whatever he says you're going to do. So just skip to that.
So that's the environment. We don't write software to meet requirements. We write it to add to the framework so that the EA can turn around and say how useful the framework is.
Except it's not. The overhead for new developers to learn how to navigate his copy-pasted code, tons of inheritance, dead methods, meaningless names, and useless wrappers around existing libraries is massive. Whatever you need to do you could do in a few hours without his framework. Or you can spend literally a month modifying his framework to do the same thing. And half the time his code collapses so that dozens of applications built on his framework go down at once.
I get frameworks. They can be useful, but only if they serve your needs, not the other way around.
I've spent months disciplining myself not to solve problems and not to use my skills.
Good luck to those of you who actually work there. I am deeply sad for the visa worker I'm handing this off to. He's a nice guy and smart. If he was stupid then he wouldn't mind dragging this anchor behind him like an ox pulling a plow. Knowing the difference just makes it harder. -
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.8 -
Lead: alright people what are your ideas and updates for this page refactor we've been talking about.
dipshit: Alright guys, I've done a quick awesome prototype that I really like...
dipshit: *starts to speak super fast* (I catch words about function composition, clean, no side effects, speed, efficiency. Basically a string of brogrammer buzzwords.)
me: what did you mean by that? How does it work?
dipshit: *basically repeats the same drivel*
me: uh..ok I don't quite understand
everyone else looks confused.
me: ok since you've done a prototype, we take a look at it later
*** After meeting, looks at code ***
It was COMPLETE GARBAGE. He used 1,500+ lines of js in 17 files to make what was essentially a simple 2 item list.
We were looking at a way to overhaul the entire page, he "refactored" maybe perhaps 5% of the page.
There was absolutely nothing clean / functional / composable about this monstrosity. It was as if he read chapter 1 of a book on functional programming and decided he understood enough to call himself an expert.
WHY THE FUCK ARE YOU STILL HIRED?
HOW DO YOU CALL YOURSELF A DEVELOPER?
YOU ARE SELF TAUGHT, DISS PEOPLE WITH FORMAL CS/CE DEGREES AND YOU PRODUCE TRASH CODE?!
ARE YOU SO RETARDED THAT YOU DO NOT RECOGNIZE HOW STUPID YOU ARE?
Please die in a fire, along with your jock attitude and unprofessionalism. Take this worthless junk unfit to be called code with you.3 -
From the book
Refactoring JavaScript
Turning Bad Code into Good Code
Evan Burchard
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.”
“Refactoring th–”
“No.”
“Refa–” “No.”7 -
I cant keep this inside anymore I have to rant!
I have a colleague that is an horrendous loose bug-cannon. Every peer-review is like a fight for the products life.
Now I understand - everyone makes bugs me included and it is a huge relief when someone finds them during peer-review. But these aren't the simple kind of bugs. The ones easily made when writing large pieces of code quickly. Typing = instead of == or a misshandling of a terminating character causing weird behaviour. These kinds of bugs rarely pass by a peer-review or are quickly found when a bug report is recieved from testers.
No the bugs my colleague makes are the bugs that completly destroy the logic flow of a whole module. The things that worst case cause crashes. Or are complete disasters trying to figure out what causes them if they are discovered first when the product reaches production!
Ironically he is amazing a peer reviewing other peoples code.
But do you know what the worst thing of all is! Most of the bugs he causes are because he has to "tidy up" and "refactor" every piece of code he touches. The actual bugfix might be a one liner but in the same commit he can still manage to conjure up 3 new bugs. He's like a bug wizard!
*frustrated Aruughhhh noises*9 -
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 -
I had a conversation that almost became an argument with a someone I manage the other day. It revolved around how we should do just the basic parts first as that's what the business needs quickly and the code base is in a bad state right now so I didn't want to build new features on a poor foundation, particularly as those new features might not be forwards compatible and might have no way of fixing.
Once basic is in, refactor and cleanup, add secondary features. Their point was to just do it all at once in a big bang. It devolved into them getting angry and telling me to leave them out of all future discussions because now we "aren't ever doing the secondary features", just give them the task and leave them alone.
I let this go, but now I've found out they went to another high up person on the team and presumably lied to them about what was said.
What to do?5 -
A friend of mine invited me to a project he was given. So basically is a flutter project already started by a guy on Fiverr... I'm just mad at the code the guy wrote! Now we have to refactor the ENTIRE code because the guy didn't know what he was doing!!!
This is my 1st rant, if i did something wrong, please rant at the comment section7 -
Tabs, or No Tabs? I did the same as this commentor 2 years ago. I can code so quick now because of this simple switch. Here's why:
(source, Laracasts.com)
Ben Smith
"I think the most beneficial tip was to do away with tabs. Although it took a while to get used to and on many occasions in the first few days I almost switched them back on, it has done wonders for my workflow.
I find it keeps my brain more engaged with the task at hand due to keeping the editor (and my mind) clutter free. Before when I had to refer to a class, I would have opened it in a new tab and then I might have left it open to make it easier to get to again. This would quickly result in a bar full of tabs and navigation around the editor would become slow and my brain would get bogged down keeping track of what was open and which tab it was in. With the removal of the tab bar I'm now able to keep only the key information in my mind and with the ability to quickly switch between recently opened files, I find I haven't lost any of the speed which I initially thought I might.
In fact this is something I have noticed in all areas of writing code, the more proficient I have become with an editor the better the code I have been writing. Any time spent actually writing your code is time in which your brain is disconnected from the problem you are trying to solve. The quicker you are able to implement your ideas in code, the smaller the disconnect becomes. For example, I have recently been learning how to do unit testing and to do so I have been rewriting an old project with tests included. The ability to so quickly refactor has meant that whereas before I might have taken 30 seconds shuffling code around, now I can spend maybe 5 seconds allowing my mind to focus much better on how best to refactor, not on the actual process of doing so."
jeff_way Mod
"Yeah - it takes a little while to get used to the idea of having no tabs. But, I wouldn't go back at this point. It's all about forcing yourself into a faster workflow. If you keep the tabs and the sidebar open, you won't use the keyboard."2 -
Trying to refactor legacy code can be a real adventure. It's like exploring an ancient ruin, except instead of hidden treasures, you're uncovering cryptic code and dead ends. But the real plot twist comes when you realize there are no unit tests to guide you. It's like trying to navigate a maze blindfolded - you never know when you're going to hit a dead end and end up with a headache! 🤯6
-
Coding distraction
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 -
I was thinking about the problems one of our clients faced with the launch of their project the other day, because things were rushed, stuff was omitted and in the end they could not meet the launch date, and I started making a list of hard lessons I learned over the years that would have helped them avoid this situation.
Feel free to add yours in the comments.
- Never deploy on Friday
- Never make infrastructure changes right before a launch
- Always have backups. Always!
- Version control is never optional
- A missed deadline is better than a failed launch
- If everything is urgent, nothing is important
- Fast and cheap, cheap and quality, quality and fast. Only one pair at a time can be achieved
- Never rush the start or the end of a project
- Stability is always better that speed
- Make technical decisions based on the needs of the project two years from now
- Code like you will be the only maintainor of the project two years from now. You probably will...
- Always test before you deploy
- You can never have too many backups (see above)
- Code without documentation is a tool without instructions
- Free or famous does not necessarily mean useful or good
- If you need multiple sentences to explain a method, you should probably refactor
- If your logic is checked beforehand, writing the code becomes way easier
- Never assume you understand a request the first time around. Always follow up and confirm
There are many more that should be on this list, but this is what came to mind now.2 -
After learning a bit about alife I was able to write
another one. It took some false starts
to understand the problem, but afterward I was able to refactor the problem into a sort of alife that measured and carefully tweaked various variables in the simulator, as the algorithm
explored the paramater space. After a few hours of letting the thing run, it successfully returned a remainder of zero on 41.4% of semiprimes tested.
This is the bad boy right here:
tracks[14]
[15, 2731, 52, 144, 41.4]
As they say, "he ain't there yet, but he got the spirit."
A 'track' here is just a collection of critical values and a fitness score that was found given a few million runs. These variables are used as input to a factoring algorithm, attempting to factor
any number you give it. These parameters tune or configure the algorithm to try slightly different things. After some trial runs, the results are stored in the last entry in the list, and the whole process is repeated with slightly different numbers, ones that have been modified
and mutated so we can explore the space of possible parameters.
Naturally this is a bit of a hodgepodge, but the critical thing is that for each configuration of numbers representing a track (and its results), I chose the lowest fitness of three runs.
Meaning hypothetically theres room for improvement with a tweak of the core algorithm, or even modifications or mutations to the
track variables. I have no clue if this scales up to very large semiprime products, so that would be one of the next steps to test.
Fitness also doesn't account for return speed. Some of these may have a lower overall fitness, but might in fact have a lower basis
(the value of 'i' that needs to be found in order for the algorithm to return rem%a == 0) for correctly factoring a semiprime.
The key thing here is that because all the entries generated here are dependent on in an outer loop that specifies [i] must never be greater than a/4 (for whatever the lowest factor generated in this run is), we can potentially push down the value of i further with some modification.
The entire exercise took 2.1735 billion iterations (3-4 hours, wasn't paying attention) to find this particular configuration of variables for the current algorithm, but as before, I suspect I can probably push the fitness value (percentage of semiprimes covered) higher, either with a few
additional parameters, or a modification of the algorithm itself (with a necessary rerun to find another track of equivalent or greater fitness).
I'm starting to bump up to the limit of my resources, I keep hitting the ceiling in my RAD-style write->test->repeat development loop.
I'm primarily using the limited number of identities I know, my gut intuition, combine with looking at the numbers themselves, to deduce relationships as I improve these and other algorithms, instead of relying strictly on memorizing identities like most mathematicians do.
I'm thinking if I want to keep that rapid write->eval loop I'm gonna have to upgrade, or go to a server environment to keep things snappy.
I did find that "jiggling" the parameters after each trial helped to explore the parameter
space better, so I wrote some methods to do just that. But what I wouldn't mind doing
is taking this a bit of a step further, and writing some code to optimize the variables
of the jiggle method itself, by automating the observation of real-time track fitness,
and discarding those changes that lead to the system tending to find tracks with lower fitness.
I'd also like to break up the entire regime into a training vs test set, but for now
the results are pretty promising.
I knew if I kept researching I'd likely find extensions like this. Of course tested on
billions of semiprimes, instead of simply millions, or tested on very large semiprimes, the
effect might disappear, though the more i've tested, and the larger the numbers I've given it,
the more the effect has become prevalent.
Hitko suggested in the earlier thread, based on a simplification, that the original algorithm
was a tautology, but something told me for a change that I got one correct. Without that initial challenge I might have chalked this up to another false start instead of pushing through and making further breakthroughs.
I'd also like to thank all those who followed along, helped, or cheered on the madness:
In no particular order ,demolishun, scor, root, iiii, karlisk, netikras, fast-nop, hazarth, chonky-quiche, Midnight-shcode, nanobot, c0d4, jilano, kescherrant, electrineer, nomad,
vintprox, sariel, lensflare, jeeper.
The original write up for the ideas behind the concept can be found at:
https://devrant.com/rants/7650612/...
If I left your name out, you better speak up, theres only so many invitations to the orgy.
Firecode already says we're past max capacity!5 -
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 -
I got assigned to work on a new project a couple of weeks ago. We got the POC code handed off from senior management, since he came up with the idea over the weekend. The project concept is hella exciting, but the dev manager and PO I have to deal with make life unbearable to say the least.
We have only 2 devs (including me) and 1 QA on this supposedly very important project. Of course, management announced the project to the clients already, so now we have to deliver ASAP cause it adds “sizzle”.
The MVP deadline is... no one knows when, either July 30th or September 1st. The MVP requirements are... unknown. I swear if someone saw the list of tasks and issues attached to “MVP” Epic, they would call us nuts trying to fit it all in.
To make things better, each PR requires 2 reviewers, so we end up adding manager as a reviewer just cause we need him to hit that “approve” button. So in attempt to make life easier, we requested to have a third developer. We are getting another developer, but that guy doesn’t know how to unit test a pure function...
Current priorities are... unit testing with coverage of 95% and if we want to refactor code, we have to add area to the list in a Google Doc. As a result, we are not tackling big things like risk of SQL injections not to mention big features like i18n (5-6 languages to support by the way and yes, it’s part of MVP as well as SSR no one knows why). Currently, I spend 2-3 hours a week in calls with the team just to figure out what the hell MVP is, what we have to do and why we have to do it. Last time we spent an hour refining 1 spike and breaking down one story into 3.
Oh, we also don’t have a deployment plan, not even to test environments since DevOps team was not aware of this project at all. Thus, QA cannot create any test suites and have to test everything manually which eats a lot of their time.
This whole project is a big hot mess and I’m considering leaving it all together especially since I’m working on two squads at the same time. I love the project, I love the idea, but management makes it unbearable, so I’m not even motivated to work on that.3 -
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.
-
How hard can it be to refactor this 170 lines file?
- a single “data” variable used to store everything
- arrays inside arrays inside arrays (see prev point)
- operations with a lot of obscure sideEffects
- $data[] = something (which in magic php land means $data.enqueue()
Why is such… biological matter… even allowed to code? Fucker’s pretending they are a senior for four years: how in hell didn’t they learn to code in this timeframe?7 -
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!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
-
We are currently refactoring our application in order to use multiple languages. The application startet 1997 and later it supported 2 fix languages. So it's one defined language or the other, this was used in uncountable places. Now a team of 6 developers has to refactor all the code of the last 20 years, where labels are used and an old translator was magically used out of nowhere..
Turns out it's a ton of work to get the software ready for really multiple language support. -
Cakechat.
Not going to deny Lukalabs' credit where it's due, it's an actually good NN chatbot. Works pretty decently even on my poor old Haswell i3.
But... the things you do, Lukalabs.
First off... PYTHON 2?!?! IN ${CURRENT_YEAR}?
Jokes aside, there's a lot of things that could've been done better, or in a more compatible way, or both. Such as:
tokenized_dialog_context = imap(get_tokens_sequence, dialog_context)
tokenized_dialog_contexts = [tokenized_dialog_context]
1. imap doesn't exist in python3, but whatever, doesn't make a big difference.
2. why wrap it in another array?
3. *two* variables, and the first one just used to create the second?
I will admit, Cakechat works well, but it's one of those things where if you try to run it on anything other than the recommended settings, it's not very fun.
Right now, I'm porting it to python3 with six, and making small refactor adjustments in random places to clean up the code.
(Official live demo at https://cakechat.replika.ai/, if you want to try it out.) -
What does projektaquarius do when he doesn't have a working IDE? Reformat code (that I am already refactoring) to an industry standard format and prepare for the arguments that are going to come from the other group who has their own coding standard that isn't industry standard.
Already preparing for the Pascal case versus Camel case argument. Emotionally that is. Mentally the argument basically just amount to "your group didn't want to refactor the code so we did it. Live with it or you do it." -
Curiosity killed the cat.. or was it Opportunity?! 🤔
You get to learn new stuff daily.
Not one assignment is the same, and if it's similar, you can hijack the old code, improve it & turn in the better version of it.. or don't improve..totally how you feel that day..if you're not a crappy developer no improvement should still also be ok..
I love mostly adjustable schedule, so there's no biggie of I have a day or two of coders block & can't produce much of value..I can switch tasks & do some simple ones on those days..or just refactor.. all's good..
I love solving puzzles, every bug is a new puzzle I can play with..
So basically, I love being a dev, because it's like being back in school, but only with the subjects you like! -
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
-
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 -
Have you ever gotten a task where you have to modify some existing code, and to get it to work the way it needs to you have to write some ugly ass code?
And I'm talking FUGLY ass code. The kind where every brain cell you have screams to refactor it all so that your code won't be so ugly and you can live with yourself. But you only wrote it that way because some numbnuts who was fired a year ago designed it that way, and left zero commentary or documentation on his reasoning ("sELf-dOcUmeNtiNg cOde, bRuH!").
It doesn't pose any sort of risk with regards to security or resource management or efficiency, or really even faulty logic. It just looks fucking awful, my brain can instantly see better ways to design it and I don't want history to tie my name to it.
But also the system is being gutted and retired within a matter of months, so maintenance won't even be a concern; and you know that you have a lot of other large tasks that need your attention too, and to refactor will ultimately prove to be a time sink.
I mean ultimately, I know what I need to do, but I guess it's a pride thing. Just makes me feel icky. -
Confession!!
Ohh Lord, Please forgive me. Today I committed a sin and tomorrow I will have to commit it again. I wrote a shitty code and will have to write it tomorrow also. I am so ashamed of myself. I promise, I will refactor the code before releasing it for code review. My excuse for doing the sin is that I want to make it work first, it is little complex. I hope, if someone will stumble on it, then that person will not judge me by few shitty snippets I wrote to make it work.
Thanks,
An embarrassed programmer3 -
I'm going to confess: I am the type of developer that creates the ExcruciatinglyLongAndSpecificClassNameObject with the UtterlyDetailedExplanationMethod. It's just a thing I keep doing, despite voiced frustrations from people I've worked with. It just feels right in the mindset of self-documenting code
And while I acknowledge this isn't a flawless process, I see no other way around without losing information. I've tried alternatives, but everything feels like trading one issue for another:
- Abbreviations work as long as they are well known (XML, HTML, ...). As soon as you add your own (even if they make sense in the business context) you can bet your ass someone is going to have no idea what you're talking about. Even remembering your own shit is difficult after X months.
- Removing redundant naming seems fine until it isn't redundant anymore (like when a feature with similar traits gets added). and you can bet your ass no-one is going to refactor the existing part to specify how it differs from the newly added stuff.
- Moving details to namespaces is IMO just moving the problem and pretending it doesn't exist. Also have had folks that just auto-include namespaces in VS without looking if they need the class from namespaceA or namespaceB and then proceed to complain why it doesn't compile.
So, since I am out of ideas, I'd like to ask you folks: Is it possible to reduce class/method name lengths without losing information? Or is self-documenting code just an ideal I'm trying too hard to achieve? Or are long names not a problem at all? I'm looking forward to your answers.19 -
Tl;dr I am incredibly ashamed of my code at work.
I recently started working as a junior dev. I know many aspects of the stack I use, and I feel pretty comfortable when solving simple and specific problems.
But this is the first complete project I make, and I received no peer review until now. And my code sucks.
I tried my best to deliver a good and working code, but it became messy in too many places. Now it's too late to refactor.
Probably I just cannot see the right way of modeling specific situations, I don't feel I should blame the frameworks I'm using, but the point is that my code sucks. Or at least this is how I feel.
I'm going to leave this workplace soon (personal reasons, not related to this topic and/or the company), and I am kinda scared of the shit I'm about to leave to them. It's a very nice environment and they don't deserve this crap. Also I have some other good reasons to worry about this, but I cannot tell them.
My plan is to finish a couple or personal stuff I have to do and then spend as many hours I can on the project trying to finish it asap and make the code better (for now I've been working only 6hr/day).
I'm really thinking that I just suck at this.12 -
You ever sit down to code, all pumped up and ready to conquer the digital world, only to have your computer decide it's the perfect time to install updates? "Sorry, can't work right now, I'm busy optimizing your experience," it says, while you sit there twiddling your thumbs and wondering who asked for this update in the first place.
And let's talk about variable names. Who thought naming things would be the hardest part of programming? You start with `count` and `index`, but by the end of the project, you're using variables like `reallyLongVariableNameThatDescribesExactlyWhatThisThingDoes`. It's like playing a game of how many characters can you type before your fingers revolt.
Then there's the joy of debugging. You sprinkle `console.log()` like breadcrumbs through your code, trying to find where things went off the rails. Half the time, you realize you've been chasing the wrong rabbit down the wrong hole, and the other half, you discover the bug is some obscure edge case that you couldn't have predicted in a million years.
But hey, it's not all doom and gloom. There's a weird satisfaction in solving those coding puzzles, like when you finally get that algorithm to work or refactor your code into something so elegant, it feels like you've sculpted a masterpiece out of digital clay.
So here's to all the coders out there, navigating the ups and downs of curly braces and semicolons with a mix of determination and exasperation. May your code compile, your bugs be minor inconveniences, and your computer never decide to update right when you're on a coding roll!!3 -
How to disconnect from work after working hours? Im working for the last 4 months as a mid level dev in this company. I mean Im able to problem-solve and do my work but sometimes I get so addicted to problem solving that I get worried and become obsessed, hyperfixated (especialy if Im stuck on something for lets say a couple weeks). It goes to the point where I work from home 12-14 hours a day just to figure out some bug in the flow.
Thing is, our codebase is large and when doing every new refactor/feature some surprises happen. I dont have a decent mentor who could teach me one on one or even do pair programming with. All i have is just some colleagues who can point me to right direction or do a code review from time to time. Thats it.
I dont know why I take this so personally. For example I had to do a feature which I did in 1 week, then MR got approved by devs and QA. After that during regression they found like 3 blockers and I felt really bad and ashamed. While in reality our BA did not define feature properly, devs who reviewed it didnt even launch the code and poke around in the app, and our team's QA tested only the happy scenario. Basically this is failing/getting delayed because of a failure in like 6-7 people chain.
However for some reason Im taking this very personally, that I, as a dev failed. Maybe due to my ADHD or something but for the next days or weeks as long as I dont find solution I will isolate myself and tryhard until I get it right. Then have a few days of chill until I face another obstacle in another task again. And this keeps repeating and repeating.
My senior colleague tells me to chill and dont let work take such a toll on my emotional/physical/mental health. But its hard. He has 7 years of experience and has decent memory. I have 2-3 years of experience and have ADHD, we are not the same. I dont know how to become a guy who clocks out after 8 hours of work done everyday. Its like I feel that they might fire me or I will look bad if I dont put in enough effort. Not like I was ever fired for performance issues... Anyways I dont know how to start working to live, instead of living for work.
I hate who Im becoming. I dont work out anymore, started smoking a lot, dont exercise. I live this self induced anxiety driven workaholic lifestyle.6 -
So i wasted last 24 hours trying to satisfy my ego over a shitty interview and revisiting my old job's codebase and realising that i still don't like that shit. just i am 25 and have no clue where am i heading at. i am just restless, my most of the decisions in 2023 have given very bad outcomes and i am just trying doing things to feel hopeful.
context for the interview story-----
my previous job was at a b2b marketing company whose sdk was used by various startups to send notifications to their users, track analytics etc. i understood most of it and don't find it to be any major engineering marvel, but that interviewer was very interested in asking me to design a system around it.
in my 1.2 years of job there, i found the codebase to be extremely and unnecessarily verbose ( java 7) with questionable fallbacks and resistance towards change from the managers. they were always like "we can't change it otherwise a lot of our client won't use our sdk". i still wrote a lot of testcases and tried to understand the working of major features.
BTW, before you guys go on a declare me an embarrassment of an engineer who doesn't know the product's code base, let me tell you that we are talking SDKs (plural) and a service based company here. their was just one SDK with interesting, heavy lifting stuff and 9 more SDKs which were mostly wrappers and less advanced libraries. i got tasks in all of them, and 70% of my time went into maintaining those and debugging client side bugs instead of exploring the "already-stable-dont-change" code base.
so based on my vague understanding and my even more vague memory from 1 year ago, i tried to explain an overall architecture to that interviewer guy. His face was screaming the word "pathetic" from his expressions, so i thought that today i will try to decode the codebase in 12-15 hours, publish a cool article and be proud of how much i know a so called martech system design. their codebase is open sourced, so it wasn't difficult to check it out once more.
but boy oh boy i got so bored. unnecessary clases , unnecessary callbacks static calls , oof. i tried to refactor a few classes, but even after removing 70% of codebase, i was still left with 100+ classes , most of them being 3000-4000 files long. and this is your plain old java library adding just 800kb to your project.
boring , boring stuff. i would probably need 2-3 more days to get an understanding of complete project, although by then i would be again questioning my life choices , that was this a good use of my 36 hours?
what IS a correct usage of my time? i am currently super dissatisfied with my job, so want to switch. i have been here for 6 months, so probably i wouldn't be going unless i get insane money or an irresistible company offer. For this i had devised a 2 part plan to either become good at modern hot buzz stuff in my domain( the one being currently popularized by dev influenzas) or become good at dsa/leetcode/cp. i suck bad at ds/algo stuff, nor am i much motivated. so went with that hot buzz stuff.
but then this interview expected me to be a mature dev with system design knowledge... agh fuck. its festive season going on and am unable to buy any cool shirts since i am so much limited with my money from my mediocre salary and loans. and mom wants to buy a home too... yeah kill me3 -
Seriously guys, how do you deal when remotely collaborating with lets say not the most motivated and competent devs?
Our scrum team got formed about 6 months ago from leftover devs of other teams, choosing a couple competent devs at the core and other devs who were kinda gotten rid of by their old teams, and after 6 months of working together I can see why.
Situation is that we are 7 devs in our team and 4 of devs are not pulling their weight. They are seniors on paper, but in reality not really.
They rarely take something complex to work on and even if they do, they make sure they take as much time as possible. Two of them are contractors who I imagine decided to treat the job as a paycheck and nothing more. There is no initiative, no push to make things better and in general attitude is to do bare minimum: only what is being asked and then delaying the hell out of tasks.
Im not exaggareting: Im talking about every possible way of dragging out the tasks: delaying communication, sitting around for a few days while not asking for new tasks to work on if they are blocked, also avoiding standups. Working for days on very basic comments in their MR's. Getting "sick" for a couple days on deadline when things get tough, so that someone else would come in, refactor and save the day. Once or twice it could be a coincidence, but nowadays I can already guess ahead of time what kind of trick they will pull now.
Our project is an android app where we have to support few different tablets, so the most recent new trick that I witnessed is devs avoiding hardware delivers, sometimes for months. Idea seems to be if you dont ping your team that you dont have hardware, then you can avoid working on related tasks with that hardware.
Worst part is that they get away with it. Our teamlead is a senior dev who is first time teamlead, doesnt code anymore and doesnt want to rock the boat. He is the type of teamlead who sets arbitrary deadlines, makes it sound that they are urgent and takes a few days off in the middle of chaos just before deadline. Restrospectives don't help at all and if I try to bring up stuff directly to him he tells me to bring it up during retrospectives. We discuss issues, rant a bit ant then continue carying on like nothing happened and nothing changes.
So little by little in the past 6 months we came to this point where 2-3 devs are carrying the weight of the team and are in a constant crunch mode, while others are allowed to slack. Its becoming ridiculous.
Problem is that this is starting to affect our morale. Only way that is left to keep my sanity right now is to pull away sometimes and also slack. Then I come back at full capacity, give my best for a couple weeks until I have to go and fix some basic leftover task that has been purposefully dragged out for 2 months and left unfinished, then I just want to scream and I know that its time to disconnect again.7 -
I realized something. No matter what tech i use to code a project there will always be a dev to take a shit on it
someone will recommend to use redis, after i use redis some other dev will trash me for having such a poor choice and recommend me socket.io
Then if i use socket.io some 3rd dev will trash me cause thats not the right way of building stuff and recommend me kafka
If i use kafka some 4th dev will trash me and say why i dont use angular
If I use angular 5th dev will trash me for not using react
If i use react 6th dev will trash me for not using nextjs
Tired of this bullshit
I'll use whatever tech i need. If i dont know what to use ill ask and take the first suggestion. I'll just build a saas and when it starts earning money ill pay other devs to refactor and scale the hell hole (which wont be cause i write good code following solid principles and not spaghetti). Much simpler solution than wrecking my head with decisions of tech stack8 -
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 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 -
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
-
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
-
As my first dev job, I took over role of solo programmer maintaining all kinds of custom-made software used by local ISP. It was about 10 years ago.
My first question was where can I find test environment and repo. Apparently there was none and I should learn and develop on production.
My sin was to quickly give up on setting up both test and repo.
My second sin was to continue using the same copy&paste PHTML with register_globals enabled, building over it without attempting to refactor it with templates. I did not use globals in any new code at least.
And I suppose my third sin was that I was playing games when I was done with my tasks. I could have used that time to refactor a bit.
But I think in the end I was absolved from them since I was the only one suffering from this. I stayed with company until it got sold and helped migrate data over (along with myself). -
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
-
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
-
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 -
Legacy code was so bad that it created the existence of my team to do a refactor and rewrite.
(Outsource to in house) -
Once took over a bunch of webservices from a coworker who had found another job.
Worst bunch of copy-pasted, anti-pattern, duplicates-ridden, dead-code infected spaghettimess I ever saw.
I spent a year getting that shit into a semblance of order. You could tell for certain the guy had no professional pride or sense of maintainability.
The kicker is, after that year of getting everything in shape, I got laid off due to cutbacks.
'Hey, great work, Refactor Ninja!
Now leave, you must be needed elsewhere!'
🙄 -
FML!!!!!! I FUCKING HATE THE COMBINATION OF XAMARIN FORMS AND MY COWORKERS.
Explanation:
I had to refactor all of our views because my coworkers did anything in the code-behind file from the views but the code should be in the viewmodels.
I had an "Unhandlex Exception" without any stacktrace or error message for a hour. What was the error? In the xaml file of the view was still an OnClicked-handler of a button but i removed the method from the view-code-behind-file.
FML1 -
The evolution of code, in Python:
-Many scripts
-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 😄😊 -
Do you plan the application, on which you will be working, before you actually begin to write code?
I do web development and usually begin with something rough or look at designs of other developers. Like an dashboard example, when I see an image on google search that I like, I try to make something simmilar and when I have the surface I can add the functionality and improve the design.
Sometimes I have to make changes in half of the development because at the beginning there was no assumption that there will be a need for a certain functionality or I change a implemented feature to work properly, so I have to refactor something I made as a ground on which other parts will rely, although if I had planed the application in detail, maybe it wouldn't come to such refactoring.
In school we did prototypes, used to draw flowcharts and hold on a precedence diagrams that we made, but now at work when I receive an projekt I just begin to code :-D maybe this should change, how do you do it? If you plan your project, how do you do it?9 -
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 -
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.
thank you.2 -
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 -
What's better for finding candidates for a development role: having the candidate solve a complex whiteboard problem or have the candidate refactor some code (maybe a couple of small modules) while explaining as he/she goes through each step?
I personally feel both are good, but I think refactoring is a very much needed skill when you're dealing with the complexity of millions and millions lines of code, so being able to change your inital design to make it more readable and flexible later on is crucial. And refactoring usually goes hand and hand with having tests in place.
An interesting exercise would be to give the candidate a test suite with the corresponding code that's tested in a working state and let the candidate decide how much refactoring needs to be done. In the process the candidate would need to break and fix tests of course while changing things... it'll give a good measure of their ability to take code and change it to a "better" state of design and flexiblity.
On the other hand I do think there is a place for cliche white boarding problems because it really shows one willingness to tackle complex problems which do arise in most development jobs. Asking the questions and being persistent goes along way and can really help when you're collaborating with other developers to solve an issue at hand.
Overall I think there should be a white board problem, but I don't think that should be the deciding factor. Rather couple it with other very practical skills you should have as a developer already; among those being refactoring.1 -
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 -
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. -
#Story time.
Been working on a project for 2 months with Colleague "Jim" doing the code reviews. Project is finished in a stable form and can be extended if needed. Then my other colleague/boss "Mo" decided that we need to do a refactor. Fast forward a bit and the conclusion is "Mo" and "Jim" are going to discuss every step with me. And we started a new project that should do the same as the project I just finished
Here some facts:
Every day a meeting/ code review / discussion.
Decisions they make I do not agree with.
I need to redo my work multiple times.
Now this does make me look like a toddler that needs supervision which is not the case.
They want something future proof and something that fits his new coding standard "Mo". and certain things I do agree with and is clearly the better architecture. however somethings are just stupid, time wasting, making it worse. I'm getting so frustrated by the fact that billion dollar companies have clear coding standards that work. and are correct. and this company decided to do their own thing of stupid rules!
- shorten variables
- Keep lines under 90char
- put multiple things in 1 file
- Keep function names short
and many more of removing stuff and let you guess stuff..
I just... *sigh* get so tired of this shit.
*names are randomly chosen2 -
Need to refactor the code base, and when looked at it, we don't have single UnitTest.... F*** them all1
-
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
-
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.
-
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* -
There is a particular power move when you take someone's shit code, refactor it to make it faster, safer and more readable and then request a review from them on your PR. "See how I dunked on you, bitch. This is what superiority is about." And at the same time you can be perfectly polite with "oh you know this part of the code well, I wouldn't want to break anything there" with the "bitch" just strongly implied.3
-
It's really sick how beginners start to code in Javascript and CSS, and their complex frameworks, without even understanding atleast the paradigm first. Googling your way up can be fine for smart ones, but as least time optimal this learning method sounds, it's as dangerous and non-productive too.
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?3 -
Currently, I refactor some code in a private project at home. Yesterday I ran tests and some things didn't work I thought I already fixed. After I fixed them other things were broke and again errors felt familiar. With every fix and every new error I was more and more sure, I already did exactly the same things before. I thought, maybe it is a Déjà-vu or I dreamed about that.
After two hours, when everything was working again, I realized I did all this two nights before in a branch and totally forgot about it.
I wasn't even drunk -.-' -
I should learn how to stop at dead end.
Sometimes I am too deep into problem and I just cant stop programming, debugging and thinking about it. It would be better to make a pause for like a hour, turn my brains off and later start again but I just cant. Even if I leave my desk my brains remains at the problem. Sometimes I want to stay at work to solve it... xD Eventually I solve the problem and after a good sleep I rewrite and refactor all code becuase I found a better solution in like 30 mins. It frustrates me because I dont know how to turn off...
Anyone else?1 -
The project that I'm assigned to was developed in haste because of some competition with other vendors.
The Devs who worked on the original code didn't really follow each others spacing conventions. So now there are files which differ in spacing. A lot. And I'm used to the standard 8 spaces=1 tab convention.
Every frikkin time I have to even look at the code, I have to refactor it (but not save it) and then undo the refactoring because when I try to check in the refactored code, every line shows a conflict.
Every line.
So if I have to work with code which was written by more than one person, my life's a living hell.
Ctrl+Shift+F people! Use it or lose it!6 -
Working now 8 months at a company. (C++)
Every feature becomes a refactor and a code clean
Every bug becomes a refactor and a code clean
Every Refactor becomes a code purge. :/1 -
I'm slowly realizing how much goofy code I put in my branch and overlooked. This code review is going to be interesting...
Some examples:
import plots as lel
<h4 id="title">Crunchatize Me, Captain! </h4>
go.Scattergeo(name="cheese", ...)
webster = { ... }
The commit messages are even worse.
- 'horizontalize' link list
- very messily hack in <feature>
- partially refactor some of the awful code from previous
- Remove one annoying space
- make background color less annoying
- remove seemingly useless property
- minor fix
- Apparently it's possible to center a DIV. Who knew?
- Made some cool bar graphs
And then there's just a bunch of reverts.2 -
Now i am given a task to refactor some piece of Predicate code and then update the unit test so it can be compatible and work with new data
WHAT. Is the Fucking point of unit tests if you have to modify them to adapt to new code anyways???
Unit tests exist just so u can stroke ur sausage??? Just so u can give ur ego an orgasm to tell others "hey look at me how good code i wrote that even unit tests are passing!" ???
I always found unit tests sketchy. almost as if its useless and unnecessary. I still get why they are used (some other dev working on feature 2 might break my shit and unit test can save the day) but if thats the only reason then that doesnt seem like a strong enough reason for me
By now im talking about java!
No wonder i have never seen a single nextjs developer ever write a single unit test. Those people have evolved beyond unit testing just as the nextjs technology itself!
This is why nextjs is the future of web and the Big Daddy Dick King 👑 of technology!8 -
When you feel that only you and maybe one other guy from the team care about product and do effort to actually refactor legacy spaghetti code while others just patch it up or even build changes on top of legacy spaghetti!2
-
At my new organization , they love spaghetti code, they neither want me to refactor it, because it works. Special thanks to php.6
-
- 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 -
Things could be soo much better if I could just refactor this code to accommodate more than one web service... #soapmessages #devwoes
-
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.
-
I need advice fellow developers, am I stubborn?
So I lost an argument in my team regarding constant vs variable directly in a method for stored procedure names.
I separated names of procedures into their own StoredProcedureConstants file because it makes it very easy to see all procedures used in a project and refactor their names if necessary. Argument against was that you loose time creating a constant. Am I silly if I am alergic to seeing quotation marks stuff without its designated purpose throughout the code?
Their way is adding var procedureName = "cc.storeProcedureName" directly in a method. I just can't find my peace with it. To me this is a magic string.
Am I being unreasonable?3 -
Today I was revisiting my first ever WPF project made, turns out that a baboon could have written better code than this.
The project literally has messages going everywhere to every viewmodel even if it's not supposed to.
I'll spare the details, but let's just say I'd rather jump in a mountain of needles than try to add a feature in this mess.
So I am now refactoring without my bosses permission since I am the only one in this company able to work with WPF and I still have enough time for a simple refactor.
Already on about 200 errors by just changing a few lines of code because everything inherits everything. -
Rarely refactor my code: sometimes there are completely same parts of code which I am too lazy to move to a separate function)))
-
trying to refactor some code to implement a issue/feature on a ticket:
try option A. .... 2 hours later hit a Dead end.
try option B .... 1 day later.. another dead end.
try option B.2f ... I want to give up... wasting all my time...
Not sure what I'm suppose to do anymore..
It feels chaotic and dirty hacking to make it work.. and even now. I cannot get it to compile...
Only solution looks like Copy and paste a couple of classes and change one single variable. with huge preprocessor #if around them.
I need to take a shower I feel dirty now...1 -
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. -
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. -
I'm sitting here in the dark and can't program because no electricians are available... Right before a deadline...
I worked on refactoring my code for our University lab's project (I am the programmer assigned to it) for almost a week and managed to refactor most of my old and unorganized code. Today I finally had the chance to finish the job.
While everything was open I decided to charge my laptop (I work on a desktop) and the moment I plugged it in the room turned dark. I realized I just have to turn the fuse back on but of course all the fuses are on already. Appearantly that short-circuit fried my home's electrical framework somehow and because it's a weekend I can't get in touch with any electricians.
All my code was committed but not pushed so now I am stuck here before a deadline with no way to work...
tl;dr Because of a short-circuit I don't have any electricity and all my work is unpushed.3 -
I thought my code was bad and that was why it was taking twice as long as any other group to run
No it’s just Illinois the state my group was assigned has almost 2000 more data rows to scrape compared to any other group. My code wasn’t running slow. It just had longer to run
I’ve spent 4 days trying to fucking refactor and improve my code Ignoring clean code and attempting clever code to run faster and now I need to revert back to clean code since no one else in my group would be able to understand or work on the damn file if I left it at clever
Fucking hell 😫1 -
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. -
Collect project specifications & details.
- order by relevance.
List & install dependencies (possibly spin up a vm).
mkdir ~/Code/{lang}/{framework?}/{project}
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 -
Coworker: "Hey, so I discovered this library that automatically brings up and tears down local containers to perform unit tests on data sources"
Me: "Sounds neat"
Coworker: "Yeah, I've been messing with it locally, and it means we don't need to have the data sources installed on our machines or rely on the ones in the testing environment."
Me: "That's good"
Coworker: "Just a shame I had to roll back our testing framework to a previous version and refactor the code in all our other tests as a result."
Me: "Wait what? *looks at documentation* It says they support the newer framework"
Coworker: "Yeah, but I couldn't get it to work. So I'm just gonna make a PR for it, okay?" *Proceeds to make a PR, approve and merge the code before I can comment further on the changes*
Welp, there goes all my motivation to get anything done for the rest of the day.3 -
Should I modify the file? or Copy the file?
it is already in use for a similar case but different.
double code vs doing one thing per class
a large refactor is needed for this one.
#codestruggles2 -
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 -
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.
-
Wait. Why does this work? It doesn't copy any of the frontend code into the deploy location.
I'm not sure how this works, but it does. Crap, there goes my morning tracking down this wretched spaghetti deploy code.
At least I understand how it works in production. Shit, why is it different between production and our integ servers ,that isn't good. Maybe I can just refactor it.
That was all on Monday. It's now Wednesday and I'm still fucking refactoring something that wasn't actually broken. It just didn't make sense.
Maybe I should just revert my last three days of work on this branch and move on. No! It's too late, I've invested way too much time into this project...
... and I'm almost done, just a few more commits right? -
Oh when you refactor the complete project structure and give for build the first time !!!
It's like you are sitting with your heart on your hand and praying to God that at least let the errors be readable(I am no genius to think I will be able to produce error free code the first time😝😝) -
“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
-
A follow-up to a previous rant: https://devrant.com/rants/2296700/...
... and how the senior dev recently took it up a notch.
To recap: Back then the senior dev in our two-man project prepared tasks for me so thoroughly they became typing monkey jobs. He described what to do and how to do it in minute detail in the JIRA tasks.
I talked to him back then how this is too detailed. I also talked to our boss, who agreed to nudge mr. senior in the right direction and to make it clear he expects teamwork.
Fast forward to a couple of days ago. An existing feature will get extended greatly, needing some rework in our backend project. Senior and me had a phone call about what to do and some unclear details in the feature spec. I was already frustrated with the call because he kept saying "No, don't ask that! That actually makes sense, let's just do it as the spec says" and "Don't refactor! We didn't request a budget for that from our customer". Like wtf, really? You don't consider refactoring part of our job? You don't think actually understanding the task improves the implementation? Dude...
We agreed this is a task for one person and I'd do it. It took me the rest of the day to wrap my head around the task and the corresponding existing code. It had some warts, like weird inheritance hierarchies and control flow jumping up and down said hierarchy, but nothing too bad. I made a mental note to still refactor this, just as much as necessary to make my task easier. However... the following day, I got an email from mr. senior. "I refactored the code after all, in preparation for your task". My eyebrows raised.
Firstly, he had made the inheritance hierarchy *worse*. Classic mistake: Misusing inheritance for code reuse. More control flow jumping up and down like rabid bunnies. Pressed on that matter, he replied "it's actually not that bad". Yeah, good work! Your refactoring didn't make things worse! That's an achievement worthy of being engraved on your tombstone. And didn't he say "no refactoring"? Apparently rules are unfortunate things that happen to other people.
But secondly, he prepared classes and methods for me to implement. No kidding. Half-implemented methods with "// TODO: Feature x code goes here" and shit. Like, am I a toddler to you? Do you really think "if you don't let me do things myself I feel terribly frustrated and undervalued" is best answered with giving me LESS things to do myself? And what happened to our boss' instruction to split the task so each of us can work on his parts?
So, this was a couple of days ago. Since then, I've been sitting in my chair doing next to nothing. My brain has just... shut down. I'm reading the spec, thinking "that would require a new REST endpoint", and then nothing happens. I'm looking at the integration test stubs ("// TODO: REST call goes here") and my mind just stays blank, like a fresh unpainted canvas. I've lost all my drive.
I don't even know what to do. Should I assign the task back to him and tell him to go fuck himself? Should I write my boss I'm suddenly retarded? Could I call in sick for a year or so? I dunno... I can barely think straight. What should I do and how?5 -
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
-
c3tools
I want to finish it so badly. I have everything I just need time.
JJittai
Every time I see the code I wanna dance. I want to work on that so much but I haven't in a long time, I want to refactor everything (I've changed a lot in that time), it will be so delicious.
If you are curious about them you can see them in my github account.
And of course the rest but with these I'd be so satisfied. -
Only God can refactor this code.
I wish I knew who wrote this. 😬
App.jsx is doomed, looks like the content of jquery.min.js.
4:04 sleep not found. -
"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 -
So worked myself into stupor for a react-native app(first -time). It is the client part for large system ecosystem. Was rough at first but after initail field test and refactor to the code base it is in 95% stable form. This all happend in 2 months. During this time co-workers build rest of system in node and other backend magic sauce 👩💻 .
My app has sibling app to collab with. I make a note (early in the development of this sibling app) that the ui is not working for the use case and get in a heated debate with co-workers. Concede 🙌 that it is not my part of the system and leave it to them, they blame the fact that no design was given. Fast forward to yesterday I get munched by client that wants to showcase the system to large company and has to struggle with sibling app. I tell him it is something "we" would look at in the next cycle ( covering for my coworkers) .
I feel shit and year now starts off with crappy feeling that all my hard work to get my app to decent version of itself is lost☠️ . -
I was planning on migrating my Mastodon instance to a new node, but then I looked carefully at my deployment scripts. I had built in support for multiple servers, but not everything supports it, and the configuration is messy now that I think about it.
Now I need to write a bunch of tests, and then refactor a bunch of my code. Hopefully I can get this done before I run out of space on my Mastodon instance. It's gonna be a fun day. :-P -
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. -
Since we are sharing some of our more interesting commits, what do people think of these commits?
General: pro.user update
297af8f
Refactor: Hide and show Spin Boxes on Normalization
6a4e1f3
Refactor: Dynamic resizing refactoring
964f0ae
Refactor: Dynamic resizing across any screen
5890a35
GUI: Measure screen size and assume the proper size.
13f2cb4
Fix: guitest.cpp has been reafactored
5cbc1b4
Dir: Clean unused directory
32c8384
GUI: Hide and show Spin Boxes on Normalization
84db444
Commits on Jun 28, 2016
GUI: Make boxes more bolded
3d23952
General Commit: 11:03 PM 6/28/2016
678c249
Del: build from previous commit
e428041
Fix: Guitest's compiled code was broken
25f546f
GUI: Make window scrollable.
07091fd
Adjust; Changing directory tree -
I need to go buy a rubber duck so it looks less like I'm talking to myself. Trying to pull out and refactor some shit functionality in a WordPress theme because the client NEEDS it. Frankly all it is doing is creating a custom post type, but they're used to the way they've been doing it and I'm stuck with dealing with it. I generally like this part of my job (my face in the code) but trying to read this huge mess of code with no standards is driving me insane.
"What in the hell are you doing here?" "Why do we have variables for $thedata, $the_data, and $theData?"
"Why are your brackets on the wrong line sometimes?"
"Why is each line in this function enclosed in it's own PHP tags rather than around the function?"
At least if I had a duck I could say I'm talking to him.3 -
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) -
Yes, actually, I will complain that the code I inherited is shit and then proceed to not refactor it2
-
As an android dev when I inherited a shitty project thats when I realized what really means to write readable and most importantly testable code. Codebase I inherited wasnt even really that bad it was quite readable, but boy it was not suited for any unit/instrumented tests. im talking spaghetti code.
Nowadays I refactor apps to make sure they are testable instead of spending weeks writing tests for a shitty codebase which was done without thinking about separation of concerns. Clients hate the extra couple weeks on top of request but what can I do, if they want tests they need to work with TDD approach or give extra time for refactors. -
So I’m taking a class on compilers (currently a college student) and as I get further into a coding project we have to do I can feel and see my code degrading into a giant mass of spaghetti. Although I know that I should refactor it because it is messy (currently trying to find a balance between refactoring and actually getting the assignment done) the scary thing is some students in my class think this is perfectly normal code and is what good code looks like. Scary thought that so many people graduating from university have no concept of object orientation, reusability, etc... but what’s even scarier is most professors could not give two shits about any of these notions. I guess this is the biggest reason why a computer science degree does not prepare you for a job in industry.
-
Have to refactor one Big shitty class with thousands of lines of code... Thanks to Bachelor thesis1
-
function customActions() {
changeActions(this);
}
Why? Why is this in the code I'm told to refactor?
What am I supposed to do with this?1 -
After almost 3 years of professional experience I’d like to specialize more in something but I struggle to because I enjoy almost every aspect of IT: I find front-end really fun, I find very rewarding to build good user experiences and I’m excited for what WASM may bring on the table but I even like to work on the back end on both: legacy monoliths and modern micro services, I love to refactor clunky programs full of “cargo cult” code and redundancies put by people who doesn’t understand the framework they’re using and to make them shine. I’m even good at UNIX/Linux scripting and with Docker (often colleagues asks me advice on these topics) so I’m really tempted to upgrade my knowledge by learning K9S and reading the 1000+ pages of Unix Power Tools to get into operations/DevOps especially considering which the field is the least likely to be overrun by cheap developers coming from a 3 months boot camp.
On top of that I’ve got even into more theoretical topics: I’m following a course on algorithms and data structures in C and in future I want to learn the basics of AI for a personal project but these things aren’t much about employment but personal culture.
Have you got any advice for this disoriented young man?12 -
So apparently my code went to prod more or less all right. Phew, the deadline was this week-end. This project have been sitting there for month, they gave me the technical requirement and never bothered to ask the stakeholders about it. When the contract went in, they started to freak out it wasn't usable.
The thing is, this project had way more moving part and trying to threat video in the frontend is not the easiest. But now is REFACTOR TIME.
I dream of getting rid of the browser video api (too flaky), download the bitmap directly and render it in requestAnimationFrame. I call it just-in-time rendering. I think i'd need to put a decoder in aws, I did it already with ffmpeg. I could not manage to put it in streaming mode though, so it was still a bit slow, but i could decode, write and re-encode faster than the video player speed.
What do you lads think? Doable or not? I at least need to general tidy up (this codebase have grown organically without any fucking direction from above, like this project took all my time on the technical side, I did not have time to run after people to get specs), centralizing state, improve monorepo and tooling, perfs,...
Hopefully they understood i cant keep adding whatever feature they want today. -
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
-
2 weeks+ ago I made a PR into our codebase containing sample refactor that streamlined a significant portion of code. Also, I did refactor only on two handler packages (for MVC folks, that's Controller) as proof of concept, to figure out how convinient / logical the part would be for everyone.
We have rule of 2 approvals for merge (for 5 team members)
While writing refactor, it obviously blown up a lot of unit tests, but still coverage was fairly poor (that stuff was rushed, there was back than no time for unit tests). After my refactor I spent couple of days writing tests that hit fairly sweet (comparatively) coverage. (I managed to bump coverage from low 20s to high 80s, and have less code for tests)
I got first approve pretty much immidietely, other team member was on vacations, and 2 of them forgot.
We generally try to close PRs fairly quickly (usually same day kind of deal), but that one was just.. hanging in there. So I pinged everyone to re-check it to greenlight it but of course, loo and behold, merge conflicts arised. I ended up fixing actual logic (just some method signatures changed, not a big deal) and ran the units.
So, one of that handlers got quite a few of edits, and guess who is pretty much rewriting unit tests for second time now...
Dude, sometimes I question why tf I even bother with these tests... Feels like sabotaging my productivity, especially with bullshit like that3 -
Best part of being a dev: seeing my code grow, take shape and become robust, line after line, refactor after refactor.
-
#Suphle Rant 6: Deptrac, phparkitect
This entry isn't necessarily a rant but a tale of victory. I'm no more as sad as I used to be. I don't work as hard as I used to, so lesser challenges to frustrate my life. On top of that, I'm not bitter about the pace of progress. I'm at a state of contentment regarding Suphle's release
An opportunity to gain publicity presented itself last month when cfp for a php event was announced last month. I submitted and reviewed a post introducing suphle to the community. In the post, I assured readers that I won't be changing anything soon ie the apis are cast in stone. Then php 7.4 officially "went out of circulation". It hit me that even though the code supports php 8 on paper, it's kind of a red herring that decorators don't use php 8 attributes. So I doubled down, suspending documentation.
The container won't support union and intersection types cuz I dislike the ambiguity. Enums can't be hydrated. So I refactored implementation and usages of decorators from interfaces to native attributes. Tried automating typing for all class properties but psalm is using docblocks instead of native typing. So I disabled it and am doing it by hand whenever something takes me to an unfixed class (difficulty: 1). But the good news is, we are php 8 compliant as anybody can ask for!
I decided to ride that wave and implement other things that have been bothering me:
1) 2 commands for automating project setup for collaborators and user facing developers (CHECK)
2) transferring some operations from runtime to compile/build TIME (CHECK)
3) re-attempt implementing container scopes
I tried automating Deptrac usage ie adding the newly created module to the list of regulated architectural layers but their config is in yaml, so I moved to phparkitect which uses php to set the rules. I still can't find a library for programmatically updating php filed/classes but this is more dynamic for me than yaml. I set out to implement their library, turns out the entire logic is dumped into the command class, so I can neither control it without the cli or automate tests to it. I take the command apart, connect it to suphle and run. Guess what, it detects class parents as violations to the rule. Wtflyingfuck?!
As if that's not bad enough, roadrunner (that old biatch!) server setup doesn't fail if an initialization script fails. If initialization script is moved to the application code itself, server setup crumbles and takes the your initialization stuff down with it. I ping the maintainer, rustacian (god bless his soul), who informs me point blank that what I'm trying to do is not possible. Fuck it. I have to write a wrapper command for sequentially starting the server (or not starting if initialization operations don't all succeed).
Legitimate case to reinvent the wheel. I restored my deleted decorators that did dependency sanitation for me at runtime. The remaining piece of the puzzle was a recursive film iterator to feed the decorators. I checked my file system reader for clues on how to implement one and boom! The one I'd written for two other features was compatible. All I had to do was refactor decorators into dependency rules, give them fancy interfaces for customising and filtering what classes each rule should actually evaluate. In a night's work (if you're discrediting how long writing the original sanitization decorators and directory iterator), I coupled the Deptrac/phparkitect library of my dreams. This is one of the those few times I feel like a supreme deity
Hope I can eat better and get some sleep. This meme is me after getting bounced by those three library rejections -
let target: any = e.target;
if (target.nodeName) //other code
Results in a typescript? error wherein it says that Property 'nodeName' does not exist on type 'EventTarget'. but if I refactor the variable name to something that isn't target it works
i don't understand2 -
Arrgh...
I need to do a lot of refactoring and testing (%80 percent of which is integration) and ITS SO TEDIOUS!!!
Now, for anyone who says "oh, you write spaghetti code, your code shouldn't be so tedious to refactor". No. It's only tedious because it's a few thousand lines that I've been too lazy to refactor till now, and I need to go through it all.
Anybody have any advice for refactoring or testing in Go?17 -
I am about to refactor a huge reactjs/nodejs spagetti code into angular9 front and php7.3 backend.
Change my mind7 -
-yesterday-
Okay i should done this code tomorrow
-next day-
Watching youtube till evening
Thinking about annoying senior who tried to refactor everythign
What i have done, -
How do you deal when you are overpromising and underdelivering due to really shitty unpredictable codebase? Im having 2-3 bad sprints in a row now.
For context: Im working on this point of sale app for the past 4 months and for the last 3 sprints I am strugglig with surprises and edgecases. I swear to god each time I want to implement something more complex, I have to create another 4-5 tickets just to fix the constraints or old bugs that prevent my feature implementation just so I could squeeze my feature in. That offsets my original given deadlines and its so fucking draining to explain myself to my teamlead about why feature has to be reverted why it was delayed again and so on.
So last time basically it went like this: Got assigned a feature, estimated 2 weeks to do it. I did the feature in time, got reviewed and approved by devs, got approved by QA and feature got merged to develop.
Then, during regression testing 3 blockers came up so I had to revert the feature from develop. Because QA took a very long time to test the feature and discover the blockers, now its like 3 days left until the end of the sprint. My teamlead instantly started shitting bricks, asked me to fix the blockers asap.
Now to deal with 3 blockers I had to reimplement the whole feature and create like 3 extra tickets to fix existing bugs. Feature refactor got moved to yet another sprint and 3 tickets turned into like 8 tickets. Most of them are done, I created them just to for papertrail purposes so that they would be aware of how complex this is.
It taking me already extra 2 weeks or so and I am almost done with it but Im going into really deep rabbithole here. I would ask for help but out of other 7 devs in the team only one is actually competent and helpful so I tried to avoid going to him and instead chose to do 16 hour days for 2 weeks in a row.
Guess what I cant sustain it anymore. I get it that its my fault maybe I should have asked for help sooner.
But its so fucking frustrating trying to do mental gymnastics over here while majority of my team is picking low hanging fruit tasks and sitting for 2 weeks on them but they manage to look good infront of everyone.
Meanwhile Im tryharding here and its no enough, I guess I still look incompetent infront of everyone because my 2 weeks task turned into 6 weeks and I was too stubborn to ask for help. Whats even worse now is that teamlead wants me to lead a new initiative what stresses me even more because I havent finished the current one yet. So basically Im tryharding so much and I will get even extra work on top. Fucking perfect.
My frustration comes from the point that I kinda overpromised and underdelivered. But the thing is, at this point its nearly impossible to predict how much a complex feature implementation might take. I can estimate that for example 2 weeks should be enough to implement a popup, but I cant forsee the weird edgecases that can be discovered only during development.
My frustration comes from devs just reviewing the code and not launching the app on their emulator to test it. Also what frustrates me is that we dont have enough QA resources so sometimes feature stands for extra 1-2 weeks just to be tested. So we run into a situation where long delays for testing causes late bug discovery that causes late refactors which causes late deliveries and for some reason I am the one who takes all the pressure and I have to puloff 16 hour workdays to get something done on time.
I am so fucking tired from last 2 sprints. Basically each day fucking explaining that I am still refactoring/fixing the blocker. I am so tired of feeling behind.
Now I know what you will say: always underpromise and overdeliver. But how? Explain to me how? Ok example. A feature thats add a new popup? Shouldnt take usually more than 2 weeks to do my part. What I cant promise is that devs will do a proper review, that QA wont take 2 extra weeks just to test the feature and I wont need another extra 2 weeks just to fix the blockers.
I see other scrum team devs picking low hanging fruit tasks and sitting for 2 weeks on them. Meanwhile Im doing mental gymnastics here and trying to implement something complex (which initially seemed like an easy task). For the last 2 weeks Im working until 4am.
Im fucking done. I need a break and I will start asking other devs for help. I dont care about saving my face anymore. I will start just spamming people if anything takes longer than a day to implement. Fuck it.
I am setting boundaries. 8 hours a day and In out. New blockers and 2 days left till end of the sprint? Sorry teamlead we will move fixes to another sprint.
It doesnt help that my teamlead is pressuring me and asking the same shit over and over. I dont want them to think that I am incompetent. I dont know how to deal with this shit. Im tired of explaining myself again and again. Should I just fucking pick low hanging fruit tasks but deliver them in a steady pace? Fucking hell.4