How do you recognize a carbohydrate molecule? I am studying carbohydrates in organic chemistry and I am confused a bit on what they are and how you recognize whether a molecule is a carbohydrate or not. For example, will a carbohydrate always have an $\ce{OH}$ group with either an aldehyde or a ketone group? Can it also contain other atoms like nitrogen or bromine? Can it have ether, ester?
The name "carbohydrate", which literally means“carbon hydrate,” arises from their chemical composition, which is roughly $\ce{(C.H2O)_n}$, where $n\ge 3$. The basic units of carbohydrates are monosaccharides.

Monosaccharides or simple sugars are aldehyde or ketone derivatives of straight-chain polyhydroxy alcohols containing at least three carbon atoms. Such substances, for example, D-glucose and D-ribulose, cannot be hydrolyzed to
form simpler saccharides.

Examples of monosaccharides:



Classification

Monosaccharides are classified according to the chemical
nature of their carbonyl group and the number of their C atoms. 

If the carbonyl group is an aldehyde, as in glucose, the sugar is an aldose. If the carbonyl group is a ketone, as in ribulose, the sugar is a ketose. The smallest monosaccharides, those with three carbon atoms, are trioses.

Those with four, five, six, seven, etc., C atoms are, respectively, tetroses,
pentoses, hexoses, heptoses, etc. These terms may be combined so that, for example, glucose is an aldohexose, whereas ribulose is a ketopentose.

However, there are similar molecules with different atoms such as nitrogen which are also considered carbohydrates. A class of polysaccharides known as glycosaminoglycans (unbranched polysaccharides of alternating uronic acid and hexosamine residues).Practical examples are Hyaluronic acid(linked disaccharide
units that consist of D-glucuronic acid and N-acetyl-Dglucosamine) and Heparin (sulfated disaccharide units):

   

Nevertheless, when carbohydrates bond with other molecules to form other newer bonds, they are given different names and are not necessarily carbohydrates but are given new names - a good example are glycoproteins (proteins covalently associated with carbohydrates.)

Reference 

Biochemistry Voet and Voet, Grisham