AV-Portal 3.23.3 (4dfb8a34932102951b25870966c61d06d6b97156)

Nothing is Something

Video in TIB AV-Portal: Nothing is Something

Formal Metadata

Nothing is Something
Title of Series
Part Number
Number of Parts
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this license.
Release Date

Content Metadata

Subject Area
Our code is full of hidden assumptions, things that seem like nothing, secrets that we did not name and thus cannot see. These secrets represent missing concepts and this talk shows you how to expose those concepts with code that is easy to understand, change and extend. Being explicit about hidden ideas makes your code simpler, your apps clearer and your life better. Even very small ideas matter. Everything, even nothing, is something.
Slide rule Code State of matter Multiplication sign Electronic mailing list Set (mathematics) Mereology 2 (number) Programmer (hardware) Goodness of fit Process (computing) Different (Kate Ryan album) Video game Quicksort Object (grammar) Pressure Social class
Slide rule Greatest element Electronic mailing list Bit Instance (computer science) Parameter (computer programming) Symbol table Number Message passing Different (Kate Ryan album) Object (grammar) Reading (process) Social class Spacetime
Boolean algebra Computer animation Multiplication sign Electronic mailing list Formal language
Code Block (periodic table) Expression Bit Measurement Power (physics) Formal language Type theory Word Message passing Computer animation Different (Kate Ryan album) Personal digital assistant Cuboid Right angle Ranking Procedural programming Object (grammar) Resultant Condition number
Implementation Message passing Computer animation Bit rate Block (periodic table) Code Right angle Instance (computer science) Social class
Arithmetic mean Message passing Computer animation Object-oriented programming Code State of matter Right angle Object (grammar) Social class Formal language
Integrated development environment Factory (trading post) Statement (computer science) Archaeological field survey Electronic mailing list Object (grammar) Condition number Social class
Point (geometry) Message passing Computer animation Personal digital assistant Code String (computer science) Core dump Right angle Object (grammar) Line (geometry) Form (programming) Condition number
Call centre Code String (computer science) Right angle Surgery Condition number
Message passing Arithmetic mean Computer animation Root Code Electronic mailing list Energy level Object (grammar) Social class
Computer animation Code Electronic mailing list Video game Right angle Pattern language Object (grammar) Student's t-test System call Resultant
Object (grammar) Condition number
Code Electronic mailing list Sheaf (mathematics) Sound effect Instance (computer science) Disk read-and-write head Mereology System call Message passing Computer animation Logic Atomic number Right angle Pattern language Object (grammar) Abstraction Task (computing) Condition number
Length Code Multiplication sign Moment (mathematics) Bit Line (geometry) Parameter (computer programming) Cartesian coordinate system Number Frequency Computer animation Term (mathematics) Personal digital assistant String (computer science) Order (biology) Website output Freeware Abstraction Spacetime Social class
Implementation Inheritance (object-oriented programming) Code Multiplication sign Equaliser (mathematics) Variance Bit Attribute grammar Revision control Arithmetic mean Process (computing) Computer animation Personal digital assistant Right angle Table (information) Resultant Condition number
Pairwise comparison Dependent and independent variables Arm Inheritance (object-oriented programming) Code Sound effect Bit Function (mathematics) Mereology Number Connected space Message passing Mathematics Computer animation Network topology Statement (computer science) Right angle Endliche Modelltheorie Task (computing) God Row (database)
Slide rule Computer animation Code Right angle Quicksort Endliche Modelltheorie Mereology Form (programming)
Axiom of choice Area Inheritance (object-oriented programming) Code Surface Program slicing Content (media) Mathematical analysis Right angle FLOPS Object (grammar) Writing
Computer animation Code Right angle Computer font
Greatest element Mathematics Computer animation Transformation (genetics) Paradox
Email Algorithm Digital electronics Water vapor Instance (computer science) Student's t-test Spreadsheet Computer animation Personal digital assistant Order (biology) Right angle Row (database) Social class
Dependent and independent variables Implementation Parameter (computer programming) Theory Computer animation Semiconductor memory Order (biology) Right angle Object (grammar) Ranking Metropolitan area network Tunis Spacetime
Gateway (telecommunications) Injektivität Randomization Computer animation Causality Semiconductor memory File format Execution unit Set (mathematics) Bit Game theory Mereology
Injektivität Arithmetic mean Word File format Multiplication sign Order (biology) Sound effect Video game console Social class
Arithmetic mean Scaling (geometry) Computer animation Code Logic Right angle Pattern language Object (grammar) Abstraction Social class
Boolean algebra Polymorphism (materials science) Mobile app Code Multiplication sign Shared memory Sheaf (mathematics) Cartesian coordinate system Rule of inference Symbol table Number Word Message passing Computer animation Term (mathematics) Right angle Object (grammar) Abstraction Spacetime Condition number
Computer animation Website Library (computing)
and in and in in the name of the list and I think if you can and saying that I am as a programmer for 35 years on women's 1 of a certain age I I really am I wrote a book a couple years ago we came out it was like a bomb went off in my life an adequate my day job was so busy doing other things in because they collide in Germany away make a living and people kept asking the teach so I finally broke down and agreed to teach to teach short object or design classes and so then I make a curriculum without scored curriculum is tough and so I sat down and I have figured out what I thought were the most important set of lessons I could teach in 3 really intense state and when I did that when I made the curriculum I thought that they were all really but they completely unrelated lessons good things yes but not the same thing and then I have been teaching the course for the last year and a half and I finally realized after since now actually now my job is to think about what a wonderful thing in this sort of advanced stage in my career I'm not driven by that deadline pressures everyday I really get to reflect about what makes code good and how we can make good code and how to explain to people what what how to do that and so in the process of making this course of time over the again and I've got up leisure to reflect deeply about code and I finally realized 18 months later that it was really teaching a bunch of different ideas that I was really teaching 1 idea 1 simple idea and I fully understand In so today's talk is everything I've learned in the last year and a half in 30 minutes and that its skin involve a lot of slides I I I calculate by my making slides better before seconds once we get them if you want to change seats now it's not too late to move over to the sides but if you're here at a given 1 they that's all I can tell so and this sudden 4 parts it's going to
build up from the bottom of this 1st part after through was published and became really clear to me that it was surprising to me to find that I had a different idea about objects then maybe the people in our communities and I was curious about why that was and when I thought about it I realized it was because I decided it was because I'm infected by small talk I Billing really since 2005 and I have not yet written really for as many years as I wrote called now I say infected it's funny on the slide there really
I think of myself as inoculum by small talk on this show you just 1 small thing about small talk today that will make it more clear how I think about objects here's the thing that's all that we really care it's that they might not be familiar with this right there's a standard method you really don't let that since the symbol evokes the method meaning the someone does the same thing we also have this you may be surprised to see that if use this and that's the same thing never what is 1 to 1 is 6 and in with 6 numbers they know this among other things this list and you can see on this list give we have that know what this means that really is that this is what's really this is a truth at the bottom of all things with Senator message to an object that when the same 1 space plus space 1 that is a special syntactic sugar put a message sent that's unique this is normal that special this is real on and this is this year so they look like that right middle and they want to apply that to make it easy because really strongly that way now you notice on this list we also see that then I don't have to tell you now I hope I don't have to convince you that I'm sending equal equal to 1 in passing 1 is an argument when I do that I get back to this now what is that well it's the it's the singleton instance of this class and what is a class known as these things as in our community to believe the useful I break true true and false and really a little bit more nuanced than this but let's pretend just for the sake of this talk that chooses an object from a dealer bison messages and that be behave that way and I wasn't surprised by this when I came to review right through churches in mountains is an instance to a class instances as I talked to the tumbling to work I was quite surprised by that idea when I came to really from small talk but I was extremely surprised by another thing about reading and it was that really had a
special syntax for doing this stock was very confusing to me you know that you know language that there was a special syntax for this this is a list of the keywords in smallpox In many no matter how many times you counted them there will still be 6 thank you to review and if you look
at that list you'll notice among other things on this this is special syntax for dealing with Booleans now this is so on question in most of our minds at that that the explanation of it to give you is going sound really weird here's how you
use that special syntax right there's an expression that gets evaluated and based on the results of that expression and 1 of the blocks 1 of the following boxes giving it a value if it were if it evaluates to true I'm going to evaluate the what is before the word else and if it evaluates to false and then evaluate the walk that is how to read the word and its so this is really truly saying this right but really it's actually a little bit more complicated and because we true the rank it's true the a down there it by with the code it before they also block of code before they also the measurement of a with the block occurred after the house this is a type checker and we'll do type checks and low right we hate this idea I don't really care what we have this syntax I just wanna say a message to an
object end of it I don't have to look at the kind of thing it is and make a decision and choose between 2 different kinds of behavior if you came to Ruby and 0 0 from procedural language like most of us did it's probably seen normal and reasonable to write long condition to start with the 4 case or whatever but I can promise you that the very presence of this key word in our language makes it easy to retain that procedural mind-set and take it teach you from worrying and taking advantage of the power of objects and to show you how unnecessary this keyword is let's just change to have small talk like syntax for dealing with conditions message sending syntax here we go version after
break up into a class because this I'm sure be fine I Sampling API API is these 2 messages on ideology if true if false so in true class the if true that noun taking advantage of the fact that all these methods take implicit walk the if true method in true class is getting you into the block now return self-testing now will be clear later what did the it's false method of fossils implementation to class does not it does not use to block and so if you want you see that you can pretty much guess what has to go and false class it's just the opposite right TrueSkill you only have to method also give yielding a false and so if you break the classes open and make this MultiPatch you can write this code right if I had a true remember that if true doesn't yield so will evaluate block by saying that message to a true if BisoNets a message to false nothing happens and the antioxidants true when dealing with false rate I send it to to an instance of Phocis Northern blot but and if I send if false to an instance of false can evaluate the still easy that's how it works now it is it's not quite right because we really need to
the falsity and that's so he did much to
promote the subconscious but I cannot duplicate this code no class right I that if you like this code which by the way this seamlessly swiped from you think you here now I can do anything and everything is true and nail and false or false takes you don't need this special syntax I can now replace this with that and you can see here this is why they himself so they can be chained together and I can replace this with that it doesn't mean we do not need a special syntax in an object-oriented language to deal with poorly and we can just send messages to objects we can do the normal thing now having shown this I'm not
suggesting that we do it not don't we get I cannot happen but what I want it is only to think about what it would mean to you how would you think about object if there were no if state what would it mean to you about in your conception of how to write object-oriented code the fact that I was trained in 0 0 why language that did
not have an if statement made me elite irrevocably an unknown unrepentantly unrepentingly sorry and and the condition of the 1st I hear and I just saying I I grew up without
mean here's a condition I really hate we can all classes a factory method find it takes an IDE their returns an object if you pass an idea that it doesn't know it gives you that no if you happen to get an array perhaps you know what you're in the survey did this array of a column of finally objects you get back to this list and you start talking to them cut will remain and so
before I go on I wanted seeded sometimes no is nothing in mill is nothing if you do
not care about that no right here you can do this in front of latent compact the array and when you talk to the object it all works however if you're sitting in
a message you know something and what we have to do is we want fix it
here so that the doesn't blow up what women know becomes now often what happens at this point in our code is that we put a condition right we had this condition we do so this is the most verbose form of it right this is a case where I wanna say no animal when there's no this is like saying guess when there's no user logged in this is that exact situation so in this case now they all respond right I I get the right was that the price for talk to me about the course for any a that we too ugly to operate in a certain astray true feed the truthiness to make that a pretty years a line of code and of course it means I've lost my ability to provide a facility that string but it does work it is not a lot of course if you're rails manner we get to i you know that I am not saying that he's trying strong myself but let's be honest about what's going on here this is really that which is your best which is really that and that if you write it all out looks like this and that K to be more scores I want that and that is is and that's what I was complaining about violence I find that it's even worse so this is a general case right and stuff continues another here is actually worse because what we're saying is if I know what tight URI supply here otherwise I'll send a message this is absolutely terrible the core problem here is because the conditions always
get worse conditions reproduce if
use but that string no in 1 your code where you're going to have is this
here and it's getting all over in the data cited change that
value you can end up doing a thing they call shotgun surgery right it's everywhere so I am I hate these conditions are extremely condition of
what I am instead this message center I wanna know these
things I just wanna send a message to an object I wanna since this message another problem here the root of the problem is that sometimes I get this object back it knows means but then sometimes I get that other object back and it does not that the objects on the list they could return to the conform to different AP on what I need down here is someone something to which I can the main message and get back the value knowing animal and so let's write the code we wish we had if only I had something like that if I had that object OK I would
prefer this is the 1st really high level idea I would prefer to know about the name of a class you know an object then I would then know than to duplicate their behavior everywhere and so if I if I can create that
object here's where here's how it using you barbarian in right there and if you do that will change this list so that everything on to understand how to respond to this improve the code well I just added Pepsi Boston it's still out conditional that's the rights life economic and it's still there but something is better it's this I no longer own behaviors and that means all the student here can disappear I could do that and now thankfully I can also do this thanks I can just talk to the object I that back in the results are correct everything now works now this thing this idea these objects this concept has any it is called the null object
pattern famous patent rights to describe that's us some guy named Bruce B. Anderson may have a beautiful town 40 call that the active
nothing the active nothing is an evil I'd love that and so if we did this
nice and like I consider that we added a dependency we had that condition but once you hear well it's I told you before but I would prefer to
know an object rather than do the behavior but it is also to the quality I don't wanna know very
many objects but once we hear nicely that behavior in an object by
itself what's here OK yes I
can see that we're doing that right but it's really
is in effect because you can take that untrustworthy actually PR you can wrap in your own object you can catch that message in forward on you can put the condition right there in that 1 place and in all places in your code where you have to do this beginning of this call your own trustworthy PI when you do that you get this was that you can talk to everyone like the same thing in the list just works this is also it's the null object pattern makes a dramatic improvement in the code and if this if that's the only thing you can take away from talk by the 5 million in the next section of atoms and I will right if you can take this home in using it will improve your head but the thing I have learned in the last 18 months is the logic pattern is a small concrete instance of a much larger abstraction it is an example of a really simple idea that's very very large and so this section part for this task which is
approximately the length of everything seen so far as can explain that next abstraction In order to do that in order to go here I might have
to switch examples the House agenda right this is a tale kids 1 it's cumulative so there's bits and we get a new bit every time you stick in front of the bits that are there i has 12 different bits so every line gets longer and longer eventually you get to this if I ask you to write the Ruby code to produce this table in such a way that you did not duplicate any of the strings you would probably do something like this you take all of its input in an array means that method for have some kind of free easy method now you may not you play from over the last on array like a case unless you read last that it takes an argument you can get the last a number of things out of an the way so in this case by past 3 to last 2 data I would get directed at the moment when hostage at back and that phrase method also died terms that back into a string by joining spaces but my waiting to put that this is the front in the period T and so if I have some kind of line thing that takes a number and then it also calls phrase to get better of i wanna recite the whole tale internal wines and have to move as many times I have bits call line for each 1 and put a new annotated up the whole thing in class if I write code I can do this line 1 is going to be that we to use this line 3 is that when you told me that I can do the whole thing the site I'm still let's imagine you've right this is value in application and has whatever for reason for a reason they battery this big loving for having done you get quickly it totally works and course
now they want something new thank the they you were they want to ask why were not she went getting rid of house were adding a new feature a new kind of have and this is called Random House yeah suspect they
want to take this this array of bits and 1 time before we start producing analyzing shaking up it a randomized magnets in this case in this 1 random version of different every time it in this case it is with the rapid them a novel notes capture and and so this the tail of the random version of it would be this is that it is made of wood not a the saccadic killing off on that date and the whole thing really this and you I suspect from your laughter variance in the variants of this seemingly innocent tail are not safe for work I serve while I can say is is an equal opportunity offender so subpart suffered from here so so if you were so here's your job right you cannot break out and I want you to do I want you to implement Random House without using any conditions FIL conditions can use condition the so you probably thinking parents and indicated here is this really attractive attribute is totally works watch great surprise house over a data shuffle is a method or a that minimizes it I mean I have to catch the result because I when shuffled wants an impermissible table if you write this code might be totally Random House works right wrapped a mean of learning can the killed in there somewhere that piece is in this case markers I so that took about 2 minutes to write right and so and they think your a total genes and so what is the next thing I have right they want something
else of course right incredibly successful they want now we want something of a collapse historical
outsourced every bit the bits duplicate the physical and so it's got this echo effect this is of course a jet eject the model and we have to check the record that the more it says we want echo house now I will introduce like refactoring before we go on here really high that's a bit I need a change I have this method this got 1 responsibility which makes it harder reaching here and change just 1 thing so before before I from another a house and a tiny bit refactoring right arm isolate that adjusts pretty darn 0 my god parts meaning is so hard so called parts and that's and message personal care about phrasing set if I could cheat right now this method returns as the numbers 3 this is the a ragged back the at house would work if I could somehow changes so that I got that instead back in as I said before your task is to do echo house but you may not use if statements would you need it we know the trees go by its failure to invite thinking and tell you do what we all know how we do right we're already going on in here it turns out it is incredibly you solve this problem or inheritance I'm an override house and I'm in someplace else over parts out of about that a 2nd thanks a super if numbers 3 Super gets this by called super twice z is not we think zippers is not compressed it's zipper right so it does this a pairwise connection of those 2 arrays in although it is not necessary to find I can't stop myself from doing it His patents physically a one-dimensional or you could be forgiven if you make the other I would certainly forgive me if you so that code if I were to write that at the house totally works right it took me about 3 minutes and my our customers think I'm a genius it is also this is why inheritance is so seductive
right so there's we have house in Random House the Reds data idea has the right parts and I was going to make of your chance yeah I
I mean America is
actually the housing market that's really not the problem and so we do you're screwed and don't tell me do not insisting that models is the solution to this problem it's not an animal more slides to debris go right echoed right it is you can do dry have the code that it is not the real solutions from is just another form here's here's what you know the inherent path I want to sort of cross-pollination of 2 subclasses very have I'm just stop that we're not using multiple here and here is not the right solution for this for I think I can offer an outsider here data depict parts or I can flip flopping here parts indicated right now both of those
choices are so obviously wrong there so obviously misleading that when I go places and I see people encounter this problem very often they choose neither 1 we do not to duplicate some of the code what they did do is they choose to do OK all i sympathetic to the contention that that is more correct writing this over copy all them and there is a way in which that is more honest than putting it on 1 side or the other and k so this is all it seems so good and is gone terribly wrong now I try your
picture I think they will help illustrate exactly what's going on here so this is the surface area house this is not your analysis of pleasing right it feels like Random House's that being an echo houses that big but really the truth here is it ran out of that it contains everything else that it did not specialize our house at is that it it doesn't really matter witnessed throw pass away where we have objects of this size this surface and if you come over here and you try to inherit from that you get these things you cannot get the Paul that will affect you cannot get in if you flip flop at yeah wait for it pop slice it doesn't work it really if you if you if you think OK what I want is multiple inheritance is not the solution is found we do not want multiple inheritance is not what's going on here if you go down in here inspectors it seems easy don't by going further down that path right there is a better idea here at no not that I
get the proper the font the worst for this is inherent for specialization is not for sharing co is not for sure encodes a
specialization of where this bargain at some or is great that's a relationship ran out of the house if I were ask you to is RAM house-to-house the we had that's a house wren house is courses answering so we fool ourselves because that means we chose these are incredibly important they can be incredibly misleading right was what what
instead of saying that trapped barbarian wants to this what changed it's really hard to glance at that code and answer that question right now it's going to be the next
improved this is a paradox you can reveal how things are different by making them more like let's do that with this
phenomena make that method is much like this method is like we create money because the methods is indelible as I can use acted in that or just put that of the actual rate constant on employment data and despite to return it so if I'm looking at the thing and I can't I can't keep on doing transformations like I could put that there it's not necessary that would work right and I could take the super out of the bottom we replace the all that's still will become appear here on a concert piano consum it's much easier to see what change with the fear what that thing is
given in the and I was I was looking at it into the
auditorium in the fall and he suggested that to the students to deal with this problem that we pretend it's rows and columns in a spreadsheet right and then like this and then label every column what is the header of the column let's class a circuit so it's called that data and the really interesting question here is what is this we call the subclass Random House but the need this is not a real like we know is an instance of whatever this thing years right what is it it's 1 case these guys your itinerary that's your problem to too much dread it's the that the thing that we're changing it's order right and so if water is that thing that this is not enough this is a algorithm it's just as valid as any other and so now you know its name if you ask orders is a hassle
there's so coeval there is absolutely no borders of war and so it's right the oral here's 1 right a
made man mouse and the API order all the of had to take an argument that the rabies can shuffle yeah with the implementation here yeah to now it's real thank so far only use this and throws a subclass away that in that went badly wrong right and this goes around on of the battery for data any of you know it's and that's where the theory that space soldiers when removed the responsibility for ordering memory from house and do by using this war right some injecting tuning parameter am eject an order and to give that warmer and opportunity data In in its whatever it does whatever it does what houses get half it works so well I just as well I have more to do exactly the same thing and this is what people complain about object-oriented signed rank is a key thing further ahead so Alexis I got the cities that an our wanted to suggest that instead not just what and thank this composition right we're trying to inject an object of play the wall of the thing that varies how we you do have a house he
totally CD into this problem already right
and it's something to do this and I need another thing to play on another variant of this wall and if I have these these things I'm inject them right we love dependency injection and I put this cooking rejected it against because so they keep the format is the gateway game here cause I wanna intervene in the most narrow part possibly large memory but I put it there when I read this discovered 9 and so now again I have exactly the same behavior I had bullfighter in these 2 new object injected but I can also adjust the other and knowing that so I defined 2 roles in each have 2 players and so it was Soviet went overseas recite the whole thing so here's a set of things I can vary I can get house I Random House I can get at the house liking get random at the house and we have not we no longer have what we've actually Lester and there's not 1 bit of duplication here we made these units of pluggable behavior
before it was inherent to look like this but really what we want if there's a specialization there's by definition there is never just 1 specialization that the new thing is 1 thing but the only thing your specializes something even if it looks like nothing ceived isolate the thing that varies yet to figure out what it is that means a whole in house for you have to plug that stuff back in the day to figure out what its meaning is here we call the word format used to define that we made ATP ice for the order and formatter and then later at 1 time somebody is again inject the place for you so I love it it is really 1 of the few consolations making talks keynote effects so this is composition class
dependency injection and this is what it means to do object-oriented design these
techniques let you find the underlying abstraction getting that extraction right is going to dramatically improve your
code if you talk to all it's something user logic pattern you're done check infidel OK stopping right now make objects this standing in for those nails in uses active nothing the next thing we're here it's easy to begin with you know ammunition isn't a star but it will be it's a nice filtering your he especially if the amount of the amount of company specializes small proportion of the class is a subclass being very careful if you use it and the race which the composition it's not for sharing behaviors the big the next the bigger ideas we move out and scale there's there's no such thing as 1 specialization you when you see all that you have a variant it means that you have to you have to isolate the thing that varies mean that concept the final and inject the players we had started
0 when you 1st sorry I was really easy to see that real things can be modeled as objects right that share the same but that the sharia in the person beside and he did take long when she started writing code to figure out that more abstract things could be modeled usually right business rules ideas concepts processes it back to the beginning this talk started with sections and Booleans and you might not have really thought were so used to those ideas that you don't really think of them as being abstractions that they're not real you cannot reach out and pick up a 6 true right but it inside my app at 6 and the true or real was the she now the unknown words are amazing abstraction but then but there's a there's a way than the abstraction of which doubles up and that's where 0 right z we have 0 for a really long time 0 represented nothing and before we had the idea of 0 so there were things we couldn't do and after we had the idea of 0 it became that concept became a a polymorphic in our terms right we can use numbers in new ways to once we discovered that the nothing in the number set could be represented by the symbol 0 the to your applications or full of things like you but there are concepts that are that are abstractions that reveal their presence by the the absence of CO I wanna write condition i just within a message to an object if you wanna do 0 that we have to find those objects and the hidden in the spaces between the winding code this seemed like nothing but they aren't they're actually something always it's true that there's something because something nothing is
always something thank you and see
next and on
and on and on and on and on the other from the data but there I'm
teaching and library teach public cost them either within which is present in the US and will my website you when you high cost and
stickers were leaving the right at that that think unions given by related and that some