If all else fails, read the instructions!
@salman_arfat
process of designing and building an executable computer program to accomplish a specific computing result or to perform a specific task.
[...] encompasses not just the act of writing code, but all of the tools and processes an organization uses to build and maintain that code over time. [...] can be thought of as 'programming integrated over time.'
—Software Engineering at Google
🔄
if all you have is a hammer, everything looks like a nail
If you know C++, you can learn Java in a day / week / month
If you know X, you can learn Y very quickly.
Language X / Framework Y is the best
I know Java, I'll learn C# now.
The Language Equivalence Fallacy
Example: Doubling a list
def createDoubleList(ls):
i = 0
doubledList = []
while i < len(ls):
doubledList.append(2 * ls[i])
i += 1
return doubledList
def createDoubleList(ls):
doubledList = []
for el in ls:
doubledList.append(2 * el)
return doubledList
def createDoubleList(ls):
return [ 2 * el for el in ls ]
Example: range
returns a sequence of numbers, starting from 0 by default, and increments by 1
function range(lower, upper) {
let result = [];
for (let i = lower; i < upper; i++) {
result.push(i);
}
return result;
}
for (let el of range(1, 1_000_000_000)) {
console.log(el);
}
function* range(lower, upper) {
for (let i = lower; i < upper; i++) {
yield i;
}
}
for (const el of range(1, 1_000_000_000)) {
console.log(el);
}
factorial 0 = 1
factorial n =
n * factorial (n-1)
function factorial(num) {
function loop(acc, _num) {
if (_num === 1) {
return acc;
}
return loop(acc * _num, _num - 1);
}
return loop(1, num)
}
Example: factorial
Why is everyone in such a rush? (by Peter Norvig)
Felleisen et al. give a nod to this trend in thier book How to Design Programs, when they says
"Bad programming is easy. Idiots can learn it in 21 days, even if they are dummies."
Alan Perlis once said: "A language that doesn't affect the way you think about programming, is not worth knowing".
Syntax
May look similar to other langauges
Behavior of this language
How is the language modelling the problem domain? AKA Idiomatic.
Language-agnostic and language-specific techniques such as Modularization, code reuse etc
Languages
Example: Summation
class Main {
static int getSum(int lb, int ub) {
if (lb > ub) {
return 0;
}
return lb + getSum(lb + 1, ub);
}
}
class Main {
static int square(int el) {
return el * el;
}
static int getSum(int lb, int ub) {
if (lb > ub) {
return 0;
}
return square(lb) + getSum(lb + 1, ub);
}
}
All code is guilty until proven innocent
I am paid to write code, not tests!
I am a developer, not tester - so I’m not responsible for writing tests!
We already have tests - why do we need unit tests?
We are working on a tight deadline - where do I have time for writing unit tests?
I don’t know how to write unit tests
Ours is legacy code - can’t write unit tests for them
If I touch the code, it breaks!
*Not an exact formulation
Model of the world
Testability of the model
Science (mainly) work by proving statements false, rather than by proving statements true.
*Not an exact formulation
Model of the world
Testability of the model
Linting is the process of running a program that will analyze code for potential errors.
Prevents these kinds of errors
Using statically-typed languages like Typescript
Does this function throw an exception or return 0 / -1 / null?
NullPointerException / cannot find X of undefined
Wait ... this function was supposed to return an object.
Wait ... this function was NOT supposed to return an object.
Unit testing is the process of testing the smallest individual components of an application.
Why am I getting the wrong value?
This function is too hard to test.
Unit testing is good.
BUT
It is the process in which individual components of an application are combined and tested as a group.
I changed file X and now Y doesn't work. I didn't even touch Y.
End-to-end testing is a technique used to test whether the flow of an application right from start to finish is behaving as expected.
describe('Amazon home page', () => {
beforeEach(() => {
cy.visit('https://amazon.com/');
});
it('contains "Amazon" in the title', () => {
cy.title().should('contain', 'Amazon');
});
});
When I hit my API from Postman / curl, it works. But it doesn't work when the user submits the form.
you start coding, I'll ask what the customer wants...
I'll think of the solution design later
I'll get more clarity as I start coding
My goal is to just make it work
Being a Tech Zealot
I'll document it later
I'll plan how to proceed later
but then how will the software be modified/updated later on?
(but do them right)
Phase that Change Occurs | Resulting Cost |
---|---|
Product Design | $1,000 |
Product Testing | $10,000 |
Process Design | $100,000 |
Low-Rate Initial Production | $1,000,000 |
Final Production/Distribution | $10,000,000 |
Error Cost Escalation
Through the Project Life Cycle
Balsamiq
Pen and Paper
If you always ask your co-worker first, you will only ever become an expert as asking for help.
Please feel free to contact me.
@salman_arfat