Representations and classes of square group (D4) The Group of symmetries of the square (D4) has an order of 8.
There are 2 classes in the group (correct me if Im wrong). These classes are: One class made of rotations in the plane of the square, of $0$ (identity), $\pi/2$, $\pi$ and $3 \pi /2$. Also 4 rotations with axis inside the plane: two across the diagonals of the square and two perpendicular to the sides by the middle.
Using the "dimensionality theorem", which says that the order is equal to the sum of the square of the dimensionalities of the possible representations, I get $2^2+2^2=8$, meaning that there are 2 representations of order 2.
One of this representations has the first class represented with these matrices:
$\begin{bmatrix} 
    1 & 0 \\0 & 1
\end{bmatrix}$,
$\begin{bmatrix} 
    0 & -1 \\1 & 0
\end{bmatrix}$, 
$\begin{bmatrix} 
    -1 & 0 \\0 & -1
\end{bmatrix}$,
$\begin{bmatrix} 
    0 & -1 \\1 & 0
\end{bmatrix}$
And the second class represented as:
$\begin{bmatrix} 
    -1 & 0 \\0 & 1
\end{bmatrix}$,
$\begin{bmatrix} 
    1 & 0 \\0 & -1
\end{bmatrix}$,
$\begin{bmatrix} 
    0 & 1 \\1 & 0
\end{bmatrix}$,
$\begin{bmatrix} 
    0 & -1 \\-1 & 0
\end{bmatrix}$
But my problem is that the traces of a same class should be the same (correct me again if im wrong), and the first class has 1 matrix of $Tr=2$, 1 of $Tr=-2$ and two of $Tr=0$. The second class has every matrix with $Tr=0$.
I immediately thought that the classes I choose were wrong, and that I have 3 classes. But it doesn't have sense for me because, if I have 3 classes I cant fulfill the dimensionality theorem, as there isn't any sum of square integers which is equal to 8.
What I am missing? There are 2 or 3 classes? Im choosing wrong the members of the classes?
 A: As was mentioned in another answer, there are 5 conjugacy classes of $D_8:=\langle r,s\mid r^4=s^2=1, srs=r^{-1}\rangle$: 
$$\{1\},\{r^2\},\{ r, r^3\},\{s,r^2s\}, \{rs, r^3s\}.$$ 
So the “dimensionality theorem” says that the sum of 5 squares must equal 8, and that these squares correspond to the dimensions of all irreducible representations of $D_8$. The only way this is possible is if $D_8$ has 4 irreducible representations of degree 1, and 1 irreducible representation of degree 2. 
And yes, the trace of conjugate elements should be the same, as the trace is a class function on $D_8$. 
We have the following matrices for members of $D_8$ in the dimension $2$ representation:
$$
1 = \begin{bmatrix}1 & 0 \\0 & 1\end{bmatrix},
$$
$$
r^2 = \begin{bmatrix}-1 & 0 \\0 & -1\end{bmatrix},
$$
$$
r = \begin{bmatrix}0 & -1 \\1 & 0\end{bmatrix}, \hspace{5pt} r^3 =\begin{bmatrix} 0 & 1 \\-1 & 0\end{bmatrix},
$$
$$
s = \begin{bmatrix}1 & 0 \\0 & -1\end{bmatrix},\hspace{5pt}
r^2s = \begin{bmatrix}-1 & 0 \\0 & 1\end{bmatrix},
$$
$$
rs = \begin{bmatrix}0 & 1 \\ 1 & 0 \end{bmatrix},\hspace{5pt}
r^3s = \begin{bmatrix} 0 & -1 \\ -1 & 0\\ \end{bmatrix}.
$$
Each row corresponds to a conjugacy class, and you can see that matrices in each row have the same trace.
A: You've got the conjugacy classes wrong.  There are actually $5$.  
Namely  $\{e\},
\{(13)(24)\}
,\{14)(23),(12)(34)\},\{(13),(24)\}$and $\{(1234),(4321)\}$.  These are, identity, $180^0$ rotation, edge reflections, vertex reflections and $90^0$ rotations, respectively...
I leave it to you to find the matrices. 
 The traces within the classes are indeed the same.
