Block and port creation code factorization