Working on Springs framework, if we want to remove "all" spaces from a string, would it be costlier to use replaceAll() method of String object than using trimAllWhiteSpaces() from StringUtils of Spring API?
I think both would be so fast it wouldn't matter. If you disagree, you could time it.
I would use trimAllWhiteSpaces because it is clearer as to the intent. Maybe they use a regexp, maybe they use a loop. The nice thing is you don't need to know. And if they tune it in the future, you don't have to change anything.
I wouldn´t consider this to be a feature. It´s always better to know what is happening behind the scenes, and more when we are talking about performance.
And if they tune it in the future, you don't have to change anything.
I totally agree with this, of course modularity and reusability must be enforced, but not at the expense of understanding.
I´ve seen too many so called "Java Developers" that have never programmed with pointers or study data structures from a theoretical point of view, and the lack of understanding about what a hast table or a double linked list are, make them awful engineers.
If you make an idiot proof language, you´ll have idiots using it.