i will talk about coding standard which i follows in c++ or swift (ios)
for c++
instead of above you can do it like
button->mybutton
button->mymybutton
button->anotherButton
7. enum is best when dealing with multiple case for example
enum myDirection
{
left,
right,
up,
down.
}
if(key==myDirection.left)
{
“move left buddy”
}
8. try to use data structure when you need to add remove updated records specially linked list , doubly linked list or circular linked list.
9. inline function are fast but you need to be carefull function which is under 9 line are good for inline function.
10. use singleton where you need same operation to held in every part of application for example a http api call or getting windows height and width based on resolution or a global sound player which playing sound in every part of your application based on different action.
11. use static classes with you deal with operation which does not required a instance of class for example math.abs()
12.try to follow some standard pattern such as mvc or mvvm these pattern help you to separate your code for example mvc where Model deals with data realted stuff V realted to views and controller deals like a bridge between them. if you belongs to gaming ECS entity component system is widely used pattern for games.
13. put configuration related data in json so you don’t need to change code again and again for minor text changes.
14. dependency injection What is dependency injection? must check it once.
15 use const instead while dealing with const values in project.
16. don’t create big function that instead of it create small function with return type
17. comment your code whenever possible it would help other to understand your code and even you too sometime.
18.check out lambda
19.check out multithreading
20. spend time with data structure and searching algorithms.
for c++
- define a class name like thats - public myGame extends baseClass checkout class name in camel case
- use abstract classes whenever you go for inheritance that would help you and other coders that there are some method already declare in base class and he don’t need to be redeclared it and also your base class can access child class method through pointer .
- overriding in bad habit when its comes to deal with a big project instead of overriding create method with optional parameter which would help you to reduce code in your project.
- generic templates are best way to deal with common things like defining a template which combine string as well as float and int based on parameter type.
- including header file in .cpp is bad habbit try to include all header file in .hpp
- resuse classes are good but too much reusability is another bad habbit for example
instead of above you can do it like
button->mybutton
button->mymybutton
button->anotherButton
7. enum is best when dealing with multiple case for example
enum myDirection
{
left,
right,
up,
down.
}
if(key==myDirection.left)
{
“move left buddy”
}
8. try to use data structure when you need to add remove updated records specially linked list , doubly linked list or circular linked list.
9. inline function are fast but you need to be carefull function which is under 9 line are good for inline function.
10. use singleton where you need same operation to held in every part of application for example a http api call or getting windows height and width based on resolution or a global sound player which playing sound in every part of your application based on different action.
11. use static classes with you deal with operation which does not required a instance of class for example math.abs()
12.try to follow some standard pattern such as mvc or mvvm these pattern help you to separate your code for example mvc where Model deals with data realted stuff V realted to views and controller deals like a bridge between them. if you belongs to gaming ECS entity component system is widely used pattern for games.
13. put configuration related data in json so you don’t need to change code again and again for minor text changes.
14. dependency injection What is dependency injection? must check it once.
15 use const instead while dealing with const values in project.
16. don’t create big function that instead of it create small function with return type
17. comment your code whenever possible it would help other to understand your code and even you too sometime.
18.check out lambda
19.check out multithreading
20. spend time with data structure and searching algorithms.
Comments
Post a Comment