Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #37388 > unrolled thread
| Started by | luserdroog <luser.droog@gmail.com> |
|---|---|
| First post | 2019-09-25 11:26 -0700 |
| Last post | 2019-09-26 12:25 -0700 |
| Articles | 10 — 4 participants |
Back to article view | Back to comp.lang.javascript
[Code Review] Turtle Doodle (my first web app) luserdroog <luser.droog@gmail.com> - 2019-09-25 11:26 -0700
Re: [Code Review] Turtle Doodle (my first web app) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-09-25 12:02 -0700
Re: [Code Review] Turtle Doodle (my first web app) luserdroog <luser.droog@gmail.com> - 2019-09-25 18:14 -0700
Re: [Code Review] Turtle Doodle (my first web app) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-09-26 12:27 +0200
Re: [Code Review] Turtle Doodle (my first web app) luserdroog <luser.droog@gmail.com> - 2019-09-26 03:40 -0700
Re: [Code Review] Turtle Doodle (my first web app) "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-09-26 12:48 +0200
Re: [Code Review] Turtle Doodle (my first web app) luserdroog <luser.droog@gmail.com> - 2019-09-26 04:44 -0700
Re: [Code Review] Turtle Doodle (my first web app) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-09-26 12:21 -0700
Re: [Code Review] Turtle Doodle (my first web app) Martin Leese <please@see.Web.for.e-mail.INVALID> - 2019-09-26 10:57 -0600
Re: [Code Review] Turtle Doodle (my first web app) "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2019-09-26 12:25 -0700
| From | luserdroog <luser.droog@gmail.com> |
|---|---|
| Date | 2019-09-25 11:26 -0700 |
| Subject | [Code Review] Turtle Doodle (my first web app) |
| Message-ID | <3f3faa3c-53c6-4c15-9276-7ceabb4cb988@googlegroups.com> |
I'm trying to work up my marketable skills (C and PostScript being quite out of fashion nowadays), and I'd appreciate any critique the experts here may have to offer. I've posted all the code to codereview.SE. I'll be sure to upvote any helpful answers posted there. Or if you post here, we can chat about it more. https://codereview.stackexchange.com/questions/229652/5912/turtle-doodle-my-first-web-app TIA
[toc] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2019-09-25 12:02 -0700 |
| Message-ID | <db04c4fc-e38d-4c4f-83eb-3631d5e4f232@googlegroups.com> |
| In reply to | #37388 |
On Wednesday, September 25, 2019 at 1:26:14 PM UTC-5, luserdroog wrote: > I'm trying to work up my marketable skills (C and PostScript being > quite out of fashion nowadays), and I'd appreciate any critique the > experts here may have to offer. > > I've posted all the code to codereview.SE. I'll be sure to upvote any helpful > answers posted there. Or if you post here, we can chat about it more. > > https://codereview.stackexchange.com/questions/229652/5912/turtle-doodle-my-first-web-app > - Don't use jQuery. Learn how to use JavaScript and the APIs first. - The rest is off topic for this group, but I'd suggest using the appropriate linters for each language: http://csslint.net https://eslint.org/demo https://www.freeformatter.com/html-validator.html https://phpcodechecker.com/ I'd also suggest using Object Orientation, and organize your code by purpose instead of by file. Next would be to choose an application architecture such as MVC, PAC, MVP, Clock, ALV, etc. MVC is the most popular.
[toc] | [prev] | [next] | [standalone]
| From | luserdroog <luser.droog@gmail.com> |
|---|---|
| Date | 2019-09-25 18:14 -0700 |
| Message-ID | <b0535a6a-240d-46e4-9e64-ceb739828a90@googlegroups.com> |
| In reply to | #37389 |
On Wednesday, September 25, 2019 at 2:02:23 PM UTC-5, Michael Haufe (TNO) wrote: > On Wednesday, September 25, 2019 at 1:26:14 PM UTC-5, luserdroog wrote: > > I'm trying to work up my marketable skills (C and PostScript being > > quite out of fashion nowadays), and I'd appreciate any critique the > > experts here may have to offer. > > > > I've posted all the code to codereview.SE. I'll be sure to upvote any helpful > > answers posted there. Or if you post here, we can chat about it more. > > > > https://codereview.stackexchange.com/questions/229652/5912/turtle-doodle-my-first-web-app > > > > - Don't use jQuery. Learn how to use JavaScript and the APIs first. Forgive me if this has already come up in the group, but why not use jQuery. It seems very nice to reduce the amount of code I have to write (and read). > - The rest is off topic for this group, but I'd suggest using the appropriate linters for each language: > > http://csslint.net > https://eslint.org/demo > https://www.freeformatter.com/html-validator.html > https://phpcodechecker.com/ > Thanks very much. These tools have sniffed out a few bugs I never would've caught by eye. > I'd also suggest using Object Orientation, and organize your code by purpose instead of by file. > > Next would be to choose an application architecture such as MVC, PAC, MVP, Clock, ALV, etc. MVC is the most popular. Thanks again. I think this is just the sort of thing I was looking for. Would it be naive as a first pass to actually make 3 javascript objects named Model, View, and Controller, and stuff all my functions into them? ISTM I could divide the js into 3 or 4 files like this.
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2019-09-26 12:27 +0200 |
| Message-ID | <XnsAAD67EBCA9491eejj99@194.109.6.166> |
| In reply to | #37397 |
luserdroog <luser.droog@gmail.com> wrote on 26 Sep 2019 in comp.lang.javascript: >> - Don't use jQuery. Learn how to use JavaScript and the APIs first. > > Forgive me if this has already come up in the group, but why not use > jQuery. If you use a taxi to visit your next door neighbour in town, you will never learn to walk. > It seems very nice to reduce the amount of code I have to write > (and read). At the expence of a magnitude more upload, execution-time, and formost a magnitude less understanding what realy happens, and therefore joy in your work. However if your work is only "have to", better take up gardening in your own garden, and stop visiting neighbours. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | luserdroog <luser.droog@gmail.com> |
|---|---|
| Date | 2019-09-26 03:40 -0700 |
| Message-ID | <60f95ace-6f71-43ee-83d0-b75e18e0f517@googlegroups.com> |
| In reply to | #37403 |
On Thursday, September 26, 2019 at 5:27:37 AM UTC-5, Evertjan. wrote: > luserdroog <luser.droog@gmail.com> wrote on 26 Sep 2019 in > comp.lang.javascript: > > >> - Don't use jQuery. Learn how to use JavaScript and the APIs first. > > > > Forgive me if this has already come up in the group, but why not use > > jQuery. > > If you use a taxi to visit your next door neighbour in town, > you will never learn to walk. > > > It seems very nice to reduce the amount of code I have to write > > (and read). > > At the expence of a magnitude more upload, execution-time, > and formost a magnitude less understanding what realy happens, > and therefore joy in your work. > > However if your work is only "have to", > better take up gardening in your own garden, > and stop visiting neighbours. > Thanks again. I suppose it's worth trying to do it without the training wheels. Evidently, I gorfed up the php too. I found a few examples and blogs about simple MVC in plain js. If I use php to compose my files into inline scripts then I can skip the whole modules tariff entirely.
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2019-09-26 12:48 +0200 |
| Message-ID | <XnsAAD6824B71500eejj99@194.109.6.166> |
| In reply to | #37404 |
luserdroog <luser.droog@gmail.com> wrote on 26 Sep 2019 in comp.lang.javascript: > Thanks again. I suppose it's worth trying to do it without > the training wheels. You lost me here. > Evidently, I gorfed up the php too. Serverside code is quite another piece of cake. > I found a few examples and blogs about simple MVC in plain > js. Developing is something else than borrowing. > If I use php to compose my files into inline scripts Eh? Presupposing you only develop for php-capable servers. > then I can skip the whole modules tariff entirely. Gardening still is an option. -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | luserdroog <luser.droog@gmail.com> |
|---|---|
| Date | 2019-09-26 04:44 -0700 |
| Message-ID | <b27b8ba1-5827-4366-8636-71b00764a942@googlegroups.com> |
| In reply to | #37405 |
On Thursday, September 26, 2019 at 5:48:34 AM UTC-5, Evertjan. wrote: > luserdroog <luser.droog@gmail.com> wrote on 26 Sep 2019 in > comp.lang.javascript: > > > Thanks again. I suppose it's worth trying to do it without > > the training wheels. > > You lost me here. That's why they call me ol' Mixed-Metaphor Mike. Always gorfing the peas and oranges. > > > Evidently, I gorfed up the php too. > > Serverside code is quite another piece of cake. > Well, I posted to discover where my deficiencies lay. So, mission accompli. I'll be back bigger and badderer.
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2019-09-26 12:21 -0700 |
| Message-ID | <c9460631-945a-44f4-bf35-a6eb2d2ab4ba@googlegroups.com> |
| In reply to | #37397 |
On Wednesday, September 25, 2019 at 8:14:35 PM UTC-5, luserdroog wrote:
> Forgive me if this has already come up in the group, but why not use jQuery.
> It seems very nice to reduce the amount of code I have to write (and read).
Don't confuse simple with easy. jquery is 30.4KB in size, and thus far you've gained the ability to do what? Find an element?
$("#angle")
You can do this in JavaScript yourself simply enough:
// find single element: qs('#angle'); qs('.foo', document.body)
let qs = (sel,ctx) => (ctx || document).querySelector(sel)
//find a list of elements: qsa('.item'); qsa('.item', qs('#angle'))
let qsa = (sel, ctx) => Array.from((ctx || document).querySelectorAll(sel)
I suspect any other use case is just as easy to emulate as needed [0], and with the added bonus of being in a single conceptual framework of your own design. The JavaScript community is a ghetto [1] and the frameworks are a bazaar instead of a cathedral[2]. If you want to navigate such a large chaotic environment, it's best to rely on standards, and time tested solutions.
> Thanks again. I think this is just the sort of thing I was looking for.
> Would it be naive as a first pass to actually make 3 javascript objects
> named Model, View, and Controller, and stuff all my functions into them?
> ISTM I could divide the js into 3 or 4 files like this.
I would start by understanding the concepts behind the architecture in the simplest way as reasonable. MVC frameworks are a dime a dozen. A classic (legacy) intro for JavaScript is the MVC guide by former regular in the group Peter Michaux:
<http://peter.michaux.ca/articles/mvc-architecture-for-javascript-applications>
I've tried to convince him to update his guide for the moden day, but to no avail thus far:
<https://gist.github.com/mlhaufe/c841b2269b0099c3c52648717f9551cc>
Between the above guides and the others you have been exposed to, I think this is a solid footing to put together your own MVC approach.
As for your server side code, have you considered using Node.js?
<https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs>
There is also client development guidance that could be given. I assume based on your example code that you used a simple text editor to do your work and FTP for deployment.
[0] <http://vanilla-js.com/>
[1] I'm echoing the sentiment of Zed Shaw from the Rails community here: <http://harmful.cat-v.org/software/ruby/rails/is-a-ghetto>
[2] Echoing Eric Raymond <https://medium.com/gitcoin/the-cathedral-and-the-bazaar-5b97349fd53b>
[toc] | [prev] | [next] | [standalone]
| From | Martin Leese <please@see.Web.for.e-mail.INVALID> |
|---|---|
| Date | 2019-09-26 10:57 -0600 |
| Message-ID | <qmiqlt$pvm$1@dont-email.me> |
| In reply to | #37389 |
Michael Haufe (TNO) wrote: ... > - The rest is off topic for this group, but I'd suggest using the appropriate linters for each language: > > http://csslint.net > https://eslint.org/demo > https://www.freeformatter.com/html-validator.html > https://phpcodechecker.com/ I didn't know about any of these, so a really useful list. I use: http://validator.w3.org/ for HTML http://jigsaw.w3.org/css-validator/ http://www.jslint.com/ -- Regards, Martin Leese E-mail: please@see.Web.for.e-mail.INVALID Web: http://members.tripod.com/martin_leese/
[toc] | [prev] | [next] | [standalone]
| From | "Michael Haufe (TNO)" <tno@thenewobjective.com> |
|---|---|
| Date | 2019-09-26 12:25 -0700 |
| Message-ID | <5c22e923-3454-4efb-8b88-4a361b645d68@googlegroups.com> |
| In reply to | #37411 |
On Thursday, September 26, 2019 at 11:57:40 AM UTC-5, Martin Leese wrote: > Michael Haufe (TNO) wrote: > ... > > - The rest is off topic for this group, but I'd suggest using the appropriate linters for each language: > > > > http://csslint.net > > https://eslint.org/demo > > https://www.freeformatter.com/html-validator.html > > https://phpcodechecker.com/ > > I didn't know about any of these, so a > really useful list. I use: > > http://validator.w3.org/ for HTML > http://jigsaw.w3.org/css-validator/ > http://www.jslint.com/ Of course with a more mature approach, you would instead have things like this integrated into your IDE such as VS Code: <https://code.visualstudio.com/>
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web