Feedback about my application

polaris · · 415 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I have been working on a todo list manager since quite some time now. It started as a simple text storing application and now includes few good features which I feel are useful like github flavoured markdown</p> <p><a href="https://github.com/thewhitetulip/Tasks">https://github.com/thewhitetulip/Tasks</a></p> <hr/>**评论:**<br/><br/>IFupvoteTHENsendNUDE: <pre><p>First of all, the front-end work is great. I&#39;m used to programming in Python for back-end. I&#39;ve just started to learn Go and I want to build web applications with it. Did you find it hard build it? I&#39;m reading your code(first web app I&#39;ve seem) and seem&#39;s pretty clean, more than I would have expected before.</p></pre>thewhitetulip: <pre><p>If you are interested, I am writing a book on writing webapps with Go.</p> <p><a href="https://github.com/thewhitetulip/web-dev-golang-anti-textbook/" rel="nofollow">https://github.com/thewhitetulip/web-dev-golang-anti-textbook/</a></p> <p>Thank you! I had worked on the front end for a long time, github.com/thewhitetulip/omninotesweb.</p> <p>I love UX/UI equally along with backend :)</p></pre>IFupvoteTHENsendNUDE: <pre><p>Such a great work. Starred.</p> <p>I&#39;ll take a look in the details later. Thanks!</p></pre>thewhitetulip: <pre><p>Thank you!! I am happy that I am helping someone :-) I face a lot of problems while writing this app</p></pre>schoenobates: <pre><p>Very nice - good work</p></pre>thewhitetulip: <pre><p>Thank you :-) any improvements I can do?</p></pre>skarlso: <pre><p>Hey man.</p> <p>This is solid work. I like the front-end. :) Very good stuff. Where did you learn to do that? :) I&#39;m lacking a good front-end design skill. Though I&#39;m going to take codeacademy&#39;s tutorial on that. :)</p> <p>Some things you could improve in regards to coding -&gt; </p> <ul> <li>When working with Json use Decoder. It will make handling json a lot easier. </li> <li>Some of your error cases are not returning a http.StatusNotFound or whatever. Like in deleteviews -&gt; log.Println(err) -&gt; After this a nice return error code should be set</li> <li>Most of your error handling in deleteViews can be abstracted out into a common function, call it handleError and give it a writer. You could skip most of the ifs.</li> <li>DB: <ul> <li>On Add file you are ignoring the error when the DB doesn&#39;t begin -&gt; tx, err := database.Begin() -&gt; you do log it but then don&#39;t do a return err. Or is this intentional?</li> <li>You have a lot of other places where you simply continue on an error and don&#39;t do return err. Is that intentional?</li> <li>I would extract database into a type where you can share the connection. That way a lot of this -&gt; database.Begin() could be eliminated since the type would handle connection with a pointer receiver. Basically a database singleton.</li> <li>Also, create a rollback conditional defer. If err != nil -&gt; rollback. They way you can skip a lot of ifs and error handling into a single pointer receiver function.</li> </ul></li> </ul> <p>Hope this helps. This is a very quick overview of the code.</p> <p>Well done! :)</p></pre>thewhitetulip: <pre><p>Thanks a lot!! I learnt front end dev by myself :-) Json decoder? I have no idea what it is.</p> <p>returning errors, yes, I am going to do that soon, two things are left in the application as of now, sessions &amp; categories</p> <p>About HandleErrors, I have read at many posts that rather than an abstracted function the <code>if err != nil</code> is more Goish.</p> <p>About rollback, yes I don&#39;t know how I missed it!</p> <p>Also a lot of placed I don&#39;t do anything on error because errors shouldn&#39;t happen there :-) like the database query things, the reason being the program won&#39;t compile if there is an error at that stage. Also it isn&#39;t intentional, the thing is when I started writing the application it was from scratch, so I put the print statements to log errors, I am yet to formulate a mechanism to notify about the error to the actual users via template rendering.</p> <p>Thank you for your comment :)</p></pre>skarlso: <pre><p>Ahh gotcha. :-) Error popups to the rescue. </p> <p>The json stuff is not that important since you are not posting anything with a json body. You are only using json in the configuration. The decoder handles closing reader bodies, that&#39;s why it&#39;s convenient. </p> <p>Like this:</p> <pre><code>decoder :=json.NewDecoder(req.Body) var t test_struct err := decoder.Decode(&amp;t) if err != nil { panic() } log.Println(t.Test) </code></pre> <p>This way you don&#39;t have to deal with io. ReadAll or something similar. </p> <p>The app <em>does</em> look very neat. :-) </p></pre>thewhitetulip: <pre><p>thank you!!</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

415 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传