Replying to your new version of the question:
DDRG |= (1<<DDRG3) OR
DDRG = 0x08
There is no "best" because those two snippets1 of C do different things - they only have the same end result in one situation; in all other situations they will have different end results! This means that, as always in programming, you must be really clear what you want to do and write your code accordingly.
1[From now onwards, I will assume that they are followed by a semicolon and call those two pieces of code "C statements".]
DDRG = 0x08;
This clearly just sets bit 3 (the
DDRG3 bit, value 0x08) in the
DDRG register. Think about what values are set for the other bits in that register? They are all set to zero.
DDRG |= (1<<DDRG3);
This reads whatever value is currently set in the
DDRG register, sets bit 3 (assuming
DDRG3 = 3) and writes this result back to the
DDRG register. Think about what values are set for the other bits in that register? They are all unchanged from their previous values.
[An optimising compiler, upon recognising that coding idiom, might be able to use a suitable assembly instruction, if one exists, to set that bit in the DDRG register - without needing to do the read-modify-write implied in the C source code - the end result is the same either way.]
So as you can now see, the only time that those two statements have the same end result, is when the other (used) bits in
DDRG are already set to zero before each of those two statements were executed.
DDRG |= (1<<DDRG3); suggests to the reader (who might be you, trying to maintain the code some years later!) that you care about preserving the other bits set in that register. Note that using a bitwise-OR operator like this, is so common that it is used by Atmel in their ATmega128A datasheet regarding setting bits in GPIO registers, for example.
DDRG = 0x08; suggests that you want to specifically clear any other bits which are set in that register, at the time when you set bit 3.
Which of those statements you should use, depends on exactly what result you want to achieve, for the value in the
I have used page 134 of this Atmel ATmega128A datasheet to confirm the DDRG register layout and DDRG3 bit value, 0x08, within that register. For other MCUs, the interpretation may be different.