If you are talking about passing an instance of one object to the method of another, then yes, of course, it is allowed! And he considered great practice.
If you want to know more about good object-oriented coding, can I offer some suggested indications:
Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson, John M. Vlissides
Known as the Gang Of Four book, it outlines a series of design patterns that seem to be displayed again and again in object-oriented code. This is a good place for ideas on how to handle certain problems in a good, object-oriented manner.
Another good one:
Refactoring: Improving the Design of Existing Code by Martin Fowler, Kent Beck, John Brant, William Opdyke, Don Roberts
This is a great book to learn what NOT to do when writing object-oriented code, and how to fix it to make it better when you come across it. It offers a list of code smells that involve poor object-oriented code and a refactoring reference section that provides instructions on how to fix these smells and make them more object oriented.
source share