While the variables are the nouns of the coding (as we've seen), the functions are the verbs.
To be sure they have a correct name, ask them:
"Whatcha doin'?"
"I [function name]" should be the answer.
"I createDatabase" - is good.
"I sortArray" - is great.
"I user" - not that much.
"I database" - nop.
Friday, November 27, 2015
Thursday, November 26, 2015
How to name your variables and your kids
Story one
Some time ago, I travelled in India and one of things that amazed me was that, after I was introducing myself, everybody was asking: “What does your name mean?”
"What do you mean what does it mean, it is a name, names mean nothing", I was thinking.
Of course I was wrong. Most of the names mean something:
John means gracious
Mary means sea
Will means of course will, desire
and so forth
Even my name Dragos, comes from Drag which means loved in Romanian. My Indian friends were amazed when I was telling them that.
Looking for the meaning of a name might help choosing a name for your kids. Even if it is nicer to find out after you've already chosen one.
*
How about the variable we use in our code?
Some time ago, I travelled in India and one of things that amazed me was that, after I was introducing myself, everybody was asking: “What does your name mean?”
"What do you mean what does it mean, it is a name, names mean nothing", I was thinking.
Of course I was wrong. Most of the names mean something:
John means gracious
Mary means sea
Will means of course will, desire
and so forth
Even my name Dragos, comes from Drag which means loved in Romanian. My Indian friends were amazed when I was telling them that.
Looking for the meaning of a name might help choosing a name for your kids. Even if it is nicer to find out after you've already chosen one.
*
How about the variable we use in our code?
Wednesday, November 25, 2015
Refactoring the evil i, j, k
For the sake of argument, consider you have the following input data:
let userIds = [1,2,3,4,5]
let userNames = [
1 : "John",
2 : "Mary",
4 : "James"
]
let userAges = [
2 : 30,
4 : 40,
5 : 25
]
Tuesday, November 24, 2015
The Programmer's Oath
Read here the Programmer's Oath by Uncle Bob
And this is a shorter version: As I love my programming activities, I will always write code that I love.
And this is a shorter version: As I love my programming activities, I will always write code that I love.
Monday, November 23, 2015
How small should be a function
"A function should be smaller than small" :)
Read more here:
https://mmrs151.wordpress.com/2015/11/04/the-poetry-in-function/
Read more here:
https://mmrs151.wordpress.com/2015/11/04/the-poetry-in-function/
Thursday, June 5, 2014
Sorting in Swift - elegant
let names = ["Chris", "Alex", "Ewa", "Barry", "Daniella"]
reversed = sort(names, { (s1: String, s2: String) -> Bool in
return s1 > s2
})
reversed = sort(names, { (s1: String, s2: String) -> Bool in return s1 > s2 } )
reversed = sort(names, { s1, s2 in return s1 > s2 } )
reversed = sort(names, { s1, s2 in s1 > s2 } )
reversed = sort(names, { $0 > $1 } )
reversed = sort(names, >)
reversed = sort(names, { (s1: String, s2: String) -> Bool in
return s1 > s2
})
reversed = sort(names, { (s1: String, s2: String) -> Bool in return s1 > s2 } )
reversed = sort(names, { s1, s2 in return s1 > s2 } )
reversed = sort(names, { s1, s2 in s1 > s2 } )
reversed = sort(names, { $0 > $1 } )
reversed = sort(names, >)
Subscribe to:
Posts (Atom)