Small and repetitive code
Yesterday, I worked on portfolio projects. They are projects to check if you know about what we’ve been using, for yourself or for the teachers. They are small, easy, and fun… And everything is relative, like Einstein said.
One of the project was hard, but not because of the complicated content, but because of the amount of repetitive code we had to do.
Don’t get the bad idea though, the challenge was cool, but it was about making a big bunch of code that we have been making for 2 weeks now. I did it late, and because of that I just ended up having to re do again, instead of doing it in the middle of my learning.
Anyway, the thing I got from that challenge is : Code is repetitive! That’s why people take and make shortcuts. Sometimes, you have to make the same thing again, a few times, and that sucks. Copy pasting and all that works, but in this particular context, it did not…
DB Constraints
I did a lightning talk about DB Constraints. The idea is that the apps that we build with Ruby On Rails, Sinatra, Nodejs, or all these things, use tools that allow you to not have to deal with database languages and small tasks by yourself.
But then, people tend to forget that in the end, we ARE working with databases. And what if one day your app falls apart? What if you want to change some portion of your code, among which is the DB reader thingy?
If you don’t put any constraints on your database, then you have a problem because now people can use empty username, 1230912301921309 characters numbers, etc…
So to prevent that, put constraints! When I say constraints, you can limit your 4 things (or 5) :
- :limit : Works for binary, numbers, strings, and texts, and set the max number of characters
- :null : Allows (Or not allow, if you give it false) this column to have a null entry in it
- :default : Give a default value to that field when none is entered
- :precision / :scale : Specifies the number of digits you can give, and the number of digits after the decimal
See? That was not hard!
Now, go ahead and go read : this.
Connecting
One thing we do here is connecting. We spend all of our time together, we are now a huge family where everybody has to know and live with everybody.
Yesterday, Irene and I “cashed in” my free meal from Sherif, our big first phase teacher that we don’t see much because we’re in phase 2 now, because we finished our sudoku solver that solves 170 sudokus in less than a minutes (8.5 seconds whaddup!).
That was really fun, we ate a lot, and learnt a lot… again. Incredible, when he is “off duty”, we learn a lot from him!
He told us a lot about how he had trouble connecting with the new cohort and I feel bad for them.
Today, I went/am going to eat with Strand, and that is awesome. He’s a 2nd phase teacher and I feel like I’m connecting with everybody and I love it ^.^