{"action":"created","issue":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/10850","labels_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/10850/labels{/name}","comments_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/10850/comments","events_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/10850/events","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/issues/10850","id":54145758,"number":10850,"title":"Code Style","user":{"login":"DavidKeaton","id":1715605,"avatar_url":"https://avatars.githubusercontent.com/u/1715605?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidKeaton","html_url":"https://github.com/DavidKeaton","followers_url":"https://api.github.com/users/DavidKeaton/followers","following_url":"https://api.github.com/users/DavidKeaton/following{/other_user}","gists_url":"https://api.github.com/users/DavidKeaton/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidKeaton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidKeaton/subscriptions","organizations_url":"https://api.github.com/users/DavidKeaton/orgs","repos_url":"https://api.github.com/users/DavidKeaton/repos","events_url":"https://api.github.com/users/DavidKeaton/events{/privacy}","received_events_url":"https://api.github.com/users/DavidKeaton/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/labels/Question","name":"Question","color":"990099"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2015-01-13T03:06:57Z","updated_at":"2015-01-13T09:44:12Z","closed_at":null,"body":"So, this is put here to either get a talk going or something along those lines. Most of this is merely my opinion, so I am obviously not trying to _change_ anything as far as how the coding style is dictated, but I wanted to share my thoughts.\r\n\r\nI am fine with the general coding style in the repository, but one thing that is driving me *bonkers* lately is all the `auto` usage. The addition of `auto` iterators on behalf of kevingranade has been great, simplifying a lot of needless boilerplate, and makes it _much_ cleaner. However, declaration of `auto` variables as their type, instead of its true type is much more of a hassle than it's worth. Why hide the type of the variable? If one does not know the inherit type spit out by a function, or does not wish to constantly check where it morphs into another magical variable container, why would you want to make it harder?\r\n\r\nAt one point, a `static_cast<int>` on an `auto` var is used, when simply declaring as `int` is more than suitable, and makes it apparant as to what it will hold. If the type shifts as it is filled with a different variable, this change won't be apparent to anyone but the person coding it, and would make bugs harder to find unless debugging the program itself. \r\n\r\nI have no qualms with `auto` in most cases, as it is glorious if used correctly (see also: my opinion), but to use it needlessly just makes the code look like a clusterf**k.\r\n\r\nEveryone has their coding styles, which is completely fine, but let's not make the code look like crap. Nowhere else in the code have I seen `auto` splattered around without reason. Hell, it was solely used in iterators. Wouldn't keeping it this way keep skimming the code _vastly_ more sane?\r\n\r\nSorry for the vent, and I am not trying to point at anyone or bash styles. I just want the code to be easily accessible to all contributors who may not have the easiest time discerning what is going on in the code, and I know that keeping it simple and accessible is important from what I have gathered.\r\n\r\n<bountysource-plugin>\r\n\r\n---\r\nWant to back this issue? **[Place a bounty on it!](https://www.bountysource.com/issues/7691387-code-style?utm_campaign=plugin&utm_content=tracker%2F146201&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F146201&utm_medium=issues&utm_source=github).\r\n</bountysource-plugin>"},"comment":{"url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/comments/69718962","html_url":"https://github.com/CleverRaven/Cataclysm-DDA/issues/10850#issuecomment-69718962","issue_url":"https://api.github.com/repos/CleverRaven/Cataclysm-DDA/issues/10850","id":69718962,"user":{"login":"narc0tiq","id":591573,"avatar_url":"https://avatars.githubusercontent.com/u/591573?v=3","gravatar_id":"","url":"https://api.github.com/users/narc0tiq","html_url":"https://github.com/narc0tiq","followers_url":"https://api.github.com/users/narc0tiq/followers","following_url":"https://api.github.com/users/narc0tiq/following{/other_user}","gists_url":"https://api.github.com/users/narc0tiq/gists{/gist_id}","starred_url":"https://api.github.com/users/narc0tiq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/narc0tiq/subscriptions","organizations_url":"https://api.github.com/users/narc0tiq/orgs","repos_url":"https://api.github.com/users/narc0tiq/repos","events_url":"https://api.github.com/users/narc0tiq/events{/privacy}","received_events_url":"https://api.github.com/users/narc0tiq/received_events","type":"User","site_admin":false},"created_at":"2015-01-13T09:44:12Z","updated_at":"2015-01-13T09:44:12Z","body":"I've learned that `auto some_var = int{ initial_value }` tends to be \"the C++11 way\", at least according to Herb Sutter. `static_cast` and friends probably shouldn't be used much anymore.\r\n\r\nI'm not sure why `auto num = 1` is nonsensical (it makes a default-sized int; you could make it `auto num = 1UL` if you wanted, say, an unsigned long).\r\n\r\nThat said, I'm totally not a C++ person at all, so this is just based on a little reading I've done over the past week."}}