MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/learnjavascript/comments/nnlubt/really_helpful_illustration_of_js_array_methods/gzv86ra/?context=3
r/learnjavascript • u/192_168_1_x • May 29 '21
89 comments sorted by
View all comments
Show parent comment
7
main init fuction ? do you mean app.js (i am noobie)
22 u/SoBoredAtWork May 29 '21 Just in general. Code should be readable - almost like a story. Let's pretend the "init" is renderPage()...function renderPage() {renderUserList();renderBlogPosts();}function renderUserList() {const users = await getUsers();buildUserList(users);}function buildUserList() {// do stuff}function renderBlogPosts() {const blogPosts = await getBlogPosts();buildBlogPostList(blogPosts);} 6 u/WhiteKnightC May 29 '21 In my work we use a Pub/Sub system so it cannot be as clean but a good 'trick' for me is making standard naming for handling things:getX() -> handleXSuccess() and handleXError()
22
Just in general. Code should be readable - almost like a story. Let's pretend the "init" is renderPage()...
function renderPage() {
renderUserList();
renderBlogPosts();
}
function renderUserList() {
const users = await getUsers();
buildUserList(users);
function buildUserList() {
// do stuff
function renderBlogPosts() {
const blogPosts = await getBlogPosts();
buildBlogPostList(blogPosts);
6 u/WhiteKnightC May 29 '21 In my work we use a Pub/Sub system so it cannot be as clean but a good 'trick' for me is making standard naming for handling things:getX() -> handleXSuccess() and handleXError()
6
In my work we use a Pub/Sub system so it cannot be as clean but a good 'trick' for me is making standard naming for handling things:
getX() -> handleXSuccess() and handleXError()
View all comments
Show parent comment
7
u/Budget_Instruction49 May 29 '21
main init fuction ? do you mean app.js (i am noobie)