# Auto contructor with all variables?

**URL:** https://discuss.kotlinlang.org/t/auto-contructor-with-all-variables/2382
**Category:** Language Design
**Created:** [March 10, 2017, 1:59pm UTC](https://discuss.kotlinlang.org/t/auto-contructor-with-all-variables/2382 "2017-03-10T13:59:17Z")
**Posts on this page:** 1
**Showing post:** 19

<div class="post-metadata">

### Author: ![jacobz\_20](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/jacobz_20/32/1468_2.png) [@jacobz\_20](https://discuss.kotlinlang.org/u/jacobz_20)
#### Post date: [March 14, 2017, 1:30am UTC](https://discuss.kotlinlang.org/t/auto-contructor-with-all-variables/2382/19 "2017-03-14T01:30:37Z")

</div>

I don’t think you understood what I said. I’m saying that you could be getting all worked up about it when an empty string is perfectly okay data. You’re assuming empty strings are a problem, which they may not be, in this case. And you’re all worried that he’s not thinking about doing proper checks, but he specifically remarked on wanting to use custom getters and setters. If I’m wrong, then I think this case would be better served by `lateinit` than null, since that’ll thrown an exception as soon as it’s referenced if it hasn’t had a decent value assigned yet. You could set up the same situation yourself with a custom getter or delegated property, but why do that when something baked into the language works so well?

Also, you pretty much said all the same things again, which isn’t really going to help.

Beyond that, in a more direct response to what you said, I can see where you’re coming from, but I largely disagree. Takipi did a study of errors raised in PRODUCTION environments, and they still found NPEs to be the most prevalently thrown exceptions. Sure, there are more automatic and natural ways of checking for null, but people still forget to check them, causing problems even in released versions. Granted, Kotlin forces you to deal with null when it’s allowed, but that doesn’t mean that a well thought-out “Null Object” isn’t a better solution. Heck, as mentioned before, `lateinit` is a better solution than nullability most of the time.

---

_[View the full topic](https://discuss.kotlinlang.org/t/auto-contructor-with-all-variables/2382)._
