PHP UK Conference 2013

Integración continua en el mundo real

Elizabeth Tucker Long  · 

Presentación

PDF (pincha para descargar)

Vídeo

Transcripción

Extracto de la transcripción automática del vídeo realizada por YouTube.

so Who am I I am Beth Tucker Leung I am III Beth T on Twitter you can find me there I'm the editor in chief of PHP architect magazine if you've ever thought about writing for the magazine or if you've never heard of the magazine you should come

and talk to me because I would love to help you get started with the technical writing or introduce you to the magazine with some free issues I also teach PHP courses and I'm a freelance consultant and I'm crazy nervous right now because I didn't

know I was speaking until about five minutes ago so bear with me so audience participation I will stare here awkwardly at you until someone answers so do us all a favor and pipe up right away so what is continuous integration continuous integration when I

first started learning about it was something I heard about with gigantic corporations with 300 developers spread all over the world and they were using continuous integration so I thought oh well I'm a freelance consultant it's just me usually I don't

need to learn about that but later on I realized oh my gosh it's amazing it's awesome and there's a lot of things that I can use as well so let's start out with what exactly is it now the obligatory Wikipedia quote so continuous integration

is a very technical thing it's a theory of development and so what you try to do is you're trying to improve the quality of software by replacing the traditional practice of applying quality control after completing all development so what we want

to do is take our old way of doing things and replace it so that definition was only mildly helpful so I kept looking and I came across Martin Fowler who has been talking about continuous integration for about ten years now and he has a lot of great resources

and I do have my slides posted online as well so that's why I have a lot of links in these slides it's not so you have to try to write them all down now it's so you can look at them later if you'd like but Martin has some great articles about

continuous integration and how to implement it and he defiance continuous integration with having a team integrate work frequently usually multiple integrations per day automating the build including testing and we want to integrate and test and detect errors

and fix them as quickly as possible so it's trying to speed up and make things more efficient so taking a look at this when I first started was okay the first step is you have to integrate your work frequently okay that's not too hard of a change I

can do that in my development that's not something just for big corporations so I can start integrating more frequently but then the second step in his definition was automating the build and detecting errors and things as quickly as possible in an automated

fashion now as a freelance consultant nothing that I did was automated I did everything myself all by hand and obviously that's not as efficient so what we want to do is figure out how to automate the process now before I could start automating the process

I needed to take a look at my code quality so writing quality code makes it easier to test and ultimately easier to code now how many of you have taken a look at code you wrote two years ago or maybe even two weeks ago and you're really embarrassed and

you don't ever want anyone to see that code okay all right so having a coding standard can improve your code quality but it also makes it easier to share your code because now your code follows a specific standard it's very clean it's easy to read

and it's easier for other people to read so I took a look at some coding standards and I looked at pair and pair two and there's also a PHP standards working group if you want more information about standards that are out there and so I picked a standard

now if you're working on a project with a team you should all pick the same standard but as a freelance consultant I usually work by myself so I just picked a pair because it was most closely related to what I was already doing now the pair coding standard

is pretty expansive and it's very picky which is really really painful at first so getting started with the coding standard is very painful I won't lie but as you get used to it it becomes second-nature and becomes so much easier to do so what kind

of things are in a coding standard well in the pair coding standard they have things like indenting for spaces okay that might seem like a nitpicky little thing but having consistent indenting throughout everything makes it a lot easier to read and follow

it has different things like your control structures so you have if and then there's a space and then your parentheses for the condition and so there's a space between the if in the parentheses which is not something that PHP requires but what it does

is it makes it really easy to scan through the code and see which one's our control structures and which ones are function names because there won't be a space with a function so it does make it easier to read in the long run so like I said a lot of

nitpicky little things now if you don't like the standards that are out there or if your team has to do something that doesn't fit into one of the standards that are out there you can build your own custom standard it's very difficult to make it

broad enough but still strict enough to cover everything and you want it to be flexible enough that it's not making people it's not making it harder for people to develop you want it to be easier for people to develop so make sure your standard is

strict but flexible and what you can do too is base it on one of the existing standards and you can just customize the pieces that you need so once you're using your standard there's a tool called code sniffer our PHP code sniffer a part of me that

can help tell if you are following your standard or not so what this does is it goes through scans your code and then gives you a readout of all of these things that you're missing or that you've done incorrectly on PHP code sniffer does allow you

to use a custom standard as well so you can customize it even to match your custom standard if you build your own so it's going to give you some output that looks like this so you can see I ran it on a file and with code sniffer you can run it on a single

file or an entire directory all at once so very flexible on how you run it and here you can see we're missing the file comment PHP keywords must be lower click lower case expected false but found false so it does give you a lot of information about what's

wrong what you need to change and where to find it so when you first start running this you'll probably end up with a really long report but as you get used to the standard these reports become smaller and smaller okay so now we have our code quality and

[ ... ]

Nota: se han omitido las otras 3.404 palabras de la transcripción completa para cumplir con las normas de «uso razonable» de YouTube.