16
votes
5answers
2k views

How can you decompose a constructor?

Lets say I have a Enemy class, and the constructor would look something like: public Enemy(String name, float width, float height, Vector2 position, float speed, int maxHp, int ...
2
votes
1answer
51 views

When should I pass setting-like value as class' variable and when as an assoc. array?

Following my other question, is there a general rule of thumb, when we should pass a setting-like value, that controls class' behavior (for example displayed texts) as as class' constant or variable, ...
1
vote
1answer
87 views

When should I pass value as class variable and when as a method argument?

Is there a general rule of thumb, when we should pass a value as as class variable and when as a method argument? Or is it just a choice of the developer? For example -- are there any reasons, why ...
0
votes
3answers
169 views

which style of member-access is preferable [duplicate]

the purpose of oop using classes is to encapsulate members from the outer space. i always read that accessing members should be done by methods. for example: template<typename T> class foo_1 { ...
19
votes
2answers
1k views

Is it a good idea to provide different function signatures that do the same thing?

Here is a C++ class that gets constructed with three values. class Foo{ //Constructor Foo(std::string, int, char); private: std::string foo; char bar; int baz; }; All of ...
5
votes
3answers
221 views

How to name an subclass that add a minor, detailed thing?

What is the most concise (yet descriptive) way of naming a subclass that only add a specific minor thing to the parent? I encountered this case a lot in WPF, where sometime I have to add a small ...
5
votes
4answers
542 views

Method flags as arguments or as member variables?

I think the title "Method flags as arguments or as member variables?" may be suboptimal, but as I'm missing any better terminology atm., here goes: I'm currently trying to get my head around the ...
3
votes
2answers
232 views

Designing class methods: self contained or explicit calls?

I'm probably butchering the terms, if someone knows the appropriate terms - that'd be great. But my question is: should I design my classes so that their methods' parameters be accessible from the ...