Why Should You Use Getters and Setters?

Some people aren’t very fond of accessors and mutators. On the surface they seem like needless functions, a waste of code when a simple class.variable would suffice. Some variables really are better off being set with variable = foo than with a mutator. On the other hand, other data types have such complex initialization procedures it’s easier to pass values into a mutator. C++’s maps are a good example of this kind of situation. Which is easier, std::map.insert(std::pair<Foo, Bar>(var1, var2)); or SetMap(var1, var2);?

Continue reading


Use a Library or DIY?

This question comes up a lot when planning (and working on) programming projects. Should I use a library for this feature or just write the code myself? It can be applied to almost every section of a project. There are so many libraries and frameworks out there that you can probably get a prototype working just by gluing together third party code. There are a few factors to consider while making the decision.

Continue reading