Hot answers tagged

144

Non-techies aren't idiots (for the most part). They can understand a technical argument if you keep it high-level enough. Pick a task you thought should be simple, and walk them through why it's not. I expected this change to be one word in one file. The most likely place to change it seemed to be here, but when I changed it there, it only worked ...


89

Imagine you have to use someone else's code designed as about below: class Messy { String concat(String param, String str) { /* ... */ } boolean contains(String param, String s) { /* ... */ } boolean isEmpty(String param) { /* ... */ } boolean matches(String param, String regex) { /* ... */ } boolean ...


86

Code structure, style, technical debt are one thing that - at least initially, until the client trusts you - you're going to need to live with. Security vulnerabilities are another matter. Personally, I would do an estimate based on the work required using the existing structure and style while making it clear that there are significant issues with the ...


74

Some great suggestions here on how to convey and communicate this to the client. Hopefully they will pay off for you. Major red flag here! If the client asks you not to make any changes other than what you've agreed to (HTML and CSS) I'd pass on this project and withdraw my bid. Even with a written and well communicated overview of all of the flaws and ...


65

Think about what you're getting back, and how you bind those to variables in your code. Now think what happens when someone updates the table schema to add (or remove) a column, even one you're not directly using. Using select * when you're typing queries by hand is fine, not when you're writing queries for code.


64

Torvalds is talking out of his ass here. OK, why he is talking out of his ass: First of all, his rant is really nothing BUT rant. There's very little actual content here. The only reason it's really famous or even mildly respected is because it was made by the Linux God. His main argument is that C++ is crap and he likes to piss C++ people off. ...


38

Another concern: if it's a JOIN query and you're retrieving query results into an associative array (as could be the case in PHP), it's bug-prone. The thing is that if table foo has columns id and name if table bar has columns id and address, and in your code you are using SELECT * FROM foo JOIN bar ON foo.id = bar.id guess what happens when ...


33

I don't believe in bad patterns, I do believe that patterns can be badly applied ! IMHO the singleton is the most abused and most wrongly applied pattern. People seem to get a singleton disease and start seeing possibilities for singletons everywhere without considering alternatives. IMHO visitor pattern has the most narrow use and almost never will the ...


29

Explain and possibly demonstrate the flaw When it's your word against his, everything you say could just be hot air as far as they're concerned. Once you show them how their app can be abused via SQL injection, then suddenly you're a person to be trusted. You're going to need credibility in order to renegotiate. And this is enough of a game-changer to give ...


27

In a word, yes. Anyone that tells you otherwise is probably, at best, mistaken. However, the key is to build on your experience to write code that is less bad. Resist the temptation to put in something to make it "just work" if at all possible, because it won't. You still need to follow some sort of process (be it your own, or your company's, or some mix ...


26

I've never (in 20-odd years) come across intentionally bad code, but the examples you cite seem (to me at least, but IANAL) to be attempts to defraud either an employer or a customer, so you probably have a legal obligation to point it out to your manager.


23

'But it works now' is the standard management response to the legitimate frustrations of software engineers. The first thing I would do would be to compile the documentation (if any) and use that to demonstrate contradictions between the code and the documentation. If you can, put together a comprehensive suite of unit tests. Run these with every change so ...


22

if you're coding with ease, it feels (or actually is, in short run) just quicker to snap out your own solutions on the spot, without turning to libraries, preexistent functionality etc. Yes. I've been that guy. And I've learned that it's a terrible thing. It's all very well for you, you don't have to learn something new. But what about the rest ...


22

Querying every column might be perfectly legitimate, in many cases. Always querying every column isn't. It's more work for your database engine, which has to go off and rummage around its internal metadata to work out which columns it needs to deal with before it can get on with the real business of actually getting the data and sending it back to you. ...


19

I started this as a comment, because at first I thought it was an aside, but it probably really isn't. I would fully document everything that you feel is should be redesigned, and why (what happens if they don't make the change), and an estimate on fixing the issue. I would be particularly meticulous with anything you perceive as a security risk. I would ...


19

Sometimes you have to understand these things in the context they were concieved in, then built in, then maintained in. Some of the worse offenders that I have seen probably started out as very nicely written programs. You can see a bit of well-thought out architecture trying to poke out through the mess. But as it happens, the requirements change during ...


18

You should choose better design if: You are going to be taking over a large part of future coding Better design isn't more expensive to the client in the long run. For instance, I have witnessed multi-month "refactorings" for projects that were discontinued by the end of the year. You should choose "same bad style" if: You're just helping out. It's ...


17

I've always thought the dangers of C++ were highly exaggerated by inexperienced, C with Classes programmers. Yes, C++ is harder to pick up than something like Java, but if you program using modern techniques it's pretty easy to write robust programs. I honestly don't have that much more difficult of a time programming in C++ than I do in languages like ...


16

If the team is in a crunch then something was done wrong. Missing deadlines is a sign of poor planning and estimation. Acknowledge that the deadline will be missed and solve the issue. Sometimes you don't have control over the planning or estimation. Identify who does and ensure that they know this was done in error. In a situation were the deadline cannot ...


14

Remember that the client is going to you for help with maintaining their application. It is your job as a professional to point out any issues you find with their application. The client likely has no idea these issues exist and they should be made aware of them. Explain these issues in a manner that they can understand and let them decide how they want to ...


14

To quote another source: Create an isolating layer to provide clients with functionality in terms of their own domain model. The layer talks to the other system through its existing interface, requiring little or no modification to the other system. Internally, the layer translates in both directions as necessary between the two models. Eric ...


13

•if you're coding with ease, it feels (or actually is, in short run) just quicker to snap out your own solutions on the spot, without turning to libraries, preexistent functionality etc. Skilled in the language but not the tools. That's not really even being a strong coder. It is just polishing one skill (language knowledge) and allowing another to get ...


13

From management's perspective, there's nothing wrong with the system and you are just complaining because [you just want to rewrite it/you don't understand what previous engineers did/you want your job to be easy]. A bit of a straw man, but when someone at the top sees that things are working fine right now, they're disinclined to see a crisis where you do ...


12

The difference in the code is usually more related to the programmer than the language. In particular, a good C++ programmer and a C programmer will both come to similarly good (even if different) solutions. Now, C is a simpler language (as a language) and that means that there are less abstractions and more visibility into what the code actually does. A ...


12

When you are sending an accept header requesting a specific media type, the server should not send back something else, and most certainly not with a 200 OK status code From Restpatterns.org: If no Accept header field is present, then it is assumed that the client accepts all media types. If an Accept header field is present, and if the server ...


11

You will not be able to fix all the tests together. I think you should focus on the word improvement versus overhaul. Neither management not developers will agree on an overhaul but if you show that there is a way to improve things without affecting the project negatively, they will be more likely to listen. First, you cannot 'fix' or refactor existing code ...


11

In the long run, it is better to use good practices. It will save time and effort as changes will take less time to implement. If possible, take little steps to refactor to good practice (for example: in SQL that would be breaking denoramlized tables to normalized one and using views with the old table names). You will note that I said in the long run - ...


11

The short answer is: it depends on what database they use. Relational databases are optimized for extracting the data you need in a fast, reliable and atomic way. On large datasets and complex queries it's much faster and probablly safer than SELECTing * and do the equivalent of joins on the 'code' side. Key-value stores might not have such functionalities ...


10

Depends on the culture of the company. More often than not, it's simply not your job to fix and clean up all bad code. From Coders at Work, Jamie Zawinski's thought on overengineering, which can also be applied in this situation: At the end of the day, ship the fucking thing! It’s great to rewrite your code and make it cleaner and by the third time ...



Only top voted, non community-wiki answers of a minimum length are eligible