🔒 Locked
Writing Clean Code....?
Advertisement
Original Post
Can anyone lend me some theory about how some clean code would look like ?
I`m trying to imagine the code with lots of classes and also well arranged in a page...
like
buga buga()
{
buga1();
buga2();
.......
bugaX();
}
Can anyone give me some more examples/tips ?
PS:Just curios about how other people write code....
Clean code doesn''t have names like "buga"
"If there is a God, he is a malign thug."
-- Mark Twain
"If there is a God, he is a malign thug."
-- Mark Twain
quote:
Original post by cippyboy
Can anyone lend me some theory about how some clean code would look like ?
I`m trying to imagine the code with lots of classes and also well arranged in a page...
like
buga buga()
{
buga1();
buga2();
.......
bugaX();
}
Can anyone give me some more examples/tips ?
PS:Just curios about how other people write code....
Don''t know exactly what you mean, but:
http://www.doc.ic.ac.uk/lab/cplus/c++.rules/
Here is a good start. Really, you don''t want to just break out segments of code like:
doSetup();
doProcessing();
doDrawing();
doPostDraw();
doSomeStuff();
What you want to do is try to break things down so you can explain it easily (IMHO).
// Transform the current entity object by it''s possition and rotation.
CMatrix matTransform;
CMatrix matRotation;
matTransform.setToTranslation(entCurrent.getPosition());
matRotation.setToRotation(entCurrent.getRotation());
entCurrent.transformBy(matTransform * matRotation);
Now obviously there are holes in what I''m saying here, but try to simplify without obscuring what you''re doing. You want it to make logical sense. You''ll notice that I don''t follow the rules in the document I attached, but I just recommend it as a guideline. Don''t know if I''ve helped or not. Good luck.
- sighuh?
This is a question that has a thousand not right, but not wrong, answers.
Clean code is consistent code. That''s about the only solid rule. Decide on a style and stick with it.
----
AIDS
Clean code is consistent code. That''s about the only solid rule. Decide on a style and stick with it.
----
AIDS
I also find that clean code means encapsulation. As you program grows, encapsulation will really help you keep it from becomming spaghetti (or in my case, soup
).
With demos its usually easier to separate classes into modules - one class per module. That way if you need it for another project, you just include the module and you''re done - that is a sign of clean coding.
With demos its usually easier to separate classes into modules - one class per module. That way if you need it for another project, you just include the module and you''re done - that is a sign of clean coding.
Well, I don''t know about how to WRITE code, but if I gave you some links to some of *my* projects I could sure as shootin show ya how NOT to write code :D
quote:
Original post by cippyboy
Can anyone give me some more examples/tips ?
Just post some of your own code, and I''m sure everyone will be happy to tell you everything that is wrong with it
"If there is a God, he is a malign thug."
-- Mark Twain
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement