software development in general Flashcards
why do we need indirection (pointers)
in functions you can only pass by value but you can use pointers instead
what function do we use to compare strings
strcomp; takes two strings and returns the difference between them
what are some issues with variables
can only represent simple scalar values
declared with a fixed size
go out of scope at the end of the scope they’re declared in
incur overhead when copied
what can we use to overcome some of the issues with variables
compound variables
dynamic memory
passing pointers
where are dynamic variables allocated
heap; dynamic memory
dynamic memory
allocated at run time
requires managing; must free and return to the heap once finished
extreme care required to avoid memory problems
what piece of code is used to allocate memory to the heap
malloc; the space allocated is saved until you give it back
what is an example of a compound variable type
structs; a user defined grouping of variables that combines simple types into one entity
api
application programming interface
file
a collection of typically related data that can be viewed as bytes
software interface
a set of operation defined for interaction for this system in a controlled way (api) || set of functions that you can call that are declared in a header file
what are advantages of having an entire project in one file
only one file for the compiler to parse to find all functions
the programmer only has one place to look
you only have to pass around one source file
what are some disadvantages of having an entire project in one file
hard to reuse code
scrolling becomes difficult
not ideal for teamwork
why is the header file needed at the top of each file
so the file know which functions to expect
how do you combine multiple files
gcc -o main main.c queue.c
how do you combine compiled files
gcc -c queue. c : creates the object file
gcc -o main main.c queue.o : combines all files into a single executable
how do you package files into a library
ar ras libq.a queue.o
what is version control
specifically choosing to mark/track certain changes in the code
a version history can be stored over the timeline of a project
how is a new version created
when you mark a new set of changes
what are the main principles of version controls
you need to create a repository (repo)
add the files you want to track
you periodically commit versions to the repo with a meaningful commit message
what is a positive of version control
enables teamwork
what is the main principle of modular code
code comes in smaller pieces that you can put together and relies on standards (api)
what are some main principles of procedural programming
has a well defined start (main())
code is modularised through functions
variables are passed through parameters or can be global
data modularity only occurs in data structures or not at all
data and code are treated as separate concepts
what is a con of global variables
you can’t use the same variable name more than once