Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 25 Mar 2003
Offline Last Active Mar 11 2013 12:21 AM

#2644084 GOTW: Prefer free functions to member functions if possible

Posted by on 31 August 2004 - 06:14 AM

Original post by Jingo
Sounds like you are more opposed to designing than you are to moving member functions out-of-class.

I'm opposed to unnecessary designing and unnecessary abstractions. These things increase design and development time, make your project more complex (how many people *really* understand STL vs. how many people *really* understand Java class library subset that provides alternative functionality) and make testing a longer process because there's more to test.
Original post by Jingo
But really, how hard is it to provide abstractions like these in the common sense, not very.

Well, for starters, you have to design them. Iterators are (somewhat) easy to provide now that they've already been designed. Then you have to understand them. Aside from understanding a public interface for each class, you'll also have to understand the "utility" interface used to implement public functions that could be members.
Original post by Jingo
If anything, making your code as generic as possible reduces development time. Removing the need to implement functions twice for two different objects saves as much time as it does to develop a flexible generic design.

This makes sense for libraries and parts of applications. However, making most code in application development generic is a waste of time. It tends to be so specific, it'll never be reused outside the bounds of the application (or of the object in question).