Best way to model a simple object

Trying to increase my modelling skills and have accomplished something that I’m sure isn’t the best way to go about it.
In a nutshell, I’ve:

• created a cylinder, stretched it along one axis.
• Created a cube, shrunk it along one axis, added it to one end of cylinder and duplicated it along the length of one side of the cylinder with a ‘small’ gap between each cube.Very simple ascii format would be:

(====================)
|||||||||||||||||||||_|

Then, in order to treat it as one ‘object’ I’ve selected all the primitives and grouped them.
Can anyone offer some advice on what the best practice would be to recreate this please.

Im pretty new to modeling as well, but I think perhaps a boolean union of the cylinder+cube would do and is simple.

Booleans will create lots of extra geometry.

I would do it the following way (and did, see attached):
-Scale the Cylinder along the long axis
-Make a loop cut in the exact center of the cylinder (ctrl-R, percentage 0)
-Delete One half of the cylinder
-In the Mesh Tools Panel of the edit buttons (F9 -> Mesh Tools Panel), enable ‘Beauty’. This subdivides a face into two, instead of four.
-With the faces of the cylinder selected (except for the ends faces), press 'W->Subdivide Multi->Enter number of cubes you want minus one, on one half of the cylinder in the number of cuts box
-Scale Your Cylinder along the long axis again so that the faces you want to grow cubes out of are relatively square. Your cylinder will move away from an axis, so just move it with g back into alignment.
-For each cube you want to extrude select the faces, and press ‘e’ and then ‘enter’ to extrude them. Then press ‘s’ to scale them in to half the amount of the gap width you want.
-When all are extruded in, select the faces extruded in, and then extrude them out until they are the cube length you want.
-The faces will be curved from the cylinder so scale them along the axis that runs through both the cube faces and cylinder (not just through cube faces), until they are straight. You may have to zoom in to get enough resolution to make them perfectly straight.
-Mirror the one side over, and your finished.

Doing that, I got the figure attached in the image.

Attachments

Thanks for that forTe, took a while to get my head around what you’ve suggested but has made sense now.
And thanks RBlackmore too, hope forTe helps you as it has me.