LA Django 2012-04-17 various talks¶
All lightning talks. I was going to give one but was too busy to finishing assembling my talk.
Talk #1 - Deploying Django with wsgi and nginx¶
by Sandy Mahalo
- Demonstrated against Django 1.4
- Very technical and spoke fast so didn’t get a chance to write things done. :P
- Material attribution: http://bit.ly/hf6974
Talk #2 - Naming things¶
by Michael Avila, works at EdgeCast
Two things hard in computer science¶
- Caching invalidation, naming things, and off-by-one errors. – Phil Karlton
Naming things is very hard¶
- Programs are just theories for how computers can interact with the world.
Implementation patterns¶
Using house and street as our naming pattern target:
class - simple super class name¶
- Top of inheritence chain
- Stick to one word
- Do this: Street
- Not this: HouseList
class - qualified sub class name¶
- How are they alike?
- How are they different?
- Do this: Hose -> GardenHose
- Not this: Hose -> WaterSource
variable - role suggesting name¶
- What is it’s type?
- What is it’s scope/lifetime?
- What is it’s role?
- Do this: adams
- Not this: adamsHouse
function - intention-revealing name¶
- Stick to verb phrases
- Do this: street.add_house(a)
- Not this: street.houses(a)
Useful books for naming things¶
Talk #3 - Extracting Domain Objects¶
by Brian Riley, Edgecast
Target of the talk was some of the code from the Django tutorial :-)
Django is for serving out the web, not not necessarily other things.
Sometimes it can be good to extract the business logic from the obvious place and put into other control systems.
- Celery comes to mind.
# old way
selected_choice.vote += 1
# domain way
class Voter(object):
DEFAULT_NUMBER_OF_VOTES = 1
def number_of_votes(self, user):
if user.is_authenticated():
return user.votes
return Voter.DEFAULT_NUMBER_OF_VOTES
Talk #4 - Integrating Facebook into Django¶
by Dan Loewenhertz of
- Has built a number of Facebook apps
- Very interesting decorator approach to getting this done.
- https://github.com/elmcitylabs/ECL-Facebook