At 8/4/13 05:06 PM, Innermike wrote:
I hate the term 'method'. Just say function jesus.
I first started programming in VB.NET and to define a function you used the Function keyword, and to define a "void method" you used the Sub keyword. To me, functions returned a value and subs didn't. When we moved onto OO, it took me ages to understand what the term "method" meant, because we were defining them exactly the same way; the only difference being we are now creating classes, rather than a bulky, "procedural" code module.
I make the distinction as a method is on an object, and a function is independent of an object. If I'm programming in Java, there are no such thing as "functions", they're all called methods. When I programmed a bit in C, I called them functions. I suppose the distinction could be between procedural vs OOP- but that's a debate I don't really want to get in to.
@Diki could probably clarify this, but I think in C++ they're called "member functions".
Then in .NET you also have properties... dun dun dun
 As with VB.NET, if you had the strict options off, you could treat a function as a sub... Silly VB.NET.
Never used a getter or setter in any actual project ever. I know what they are, I know how to use them, and I know I probably never will.
My biggest gripe with getters and setters is that we're told one of the important aspects of object orientation is encapsulation. Then someone comes along, creates a class, and exposes all their instance variables through getters and setters. Nice encapsulation, dude.
More people need to create classes with accessor and mutator methods that hide their information. They seriously need to ask themselves "does a client seriously need access to all this? Or will an accessor method with some black magic suffice?"
I still make around 5% of my variables two letters long, it's an improvement over the 95% from a few years ago but still...
I've been guilty of poor naming conventions for a while now. Then I read an excellent book called Clean Code: A Handbook of Agile Software Craftsmanship, and it really blew my mind and changed my thinking. If you can get a copy of the book, I highly recommend it.