<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><title>RE: [erlang-questions] I need some advices for a framework I'm doing</title><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.EmailStyle18
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-size:10.0pt;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=EN-US link=blue vlink=purple><div class=WordSection1><p class=MsoNormal>Yes usually happens when people try to build nice things and other people not.<o:p></o:p></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div><div style='border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal><b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'>From:</span></b><span style='font-size:11.0pt;font-family:"Calibri","sans-serif"'> Tony Rogvall [mailto:tony@rogvall.se] <br><b>Sent:</b> Tuesday, August 25, 2015 3:23 PM<br><b>To:</b> Ivan Carmenates Garcia<br><b>Cc:</b> Loïc Hoguin; <erlang-questions@erlang.org><br><b>Subject:</b> Re: [erlang-questions] I need some advices for a framework I'm doing<o:p></o:p></span></p></div></div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>Ha ha ha<o:p></o:p></p></div><div><p class=MsoNormal>This is funny, please stop!<o:p></o:p></p></div><div><p class=MsoNormal> <o:p></o:p></p></div><div><p class=MsoNormal>"typed while hacking!"<o:p></o:p></p></div><div><p class=MsoNormal style='margin-bottom:12.0pt'><br>On 25 aug 2015, at 17:58, Ivan Carmenates Garcia <<a href="mailto:co7eb@frcuba.co.cu">co7eb@frcuba.co.cu</a>> wrote:<o:p></o:p></p></div><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p><span style='font-family:"Calibri","sans-serif"'>Hi, </span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>Well the good news here is that I am making it together with a system a am also doing so, it any problems present I will notice they quickly and at the same time</span> <span style='font-family:"Calibri","sans-serif"'>I will get feedbacks.</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>Regards documentation, that one of the thing a love more, so it will be plenty of it, with a lot of examples and explanations. Currently the code doc for any function and even examples of how to use them.</span> <span style='font-family:"Calibri","sans-serif"'>i.e.</span> <span style='font-family:"Calibri","sans-serif"'>this is a nice doc for one of the functions:</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% -------------------------------------------------------------------</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% @doc</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% Makes a query to a database using a 'DBSession'.</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% Returns a 'ResultData':</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% - 'ResultData' depends of 'result_format' Option.</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% - 'result_format' could be one of 'raw', 'proplist', 'map'.</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% - 'proplist' and 'map' result formats have the same</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% 'ResultData' struct:</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% {ok, Data} when using 'select'.</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% {ok, Count} when using 'update', 'insert', 'delete'.</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% {ok, Count, Data} when using 'update', 'insert' with returning.</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% The only differences are:</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% 0 results:</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% 'map' -> no_data,</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% 'proplist' -> [],</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% 1 result:</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% 'map' -> a single map #{...},</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% 'proplist' -> a list of proplist [[...]], (template</span> <span style='font-family:Consolas'>compatible)</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% N results:</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% 'map' -> a list of maps [#{...}, ...],</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% 'proplist' -> a list of proplists [[...], ...],</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% 'raw' by the other hand is 'Backend' dependent.</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% Example:</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% {ok, #{id := Id}} = database_manager:query(DBSession,</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% Query, Params, [{result_format, map}]).</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% NOTE: 'map' is the default result format for 'query/3' function.</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% NOTE: All result format has its pros and cons, 'raw' is the fastest</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% but uncomfortable to deal with, 'map' is the slowest but very</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% easy to deal with. So this is the performance order from</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% fastest to slowest 'raw' > 'proplist' > 'map'.</span> <span style='font-family:Consolas'>'proplist' can</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% be used to return directly to a template.</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% @end</span><o:p></o:p></p><p><span style='font-family:Consolas'>%% -------------------------------------------------------------------</span><o:p></o:p></p><p><span style='font-family:Consolas'>-spec query(DBSession, Query, Params, Options) -></span><o:p></o:p></p><p><span style='font-family:Consolas'> ResultData | {error, Reason} when</span><o:p></o:p></p><p><span style='font-family:Consolas'> DBSession :: db_session(),</span><o:p></o:p></p><p><span style='font-family:Consolas'> Query :: string() | bitstring(),</span><o:p></o:p></p><p><span style='font-family:Consolas'> Params :: [] | [any(), ...],</span><o:p></o:p></p><p><span style='font-family:Consolas'> Options :: proplists:proplist(),</span><o:p></o:p></p><p><span style='font-family:Consolas'> ResultData :: any(),</span><o:p></o:p></p><p><span style='font-family:Consolas'> Reason :: term().</span><o:p></o:p></p><p><span style='font-family:Consolas'>query({Backend, Connection}, Query, Params, Options) -></span><o:p></o:p></p><p><span style='font-family:Consolas'> %% executes query/4 in the current 'Backend'.</span><o:p></o:p></p><p><span style='font-family:Consolas'> Backend:query(Connection, Query, Params, Options).</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>Anyone have more</span> <span style='font-family:"Calibri","sans-serif"'>suggestions I could use?, thanks in advantage.</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>Regards,</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>Ivan.</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>-----Original Message-----<br>From: Loïc Hoguin [<a href="mailto:essen@ninenines.eu">mailto:essen@ninenines.eu</a>]<br>Sent: Monday, August 24, 2015 5:45 PM<br>To: Ivan Carmenates Garcia; <a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>Subject: Re: [erlang-questions] I need some advices for a framework I'm doing</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>On 08/24/2015 10:20 PM, Ivan Carmenates Garcia wrote:</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>> Hi everyone, I am making a little framework for cowboy, but in general </span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>> what I need is some advices regards final looking, i.e.:</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>OK I am a bit lost on everything you explained so allow me to give some generic advice:</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>* Make it work</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>* Start making apps with it</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>* Notice everything inefficient in how you now write apps</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>* Update your framework</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>* Repeat</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>Practice makes perfect. Add a little of looking at how everyone else does things in the mix to get ideas; sometimes you will notice something is bad in your framework but have no idea how to make it better, that's why you need to look elsewhere. Sometimes the idea might come from a completely unrelated source.</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>A few more things:</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>* Keep it simple and explicit</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>* Focus on the use cases that benefit the majority of users</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>* Choose good, short names</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>* Write a user guide when things stabilize</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>On the last point, you want the guide separate from code entirely because this forces you to think about how you really use it rather than just documenting functions or modules one after another. Think of it like writing a book, except the only role of this book is to explain to others *what* they can do with your framework and *why* they will do things that way.</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>Once you get there, you should have a pretty good product, and you'll most likely have gotten a ton of users along the way.</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>Cheers,</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>--</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>Loïc Hoguin</span><o:p></o:p></p><p><a href="http://ninenines.eu"><span style='font-family:"Calibri","sans-serif"'>http://ninenines.eu</span></a><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>Author of The Erlanger Playbook,</span><o:p></o:p></p><p><span style='font-family:"Calibri","sans-serif"'>A book about software development using Erlang</span><o:p></o:p></p></div></blockquote><blockquote style='margin-top:5.0pt;margin-bottom:5.0pt'><div><p class=MsoNormal>_______________________________________________<br>erlang-questions mailing list<br><a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br><a href="http://erlang.org/mailman/listinfo/erlang-questions">http://erlang.org/mailman/listinfo/erlang-questions</a><o:p></o:p></p></div></blockquote></div></body></html>