Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Get a devDuck
Rubber duck debugging has never been so cute! Get your favorite coding language devDuckBuy Now
Search - "code pattern review"
Allright, I'm pissed.
Warning: more than 4k characters written by a non native english speaker ahead.
> Short summary of the current situation
> "Something being said"
> (Something being thought)
* Actions *
-- Background --
In an attempt to reorganize my desktop I accidentally deleted a folder I called "development". In there I stored links to all my IDEs (Not sure how you call these in english), but also some workspaces like unity (Not much stuff there, processing (just some hobby stuff) AND Eclipse (FUCKING EVERYTHING RELATED TO SCHOOL WEB DEVELOPMENT). Now 3 days have passed and I realized this important folder was missing. Cleared that windows trash the instant I deleted the trash on my desktop.
> Shit, Regret
Install a file restore programm. Do every possible search. Nothing found.
> Big shit
Deadline was in like 3 days. Week was fucking rough so:
> "Screw this, the teacher nevet corrects the assignments and also fuck JSP"
Fast forward 2 months to last week. Teacher starts checking assignments.
* Sees pattern: Only students with missing or bad marks are checked. *
* Feels save *
Teacher approaching me while working on current projects.
* Doesn't feel save anymore *
> "Well, I'ld like to see your THAT programm"
> Well fuck
* Tells the truth *
> "Well that's unfortunate, but I must write a mark. Do you really have nothing to show?"
* Remember that I worked on the school pcs when I started *
> (Better than nothing. Gotta try it)
* Teacher checks programm, not pleased *
> (Fuck me, but at least it's over...)
* Teacher calls me over *
> "With the mark I had to write today you can't reach that good mark even with a good examination, what are we gonna do about this?"
> "Well, there were other assignments that were never checked. Could we replace that mark with one of those?"
* Teacher agrees *
> (Srly bless this guy for that support)
My best choice was an Android app we had to develop during December in pairs. I did the front end (90% of the whole work) and my partner the backend (10 %). I also did 30 % of these 10 %, because I had to review the shit he wasn't able to debug himself.
> brainlogic.exe provided by windows vista
This distribution was partly my fault since I overestimated the work needed for the backend, but also the fault of that fucker. I mean, he didn't tell me the professor already provided 90 % of the backend...
Rest of the week was really busy (always 1 or 2 things to study for each day, workout and family stuff).
Yesterday (It's past 12 already) I arrived at ~9 pm in the dorm I could finally start reviewing my code.
Internet gets shut down at 10 pm.
* Opens project *
* Sees half a year old code *
* Fights urge to puke *
> (Alright I gotta do this. For the mark!)
* waits for gradle to index files *
* Remembers the fact that I haven't opened Android Studio in the last 2 months *
For those who don't develop with android studio: This is an equivalent to ~10k windows updates waiting to be installed
> (Well, gotta work with this kinda old version)
"gradle sync failed"
> ( Ok, just restart it. You're fine )
* Android Studio doesn't react anymore and/or renders *
* Waits 5 min *
* Restarts laptop *
* Android Studio is reacting again*
"gradle is synching"
9:45 pm: gradle is done and I can finally compile my app
* Sees App launched on phone *
* Almost pukes again *
> (This was the assigment for the UX chapter, so design doesn't matter)
UX is decent. Proceeds with testing stuff. Save paths work, but some bugs can be caused by going of it
* fixes as much as possible *
* Takes quick look at backend *
Date date = new Date (GregorianCalender.getInstance().getTimeInMillis());
C'mon, I asked you to be the backend. You got 90% of the methods already written by the teacher and had 2 months to write the interfaces to my Front end AND you come up with shits like that.
Note: this example is a minor example of brainlogic.exe
I did what I could to make improve my situation. Hopefully he doesn't discover the bugs. And If it's a backend bug then I could't care less, since that was not my job!
Wish me luck for today!9
Refactoring code of somebody who left and:
- Plagued the code with TYPOS (milions of them but ok I can live with those... to a certain point)
- Used global variables by default.... of course even where they're not needed
- Used comments only in parts of code where... well they're not needed, important ones are of course left out
- Did not indent code. 3..2..1... Did not FUCKING indent code properly and when he did... did WRONG!
- Instead of indentation he used commented line with multiple ==== signes.... so far top is 60 consecutive lines with olny ==== again no apparent pattern here
- Did not follow a fucking standard in variable naming... no camle casing... there are varaibles assigned multiple times to "temp" variables without no reason just for the sake of wasting resources on the system I guess
This is just the beginning of the review but I already want to change job, die, scream, cry... not in any specific order.10
Just need to get this off my chest. Started a new job 3 weeks ago at a company that has been around ~18 years, it is only recently that they have started to grow more rapidly. I was brought in under the guise that they wanted to embrace change and better practices and so said I was up for the challenge.
In my 2nd week I was asked to produce a document on tackling the technical debt and an approach to software development in the future for 3 consultants who were coming in to review the development practices of the company on behalf of the private equity firm who has taken a major stake in the company. I wrote the document trying to be factual about the current state and where I wanted to go, key points being:
Currently a tightly coupled monolith with little separation of concerns (73 projects in one solution but you have to build two other solutions to get it to build because there are direct references.).
Little to no adherence to SOLID principles.
No automated testing whatsoever.
Libraries all directly referenced using the file system rather than Nuget.
I set out a plan which said we needed to introduce TDD, breaking dependencies, splitting libraries into separate projects with nuget packages. Start adhering to SOLID principles, looking at breaking the project down into smaller services using the strangler pattern etc. After submitting what I had written to be part of a larger document I was told that it had been tweaked as they felt it was too negative. I asked to see the master document and it turns out they had completely excluded it.
I’ve had open and frank discussions with the dev team who to me have espoused that previously they have tried to do better, tackle technical debt etc but have struggled to get management to allow them. All in all a fairly poor culture. They seem almost resigned to their fate.
In my first 2 weeks I was told to get myself acquainted and to settle myself in. I started looking at the code and was quite shocked at how poorly written a lot of it was and in discussions with my manager have been critical of the code base and quite passionate and opinionated about the changes I want to see.
Then on Friday, the end of my third week, I was invited to a meeting for a catch up. The first thing I was told was that they felt I was being too openly critical in the office and whether I was a good fit for the company, essentially a stay or go ultimatum. I’ve asked for the weekend to think about it.
I’ve been a little rocked by it being so quickly asked if I was a good fit for the company and it got my back up. I told them that I was a good fit but for me to stay I want to see a commitment to changes, they told me that they had commitments to deliver new features and that we might be able to do it at some point in the future but for now I just needed to crack on.
Ordinarily I would just walk but I’ve recently started the process to adopt kids and changing jobs right now would blow that out the water. At the same time I’m passionate about what I do and having a high standards, I’m not going to be silenced for being critical but maybe I will try and tackle it in a different way. I think my biggest issue is that my boss who was previously a Senior Developer (my current position) has worked at the company for 12 years and it is his only job, so when I’m being critical it’s most likely criticising code he wrote. I find it hard to have the respect of a boss who I had to teach what a unit test was and how to write one. It makes it hard to preach good standards when by all accounts they don’t see the problems.
Just wondering if anyone has suggestions or experience that might help me tackle this situation?12
Ever heard of event-based programming? Nope? Well, here we are.
This is a software design pattern that revolves around controlling and defining state and behaviour. It has a temporal component (the code can rewind to a previous point in time), and is perfectly suited for writing state machines.
I think I could use some peer-review on this idea.
Here's the original spec for a full language: https://gist.github.com/voodooattac...
(which I found to be completely unnecessary, since I just implemented this pattern in plain TypeScript with no extra dependencies. See attached image for how TS code looks like).
The fact that it transcends language barriers if implemented as a library instead of a full language means less complexity in the face of adaptation.
Moving on, I was reviewing the idea again today when I discovered an amazing fact: because this is based on gene expression, and since DNA is recombinant, any state machine code built using this pattern is also recombinant. Meaning you can mix and match condition bodies (as you would mix complete genes) in any program and it would exhibit the functionality you picked or added.
You can literally add behaviour from a program (for example, an NPC) to another by copying and pasting new code from a file to another. Assuming there aren't any conflicts in variable names between the two, and that the variables (for example `state.health` and `state.mood`) mean the same thing to both programs.
If you combine two unrelated programs (a server and a desktop application, for example) then assuming there are no variables clashing, your new program will work as a desktop application and as a server at the same time.
I plan to publish the TypeScript reference implementation/library to npm and GitHub once it has all basic functionality, along with an article describing this and how it all works.
I wish I had a good academic background now, because I think this is worthy of a spec/research paper. Unfortunately, I don't have any connections in academia. (If you're interested in writing a paper about this, please let me know)
Edit: here's the current preliminary code: https://gist.github.com/voodooattac...
My worst code review involves line endings. In one of our products we use the facade pattern, and one of the facades is about 5000 loc.
Well, a dude in our team messed up with line endings, so our diff tool showed that 5000 lines have changed. A newb I was at that time, I didn't know any other diff tool, so I went through all the lines manually only to see that 2 lines effectively have changed.. and the newb I was, didn't thought about rejecting the change immediately! We then had somehow to revert that commit, but messed up our central repo (was still with CVS). In the end we had to restore the daily backup for the repo because we couldn't manage it to do it right.
Never ever had such a disastrous code review again.
ME - me, TM - teammate
I was just recruited to the company. We're starting new project based on few modules.
ME: So this module will do X and Y, I will use good old interfaces and design based on abstractions so that stuff does not get glued too much.
TM: But why? Make good old processor with all the logic and throw objects at it.
ME: B-but unit tests, decomposition and othet stuff...
TM: *insists and forces me to agree*
ME: *gets shit done his way, TM checks on code review and complains but generally doesnt give a fuck*
ME: Ok, its done. Lets get shit shipped.
TM: Well, we were just told by PM that we will need to process one more source with much different logic that does not fit current solution (he did meant GOD-PROCESSOR, idea of his).
ME: What do you mean? *injects another contextual implementation of processing logic to template method pattern solution*.
TM: I will tell PM you cant make it because of the implementation.
ME: But I just did it...
TM: Impossible, processor needs to be reimplemented. Get your shit together!
ME: *still doesnt get the shit about the god processor love*
TM: *rage quits next month*
ME: *module gets reused once more 2 month later, profit*
After a code review where I identified an odd way a request was being generated, I suggested to the developer to utilize the Strategy pattern.
Knowing that the Strategy pattern probably wouldn't make sense in the current context, I told him I would put an example together by the end of the day.
I throw something together, sent it to him.
Go to the restroom, come back and 'Bob' says..
Bob:"There is my hero. Justin said you saved the world again. What was it this time? World hunger? Global warming? Ha ha ha."
Frack off you condescending kiss ass. Why don't you take 5 minutes to listen and understand the problem Justin was having instead of making fun of him?
Yea, I heard you this morning laughing at his code, monday-morning quarterbacking a solution in which you have no idea whats going on.
Heard your days are numbers anyway. Good riddance.1
If you have a method which returns a value from an array. What do you prefer in a case when the item is not found?
A)Throw an exception
C)return a special value like a null object or some primitive type edge value like Integer.MIN_VALUE14
About 2 months ago, my company wanted to build a micro service that will be used to integrate 3 of our products with external ticketing systems.
So, I was asked to take on this task. Design the service, ensure extendability and universality between our products (all have very different use cases, data models and their own sets of services).
Two weeks of meetings with multiple stakeholders and tech leads. Got the okay by 4-6 people. Built the thing with one other guy in a manner of a week. Stress tested it against one ticketing service that is used in a product my team is developing.
Everyone is happy.
Fast forward to last Thursday night.
“Email from human X”: hey, I extended the shared micro service for ticketing to add support for one of clients ghetto ticketing systems. Review my PR please. P.S. release date is Monday and I am on a personal day on Friday.
I’m thinking. Cool I know this guy. He helped me design this API. He must’ve done good. . . *looks at code* . . . work..... it’s due... Monday? Huh? Personal day? Huh?
So not to shit on the day. He did add much needed support for bear tokens and generalized some of the environment variables. Cleaned up some code. But.... big no no no...
The original code was written with a factory pattern in mind. The solution is supposed to handle communication to multiple 3rd parties, but using the same interfaces.
What did this guy do wrong? Well other than the fact that he basically put me in a spot where if I reject his code, it will look like I’m blocking progress on his code...
His “implementation” is literally copy-paste the entire class. Add 3 be urls to his specific implementation of the API.
Now we have
The latter 3 are his additions... only the last one should have been added in reality... why not just add a type to the payload of the post/put? Is he expecting us to write new endpoints for every damn integration? At this rate we might as well not have this component...
But seriously this cheeses me... especially since Monday is my day off! So not only do I have to reject this code. I also have to have a call now with him on my fucking day off!!!!
“So please don’t expose IQueryable or SaveChanges() beyond here... this is the pattern. Don’t fuck it up.”
🤬 There will be blood.