[need-advice]what is your web app development workflow?

agolangf · · 249 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I am a newbie web developer. I have had no prior app development experience using other languages such as PHP or Ruby. for months I have been learning Go and web application development through books .I have been writing small web apps. I also read some good example code. I can understand it as well. But now I have and idea for a large web app. The thing is I have no idea how to put it all together.I am really confused where to begin? what to write first routes or models or templates?how should be my workflow so that it will be easy to refactor code later. P.S. that web app is kinda like hacker news but with a job board.so it will be having authentication , users ,posts etc</p> <hr/>**评论:**<br/><br/>Integralist: <pre><p>Draw the architecture on paper. Then highlight in red the critical aspects for an MVP.</p> <p>Implement those parts first, then start layering the functionality.</p> <p>Eg. You might highlight routing and serving a 200 service health status page using some basic template logic a MVP.</p> <p>Next step might be to implement a few basic pages.</p> <p>Step after that might be to implement basic with to prevent general access to those pages</p> <p>Etc</p> <p>But you need the overall architecture modelled out on paper or electronically somewhere to help guide you</p></pre>pvsukale1: <pre><p>is there any generalized or well known way to do these things?</p></pre>Traim: <pre><p>That should help:</p> <p><a href="https://www.youtube.com/watch?v=sJhhLvW-Xvg&amp;list=PLqGj3iMvMa4KeBN2krBtcO3U90_7SOl-A" rel="nofollow">https://www.youtube.com/watch?v=sJhhLvW-Xvg&amp;list=PLqGj3iMvMa4KeBN2krBtcO3U90_7SOl-A</a></p></pre>pvsukale1: <pre><p>thanks</p></pre>Tikiatua: <pre><p>Hi there, </p> <p>Starting with paper is a really good advice. I would even go further and not only draw up the architecture, but draw a context diagram (who is interacting with your system and what are their intentions) and draw a flow-chart of your pages (what pages will the application have, who has access to which page, what is the main purpose of the page - we use shapes from uxkits.com for this). </p> <p>Ideally you would also collect something called user stories. The purpose of this is to gain an understanding of what certain users would want to achieve on your website. i.e. &#34;As a designer I would like to see a list of all job offerings in my area, so I can apply for a job and increase my earnings&#34;. The most important part of this is the reasoning. Collecting the reasons will often lead to ideas of how to find an even better solution to the problems at hand.</p> <p>The next step would be to draw some basic mockups of all the pages. Once you have done all this, you will have a fairly good understanding of your sites structure and functionality and can start with the coding.</p> <p>My advice would be to clearly separate your backend from the frontend (i.e. we use vue.js for all frontends and are very happy with it) and fetch all data from the backend via api calls.</p> <p>On the backend, we tend to use the echo framework for web services, as it does provide a good balance between additional abstractions on top of the base packages while not trying to do too much. </p> <p>We usually put the route-definitions into separate files depending on the context (i.e. public sites, admin sites, user sites) and put the actual route handlers into separate packages. This helps to keep the boundaries between different functionalities.</p> <p>If the application gets really big, we split out the different modules into separate &#34;micro-services&#34;. But this will require a more complex architecture to manage and monitor your application in production (take a look at traefik.io if you are interested in something like this).</p> <p>Currently we are using RethinkDB to store all data, as it is very easy to administrate and provides a cool document based storage even supporting &#34;near real-time&#34; change feeds out of the box.</p> <p>By the way, I would recommend to check out docker and start developing your application in a docker container. This will ensure it can easily ported to production systems without running into problems with configurations and such.</p></pre>pvsukale1: <pre><p>thank you for your thorough advice. It was really informative.btw I don&#39;t have any experience with frontend frameworks . I have been just executing templates with data structs. will it be more efficient to make my site API based?and if yes where should I start?</p></pre>hukiki: <pre><p>Personally I have found the API based approach a lot easier for me and my team. We have a reactjs front end that runs on the client&#39;s browser, and all the actions are supported by the backend programmed in go. </p> <p>Say for instance we are trying to add something, on the UI side using react we make a component to provide our user with a form to enter data about this thing, its does client side validation to help the user, and when the user clicks on add, the data gets to our go server as a json. </p> <p>Our go server then reads this JSON file, puts the data in to a struct, we then do server side validation, yes ever everything we checked on the client side, we check them again on the server end. </p> <p>Then when we are happy this data is valid, we pass it to a layer in our go server that talks to our sql database and adds that information, if everything goes right we send back a message to the UI of the user, and the UI will tell our user what happened. </p> <p>The best thing about this approach for me as a manager is, I can allocate people to work on well defined problems. The code to our UI and server are hosted in the same repo, and thanks to this separation, its very easy for me and my team to work independently.</p> <p>The only problem with this approach is that, our user&#39;s browser has to download the entire UI component before they can use it. (Around 1 mb)</p> <p>Thanks to caching this is not a problem that happens too often.</p></pre>tmornini: <pre><p>This.</p></pre>interactiv_: <pre><p>You need a good data model first. It&#39;s 50% of the job.</p> <p>Think about what you need and how it will be organized in your database.</p> <p>When DB modelling is done it is 50% of the job done trust me, there rest is basically just about writing forms that will gather data to be persisted in the database. </p> <p>. Also If you are a newbie just don&#39;t try to write your app in Go. Go won&#39;t get you far. Forms ? Validation ? Auth ? Routing ? ORM ? Testing ? Do you really want to have to write all these things from scratch or use half baked tools bundled with Go ? No, you&#39;ll learn nothing and you&#39;ll write something that is insecure , buggy and you&#39;ll have wasted your time.</p> <p>IMHO use Ruby on Rails. Then when you have a good product if you need to scale rewrite it in Go. Go isn&#39;t for beginners, it is for people who know what they are doing. Do you really want to deal wit race conditions ? pointers , mutexes and shit like that ? Because that&#39;s what you&#39;re going to deal with if you choose Go.</p> <p>You&#39;ll have a much better understanding of your requirements up front if you can get a professional result quickly with Rails. Go isn&#39;t made for prototyping classing web apps that spit HTML and forms at all. At least its ecosystem doesn&#39;t reflect it. </p></pre>tmornini: <pre><p>I used to think data model is the most important aspect, but I now tend to favor the applications semantics, and design the data model from that.</p> <p>What is the minimum set of operations (HTTP request methods on URIs) that are required to implement your application?</p> <p>Build the API one of those operations at a time, handling the data model along the way.</p></pre>FPSports: <pre><p>In my opinion it doesn&#39;t hurt to know what your website is doing... why... and how... </p> <p>I&#39;m coming from php, mainly using symfony2 but at some point I kinda hit a wall and searched for other solutions. Go. So far I&#39;m very pleased and at the same time angry about myself for depending on 3rd party libraries so much in my past. I missed the opportunity to learn a lot. Of course if pure productivity is required.... Go seems a bit.. Not the best choice. At the moment I&#39;m building stuff (for example an Aerospike cache) myself for learning and boosting future productivity. </p></pre>interactiv_: <pre><blockquote> <p>In my opinion it doesn&#39;t hurt to know what your website is doing... why... and how...</p> <p>I&#39;m coming from php, mainly using symfony2</p> </blockquote> <p>Sure you know how to write a (classic) website from scratch PRECISELY because you have a prior experience in writing websites with another language that is more suited for the task.</p> <p>You know how to architecture your code, how to do routing, authentication, authorization, deal with forms, CSRF tokens, sessions , cookies , how to use a data mapper , how to write a data access layer, how to deal with entities and relationships , how to validate data , how to write migrations, how to work with templates, how to do testing BECAUSE you followed some Symfony tutorial explaining all that shit and you had prior experience. All you need is for each part that is missing from the Go library find the equivalent as a third party library.</p> <p>Now imagine a beginner who wants to write a website with Go without knowing all this. Where are the tutorial explaining how to architect an application from scratch in Go and create a professional product ? my point is , when you came to Go , you knew exactly what writing a website was about. That&#39;s why Go isn&#39;t good for people who want to start in web development and know barely anything about it. Why is the OP asking that question then ? if he knew all this , he didn&#39;t need to ask how get started with Go.</p> <blockquote> <p>for example an Aerospike cache</p> </blockquote> <p>Sure , but it has nothing to do with writing a classic website from scratch with all bells and whistles and security requirements. </p></pre>pvsukale1: <pre><p>exactly @interactive it is really overwhelming and I am confused as hell. </p></pre>pvsukale1: <pre><p>will Michael Hartl&#39;s book be a good start?</p></pre>interactiv_: <pre><p>Hartl&#39;s book is a book about web development which uses Ruby as a learning tool,at least that&#39;s how I see it, so absolutely. </p></pre>kaeshiwaza: <pre><p>It depends if the beginner wants to learn or stay... beginner. It&#39;s interesting to study how other languages and framework do but with the std lib of Go you have everything to do it yourself and really learn web development.</p></pre>pvsukale1: <pre><p>thank you for your opinion . I am also thinking of using ROR.</p></pre>pvsukale1: <pre><p>hey someone just suggested me to use ruby on rails. I want to ask as I am new to web app development should I use ROR instead of Go for my first few projects to get better understanding of all these things? </p></pre>kaeshiwaza: <pre><p>If you want to understand what&#39;s append, you better stay with Go and the std lib. RoR, Django, but also Revel, Beego can help you to have idea, but you don&#39;t need to pay for what you will not eat.</p></pre>bobcrotch: <pre><p>As a new developer I would suggest getting as far as you can without using frameworks.</p> <p>The reason why is that when something goes wrong, or you don&#39;t understand a framework idiom you don&#39;t have the supporting knowledge to dig into it. </p> <p>However this is largely biased on how my brain works and how I learn and understand things. It&#39;s personally always helped me to be a bit more reductive when it comes to programming. Abstraction is really nice and saves you a ton of time and boilerplate; it can also get you really far. It&#39;s important to understand what is being abstracted and what the constructs are.</p></pre>

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

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