New answers tagged

4

according to Clean Code, is it okay to add a single constructor to a plain data structure? Yes. Constructors are not functions in this context since they're not something that operates on data. They don't hide the data. And if the data changes, they'll need to change, but that's no different from any other initialization strategy.


2

When you see a good move, look for a better one. —Emanuel Lasker, 27-year world chess champion It's a very good readability enhancement, but always look for the better move. In this case, you are likely often covering up problems with your responsibilities being misplaced. The principle of seeking to avoid those chains of identifiers has its ...


2

(My answer ignores the effects of optimization - I'm assuming there is a machine processing your code that can do decent optimization so that the extra variable being created for readability will not make a difference in performance.) In my experience, write your code to be understood. A short, meaningful name is definitely more acceptable than repeating a ...


6

It's a matter of using an unexpected mechanism for returning a value from the function, which is usually a result of doing too much in the function or having misaligned responsibilities. By far, the best way to communicate a function's result is to use the return value. I hope that's self-evident. In object-oriented languages, the second-best method is to ...


6

Bob Martin is simply talking about readability. The problem with the appendFooter example is, if you find the code line appendFooter(s) somewhere in a program, it is not immediately obvious if that call takes s as an input and appends it somewhere, or if s is just passed to take the output of that function. To be sure, you need to check the function ...


1

Embedded development. When you're working with a tiny memory footprint and real time requirements you have to constantly be thinking about every aspect of performance, both speed and memory. Real time embedded devices often require response times in the order of milliseconds in my experience. If a routine is off running for 10 seconds somewhere, you've ...


3

If they have competitors, then performance is a major criterion by which they are judged. By the way, if you think performance is a matter of using switch vs. if, you're missing the point by an enormous margin. You don't know what to fix in the code until you find out what takes time. That can seldom (i.e. never) be done by eyeballing the code. What I do ...


1

Projects that have performance requirements. It really doesn't matter what the hardware is. I can drive anything to 100% utilization. Same as I can fill any hard drive. The question is, can I ignore performance and still hit my performance goals. If yes, I am justified in ignoring performance. Some projects find they have performance problems. If they ...



Top 50 recent answers are included