<html><head></head><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:16px"><div id="yui_3_16_0_ym19_1_1474984041665_358778" dir="ltr"><span id="yui_3_16_0_ym19_1_1474984041665_358777">That is bad design and advice IMO. Structs in elixir define object orientation, functional programming is about data, everything is data. The tuple being a core building block.<br><br>When you define your application using structures, you have just added an extra layer of inference. Now in most cases that extra layer will just get in your way, providing no reasonable benefit.<br><br>One of the biggest enlightenments and problems Erlang developers learn early on is the record. First the record is pretty much a Struct in Elixir, with some insignificant differences. Now most developers would do this; define rigid records like 'User', 'Location', 'Job' with default values and start writing expressions to work with them. Before the developer knows it, the record is being used throughout multiple modules across the entire code base. Everything is unit tested and static analysis reports the code is 100% excellent, not a single flaw.<br><br>Now the developers code is running in production and its working great! <br><br>But now a problem comes along, the job the code does has changed, storing the email_verification_token inside the 'User' record is no longer valid, and a new record is created called 'Validation' that houses email_verification_token with sms tokens and other validations. Sure no problem, well defined structure is awesome!<br><br>The entire code base was written rigidly following the spec defined by the records (Struct), as soon as we want to make a change now multiple modules need to be rewritten. Now this is not a problem, a day can be expent to rewrite/replace 20 modules that use that record. Done, rewritten! <br><br>Now the developers code is running in production and its failing :(<br><br>Turns out by simply replacing text in 20 modules something was missed that is producing undefined behavior now. The project is rolled back in production to the previous version and the entire development process starts all over, trying to figure out where the bug is that was introduced from the simple record change.<br><br><br>Tl; Dr: Never rely on records (Elixir Structs) across multiple modules, always write expressions that manipulate DATA, never write expressions that manipulate OBJECTS (oop definition).<br><br><br>On the count of maps anything used as a key is optimal, there is no limitations. Maps are a great flexibility and there is no one right way to use them. An example of a useful map key:<br><br id="yui_3_16_0_ym19_1_1474984041665_364189">DataChannelLookup#{}<br>maps:put({peer1, peer2}, Channel, DataChannelLookup)<br>maps:put({peer2, peer1}, Channel, DataChannelLookup)<br></span></div><div id="yui_3_16_0_ym19_1_1474984041665_358778" dir="ltr">maps:put({peer2, peer3}, Channel2, DataChannelLookup)<br>maps:put({peer3, peer2}, Channel2, DataChannelLookup)<br><br>Channel2 = maps:get({peer2, peer3}, DataChannelLookup)<br><br><span><br></span></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font size="2" face="Arial"> On Saturday, October 1, 2016 7:52 AM, Uniaika <uniaika@crypto-keupone.eu> wrote:<br></font></div> <br><br> <div class="y_msg_container">Maybe this blog post (originally for Elixir though) will help you:<br clear="none"><a shape="rect" href="https://engineering.appcues.com/2016/02/02/too-many-dicts.html" target="_blank">https://engineering.appcues.com/2016/02/02/too-many-dicts.html</a><br clear="none"><br clear="none">TL;DR<br clear="none"><br clear="none">> WUse string-keyed maps for data which has just arrived from an ><br clear="none">external source.<br clear="none"><br clear="none">> Convert external data to structs as soon as possible.<br clear="none"><br clear="none">> Use structs almost everywhere else in your program.<br clear="none"><br clear="none">> Use other atom-keyed maps sparingly.<br clear="none"><br clear="none">On 10/01/2016 12:37 PM, Pagayon, Ruel wrote:<br clear="none">> Hi everyone,<br clear="none">> <br clear="none">> I'm just wondering (assuming the keys of my maps in my application is<br clear="none">> not dynamically generated):<br clear="none">> <br clear="none">> 1. What is the most optimal key type for maps?<br clear="none">> 2. If there is little to no effect in performance (or resources in<br clear="none">> general), as a convention, which is the best to use?<br clear="none">> <br clear="none">> Thank you in advance for your responses.<br clear="none">> <br clear="none">> Cheers,<br clear="none">> Ruel<br clear="none">> <br clear="none">> <br clear="none">> _______________________________________________<br clear="none">> erlang-questions mailing list<br clear="none">> <a shape="rect" ymailto="mailto:erlang-questions@erlang.org" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br clear="none">> <a shape="rect" href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><div class="yqt8154380670" id="yqtfd03177"><br clear="none">> <br clear="none">_______________________________________________<br clear="none">erlang-questions mailing list<br clear="none"><a shape="rect" ymailto="mailto:erlang-questions@erlang.org" href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br clear="none"><a shape="rect" href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br clear="none"></div><br><br></div> </div> </div> </div></div></body></html>