Be A Better Software Developer
Gerard Sychay
4/6/2014
Who Am I?
Gerard Sychay
How Do You Write Better Software?
It depends.
Thanks!
Gerard Sychay
Differential
Revolution UC
Just kidding...
There are no absolutes
(except for source control).
But Seriously...
-
Better code
- Better processes
- Better habits
-
Better code
- Better processes
- Better habits
Better Code
Better Code
function login()
{
$username = request('username');
$password = request('password');
$sql = "SELECT * FROM USERS
WHERE username = '$username' AND password = encrypt('$password')";
$user = mysql_query($sql);
if ($user) {
return redirect('/dashboard');
}
else {
throw new Error("Username or password not correct!");
}
}
Better Code
function login()
{
$username = request('username');
$password = request('password');
$sql = "SELECT * FROM USERS
WHERE username = '$username' AND password = encrypt('$password')";
$user = mysql_query($sql);
if ($user) {
return redirect('/dashboard');
}
else {
throw new Error("Username or password not correct!");
}
}
Better Code
function login()
{
$username = request('username');
$password = request('password');
$sql = "SELECT * FROM USERS
WHERE username = '$username' AND password = encrypt('$password')";
$user = Database::get()->query($sql);
if ($user) {
return redirect('/dashboard');
}
else {
throw new Error("Username or password not correct!");
}
}
Better Code
function login()
{
$username = request('username');
$password = request('password');
$user = Authenticator::get()->authenticate($username, $password);
if ($user) {
return redirect('/dashboard');
}
else {
throw new Error("Username or password not correct!");
}
}
Better Code
function login($authenticator)
{
$username = request('username');
$password = request('password');
$user = $authenticator->authenticate($username, $password);
if ($user) {
return redirect('/dashboard');
}
else {
throw new Error("Username or password not correct!");
}
}
Better Code
class Authenticator {
function authenticate($username, $password) {
return ($password === "realpassword");
}
}
// Test Login
function testLogin() {
assertError(login("gerard", "wrongpassword"));
assertTrue(login("gerard", "realpassword"));
}
Better Code
-
Separation of Concerns
-
Single Responsibility Principle
-
Dependency Injection
Keep your interfaces clean.
Decouple your logic.
Better Code
Keep your interfaces clean.
Decouple your logic.
- Maintain
- Extend
- Test
Better Code
Hold on!
Use the simplest solution, until you feel pain.
Better Processes
Better Processes
Better Processes
Better Processes
Communication
trumps
-
Documentation
- Planning
- Processes
Better Process
- Static Analysis
(lint, cyclomatic complexity)
- Automated Testing
(unit, functional, acceptance)
(lint, cyclomatic complexity)
(unit, functional, acceptance)
- Automated Deployment
- Source Control
Better Habits
Better Habits
"If you're not breaking things, you're not moving fast enough."
- Mark Zuckerberg, CEO Facebook
Better Habits
He who ships, wins.
<img src="...">
Better Habits
What makes software successful?
If it's useful.
Ask yourself:
- Why are they doing this?
- Am I making it easier or faster?
Better Habits
"In god we trust. All others bring data."
- W. Edwards Deming
Habits to form:
- Meet the user.
- Watch them work.
- Communicate frequently.
Better Habits
- Participate in a community
- Always be learning
- Always be sharing
- Learn to explain technical things to
non-technical people.
non-technical people.
You Are Lucky To Be A Software Developer
- See the results of your craft very quickly.
- That which you produce is inherently shareable – it's just text.
Thanks!
Gerard Sychay @hellogerard
Full-time Meteor shop
Startup Studio
Now accepting resumés!
Be A Better Software Developer
By Gerard Sychay
Be A Better Software Developer
Better code, better processes, better habits.
- 1,099