hacking the way you work

21
Hacking the way you work: simple tools & tricks for your daily development workflow Fotis Alexandrou JOOMLADAY Greece 2013

Upload: fotis-alexandrou

Post on 14-Jul-2015

93 views

Category:

Software


0 download

TRANSCRIPT

Hacking the way you work: simple tools & tricks for your daily development workflow

Fotis Alexandrou

JOOMLADAY Greece 2013

Who am I

• Developer at PeoplePerHour.com

• Freelance Web Developer (Past)

• Automation enthusiast

• Nervous when talking in public

Challenges

• Time management

• Tracking changes & collaboration

• Code structure

• Code maintenance (the horror)

Time management

Common problems

• “But it worked on my dev machine! What

happened now?”

• “Oh no! we use version 1.3.15 on the server? I

run 2.6.13 which has the feature X

implemented!”

Enter Vagrant

• What it provides

– Virtual Machines called “boxes”

– Provisioning

– Requirements: VirtualBox, Ruby

Configuration

• Simple Ruby file called “Vagrantfile”

– http://www.vagrantup.com/

• Plethora of pre-packaged boxes

– http://vagrantbox.es

• Provisioning via Puppet or Chef

Benefits

• Consistency between local dev machine & production

server

• Ability to use the same provisioning recipes on production

• Prevents from bloating the host OS with many services

• Production server changes can be tested locally before

being applied to production

• Cloud integration (knife, vagrant aws)

Provisioning: Puppet vs Chef

• Never ending discussion

• Chef

– Write Cookbooks in Ruby– http://docs.opscode.com/just_enough_ruby_for_chef.html

• Puppet

– Puppet manifests in Puppet script language

• Both have the same results

Common Vagrant gotchas

• Nginx + Apache sendfile (VirtualBox bug)

• Memory increase– config.vm.customize ["modifyvm", :id, "--memory",

1024]

• Shared folder

– :extra => "umask=0002,dmask=0002,fmask=0002"

• Symlinks

– https://coderwall.com/p/b5mu2w

Tracking changes & collaboration

SVN vs Git

• Pros

– Simple flow

• Cons

– Brances are separate directories

– Always commiting to repo

– Extreme CPU usage on big repos

Enter Git

• Feature branches: No separate directories for

branches

• Submodules

• Stash

• Remotes

Remote Repos

• Hosted on 3rd party services

– Github

– Bitbucket

• Can be self-hosted

– Gitlab

– Gitolite

– Gitorious

Git

• Pull requests: Non merged commits –Visual

representation of changes

• Squash / Rebase: Merge several commits to

one

– Reverting only one commit if needed

Code Structure

• Design patterns

– “Design patterns are reusable solutions to

commonly occurring problems in software

design”

• Help you get a solid start

Design patterns

• Not the holy grail

• Help developers read each others code as

structure is somehow pre-defined

• Avoid duplicate code

Examples

• PHP design patterns:

– https://github.com/domnikl/DesignPatternsPHP

• Javascript design patterns

– http://addyosmani.com/resources/essentialjsdesi

gnpatterns/book/

Best Practices

• Avoid hacks

• DELETE your code

– http://www.youtube.com/watch?v=Ev7lM7SWVHE

• Less code is always better

• Refactor while you still code

Other tips• Embrace coding standards

– https://github.com/php-fig/fig-standards/

• Exceptions are your friends

– Traceable, Catchable

• Read other developers’ code

– Github => Facebook for developers, browse repos,

even in languages you are not familiar with

Thank you

• Questions

• Twitter: @falexandrou

• Blog: falexandrou.com