Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
enthe0s
Oct 24, 2010

In another few hours, the sun will rise!

Lumpy posted:

This is why I started learning Backbone the other day.

How did a comparison between Angular and Ember spur you into learning Backbone? Just curious since I also started picking it up recently.

Adbot
ADBOT LOVES YOU

DreadCthulhu
Sep 17, 2008

What the fuck is up, Denny's?!
This has been bothering me for a long time and maybe you guys know the answer.

Does anybody have advice on how to properly structure lazy fetching of resources in nested views with Backbone + LayoutManager? Say you have a tree of views, and the topmost view calls render() (that's how LayoutManager does it at least) on its children views, which recursively go ahead and call render() on their own children etc. This is all fine and well until you need to fetch() a collection or a model in order to be able to render one of the views in the tree, an asynchronous operation.

Do you essentially call fetch() on initialization of each view and immediately render a spinner in place, then register a callback on whenever the collection is done and just replace the contents? I think this is the simple case, but I also think there's a situation where some views don't quite know what children views to initialize until an outstanding fetch is completed, in which case now calling render() recursively cannot work, and you have to manually setup logic that checks for the presence of data.

The other hassle is that you need to account for two ways of fetching data: sometimes you already have it (a user lazily fetched it before, and never reloaded the app), you can render right away, and sometimes you don't, so you need to do an async operation.

Really wish this crap was less convoluted :)

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

enthe0s posted:

How did a comparison between Angular and Ember spur you into learning Backbone? Just curious since I also started picking it up recently.

Because after messing around with both a bit, i had this conversation with myself: "I like Ember more so I'll learn that, but it looks like angular is the runaway train, so maybe I should learn that, but Ember fits my way of thinking, so I'll go with that, but there's so much more angular stuff coming out so maybe....and what exactly am I trading off by picking one over the other anyway? gently caress it, Backbone does 95% of what I need and I can figure it all out in an afternoon. "

sim
Sep 24, 2003

DreadCthulhu posted:

Does anybody have advice on how to properly structure lazy fetching of resources in nested views with Backbone + LayoutManager? ... Do you essentially call fetch() on initialization of each view and immediately render a spinner in place, then register a callback on whenever the collection is done and just replace the contents? I think this is the simple case, but I also think there's a situation where some views don't quite know what children views to initialize until an outstanding fetch is completed, in which case now calling render() recursively cannot work, and you have to manually setup logic that checks for the presence of data.

The other hassle is that you need to account for two ways of fetching data: sometimes you already have it (a user lazily fetched it before, and never reloaded the app), you can render right away, and sometimes you don't, so you need to do an async operation.

Use event listeners. They are meant to get out of callback hell and situations like this. Usually I assign a model or a collection to each view (or multiple views to the same model/collection), then assign the view to render itself on model/collection sync.

For example, inside each view's initialize function:
code:
this.listenTo(this.model, "sync", this.render);
You could also trigger a custom function to get rid of the loading animation (and maybe have that call render instead). This is one of the nice features of Marionette; the collection views will automatically re-render in response to model/collection events.

excidium
Oct 24, 2004

Tambahawk Soars
Does anyone have any suggestions on organizing large projects and coming up with trackable and achievable goals to prevent being overwhelmed? I feel like I'm getting no where on this thing because I spend too much time researching ways to do things instead of just doing them due to a lack of organization and structure. Any tips would be appreciated.

A MIRACLE
Sep 17, 2007

All right. It's Saturday night; I have no date, a two-liter bottle of Shasta and my all-Rush mix-tape... Let's rock.

What project management tool are you using? I'm not a die hard agile fanboy but it can be helpful to organize your project into epics, features, sprints, bugfixes, release schedules etc. Look into kanban too if you like writing stuff on post it notes

excidium
Oct 24, 2004

Tambahawk Soars

A MIRACLE posted:

What project management tool are you using? I'm not a die hard agile fanboy but it can be helpful to organize your project into epics, features, sprints, bugfixes, release schedules etc. Look into kanban too if you like writing stuff on post it notes

Right now all I have is Todoist set up to try to somewhat organize my ideas/goals to track against, but I'm not all that impressed with it.

Pseudo-God
Mar 13, 2006

I just love oranges!
https://www.scrumy.com is really cool, and has all the features a scrum beginner might want. My company paid a ton for some 500 ton giant, when this website could have done the same job for only $5 a month for the pro version.

Pseudo-God
Mar 13, 2006

I just love oranges!
In PHP, if I want to connect to a DB, I usually set the DB connection details in some config file, or even the page source itself, and this information is never revealed to the end-user. However, I cannot figure out how to hide these details in a JS only app, where everything is exposed to the browser. Is it possible to store confidential details, such as DB passwords, in a JS file or similar, but prevent them from being read by the user?

spiritual bypass
Feb 19, 2008

Grimey Drawer
Do you have the difference between your server-side (nodejs) code and client-side code confused?

jony neuemonic
Nov 13, 2009

Yeah. I could be misunderstanding (I'm almost entirely a back-end guy), but I can't see that you would ever want to expose DB credentials to a web browser. Where are you calling out to your DB from?

Pseudo-God
Mar 13, 2006

I just love oranges!
I was wondering if it was possible to replace the database with AJAX calls to a third party, but I can't see a way to store the credentials without exposing them to the end-user.

G-Prime
Apr 30, 2003

Baby, when it's love,
if it's not rough it isn't fun.
Why not set up a server-side script that accepts predefined actions from POST actions, and leave the DB abstraction to that? You could make calls to that through AJAX and never expose the DB.

Pseudo-God
Mar 13, 2006

I just love oranges!

G-Prime posted:

Why not set up a server-side script that accepts predefined actions from POST actions, and leave the DB abstraction to that? You could make calls to that through AJAX and never expose the DB.
I want to do it without a server-side script at all, but I guess the tech is not here yet.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Pseudo-God posted:

In PHP, if I want to connect to a DB, I usually set the DB connection details in some config file, or even the page source itself, and this information is never revealed to the end-user. However, I cannot figure out how to hide these details in a JS only app, where everything is exposed to the browser. Is it possible to store confidential details, such as DB passwords, in a JS file or similar, but prevent them from being read by the user?

1. You need to build a server-side layer between your DB and your client-side apps that communicates in JSON or whatever.
2. It's not possible to hide the auth info to a DB or the layer mentioned in the last point from the end-user. You can require logged-in users and that's about it.

G-Prime
Apr 30, 2003

Baby, when it's love,
if it's not rough it isn't fun.

Pseudo-God posted:

I want to do it without a server-side script at all, but I guess the tech is not here yet.

Keep in mind, even if you found an elegant way to have user-run javascript authenticate to your DB in a secure way that the user can't hijack the credentials from (which doesn't seem possible), you're still relying on that script to make direct SQL queries, which hoses your security entirely. That's why you need the abstraction. Instead of blindly accepting queries, you've got predefined queries that the abstraction layer provides based on criteria that the user submits via the javascript.

Pseudo-God
Mar 13, 2006

I just love oranges!

Thermopyle posted:

1. You need to build a server-side layer between your DB and your client-side apps that communicates in JSON or whatever.
2. It's not possible to hide the auth info to a DB or the layer mentioned in the last point from the end-user. You can require logged-in users and that's about it.
Like I said earlier, apparently it's not possible to do this entirely in front-end JS. However, it may be possible to have a tiny PHP/ASP/node/ruby etc script, which can hold authentication data, and act as a relay to the external DB.

jony neuemonic
Nov 13, 2009

Pseudo-God posted:

Like I said earlier, apparently it's not possible to do this entirely in front-end JS. However, it may be possible to have a tiny PHP/ASP/node/ruby etc script, which can hold authentication data, and act as a relay to the external DB.

This is a perfect use-case for a micro framework. Pick whichever one matches your language of choice, wire up some simple routes, and you're done.

Pseudo-God
Mar 13, 2006

I just love oranges!
I got this idea a couple of days ago when I was checking out neocities.org. I was wondering if it could be possible for them to actually have a database hosted by a third party, but without the public having direct access to the data. It's not possible according to you guys, but a tiny server-side script could be used, in whichever language, to store these credentials and contact the third-party database.
I also never said that SQL would be used, but an abstracted one, where you write to a URL, and get a URL back to access this data.

Stoph
Mar 19, 2006

Give a hug - save a life.
Parse (https://parse.com/) and Firebase (https://www.firebase.com/) are hosted backends for a "static files application". Perhaps you should give them a look.

Pseudo-God
Mar 13, 2006

I just love oranges!

Stoph posted:

Parse (https://parse.com/) and Firebase (https://www.firebase.com/) are hosted backends for a "static files application". Perhaps you should give them a look.
I should have guessed that these things already existed. Thanks to everyone for the guidance.

Doh004
Apr 22, 2007

Mmmmm Donuts...

Knyteguy posted:

Also has anyone tried developing with either with a Microsoft stack like MVC and SQL Server?

Thanks.

Our entire site is a MS stack and it works great. Using MVC.NET 4.

sim
Sep 24, 2003

Anyone have experience with Ext.js or Sencha Touch? I've avoided it like the plague but I keep getting recruited for jobs that require it.

Quebec Bagnet
Apr 28, 2009

mess with the honk
you get the bonk
Lipstick Apathy
If you hate manually designing and laying out HTML and just want to get some widgets on screen it's great. I also find I rarely have to go outside the framework for anything (except for stuff designed for it). Ext apps definitely behave more like native desktop/mobile applications but it's great for things where you want to think more about the widgets and components than the actual HTML. That said, my background is desktop applications. If you're used to jQuery callback soup and sperging over templating engines you may find the learning curve to be more of a cliff.

Sil
Jan 4, 2007
Trying to build an Ember app on top of an existing API and I am having the most absurd problem. I want to authenticate certain routes. I've managed to grab the authentication token from the server and now I want to place it in X request header for every subsequent ajax call. How the hell do I do this?

I try to call Ember.$.ajaxPrefilter and use a global variable to pass it from the controller to the function call(since I can't access controller variables in the prefilter call. For some reason). Doesn't set a header. I try to add a field to the json request sent to the server. Doesn't seem to be possible?

Every google search seems to send me to an Ember-auth tutorial. I really don't want to implement 5 million gems when the entire auth process should involve passing one bloody variable from a controller into a json pre formatter.

NovemberMike
Dec 28, 2008

Pseudo-God posted:

I want to do it without a server-side script at all, but I guess the tech is not here yet.

To clarify, the tech will never be here because what you are talking about is fundamentally a bad idea. The problem is generally solved by wrapping the database in an API of some kind and then having the client query against the API. The goal is to never allow the client to say "I want to run SQL", you let them say "I want data" or "I want to write data" instead.

Uziel
Jun 28, 2004

Ask me about losing 200lbs, and becoming the Viking God of W&W.

sim posted:

Anyone have experience with Ext.js or Sencha Touch? I've avoided it like the plague but I keep getting recruited for jobs that require it.
I am passingly familiar with ext.js through the .net implementation of it. Initially I thought it was awesome as it took care of so many little things for me and worked well, but after it spread through my team's application, it became cumbersome and some of the warts make me want to just remove it and redo everything another way.

xf86enodev
Mar 27, 2010

dis catte!
I remember a few years ago when people still couldn't decide between jquery, prototype, mootools, etc., Extjs was _the_ thing to wow middle-manager types.
Look at all those widgets! And we can write them in Java!

xf86enodev
Mar 27, 2010

dis catte!

NovemberMike posted:

To clarify, the tech will never be here because what you are talking about is fundamentally a bad idea. The problem is generally solved by wrapping the database in an API of some kind and then having the client query against the API. The goal is to never allow the client to say "I want to run SQL", you let them say "I want data" or "I want to write data" instead.

Dude, data comes from the cloud now.

Sedro
Dec 31, 2008
Ember newbie question:

I'm trying to change this master/detail example. I want to add a "users" route instead of using the application route. Here is my attempt. How can I get the links to work?

Edit: figured it out

Sedro fucked around with this message at 17:05 on Dec 12, 2013

ManoliIsFat
Oct 4, 2002

NovemberMike posted:

To clarify, the tech will never be here because what you are talking about is fundamentally a bad idea. The problem is generally solved by wrapping the database in an API of some kind and then having the client query against the API. The goal is to never allow the client to say "I want to run SQL", you let them say "I want data" or "I want to write data" instead.

[20 pages of that Super Meat Boy hi score mysql fiasco]

abraham linksys
Sep 6, 2010

:darksouls:

xf86enodev posted:

Dude, data comes from the cloud now.

Firebase (a real time key-value store as a service) has an interesting solution for this: security rules that let you limit access to your data. It's very, very simple (and built mainly for keeping a single user's data private to only them), but Firebase is only meant for simple data storage anyways (the real-time aspects are far more interesting than the actual "database").

But just pick something that makes it easy to write a minimal backend or API and you're good to go. We're not quite in a backend-less future, except for very simple use cases (though it is pretty awesome to prototype something w/o a backend).

Pseudo-God
Mar 13, 2006

I just love oranges!
A backend-less future could be simulated by having a minimal backend, which is only used for authentication and security. In principle, there will always be data which should not be exposed to the user. For everything else, a JS only app is perfectly suitable.

xf86enodev
Mar 27, 2010

dis catte!
"Data is your most valuable asset" and "never trust the client" are the 2 most important mantras for people who want to do stuff with computers and networks.
Either you control the data or you don't. If you want to control the data, you need to own the data source. This is the so-called backend.

Mashups are kind of an example for something that works without a backend already by solely relying on external data sources. But as soon as those sources stop providing data those apps lose all of their functionality.

So if you want to build something that works and you want to guarantee that it keeps working you need a backend.


Moustaches own btw, don't know about handlebars though.

Mike1o1
Sep 5, 2004
Tiluvas

excidium posted:

Does anyone have any suggestions on organizing large projects and coming up with trackable and achievable goals to prevent being overwhelmed? I feel like I'm getting no where on this thing because I spend too much time researching ways to do things instead of just doing them due to a lack of organization and structure. Any tips would be appreciated.

A bit late, but I've started to use Team Foundation Service in the cloud for this. It's free for teams up to 5 people and I think you can have unlimited repositories either as TFS or Git. http://www.visualstudio.com/products/visual-studio-online-overview-vs

I went from a todo-list in notepad, to a todo-list in evernote, to finally settling on the hosted TFS solution above. I do everything from a mac using the web interface which is just fantastic, so I can easily add "to do" items to my backlog from any internet device pretty much.

The great thing is that it supports git, so I have all my source code in git and all my issues and stuff setup in TFS. All my code is node.js.

I'm probably not using all of the abilities, but I basically just outline all of my major goals as features, and break those up as tasks and assign them to myself and give myself a rough time estimate. I've been a member since beta, but just started using it seriously for my first project for a month and just completed my first "sprint" and it's really helped me keep myself organized and on-task and to keep my git commit history clean.

You can automatically tie git commits to items as well just by referencing the item number in the commit message, similar to GitHub.

Xom
Sep 2, 2008

文化英雄
Fan of Britches

abraham linksys posted:

Firebase (a real time key-value store as a service) has an interesting solution for this: security rules that let you limit access to your data. It's very, very simple (and built mainly for keeping a single user's data private to only them), but Firebase is only meant for simple data storage anyways (the real-time aspects are far more interesting than the actual "database").

But just pick something that makes it easy to write a minimal backend or API and you're good to go. We're not quite in a backend-less future, except for very simple use cases (though it is pretty awesome to prototype something w/o a backend).
I just made MY FIRST WEB APP, and I used Firebase: https://pandante.neocities.org



The server is literally javascript on a page in another browser tab. Hopefully leaving it running like that for hours is not an issue? (how do I dev web I do not know things)

Xom fucked around with this message at 19:07 on Dec 18, 2013

a lovely poster
Aug 5, 2011

by Pipski

excidium posted:

Does anyone have any suggestions on organizing large projects and coming up with trackable and achievable goals to prevent being overwhelmed? I feel like I'm getting no where on this thing because I spend too much time researching ways to do things instead of just doing them due to a lack of organization and structure. Any tips would be appreciated.

Is your project on GitHub? Maybe try using some of the issues and milestones features?

Kobayashi
Aug 13, 2004

by Nyc_Tattoo
I want to learn about testing, both unit and integration. Can anyone point me at a real low-level, in-depth introduction? Something like Todo MVC for Javascript testing. I get the idea, but I don't know where to start, or how to approach writing tests, or even how to integrate testing into my workflow. It would be nice to learn by example.

Cocoa Crispies
Jul 20, 2001

Vehicular Manslaughter!

Pillbug

a lovely poster posted:

Is your project on GitHub? Maybe try using some of the issues and milestones features?

You can use them with https://waffle.io to get a nice view.

Adbot
ADBOT LOVES YOU

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Kobayashi posted:

I want to learn about testing, both unit and integration. Can anyone point me at a real low-level, in-depth introduction? Something like Todo MVC for Javascript testing. I get the idea, but I don't know where to start, or how to approach writing tests, or even how to integrate testing into my workflow. It would be nice to learn by example.

It might not be exactly what you are looking for, but I found the book Test Driven Development by Kent Beck a really read on the subject. TDD is a bit "heavy", but even if you don't adopt the methodology, I think it will get you thinking about testing "the right way" .

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply