  Lately, to provide a solid ground for quantization of the open string theory
with a constant B-field, it has been proposed to treat the boundary conditions
as hamiltonian constraints.
  It seems that this proposal is quite general and should be applicable to a
wide range of models defined on manifolds with boundaries. The goal of the
present paper is to show how the boundary conditions can arise as constraints
in a purely algebraic fashion within the Hamiltonian approach without any
reference to the Lagrangian formulation of the theory. The construction of the
boundary Dirac brackets is also given and some subtleties are pointed out.
  We consider four examples of field theories with boundaries: the topological
sigma model, the open string theory with and without a constant $B$-field and
electrodynamics with topological term.
  A curious result for electrodynamics on a manifold with boundaries is
presented.
