is this function too long?

Started by
29 comments, last by Mad4Life 22 years, 6 months ago
Actually, you just add the .h file to your project and call the function.. it recognizes it as if it was part of the .cpp. You are using MSVC++ right? I am pretty sure thats how it works..


You just type them any where in the .h file

"I've sparred with creatures from the nine hells themselves... I barely plan on breaking a sweat here, today."~Drizzt Do'Urden

Edited by - Drizzt DoUrden on September 23, 2001 8:31:27 PM
------------------------------Put THAT in your smoke and pipe it
Advertisement
I use Dev C++.....
"And God said, 'Let there be death', and there was death"
I strongly advise that you break up that function into ''sections'', where each case statement would have its very own, private function Also Drizzt DoUrden, the idea of placing comments on the side of code, is really not such a good idea (in my opinion) I really dont want to type anymore to explain why, as of me being tired, so tata
masterghttp:/masterg.andyc.org
I strongly advise that you break up that function into ''sections'', where each case statement would have its very own, private function Also Drizzt DoUrden, the idea of placing comments on the side of code, is really not such a good idea (in my opinion) I really dont want to type anymore to explain why, as of me being tired, so tata
masterghttp:/masterg.andyc.org
I dont think it matters. It should work the same way.
------------------------------Put THAT in your smoke and pipe it
thx alot guys, imma put it all into smaller functions and then put those functions into different header files just to be nice and clean
"And God said, 'Let there be death', and there was death"
Personally,

If there is a switch statement in my code, it usually means that that is a good place to use virtual methods and polymorphism

I would like to see your OOD design document and see where things can be changed. 512 lines in a c++ method is way to large.

From what I''ve seen in the code you have posted, I would create a base class called CBaseSkill

CBaseSkill would have a virtual method possibly called Create();
CBaseSkill might also have a method called Validate().

Then create your skill implementations. ie CFireSkill : public CBaseSkill

I would also create a Virtual Factory that would return the correct implementation type for the selected Skill.

// Your large switch statement would be in CreateSkillImp
CBaseSkill* Skill = SkillFactory::instance()->CreateSkillImp("FIRE");

Skill->Create();

If the above doesn''t make sense, then I would break out the implementation in the switch statement to call another function to ask for value input, validate the code, etc..

Just my .02

Alek
Doh! didn''t see the second page. My bad, seen that you''ve already come to a solution.

Sorry,

Alek
i just have one variable for each skill that measures how many points are in it

i think it hardly validates using a class for em


from that one variable i cna do everything i need to do( like damage, etc)
"And God said, 'Let there be death', and there was death"
hehe

your the only other person besides me that i have seen use the phrase my bad lol
"And God said, 'Let there be death', and there was death"

This topic is closed to new replies.

Advertisement