Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Aug 17 09:32
    User @bjorno43 unbanned @linkin-park
  • Jun 20 21:19
    @bjorno43 banned @shenerd140
  • Apr 25 17:13
    @mstellaluna banned @cmal
  • Jan 08 22:05
    @mstellaluna banned @dertiuss323
  • Nov 07 2018 04:42
    User @texas2010 unbanned @ows-ali
  • Nov 02 2018 16:25
    @texas2010 banned @ows-ali
  • Oct 12 2018 05:50
    @bjorno43 banned @NACH74
  • Oct 05 2018 23:02
    @mstellaluna banned @JomoPipi
  • Sep 16 2018 12:21
    @bjorno43 banned @yash-kedia
  • Sep 16 2018 12:16
    @bjorno43 banned @vnikifirov
  • Sep 05 2018 08:12
    User @bjorno43 unbanned @androuino
  • Sep 05 2018 07:38
    @bjorno43 banned @androuino
  • Aug 23 2018 16:57
    User @bjorno43 unbanned @rahuldkjain
  • Aug 23 2018 16:23
    @bjorno43 banned @rahuldkjain
  • Jul 29 2018 14:13
    User @bjorno43 unbanned @jkyereh
  • Jul 29 2018 01:00
    @bjorno43 banned @jkyereh
  • Jul 10 2018 22:09
    @bjorno43 banned @manafn
  • Jul 06 2018 15:20
    @texas2010 banned @imlegend19
  • Jul 03 2018 12:28
    @bjorno43 banned @vbvmatta
  • Jun 29 2018 13:54
    @bjorno43 banned @OGTechnoBoy
Santiago Fernandez
@sf-jd
but then again, DRY stabs me in the face and i HAVE to avoid repeating stuff :D
all in all im not satisfied that the implementation works, but i'd like the code to look nice... despite the fact they know i havent worked more than a few freelance projects (and you pretty much make up the rules as you go there)
Brad
@bradtaniguchi
I mean its really realtive. Do you know if you can find out if the company your submitting your code to has any style guides? (might be able to do some digging)
otherwise the general stuff should be ok. Idk if you code looks like a mess so idk past that
Santiago Fernandez
@sf-jd
they dont, one of their front end leads is a good friend of mine and he agrees on my approach "i dont know everything, this is the best i can do"
mayhaps just need to vent it out a bit and then click the send button with what i've got :D
Brad
@bradtaniguchi
I mean i don't see how style could hurt you as long as its not total garbage haha
Santiago Fernandez
@sf-jd
take the following
function a(){
 functionb()
functionc()
functiond()
}
i just feel that is dirty for some reason
but it does help me handle an event on the browser in multiple places, by using a() and keeping each eventhandler short
Brad
@bradtaniguchi
I usually don't nest functions, unless there's some sort of OOP going on
were talking about vanillajs right? Opens up alot of ideas on style
Santiago Fernandez
@sf-jd
yea
constraint is use no libraries, no frameworks, just vanilla
Brad
@bradtaniguchi
Yea, id still stick with the no nested function thing (besides an Iffe)
Santiago Fernandez
@sf-jd
so just repeat the code?
i am wrapping all those methods (b,c,d) inside another method basically, that is my approach, to avoid repeating like a madman and spanning 150 more lines of code
Brad
@bradtaniguchi
what? whats wrong with:
function a() {
  addEventListener.on('click', b);
//...
}
function b() {}
function c() {}
function d() {}
Unless your using the same functions, (b,c,d) on different elements or something I'm missing
Santiago Fernandez
@sf-jd
yea i am
i have click handlers for left arrow, right arrow, and then a nav with different positions
Brad
@bradtaniguchi
Ah, I guess the naming of b,c,d isn't the best :P
Santiago Fernandez
@sf-jd
rofl
Brad
@bradtaniguchi
In that case i think its ok. Id probably keep the functions out of the main function just to then you can use them seperatly in special cases.
Santiago Fernandez
@sf-jd
handleRightClick(){
 currentPosition += 1;
doStuffWithPosition() #this is where all the other handlers are
}

handleLeftClick(){
 currentPosition -=1;
doStuffWithPosition() #same handlers
}

goToPosition(e){
 currentPosition = e.target.dataattribute;
doStuffWithPosition() #again same handlers
}

doStuffWithPosition(){
 stuff();
 moreStuff();
 yetMoreStuff()
}
oh wow that pseudocode.
i felt that's cleaner than just one function with a switch or if/else inside... handling left, right and passing position.
as handleRightClick or handleLeftClick also let me use arrow keys and i just debounce those, withouth extending their bodies with more logic.
Brad
@bradtaniguchi
I guess it depends on the use-case haha
Santiago Fernandez
@sf-jd
:)
thanks @bradtaniguchi
CamperBot
@camperbot
sf-jd sends brownie points to @bradtaniguchi :sparkles: :thumbsup: :sparkles:
:cookie: 468 | @bradtaniguchi |http://www.freecodecamp.org/bradtaniguchi
Brad
@bradtaniguchi
@sf-jd np and goodluck, I think you should be fine :D
Santiago Fernandez
@sf-jd
fingers crossed
Jesse Ross-Huffman
@jecmstudios
So I'm stuck on the beginner's front-end project, I just feel scared of being on my own. I need inspiration.
Thomas Tylek
@zippkidd
@jecmstudios what do you have to do for that project?
Is the example codepen given not enough inspiration? Lol
hansUno2
@hansUno2
@jecmstudios break the project down into steps. Develope an algorithm/recipe for how you will get from blank page to final result before evening writing any code. Its like building a house, you get your ideal design and you change things as you go. This helps you to avoid freestyle coding which can lead to frustration.
zootechdrum
@zootechdrum
@jecmstudios plan plan plan.
@ehutchllew no i got it it was just returning a promise
Lallo Vigil
@lalov1
@jecmstudios I can help! Let me know with what
I mocked up the react recipe project. Please let me know some hints on how I will save the items in state and pass them using props: https://codepen.io/lalov1/pen/97756811476267a589a730dc15f881a1?editors=0010
Claudio Restifo
@Marmiz

@lalov1 you just make your child component "dumb", in the sense that both the data and the method to change that date comes from the parent, the child only purpose is to render the latter:

An example would be:

const child = ({value, onChange}) => (<div onClick={() => onChange()}>{value}</div>)

class Parent [...] {
 state={value: 1}
 onChange = () => this.setState({value: this.state.value +1})

 render() {
  return (<Child value={this.state.value} onChange={this.onChange} />)
}
}

hope it helps :+1:

Jesse Ross-Huffman
@jecmstudios
Thank you guys all of you helped. I just have always frozen up when I feel left on my own.
habibaatify
@habibatify_twitter
hello
any one who know latex?
coderNewby
@coderNewby
@DarrenfJ thanks for the pm
CamperBot
@camperbot
codernewby sends brownie points to @darrenfj :sparkles: :thumbsup: :sparkles: