On classical finite and affine W-algebras