Tutti i miei sbagli, versione 7 Marzo 2012 al XPUG mi

Post on 24-Apr-2015

807 views 1 download

description

Gli errori e le lezioni che ho imparato dallo sviluppo di un progetto Open Source

Transcript of Tutti i miei sbagli, versione 7 Marzo 2012 al XPUG mi

Tutti i miei sbagli Gli errori di un Wannabe Open Source Developer

Andrea Francia

Thursday, March 8, 12

Contenuti

Il progettoGli Sbagli• Generic Naming Issue• Using Bash for functional

testing• Feedback• License• Project hostingUna cosa giustaConclusioniApplausi

Thursday, March 8, 12

trash-cli$ trash foo

$ list-trash

2012-03-02 19:43:44 /Users/andrea/foo

$ touch foo; trash foo

$ list-trash

2012-03-02 19:43:44 /Users/andrea/foo

2012-03-02 19:44:04 /Users/andrea/foo

$ restore-trash

0 2012-03-02 19:43:44 /Users/andrea/foo

1 2012-03-02 19:44:04 /Users/andrea/foo

What file to restore [0..1]:0

Thursday, March 8, 12

Generic Naming Issue

Thursday, March 8, 12

Comandi del pacchettotrash Butta un file

empty-trash Svuota tutto il cestino

list-trash Elenca il contenuto

restore-trash Recupera un file

Thursday, March 8, 12

Debian

Thursday, March 8, 12

Fedora

Thursday, March 8, 12

trashlist-trashrestore-trashempty-trash

Debian

FedoraQArejected

OK

Thursday, March 8, 12

Command name changes

trashlist-trashrestore-trashempty-trash

trash-puttrash-listtrash-restoretrash-empty

Thursday, March 8, 12

Risultato

Debian --> vecchi nomiUpstream --> nomi nuoviFedora --> Niente!!! (perdita di interesse dal package maintainer)

Thursday, March 8, 12

Using Bash for functional testing

Thursday, March 8, 12

shunit

Thursday, March 8, 12

Results

Very slow testsUnreadable failure messagesComplex fixture set upTwo test suites (bash+python)

Thursday, March 8, 12

Lessons LearnedTest di Integrazione? Ok, servono ma meglio che siano pochi.Test Funzionali? Meglio che siano omogenei con i test di unitàPer la bash non sono necessarie librerie/framework di test

Thursday, March 8, 12

Bash for Testing(1)

#!/bin/bashset  -­‐o  errexitset  -­‐o  nounset

Thursday, March 8, 12

Bash for Testing(2)

touch  footrash-­‐put  foo

#  foo  should  have  been  deletedtest  !  -­‐f  foo

Thursday, March 8, 12

Bash for Testing(3)

diff  <(trash-­‐list)  -­‐  <<  EXPECTED_RESULT2012-­‐03-­‐02  19:43:44  /Users/andrea/foo2012-­‐03-­‐02  19:44:04  /Users/andrea/fooEXPECTED_RESULT

Thursday, March 8, 12

License

Thursday, March 8, 12

GPL v2+

Thursday, March 8, 12

Lessons Learned

Thursday, March 8, 12

Lessons Learned (1)

Licenze già fatte sono comode ma vanno capite

Thursday, March 8, 12

Lessons Learned (2)

Il papiro all’inizio del file é una rottura

Thursday, March 8, 12

#!/usr/bin/python# list-trash: list trashed files## Copyright (C) 2007,2008 Andrea Francia Trivolzio(PV) Italy## This program is free software; you can redistribute it and/or# modify it under the terms of the GNU General Public License# as published by the Free Software Foundation; either version 2# of the License, or (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implied warranty of# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the# GNU General Public License for more details.## You should have received a copy of the GNU General Public License# along with this program; if not, write to the Free Software# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA # 02110-1301, USA.

from libtrash import TrashDirectory

for trashed_file in TrashDirectory.trashed_files() :    print "%s %s" % (trashed_file.deletion_date, trashed_file.path)

Papiro della GPL

Thursday, March 8, 12

Lessons learned (3)

A volte conviene usare licenze più semplici

Thursday, March 8, 12

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE                     Version 2, December 2004

 Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

 Everyone is permitted to copy and distribute verbatim or modified  copies of this license document, and changing it is allowed as long  as the name is changed.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE    TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE FUCK YOU WANT TO.

http://sam.zoy.org/wtfpl/

Thursday, March 8, 12

Code Hosting Services

Thursday, March 8, 12

sourceforge.net

Thursday, March 8, 12

Lessons LearnedAutomatable release supportFeedback barrierSi può sempre cambiare

sf.netbitbucket

google code GitHub ?

Thursday, March 8, 12

Internals: TrashDir

Thursday, March 8, 12

KDE Gnome

cli XFCE

TrashDir

Thursday, March 8, 12

How it works

~/.local/share/Trash/                        +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+        info/                                    ,-­‐-­‐-­‐-­‐-­‐|  [Trash  Info]                                        |                pippo.txt.trashinfo            |  Path=/tmp/pippo.txt                          |        files/                                              |  DeletionDate=2012-­‐02-­‐29T00:13:54|                pippo.txt                                +-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐+                                  `.                                      `-­‐  original  file  moved  here

$  trash-­‐put  pippo.txt

Thursday, March 8, 12

How it works

~/.local/share/Trash/          info/                                                    pippo.txt.trashinfo                pippo_1.txt.trashinfo                pippo_2.txt.trashinfo                pippo_3.txt.trashinfo        files/                                                  pippo.txt                                    pippo_1.txt                                    pippo_2.txt                                    pippo_3.txt                    

$  touch  pippo.txt;  trash-­‐put  pippo.txt          #  again$  touch  pippo.txt;  trash-­‐put  pippo.txt          #  again$  touch  pippo.txt;  trash-­‐put  pippo.txt          #  again

Thursday, March 8, 12

KDE Gnome

cliXFCE

TrashDir

Thursday, March 8, 12

Thursday, March 8, 12

pippo.txtpippo.txt

Thursday, March 8, 12

open(3)#include  <sys/stat.h>                                                                #include  <fcntl.h>                                                                                                                                                                                int  open(const  char  *path,  int  oflag,  ...  );                                                                                    ^                                                                    O_EXCL  |  O_CREAT  -­‐’  

Thursday, March 8, 12

os.openimport  os

fd  =  os.open(dest,  os.O_RDWR    |                                        os.O_CREAT  |                                      os.O_EXCL,  0600)                                                                        os.write(fd,  content)os.close(fd)logger.trashinfo_created_as(dest)

return  (dest,  trash_id)

Thursday, March 8, 12

Conclusioni

Thursday, March 8, 12

Lezioni miste (1)

Utenti: va bene ascoltarli ma la vision la devi avere tu (WONTFIX, parallelo)Promozione per distro: Non vale la pena se poi non lo aggiornano

Thursday, March 8, 12

Lezioni miste (2)

Code Review? Utilissime, basta chiedere in lista.Occhio alle librerie e ai framework (OptionParser, Unipath)

Thursday, March 8, 12

Lezioni miste (3)

Tempo a disposizione? Peggio che al lavoro!

Alta coesione e basso accoppiamento e test veloci sono indispensabili

Thursday, March 8, 12

Lezioni miste (4)È vero che Git sembra più complicato di Subversion?Però

è più facile integrare le patch degli altri meno conflitti inesistenticommit localinon si incasina se sposti una directorycapisce da solo se hai rinominato un file

Thursday, March 8, 12

Lezioni miste (5)

Collaboration tools (wiki, blog , mailing-list)➡Cominciano ad essere usati solo dopo

quando c’e’ veramente tanto interesse➡Si può aspettare a farli.

Thursday, March 8, 12

Branches

Thursday, March 8, 12

Lezione più grande

Thursday, March 8, 12

Come lo farei ora?Beer/Pizza LicenseGitGitHubOutside In TDDNo Wiki, solo .txt tra i sorgentiNessun push promozionale

Thursday, March 8, 12

GrazieAndrea Francia

http://andreafrancia.itandrea@andreafrancia.it

Libero da settembre 2012

Thursday, March 8, 12

Altre cose

Thursday, March 8, 12

Altro

Singleton LoggerTroppa docs sulla wiki

Thursday, March 8, 12