# Companion object vs top level declaration

**URL:** <https://discuss.kotlinlang.org/t/companion-object-vs-top-level-declaration/7538>\
**Category:** Support\
**Created:** [April 23, 2018, 5:28pm UTC](https://discuss.kotlinlang.org/t/companion-object-vs-top-level-declaration/7538 "2018-04-23T17:28:26Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![darksnake](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/darksnake/32/2479_2.png) [@darksnake](https://discuss.kotlinlang.org/u/darksnake)\
**Post date:** [April 23, 2018, 5:43pm UTC](https://discuss.kotlinlang.org/t/companion-object-vs-top-level-declaration/7538/2 "2018-04-23T17:43:43Z")

</div>

I think it was discussed a lot of times. Global functions pollute global name space and make it hard to use auto-completion. Companion object function in most cases is much safer. I would recommend using global functions either in very small projects, or in cases you do need for them to be global.

---

_[View the full topic](https://discuss.kotlinlang.org/t/companion-object-vs-top-level-declaration/7538)._
