<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Hello again,<DIV><BR class="khtml-block-placeholder"></DIV><DIV>So, I am gradually understanding the design philosophy of an Erlang application.</DIV><DIV>On the one hand, functionnal programming is about having no state. However, in the situation of a Web application, you obviously need to keep some state otherwise you are back to PhP style (in the sense you are recalculating everything at each request).</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I went back to Joe's book and read again the chapter on processes. And, as someone suggested earlier, I realized the state of an Erlang program can actually be kept in a process. So when designing an application, you indeed model the processes, then the state of the processes, then the messages.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>So for example, if I create a process for each user who logs in to a program. Upon creation of the process I could fetch all the features and worklists the user has, then keep them in his process until he logs out (or after a given long timeout).</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I can do that for every task which needs to keep a state between requests.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Therefore, I have a question: where is it usuall or reasonnable to keep the state of a process?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>1) in the parameters of the function we spawn</DIV><DIV>2) in the process dictionnary</DIV><DIV>3) in an ETS structure</DIV><DIV>4) in a in-memory mnesia structure</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I suppose it really depends on the amount of data and how it will be modified (and if we want to keep persistent some session data after the process is killed).</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Tell me if I am wrong, but the first two solutions will put data on the process stack and will be destroyed when the process is killed. The two other solutions will have to be cleaned out when the process is killed.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Are there some guidelines?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>For a user process, I might have 30 or 40 features in a list, some values about his account, etc...</DIV><DIV>For a process managing (for example) browsing patients in a list, I will have the list of patients with the visits for the currently selected patient, etc...</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Thanks for any hints!</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Alex<BR><DIV> <SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><SPAN class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><DIV>--</DIV><DIV>Alexander Lamb</DIV><DIV>Founding Associate</DIV><DIV>RODANOTECH Sàrl</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>4 ch. de la Tour de Champel</DIV><DIV>1206 Geneva</DIV><DIV>Switzerland</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Tel:  022 347 77 37</DIV><DIV>Fax: 022 347 77 38</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><A href="http://www.rodanotech.ch">http://www.rodanotech.ch</A></DIV><DIV><BR class="khtml-block-placeholder"></DIV></SPAN></SPAN><BR class="Apple-interchange-newline"></SPAN> </DIV><BR></DIV></BODY></HTML>