0

How to write faster and more consisten code??

I started studying computer science one year ago. At university we began with C then went over to C++ then we learned a bit about assembler. In the last 3 month i learned much about Java and web development (Html,Css,Javascript) on my own. Now that i have a basic understanding of the most important programming concepts I was just wondering what i need to learn to write faster and more consistent code. So i came about 'dynamic memory allocation'. But what is dynamic memory allocation in detail, how can learn it and when do I use it? What other programming-concepts can you recommend me to learn to improve my coding skills? regards Ju

3rd Aug 2018, 12:18 PM
julian
julian - avatar
4 odpowiedzi
+ 3
Dynamic memory allocation is not something many programmers worry about. In object oriented languages, it basically refers to creating objects using the new keyword. This allocates memory for the object on the heap, and pushes a reference to this part of memory on the stack. This reference is what is held by variables. If you want to continue programming in the object oriented paradigm (and do it well), I recommend studying it's basic concepts first (abstraction, polymorphism, etc). Then moving on to studying design patterns (know when and how to apply them). After which you study the SOLID principles. And finally learn about things like test driven design and domain driven design.
3rd Aug 2018, 12:44 PM
Jeroen van der Laan
Jeroen van der Laan - avatar
+ 2
hope you are much more familiar with oops concepts... make it more clear and gain detailed knowledge of same. you can also refer data structures, design pattern, algorithm and dynamic programming...
3rd Aug 2018, 12:22 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
3rd Aug 2018, 12:23 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
+ 1
when you are sure about variable sizes at compile time, it is static memory allocation... For example, int array[8] when you are not aware about size I.e. you are not sure how many int you gonna need, then new operator is used to allocate memory dynamically.. vector from standard template library is also used for example, vector<int> and then push back your data instead of using new operator... struct are still used as it has all capabilities (inheritance and function) in c++ .. Only default access specifier is different for class and structure... but as a thumb rule, people are generally using structure when methods are not required and mere purpose of same is to store different data together... for example, you need to store x , y and z coordinates of all points , then use structure with x,y and z as members
3rd Aug 2018, 1:14 PM
Ketan Lalcheta
Ketan Lalcheta - avatar