Qt's Home

The Story of a french guy discovering the world

Week 5 - Day 2 - OOJS Again and Namespacing, Helpers, and Lack of Sleep

| Comments

OOJS again and Namespacing

Yesterday I told you about Object Oriented Javascript. Today I have to tell you again :

If you make some software in Javascript and DON’T use that, you are a BAD person and should feel BAD.

Javascript is powerful, and the community using it gives you some really good tools that enable you to make almost anything in JS today, but coding, like what I did before, in a whole file with random stuff around is NOT the way to go. One could try and go Procedural, but then, even if procedural programming is actually a thing, it makes code that is a bit more messy, less maintainable, and less readable for the people working with you.

JS gives you classes, attributes, methods, instances, packs of methods and way to call them, inheritance, and everything you would need to make “real” software. If you don’t use it, then you’re not doing it right.

The way to actually name everything to identify and sort them the way you understand it is called namespacing. That IS a thing, and should happen in all of the code you write. That is what I have spent the last articles talking about. That is the way to go when working on big project, even alone, and now you have to do that. You’ve been warned. Twice.

Helpers

In Dev Bootcamp phase 2 we have thing thing we call lightning talks. In the afternoon, we register at least once a week to talk for 4 minutes about one particular topic. We start the week not knowing about the topic, but then we learn about it, and have 4 minutes to share about it.

Yesterday, I had one about helpers. Helpers are all of these “packs” of methods that you can use in other parts of your apps. That is the name that has been given to these packs in MVC app frameworks like Node.js, Sinatra and Rails are good examples.

The idea is that you have a separation between your code that shows stuff to the user, the one that does things, and the one that stocks and pulls out data. Helpers are packages that allow one of two things :
– Be able to encapsulate a pack of code you use at multiple times in one simple method you would call instead (GET DRY !, and use namespacing like I’ve been telling you ! )
– Be able to use simple code in the things that are supposed to only be able to print stuff to the user (ex : Show a logout button when the user is logged in. You just print something “If logged_in == true”)

In Sinatra or Rails you can actually even build a whole module to plug in helpers, I did that, that was fun… Until I realized that people did it before and that I did not need to reinvent the wheel.

Lack of sleep

Last week, I went to sleep at 1AM or more every day. After a week of doing that and waking up between 7 and 8 I can tell you : Don’t do that.

I have been feeling a bit tired (what a surprise…) and ended up not being myself, like every time I am tired. When I am like that, I tend to be less patient, and to get things done silently.

Now, DBC is about pair programming… And so I ended up trying to make things work that were just remotely connected to our project, without sharing much about where I was and what I was doing, and in the end did not get stuff to work. At some point, I had lost :
– My focus
– My buddy’s focus
– My time
– My energy and happiness (I’m grumpy when I don’t make things work…)

We ended up finishing the project and doing it a way I can teach people too, so that’s cool, but it took us so much time, I wasted so much time, and I felt so bad for my pair, that most of my day was actually really tiring.

Now, I slept more, and I am learning from my mistakes. today is another day!

(Plus, we had great talks with Armando, and Armando rocks haha. Oh and Armando got a new challenger, Christine is pretty awesome too :p) (Though, to be fair, Janet, Roy, Nic, and many others rock too haha…)

Comments