Bestand wählen

Tricks and treats for new developers

Zitierlink des Filmsegments
Embed Code

Automatisierte Medienanalyse

Erkannte Entitäten
2 and human and welcome my name is David uh by me on the
Internet as down we're giving up they were for a company called me to line up like to drink the if you've never had 1 which lies in great drink that as Mexicans slot drink all the time it's made
with eyes a clam juice uh medical Mexicans solves uh chili powder assault line and of course beer the an isolationist you should
get 1 if you've never had by the way and the name of my dog is tips and tricks for new developers and until you will uh and then Miller Bill context
systolic uh when I decided to give this talk so lump them go galaxy far far away 2009 the
Las Vegas my 1st it was
great rails down and back then I
was building uh I just move onto rails had my 1st job I was being paid to write my 1st trails up and I was building a huge e-commerce platform but knew nothing about you know the real stuff like while once once you're past like the tutorial face of rails like what happens next right and I remember that there were several talks at his rose at this particular rose count that sort of change my view by in and help me a lot of things like that and solving the riddle of search using Sphinx would rails like it made me figure out that it might not be a good idea to fill the my products which sequel or do searches we'd like you know like searches so I learned that there was this thing that you could use to search we ended up using solar by the way that saints but anyway I sort of learn something I learn about Web rat you probably don't remember where red but it was what we used to test applications before a capybara and all these fancy new stuff that we have but I learned about it and then the most important 1 or 1 of the most important ones is uh I learned about it I was using as the and before that and diesel source safe before that is half half so I learned about yeah and and he was uh I think it's 1 of my the best oxide I've ever heard of it started with
did in 60 seconds I remember clearly and the speakers sat there
just basically read that in less than 60 seconds it was amazing a half and then he proceeded to do the proper top right the and i important thing that I learned that braille scarf is how to put like what was uh I to do you want to have my application I learned that there was this thing called mongrel but it's it was a web server I remember mongrel course but I learned that I had to you know set up in different ports you have a process among the crosses the start of each of 4 uh and and then you had and some top or Apache on top of it that's a a flight with the proxy around and then if you want to scale well you scale that that just added more servers n h a proxy to do an the Europe that the proxying and you will be fine and you need more more power to just added another 1 of those and that was back then in 2009 the proponents of this new fancy that the stuff that we have so and I remember status right so I think that we still need talks for beginners at rest we do need to know how to do like Michael services and how to handle a gazillion of requests per 2nd and all that but we need talks for the beginner so people can come here and learns stuff that they don't even know they need to know right so what this stock
is for beginners and most of the thing that you learn here maybe you already know it maybe maybe not but I do want you that the stock is for beginners and it's just the based on my experience of what I do when I start a new Rails application uh like the things that I always use things I usually do and all that so I hope it helps the user had to remove a bunch of stuff but this is the most important things that think of
it we were for user let's again personal
Osogbo configuration facts I want to start a new projects right you
your rails new and commands
the 1st thing that you want to do well it's gonna do don't like your bundles of it's gonna go before after all but the 1st thing that you want do uh a I considered as a courtesy to developers this please
copy here database file Indian example file and then ignored original 1 so we can always have on hand a configuration file that we can base on it's awful to go into a new project and then you know start derail severed you have no database general file and then you realize there's nothing you have to go google base there than other it's just time-consuming so please keep an example file of your database file it's it's it's it's gonna pay out in the future and do so for any other configuration file that you think about that it's needed for uh the prior to run please create sample files and copy them and just ignore improve that you know the real ones from from getting the right and what will talking about configuration files did you know that you can have as many as you want and you can separated those in different files like for example if you have a payments uh Jamil file and then you can just call it from the application like this use convict for and just send the the name of the file s a 7 and you will get to that particular configurations so you can you can use it to just the organiser configuration files and everyone will be happier when when when it's it's clear and you know exactly what kind of information is on each of the file the and I remember that whatever it does a string or any integer on the cold that's comparing the something else you probably probably 1 of these constants the settings on 1 of those big fat so remember that if you if you
see code like this in your in your Rails application and try change to something like this is a constant for that 30 um and if you want to go like if you think it's gonna change constantly just move it all the way over to the configuration file you're gonna be very happy that you did this when your boss comes they I to change that to 10 minutes and then if the mean of letters is considered like it changed 20 minutes this way you can do no where to change something just restored a server and you know you're done instead of like looking for that sitting in the cold that's not about the
database now this 1 you can't imagine on 8 years of being of over I've seen it a lot do not give
ignored the schema file police have been 2 teams where or as a joint applications with there's no schema file and then I have like what happened at and that there were too many conflicts with it so we just got rid of it I I had like but that's a point to so please do not ignored your schema file it's very poor that you always able to restore
your database stayed with either the the set up for the new set especially during you if you're new to the project you can just go there you know computer database run 1 of those and you're up and running to the stock coding so please please do not do not ignore that but it's very important that you find those conflicts and then talk to your fellow developers say a disk along and yeah me too so let's figure out right if there's a scenario of is a tricky 1 I
don't change your data in your database migrations this is I mean hard to achieve so I'm going to change a little bit that have to be careful when you change data endured database migrations we it is common you do something like that you had a column to 1 of the tables and you already have and and you decide that you wanna fill it with something may be based on the on the current data the jury have like here right where splitting the cold column into 2 columns so you knew something like the stride you add a new columns you go through all the companies use later and then get rid of the of the old calls the problem with this kind of gold 1st of all is that it's not future-proof
the it's not to prove because for example what happens if you in the future your
company model is now the organization model for example this migration 1 running and while migrations are not supposed to last that long they're just you know to each word and they help you to keep track of history of how the database of all your schema are which follows the 1 that's supposed to have like the the the real in a data structure the instructor and it's still nice to sort of you know trying to keep it as as coherent as possible the other problem that you might find with this kind of voters is that you
can get a you know have longer deployed times it's very very common that you are you know on development mode and you around migration brunch real fast but due for that that there's like 3 million companies in your data at its and now it's going through all them in production and you know it's doing all that and you can't like your databases in a weird state maybe there's more migrations are coming and the site is set can run without those migration so you're X that you're doing maintenance mode or whatever and your boss angry because it's aching along and you forgot about the tree million rows so I had to do that you're risking downtime basically the change the Gerd dating migrations and the other 1 so this goal for example this this is going to happen branch and I guarantee you did do forgot that maybe code is near labels up and haven't you know you're stuck with migration weird state in the database and everyone's yelling at you because you have to log into the server change that call real quick run immigrations again and in there so really it's a really bad idea to do this so 1 to fix it sequel over if you're gonna do it you're going to be careful but if you're going to do it you might be better off like this do your thing update you know use regular sequel to do your updates and get more on right this is faster of course because it's not a hiding true although all the objects in that instant dating anything so it's just updating whatever needs to be done if there's no it's not gonna blow up so that this is his way past a surprise thing you're gear changes in data at a sequel and preferred this it's gonna be it's gonna be um safer to do this with the best thing to do in my opinion is to use a gem like this rails of beta migrations there's a lot of dense that do the same thing but I think this is the best 1 because it works would rails 5 right way and is it this gen is going to give you a different set of freight tasks for Gerd beta migrations right so for example if you if you had this at the regular migration and want to happen Jan under any column and then do another and update go on on all although all the records in the table what you would do in this case is created a data migration you know said the author spent active and it will create M and a special migration is different for work and then in that language and you will have data changes right that you don't need them anymore and the regular migration and now would you deploy you will
run 1st year dated your database migrations that will change the structure and then would have different the rate uh that's you will are your data migration so it's a separate process and it makes everything clear and also keep track that keeps track of how how how data is changing using that the same like the timestamp that the data is migration is so this is this is way better and you don't wanna use a gem at least and maybe 1st make all immigration to change the structure and then at migrations later to change the data when let's
talk about background drops the it's a pretty useful visit use of background jobs on you have something in place like said he can rescue delay job they still use delay job couple months ago I the and what I notice is that it's a really bad idea to pass objects your methods
that go in the background there's so few things have been wrong but what I mean is this let's say you have a job class that has this perform method and you you probably want to do this right you have an ordinary user driven assigned to it where means that it's better if you do this just pass the ideas the then fine addenda objects on the job and just do whatever needs to be done the problem with using objects is that of they're usually converted into Jamil and they end up being like huge strings that if you're not carefully and the special characters in a in a description Fula something that it just makes everything will love and you would will not notice in this until you see all dealers coming up so it's very obvious use DAT it smaller to just you know passes uh an integer around inside a household whole object as general and it's it's just gonna do is gonna be better at the it doesn't matter in terms of performance because it's already on the background so the yes when to do it right and speaking of backward jobs
always when you start a new application always always deliver your e-mail later don't wait until you know your 1st SMTP of education happens and then make the check a lot because you were expecting to check out to send e-mail of the payment was completed was something that always when when to start you start thinking about the living during a
later always and the same rule applies for mailer uh is passing objects spread opacities and just bolimow were from from from the cold on the mailer right this way um even if you don't have anything in place right now to sort of uh the late the sending of the mailers so in the end you're just gonna need to add that the layman 13 years inside Cuba delay job you're active job just use the little later and that will be but use the figures don't use the optics for the same reasons as the the backward thank you we we this talk about
breast the this is um my favorite lesson for all new developers you have to be RESTful time
rest is like the core hole rail-thin NBC and everything that you're doing and it's simple or it is very simple to to sort of explain but it's hard to like actually and like actually implemented let me tell you I rest to me it means that in your controllers you only
have this actions nothing more action show would be indexed shown you create and it a very orderly no other action but is very common defining coal basis things like this right you have the products controller and then you have an action to deactivate the product and you know you create around and it is getting member whatever right this is what this is not RESTful when you think about RESTful you should think that for every request there's a something a resource that's changing so in this case when you're deactivating the product what's changing its the product state so the correct thing to do here is to create a product state controller and updating right this is more restful much more restful and for example you have if you have a shopping cart right instead of having an action to apply a coupon what's happening and you're creating a discount for a shopping cart discounts of create a controller for this count and you are creating it this is restful found this is very common if you have context you are you have a search so you create a search actions wrong that's going wrong you create the context search controller searches controller and then you have an action for that search this is restful right you have something that is changing because that's what RESTful is supposed to be um the so that the way to make sure that you're complying with this rule it's very easy just don't have controller actions that are not on that list it's always index show that new create update or delete that's it if you have an action that's named differently drunk right when I now at you Ruby gems that I
think must be on all of our products right find them useful uh I always add them so I hope this helps for you to this 1 you probably heard a lot the
rule book woke up it's gonna analyze your cold it's going to check its uh how it's written and it's tell you where you're doing things right and when you're doing things wrong the and it's automated so it's pretty cool instead of having someone gelling edges a cup like showing you their teacher than humans trust me a very common and excuse that I've heard about not using rule covering your product is because you're already you know you have a large application neural with uh it's been 2 years in development of United out is gonna be like 500 errors and you have the time to fix them that's OK would you can do it you can
add this as run it with this option of 2 outage and compare and it's going to create a year rural RoboCup to do that Jamil file that can include an exception for everything that it found so that way and you just added to you to as as a sort of an include file to your main broke a pile and that way and you have like a sort of a clean
slate at that point in time and then you are supposed to come back
later that's weights color a to do
file and remove all those exceptions and fix them that's what you're supposed to do probably won't but it's fine right at least at least from that moment like for example right right there it's green at least from that moment on if there's something like if you write bad really cold it's gonna tell you starting from there instead of trying having to pixel the like 500 or whatever you find I outage entropy goes also helps for new project so you can like pole configurations that you might use and like change the rules depending on your style for
example so there's there's 1 where um it confucian look up to how many columns how many characters GC per line I I usually have that 80 90 considered to 130 and there's people that says we have a large monitors like why do we need that the thing is that you know your vision is only like it's really narrow so it's very you if you have less characters to read at once receptor-like sort of nasty cold around so it it it looks better if you if you try to to remove the characters underlines that try that 1 on this 1 a style and accommodation usually move it to the to the main fire because 100 gonna write comments in my classes or methods or anything so I just get rid of who's no 1 has time for that right and this 1 I think it's important is this is the 1 I value the most of a broke up at the metrics met blank it forces you to make methods that are no longer that 10 lines it's hard to you know comply with this 1 but if you do your code will be sold much cleaner so much readable so trust me try this 1 I will allow you to go to 12 or Turkey lines that's fine but don't go over that but you know forcing your methods to be 10 statements and that's that helps you like clean up your code base it's good to go in and you know you're supposed to um try to abstract although although like the code into smaller methods and then passed those unit testing that Waco unique testing I so keeping this 1 is like really it's gonna make your code so much real will and so much better I mean and then if you if you wanna run this before you push called to Europe and to to get you can use a hook if you have a file and that the 8 slash hooks slash re push is going around room before uh it actually pushes the code to the repo and if it fails then the Bush will be canceled so that way you can just push of failed out at the fixes 1st fix the whatever often still have and then which and it's very useful for example us we have a a CA server that actually wants to look up at hand AREPO soft filled with comments that you know read like affix that group of things that that grow the because the bill fails when for cocktails so it's usual to push wait for a CI server failed why because you know you you um maybe you went over with with with the characters or 1 that you have to make a map that only fixes that death damn grew about this letter from it's like that's 1 r equals so had Deléglise adjusted to use a hook so you know you you run Andriluka before actually pushing if it doesn't fast and you what Bush and you can fix it and that presented the
annotates out this in our damn that I don't see often and I don't know why and but I love it annotates I would would thus is
let's say that you have a like a model of user uh we named username password active whatever so when you run annotate on rails project on all of the you do your migrations what it's going to do it's it's a it's gonna well annotate your models with
information about the database automatically based on their view of columns you just run at the beginning is gonna it's been at that information at the top of your classes and is going to do so for models test file unit test pilots and factories abuse so it may be that works as a reference we reference if you are working on a model about the content has instead of you know going to declare a source on chicken schema what that you just have it right there at the top of the model and you can see it real quick this very useful to have this and this annotations are handy and this 1 is very useful to give you use routs as an option it it will annotate your outside 5 so you don't have to rake routs everything you you need to and to figure out where my controllers should go you you will already have it any of Europe have very old like me and use the I as you're a text editor given attain that it has like contextual around complete so a basic out a complete only on what's open so you open your file and you have like out a complete those that patent so it's it's legal very useful but I don't know why people that use it so now you know that you said annotate for useful we bullets and
would be taxed the n plus 1 problem as it's
happening as you're developing it if you know what the n plus 1 problem as it's very common in rails but it's something
so it let's say you have a book method that belongs to offer has many comments and then you have the author that has you know namely whatever and then you have a common that builds a user belongs book and your index file looks like light sorry during the page looks like this right so when you go to this page the the controller usually looks
like this probably and then
and when you look at page your love file will look like this there's a bunch of where is going on I like tree queries and 4 queries per row and and you know it's it's is getting all the objects 1 by 1 because that's what you told braille's to do it doesn't know what else to do so this is called the N plus 1 problem is very common when you're devolving patients so use bullets and you configure it let's say for example what I'm doing here is what enabling it I wanted to show on the consul I wanted shown on the rails logs and the 2 at the folder when it happens is as you look at
page you will notice that there is a fluid that's a say you know you are probably better off if you include the alpha on the query or review included comments on the way and it's going to jail at you
from the from the consul to from from the from the rails lover right start the day you know you're doing something we're here the white fix it and another of Pangaea limit thinks so you
go to your controller use includes properly you nested um as needed and then when you load your page you will now have but you know that the queries for a breach of the of the classes you don't have like bunch of micro microporous so this is way and bullets you know we just tell you assume that you're developing that you're doing something not wrong but maybe we're then a this another similar jamming point I this
detecting memory leaks before it's too late I don't know if you work with rails applications that have a memory leaks you have a memory leak when your applications that growing like the 1 going to Gates in RAM and then you need to restart how actually that's the best way to fix memory leaks on Rails application gets set up monitor and if it goes Bassett threshold as restart the server done right because it's so hard to find memory leaks on the cold war on rails it's very very hot once it's there it's not gonna ever like you're stuck with it deal when we deal with basically that's that's a solution so only
when you have it on your on your code base and you it's it's uh some sort of middleware so you initialise set and it's going on at the bottom of your remarks like when you're developing but this information which is basically how much memory it's using and the a number of objects that you're instantiating in that request the so if you're developing something like this and you see that you have like five-hundred common objects instantiated something must be wrong there's something wrong going on and it's actually Dennis safe need to using production I would enable it all the time but in your of trying to figure out where the problem as I would enable it and then does let a lot of your requests and try to find where I'm instantiating a lot of objects so it's great is very useful for and not right on the very minute that
said that so that's all I have for you right now like I said I had to remove a bunch of them of like advice but this is like what I thought was most important and that's it thank you few Berlitz at
home are used what we
Deskriptive Statistik
Ordnung <Mathematik>
Befehl <Informatik>
Boolesche Algebra
Zeiger <Informatik>
Kontextbezogenes System
Dichte <Physik>
Dienst <Informatik>
Suite <Programmpaket>
Einheit <Mathematik>
Rechter Winkel
Tabelle <Informatik>
Objekt <Kategorie>
Verzweigendes Programm
Selbst organisierendes System
Klasse <Mathematik>
Content <Internet>
Patch <Software>
Open Source
Weg <Topologie>
Reelle Zahl
Migration <Informatik>
Inhalt <Mathematik>
Tabelle <Informatik>
Verzweigendes Programm
Tablet PC
Elektronische Publikation
Komplex <Algebra>
Offene Menge
Overhead <Kommunikationstechnik>
Faktor <Algebra>
Wort <Informatik>
Abstimmung <Frequenz>
Prozess <Physik>
Formale Sprache
Befehl <Informatik>
Kartesische Koordinaten
Fortsetzung <Mathematik>
Lokalität <Informatik>
Technische Optik
Regulärer Graph
Konsistenz <Informatik>
Prozess <Informatik>
Hook <Programmierung>
Total <Mathematik>
MIDI <Musikelektronik>
Maschinelles Sehen
Figurierte Zahl
Prozess <Informatik>
Konfiguration <Informatik>
Arithmetisches Mittel
Ganze Zahl
Automatische Indexierung
Projektive Ebene
Proxy Server
Web Site
Gewicht <Mathematik>
Kondition <Mathematik>
Physikalisches System
Ganze Zahl
Inverser Limes
Leistung <Physik>
Spiegelung <Mathematik>
Migration <Informatik>
Inverser Limes
Objekt <Kategorie>
Mapping <Computergraphik>
Tablet PC


Formale Metadaten

Titel Tricks and treats for new developers
Serientitel RailsConf 2017
Teil 54
Anzahl der Teile 86
Autor Padilla, David
Lizenz CC-Namensnennung - Weitergabe unter gleichen Bedingungen 3.0 Unported:
Sie dürfen das Werk bzw. den Inhalt zu jedem legalen und nicht-kommerziellen Zweck nutzen, verändern und in unveränderter oder veränderter Form vervielfältigen, verbreiten und öffentlich zugänglich machen, sofern Sie den Namen des Autors/Rechteinhabers in der von ihm festgelegten Weise nennen und das Werk bzw. diesen Inhalt auch in veränderter Form nur unter den Bedingungen dieser Lizenz weitergeben.
DOI 10.5446/31295
Herausgeber Confreaks, LLC
Erscheinungsjahr 2017
Sprache Englisch

Inhaltliche Metadaten

Fachgebiet Informatik
Abstract Are you ready to begin building applications with Ruby on Rails? It's very easy to follow a tutorial and learn how to build a blog in 15 minutes, but there's a lot more to it in real life when you try to code a big web app. During this talk I will give you a bunch of tips and tricks for Rails development that almost everyone follows but rarely anyone talks about. If you are about to join this fantastic community, this talk is for you.

Ähnliche Filme