prime sub sandwich hey hey hey hey you you yeah you come here do you own amazon prime you do wow did you know you could get a free subscription on twitch how well i'm glad you asked link your amazon account to your twitch account that's it you're done come back to twitch.tv slash born and get your free sub thanks and you're welcome oh that's that twitch prime sub sandwich right there boy that's that stuff i guess i get the motorcycle i don't know what to get shawty's and i guess shawty's and club and hammer all right clubs does that include hammers i don't even know i can't hear you save them i could do you unlock the next page i could yeah because of this gated by a quest which is what's your next quest uh plankerton trail uh complete to retrieve the data missions in a 34 plus zone so i have to complete uh plank off wherever that it is before i can get to the next skill i'm on plankerton page eight of 13 it seems like an eternity uh so retrieve the data missions two of them what's that icon look like that the satellite dish it's the one that has like the um how do you describe this um kind of looks like a a raindrop with a triangle at the bottom and um it has like lines that go downwards on the raindrop i see it i see it it's an upside down raindrop yeah almost looks like a pin with the arrow pointing downward or it looks like an alien head with a with a pop collar yes all right so 34 plus retrieve the data um there's one right here there we go uh 10 drops of rain 65 tickets survivor xp and gold so let's do that i sent you that trailer and discord okay this guy's dead already not a good sign uh enraged and uncharted enemies they don't show up on the minimap okay what am i short on the heck is that butterfly that is the weirdest looking but what in the world is going on i'm not crazy nope not crazy at all i feel safer already nope oh i was gonna get hurt i see a cake such loud noises i marked um one of the loot almost as loot i don't see it yep i see you but i don't see you look on the minimap it's oh i see it now i see it now it's the purple down the minimap there's another one that i marked that guy came in there expecting loot uh the giveaway is gonna end when that timer hits an hour so in about 20 minutes so we'll get more people time to enter escalation point ticket one if you want to enter chat for a sub gift if you're already sub you still can enter if that's the case i will just gift yourself to somebody else's stream i press z on here whoops oh there's so many um go get those i can't hear you i think um go get those lamas there's like two more over here okay i'm on this one now i had thought to use the one that i had why is there so many whoa my frames probably gonna cap all my materials actually no the brick won't be capped there's one more oh my goodness i didn't see this one yeah that's nice jeez definitely gonna be capped oh no i need five more stone a regular one over there on the cliff locate the landing site should be over here i should it's like she's gonna find it before we do that's three minutes oh i thought yeah that was that countdown yeah and the easy way to find it is you just look up in the sky you see a balloon it's like like you can see it from anywhere i'm gonna let you build no okay and you know actually actually the data is not that big like what you're but you're building okay if you the data is just a square right here this four square okay i see so i should just focus on that part i mean you can just build like two sides and then wait for it to drop and then build the other two and the top i mean it's up to you we have 100 i was gonna say did you ask me to build or what is happening here missy is this my build or is this a collaborative effort i'm just letting you know see you know okay i'm just gonna build a derp this this it's just not snapping as good as you used to for me i i think they have some lag or something yeah it's really frustrating how it just doesn't apply it it's really frustrating all right stairs i become a big fan of this stair method remember they didn't let you build them trees peppers from the members i do remember that trouble shut up girl so everybody put a top on it for the lobbers or this is me asking well you can't build it now until the data drop right right that's true okay it's cool man you can't edit and rotate can you you have to if you want to rotate like a built stairs you have to actually break it down right no you can rotate it how is that to find the right angle find the right angle what are you trying to rotate i was gonna rotate the stairs the other way so what you do you just edit it that's amazing that's impressive that's some advanced defense right there so what'd you do you went on the other side and yeah because you wanted that way right so you just kind of go the opposite way that okay yeah i wish i could that's gonna be pretty freaking sturdy can i make it why i didn't see that wall wow that eats a lot of stone wow just doing all these upgrades i was full on stone and now i'm down to a thousand just this structure i'm doing just it's a lot of stone so i don't have like 10 000 limit like you do okay so so coming from this one with a storm rotates um are you trading don't worry yeah i'm not taking your stuff hi hi hi hi hi hi hi hi hi hi hi hi the chest in here nope yay i just killed myself that's how you don't dash i tried to dash up and it went to the side okay i have no lies remaining what that was me well no if you go off the cliff you can't revive in there there why not because then you just die again details details new people in chat so they're gonna only come from that direction or is this the one that what the storm rotates i didn't see at the beginning but i always plan on them yeah that's what i'm thinking right there's some back ramps back here you can possibly come it's basic stuff over here just in gill um i don't have that many traps built so i'll just do typical stuff here i don't have any ceiling traps i don't have any okay let's build a cheaper one cheaper one a blue one double jump very basic they may break that i know because there's no clear path to the objective may break what though the wall yeah because there's no like way for them to get to us although just break if they come that way yes storm will be able to change direction well that's kind of the point i want to put this here to stop them from coming up here i mean that's why i'm i'm gonna build more if they come this way but you get the idea fire i'm just gonna drop this and if they come i'll uh i'll just switch it up that's a really good base i know did you put a top on it no i'm about to this guy doesn't beat me to it the heck is going on what is this um he just put something where i was gonna put stairs to get up here but you jump on top of that thing just do this i should have put wood and a tool so you don't need to leave an opening right it'll just go right through it right babe said i didn't understand what you were saying uh at the top of the roof you don't need to leave an opening it'll just go right through it right what will the balloon when it lands oh it already did i'm thinking the thing still has boy i'm okay i'm okay if you i'm okay it's fine it's fine everything's fine if you come in here and look where i'm at you just build a door here where you inside build a door i put a door this is what it is okay i knew that i thought it hadn't landed for some reason don't ask me why oh look at all these chickens so good you guys looking good i know it's like i was taught by somebody who knew what they were talking about it's like so tight not wasting materials either well you could have made a smaller i know i know i'm not that advanced all right guys we're gonna do the drawing for the giveaway the winner is hey i'm pony uh hey i'm pony uh hey i'm pony you are the winner uh hey i'm pony hey where you want me to put a on pony where in the world do you want this up to go you're so crazy davis you didn't win jack oh you won points my bad you did win you're still crazy don't you dare vince viga okay vincent viga street fighter i will get on that sir congratulations and enjoy and thank you guys for helping me meet the sub goal dbrn with the big big uh sub goal or the tip not mean to what is it the gift of subs at the beginning of stream thank you man that made that giveaway happen there's a little guy down here and now he's dead mark the giveaway is complete so what not the bomb he keeps jumping past the bobs i was chasing that dude all over too i just kept jumping over so cool i just keep jumping over these dudes i think after this i'm gonna get some food too i'm my stomach is doing backflips hello b one to pop in three and cool man thanks man thanks for coming by i hope things get better for you what is this guy making what is this it's like a boy really like that scarecrow it's a decoy yeah no i don't know what this guy's doing that's what i said he's like building like a boy there's something i don't know what this is it's he's trying to express himself because we're doing all the work all the work the wilds go live yet


Thank you everyone for coming. This session is aphorisms of API design. If that's not what you're looking for, you're in the wrong room. My name is Larry Garfield. You may know me as Krell online. If you want to make fun of me on Twitter during the session, that's where you do so. I'm a senior architect at Palantir.net, where a web consulting firm in Chicago is focusing on Drupal. For Drupal 8, I'm the web services initiative lead. I'm the Drupal representative to the Fwingwork Interoperability Group. I'm an advisor to the Drupal Association. And general purpose busy body who flies around and tells people what's wrong with their code. That's kind of what I do. Let's start off by defining our terms a bit. An API is an application programming interface. That is, it is code intended for other code to use. Or people who write code. But this is not something end user see. We're talking about the interface from code to code from coder to coder. And an aphorism is a concise statement containing a subjective truth or observation cleverly and pithily written. Cleverly and pithily written, that sounds like me. So what we're talking about here are not hard blind rules. They're more like guidelines. So what we're going to be doing is covering some clever and pithy sayings about good code. Everyone's down for that? Sounded like a good plan? All right. The first one we need to know. Learn the rules like a pro so you can break them like an artist. This is not specific to programming, but it applies here. For everything I'm about to say, I guarantee you you will find an exception to it. I can find an exception to it. But these are still things you want to understand so that when you don't do it, you have a good reason. When you don't follow these guidelines, you understand why you would want to skip over them. First off, everyone know Isaac Asimov? Most people, I hope. One of his books, The Gods Themselves, which I do recommend, he posits that if there are multiple universes, there are infinite universes. Basic idea of the book, humans are contacted by aliens from a parallel dimension and plot happens and one of the characters observes, you know, if there's two universes, why would there only be two? There's probably a whole lot more parallel universes. Because really, two is the least likely number in the universe. Why would there only ever be two of something? Things could be unique. There could be a whole lot of something. Why would there only be two? And that means that in software, if there's multiple possible implementations of a given problem, if there's multiple possible ways to deal with a certain situation, then you should assume that there are an infinite number of possible implementations, an infinite number of options. So what does that mean? At a very applied level, who's ever written an API in which you control options with constants with numbers? A couple of people? Yeah, don't do that. So let's say we've got this code here, load articles by status, whatever. And so we pass in one of these status constants, publish a draft, and then, you know, look those up from some mechanism, some views or database query or whatever, and then load them. Great, and that's fine, that's wonderful, and it's right until you try to extend it or let someone else extend it and you go boom. Because you didn't say anything about three, but guaranteed someone's going to want another status. So how do you fix that? It makes that as a string. There's a lot more strings and less likely to bump into each other. This is exactly what Drupal does when it's doing it right, and in some places there are contrib modules that have done it the wrong way and have regretted it. I think voting API is a good example. There are early versions of voting API used constants for different modes and a whole bunch of voting API extending modules came along and tried to add their own constants and things exploded. But wait, Larry, what about booleans? Aren't booleans a two-state? Isn't that a case of something of which there's only ever two? No, because booleans are not a two-state value. A boolean does not mean it's either or, it does not mean A or B. A boolean is true or false. A boolean is true or the absence of true. A boolean is a single value. It's a value that is or is not. It's a very subtle distinction, but it's something to keep in mind. If you know that something could possibly be true or not, that's a boolean. If you could be using option A or option B and A and B are the only ones you can imagine ever existing, you're wrong. There's going to be a C and someone's going to come up with it and you're going to be stuck if you try using a boolean for that. Don't use booleans for modes. Good example here. Access is a boolean. Does user five have access to edit node 12? Yes, no. It is the presence of access or the absence of access that is not option A or option B. Access control, which system decides the user has that access, is n possibilities. In Drupal 7, you only had one access control callback, but you could exchange it. In Drupal 8, you could have many access control callbacks. And you have to account for potentially an infinite number of them. Corollary to this, so I like to call Garfield's law because I'm not egotistical at all. One is a special case of many. Some of you may have heard me say this before. What does that mean? Let's take a look at node load multiple. You've all used node load multiple at some point. So in Drupal 6, this is how node load worked, vastly simplified. You pass in a node ID. We look up the base record out of the node table, and then we do extra stuff with it, call hooks and so forth to make extra database queries, and return that object. And that's great and that's wonderful. Right up until you actually want to do the same thing to seven different nodes at once, and then, oh, good. The only way to do it would be to load one table, load all the nodes base records, and then call all of those hooks on each node individually. And this is what you did in Drupal 6 with your own custom code. You looped over some node IDs and did node load on each one of them, and ended up generating about 500 database queries. This is known as the select n plus one problem.  Please don't make your database administrator hate you. This was fixed in Drupal 7. And in Drupal 8, any entity operation is innately a multiple operation. Node load is simply a simple wrapper around loading multiple nodes. Hook node load always assumes you're dealing with multiple nodes, because if you have an array of nodes, the iteration you do is exactly the same if you have one 50 or 100. It's the exact same code, which means you can treat one as a special case of many. That greatly simplifies your code. If you have to deal with, you know, I may have one of these, or I may have to do a multi-operation, that one case is always a subset of the multiple operation. Merge them. Which brings us to our first guideline. N is the only number. Don't assume you know how many of something is going to be. There will be many of them. Many is a non-defined number. Number two. Quote from Rosmas Leador, founder of PHP.  Everyone here is lazy, right? If you're not, then you're not doing a good job as a programmer. Good programmers make the code debug for them, because really, why are you going to waste time debugging when you can make the machine do it for you? The whole point of having a computer is to make the computer do work for you so you don't have to. Don't plan for every eventuality. Don't plan for everything that could possibly happen. Figure out how it's going to break in a way that's going to help you. Good example of that. Drupal 6. This is an excerpt from the theme function. And, you know, go through the system and check, all right, we're calling this theme key. Does the theme key exist? If not, all right, just return null. Except that null in PHP gets cast to an empty string when you try to use it as a string. If you have a typo in your theme function somewhere in one of the four places you need to specify it, you don't know. In fact, the system will not only not tell you, it will actively try to keep you from finding out that you have a typo. This is not good. Who has ever run into the problem where, you know, you're trying to use a formatter in Drupal 6? And first, who remembers developing in Drupal 6? Okay. All had the experience of developing a formatter and having that crazy long name for the theme function you need for it. And you're trying to write it and it just doesn't show up and you have no idea why. This is why I have lost tens of hours of my life to this problem that I will never get back. Whoever decided this was a good idea, I blame you. We fixed this in Drupal 7. Instead, you know, some of the logic changed, but now, if there's no hook found, we log it. Which means if you are getting a weird problem where you're trying to theme something and it doesn't show up, you can check the log and it'll tell you, oh, by the way, this theme hook's not found. And you can look at it and go, oh, duh, I have a typo. And you can fix this in about 5 to 10 seconds instead of 5 to 10 hours. Yes, I've been there. Who's old enough to remember DOS? Uh-huh. This was a pretty useless error message, wasn't it? Who's run into the Drupal equivalent? Does anyone know what this even means? A couple people? What this means is somewhere in a form array or a render array, you have a string where you're supposed to have an array. Where? I have no idea. You have no idea. And because that system is recursive, try debugging to find it. You're still not going to find it. You're pretty much left with guess and check. This is a very, very bad thing. This is why big anonymous arrays are not a good data structure because they are impossible to debug. Because all this error message tells you is, by the way, somewhere there's a bug in an array. It's Drupal. There's lots of arrays. This doesn't help me. This might be an American joke. Code failures like voting in Chicago. Do people actually get that joke here? Failorily fail often. Some people get it now? Yeah. Vote early, vote often. It's the tradition in Chicago. The way to do that is you constrain your inputs and fail usefully. What do we mean by that? Constrain inputs, good APIs are picky. This is an excerpt from the database system in Drupal 7 and Drupal 8. If you call this fields method and you pass in two arrays, you're fine. If you pass in something that is not an array, this code does not know how to handle that. So we specify it in the method call.  PHP is slightly more polite than that, but that's the idea. But you can know exactly, oh, I have a bug right here that I can go fix. Instead of 15 function calls later, something not working because you passed something is not an array when it expects an array. Be picky, that will help you. Another example, pre-execute. In this case, we can't detect it just through the language, but SQL insert queries let you specify this field should have this value. It also lets you specify this field should have whatever the default value is defined in the database. Completely legit things to do. If you specify the same field in both of those lists, your query will break because SQL has no idea what to do. If you just let this all the way through, you will get a completely useless error message from MySQL giving you a parse error and MySQL error messages are not the most useful. Instead, we check for that and throw an exception. And that exception tells you exactly what you did wrong. You specify this field in both places. Don't do that. And you now know exactly what it is you did wrong and can go fix it. Save yourself time by telling yourself what you did wrong.   Also means if you are not developing under eStrict and eAll, who knows what these mean, eStrict and eAll? Okay, you're all using this, right? You will be by the end of the day. If you're not doing this, you are doing it wrong because you are giving up the ability for PHP to find bugs for you. Make PHP find bugs for you so you don't have to. That's why the capability is there. Make PHP run in picky mode. You want it that way. Another corollary here. Who's heard the phrase, we don't babysit broken code? We don't use it as much anymore in Drupal for good reason. What we don't babysit broken code is code for we don't care about developers. Do not take that approach. Always make sure your code fails in a useful fashion as soon as possible.  Number three. You can't teach what you don't know. And if you can't teach it, you don't know it well enough. Okay, it makes sense. It also means you don't understand what you can't document it. If you can't explain what's going on, you don't actually know what's going on. And neither do I. If you don't document something, I have no idea what you're doing. This is somewhere that Drupal actually does really well. When putting together this presentation originally, it took me a while to find some examples where Drupal didn't do this right. But I found some. This is the file transfer FTP class in Drupal 7. And it starts off pretty good. So we've got a proper dock block on this method. It's named well, so we know it's a factory method of some kind. And we know it takes two parameters. One is a string, one is an array. It returns file transfer FTP. So it's the name of a class. And we know if it's going to get back that class or a subclass of it based on the available options, cool. So I know what I'm going to get back now. And what I need to pass in is a jail string. What does jail mean? I have no idea what jail means. Is that a path for a CH route? Is it just an arbitrary string? I have no idea. To this day, I still don't actually know. And settings. Okay. Well, we know it's an array. I'm going to assume it's an associative array with configuration keys of some kind. What are the possible options? Anyone actually know? I don't. This tells me nothing. Don't be this. Do better than this. Contrib is much more of a mixed bag. Here's my favorite example. Date module. This is a bit old, so they might have fixed this by now. Date entity metadata field getter. All right. It's a getter callback to return date values as date stamps. Okay, then. And its parameters are objects, options, name, object type, and context. Oh, my God. Well, object. So does that mean standard class object? Does that mean an entity? Does that mean... I mean, there's lots of kinds of objects. I don't even know what this is. Could it that be an array that we use as an object? Because Drupal's done that a lot. Object type. Wait, why do we care about object type? Wouldn't that be intrinsic in the object? That's what a class is? Oh, wait. Maybe it's not a classed object, but I don't know. Array of options. Well, we're right back to settings again. No idea what that is. Name. What's the name of the object? I have no idea. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. Context. So I'm not going to trust your code. It could mean you don't actually know what's going on. You don't know what you're actually writing. And so I don't want to use your code. Or it could mean you know what's going on and you're just embarrassed about it. But I don't know that. I'm going to assume one of the others. If you're embarrassed about it, document the fact that you know it's terrible so that someone else doesn't blame you for it being terrible. In the Linux kernel, there is a block of code somewhere which has a doc block on it, or a comment above it that says, I don't know why this works, but it does. This is an incredibly useful comment because I know here be dragons. I know not to touch this unless I have cleared a week to figure out what's going on. I don't even remember which block of code it is, but it's some weird probably bitwise logic or something. What should you document in your code?  Document those two actually. If you find a contrib module that doesn't do this filabug market major, and yes, Jen Hogden, the Drupal documentation lead, has told me it's OK to say that. Even better, usage documentation. You're all familiar with the phrase, a picture is worth 1,000 words. A code sample is worth 1,000 comments. How do I use a piece of code? How am I expected to use something? This is the documentation page for Gearman. Gearman is a queuing server that has very good PHP support. On their front page for the project, they have a code sample of exactly how you should use it. They have English text describing what's going on and what you're supposed to do. They have a diagram showing how it all fits together. Oh my god, this is amazing. I have never used Gearman in a project. I want to because their documentation is just that good. Can you say that about your code? If not, you've got work to do. Documentation is part of your API. Do not forget that part. If you'll excuse me a moment for a side rant on documentation. You may have heard this line before. Clearly written code with well-named methods is self-documenting. Great, you don't actually need to write comments. Doc box fine, but you don't need to do comments in line. No. It's a wonderful thing to shoot for, but no. Here's an example. This is actual code I wrote for a non-Drupal project a few years ago. It's called normalized character set. OK. So I assume that's what it's going to do. And it's going to pass in a value, which I'm assuming the string we're going to normalize. And I switch based on the encoding. And in case of ASCII, I do nothing. In case of UTF-8, I do what in the hell am I doing? Converting to HTML and back. And false. Why does false mean windows? Anyone know what's going on here? Anyone know why I'm doing any of this nonsense?  This does not make any sense to me at all, and I wrote it. Here's the code with the actual comments that are in it. MBDetectiveCoding in most situations only supports two character sets. And so we're going to guess that if we don't, if it's not a found character set, then it's probably Windows 1252, which is the garbage, 1251, which is the garbage character set used by Microsoft Word and nothing else in the universe and therefore is still polluting computer systems the world over. This is why Microsoft Word is evil. This code is here to compensate for Microsoft Word being evil. Now I know that because it's been commented. I'll put the rest of this. I have absolutely no idea why UTF-8 strings need to be converted from UTF-8 to UTF-8. But if this code is removed, everything breaks. To this day, I do not know why I had to put this code in there, but I did. And I left a comment so that someone coming by to maintain this project after me a year later doesn't waste their time trying to optimize away this line of code and then wonder why it breaks. And so why are we doing it this way? Well, HTML entities, in my experience, is the most forgiving tool PHP has for guessing at a character set of a string. PHP has like four different mechanisms to do that. And this is the one that, in my experience, is most reliable. Why? I have absolutely no idea. But it works so I document that fact and move on. And then Windows, all right. A false return means that it couldn't figure out so we're gonna guess it's Windows. And if it's correct, it'll work. If it's not correct, it's gonna break. But now we know where to look if something breaks. It's probably a character set other than these we're dealing with. Document your code, comment your code. Don't explain what, explain why. These comments are explaining why we're doing this ridiculously silly thing.  That's good comments. End rant. So aphorism number three. Doxer didn't happen. This is enforced in the core issue queue. You should enforce it in your issue queues too. Number four, a UI is not an API. Seems obvious, right? A user interface is not an application programming interface. These are different things. For the very simple reason that a user is not a program. Most of the time. Unless you're Kevin Flynn. A UI is a client of your API. It is not itself the API, it is just a client of it. It is a user of your API. Why would we have a website without a UI? What are you talking about, Larry? Who said anything about a website? I didn't, did you? I didn't hear you say it. No, we're just talking about APIs. And really, websites are just a small fraction of the software out there. Maybe you need to do a command line tool. You want something that'll work in Drush. Or some other command line tool like Clex. Or you want to test it. And you want to test it correctly using PHP unit instead of simple test. Tester didn't happen. Or maybe you're doing a REST API. Who is just here for the REST session in the last session here? Your code needs to work through the REST API. Your code needs to be able to work without there being a form involved anywhere. Just REST calls coming back and forth. Because someone's going to try and do that with your code. And maybe, maybe you'll have some forms in a web page. This is an edge case. Web forms are an edge case as far as APIs are concerned. If you treat this as your only output, you don't have an API. You have a pile of code. A pile of code does not qualify as an API. A website is not an API. It uses an API. It is just one use case of an API. The API can exist on its own without a website, without HTTP at all in most cases. And if it can't, there's a problem. There's a common saying in software development. You're not done until you have three implementations. If you're designing an API, you need at least three different systems that are able to use it differently to prove that you got it right. This is what we did for Drupal 7 and for Drupal 8, the database layer. Why do we have three databases in core? To make sure we can support multiple databases correctly. Before we had all three in there, it didn't entirely work. We had to refactor it for each one of those three. Once we had that, people started adding support for Oracle or Microsoft SQL in contribe. I didn't even know about it. And that's good. That means we did it right.  What three implementations do you want? Well, your first one's a unit test. You always want that implementation. You want a web services call. You want a command line interface for it and a website. Pick three. If you're designing an API, pick three of these and make sure it works. Otherwise, you don't actually know you did it right. And this also means your API can work without any one of these in particular. It means you're decoupled from your website and your command line tool. That means you did the right thing. A UI is not an API. Don't pretend it is. Which, incidentally, means if you're doing CRUD operations through hook form alter, stop. It's going to break. I love this one. You know that saying about standing on shoulders of giants? Drupal is standing in a huge pile of midgets. Drupal 7 had nearly 1,000 contributors. Drupal 8 is around 1,600 in climbing. There are lots of people who have done stuff before you. Don't reinvent the wheel. There's plenty of them out already. Don't add to API bloat. There's too much code in the world as is. Who's a fan of XKCD? You've seen this one before, haven't you? Don't do this. Don't create standard number 15. When possible, leverage existing patterns. Memory is the highest form of flattery. It means you're complimenting someone to say, your work is good enough that I'm just going to use it. It's easier to remember because you already know this other thing, and you can do it the same way. It means less work for you.  You can hold more things that way. And it takes less work. I would rather reuse some other design, some other code, and go home at 5 o'clock than pull it all night or four nights a week. Does anyone disagree? You'd rather pull it all night or four nights a week? I didn't think so. Follow existing patterns. Learn design patterns, especially for Drupal 8 with all of this new OO code. We've got look into existing design pattern resources. There's a link to some good sources for that. Follow your platform's patterns. If you're using Drupal, entities, hooks, plugins, and so forth, use these tools that are already there. It's easier for you to develop. It's easier for people using your API to develop. You want to make something swappable in Drupal 8? Either make it a service or use plugins. Both of these, everyone who knows Drupal 8 is going to be familiar with. You follow those patterns, your API becomes really, really easy to learn. Do not make your API hard to learn. If you're doing something with Symphony, it uses YAML configuration files. It uses events. It has its bundles mechanism for extensions. Whatever system you're using, if you're using Zend, Cake, whatever, it's going to have these patterns already. Follow them, go with the flow. It'll make your life easier and everyone else's life easier. And documentation. Best API is the one you didn't have to write. Number six, it's a very good book. 97 Things Every Software Architecture Know. I highly recommend it. One of the lines in there, use uncertainty as a driver. What does that mean? It means don't make decisions if you don't have to. Put off making decisions if you can. You want to make changing your mind cheap. You don't know enough at the beginning of a project to really decide what you want to do. And certainly, your client doesn't. Your client is going to change his mind, probably right before launch, multiple times. Who's actually had that experience? This is how you make your life easy when that happens. You can only change things that have been encapsulated, that have been carved off into their own swappable piece. For example, logging. The system wants to have logging, fine, whatever. And we're going to log to the database because, well, it's there. And that's great and wonderful until your client comes along and says, no, no. Our SysAdmins want everything logged to SysLog instead so they can have all of their logs in the whole system together. That happens to me two months ago. No, actually, sometimes you want to display them on screen during development, too. So they're in my face. And if they're really important, we need to send someone a pager in the middle of the night to wake them up.  Yes, he actually did that. I don't know why you'd want to, but you can. Don't decide in advance where you're going to log because, guaranteed, you will have to change that later. Instead, simply hide it behind an interface. It's really simple to do this one, guys. Just throw stuff into an interface. You have an object behind it. You're done. You want to log somewhere else? You swap out the object. Problem solved. Or better yet, don't design your own and just use the existing interface that's already standard in the PHP community. This is a recent product of the PHP Framework Interoperability Group, PSR3. It is a standard logging interface. We are trying to get this into Drupal 8. Basic idea. Logging is a commodity. Why do we have everyone developing their own logging interfaces, their own logging mechanisms? That's silly. Here's the logging interface. Use it. You're fine. Main one, log. Give you a level, a message, and context information. Context here. Same thing as placeholders in Watchdog. In fact, based off of them. And all these others, these just utility methods for the different log levels. Cool. Use that. You're done. Use this for logging. And it doesn't matter what's on the other end. Your client changes their mind five minutes before launch. You can swap out the object and you're done. How about caching? Well, we could cache to the database. But then APC comes along and you want to cache some stuff there. But then memcache comes along and you've got multiple servers. So you can't use APC. You have to put stuff in memcache instead. Oh, great. Now I need to rewrite my caching layer. And oh, wait. Now Redis is the cool thing instead of memcache. And the system wants to use what's cool. And Redis is cool. So we have to use that now because the system wants to do so. And oh, wait. Now they want to use RIAC. I don't even know what that is, but it's supposed to be good for caching. I don't care. I shouldn't have to think about this at my application level. Don't decide in advance. You should not have to decide. Carve that out. In Drupal, we have this interface already. This is from Drupal 7. Drupal cache interface. Get multiple. Fine. What's on the other side of this? I don't care if it's memcache, or Redis, or RIAC, or whatever, or something that doesn't even exist yet. I can punt that question to later. Avoid decision making punt questions to later. Or even better, don't write your own interface for that. There's another PSR standard in the works for caching. I'm actually the editor for it. Stay tuned. Hopefully that'll be out in the not too distant future. And then everyone can cache using the same common API. Incapsulation avoids decision making. You want to avoid decision making until you can't get away from it. Put it off as long as possible. And in order to do that, you need loose coupling. You need your code to be loosely coupled, not relying on implementation details. You want explicit interfaces to hide behind. Hide implementation details behind interfaces so that you can change what's on the other side of that interface without breaking all the things. You want that. How do we get that? Dependency injection. You've heard me say it before. I'm going to keep on saying it. This is one of the great things in Drupal 8 is we have most of the system factored out this way so that you can swap pieces out. It's not just for testing. Dependency injection is great for testability. It also is great for changes that happen right before launch because you can just swap out one class for another class and be done with it. And the rest of the system doesn't break. Another way to get this, make sure you separate your logic from your data. Oh, come on. Only a few joe laughs at that one. Separation of concerns. You want to have interface-driven development. This is, again, a big change in Drupal 8, and it's a good change. Because we have node objects that are classed and clearly defined with an interface you can rely on, which are separate from the logic to email someone about a node or whatever. These are separate objects, separate problems. Your logic, your services should be stateless and context-free. What does that mean? It means if I send an email through using the email service, next time I try to send an email, that first call doesn't affect it. No state is maintained between those. Why is that good? It means I can change the order in which I do things and not break things. I don't want my code to break depending on the order in which I do things. Wherever possible, code that has actual business logic in it should be stateless. You should be able to call it 50 times and get the exact same result without anything changing out from under you. When things change out from under you is when things break. State is the enemy of stable code. Follow the single responsibility principle. One object does one thing. That thing could be being a node. It could be loading a node. It could be emailing a node. It could be exposing a node on a REST URL. Whatever it is, one object does one thing. And dependency injection. That makes it easy to swap things out. If you don't dependency inject, it means you have hard-coded classes. And when you need to change something at the last second, you can't avoid making decisions. Don't make decisions if you can get away with not doing so, because that lets you make the decision later when you have more information. Great, all this delegation adds indirection. And indirection requires abstraction. OK, this makes sense. And abstraction doesn't solve. It just hides complexity. Abstraction does not change how complex something is. It simply means you don't have to deal with it directly. It is still there. Abstraction is not free. We're talking about all this great abstraction stuff, but there is a cost to it you have to weigh against. On the performance front, at the language level, for example, call user funk array costs as much as three PHP function calls. And using the magic underscore underscore call method costs as much as three method calls. Actually, benchmark this, it's about that expensive. By the way, guess what pretty much the entirety of Drupal is based on? Now, that's OK. Function calls are not that expensive these days. Modern PHP is pretty good about that. But that cost is still there. You have to be aware of it. Or further up, we've all used the query builders in Drupal, DB Select, right? DB Select is 30% slower than just using DB Query, plus more memory overhead. And that's not even a complicated query system. As query builders go, ours is pretty simplistic. Don't use DB Select if you can get away with using DB Query and save yourself some time. And also, save yourself complexity. Save yourself confusion, because it is very easy to set up a system where you can't actually figure out what's going on. There's just too many layers of abstraction to dig through. Getting that balance right, where you have just enough abstraction to keep the problems away from you, but not so much that you can't figure out what's going on when you need to, is hard. Balancing that is hard. And you're probably going to get it wrong on your first try. But it's still a skill you need to learn. There are two ways of constructing software. One is to make it so simple that there's no obvious deficiencies. The other is to make it so complicated there's no obvious deficiencies. Great, this doesn't help me much. Guess which one is harder? The unavoidable price of reliability is simplicity. Now, this doesn't necessarily mean simplicity at large, but within a certain area, keep something as simple as possible. Build a series of simple solutions that you collect together into a larger problem. That helps you break up the problem space better. That helps you keep the simplicity where you need it and still be able to solve the complex problems. But remember, there is no problem in the world that cannot be solved by adding another layer of abstraction, except abstraction. And finally, Drupal has idiosyncrasies, but really, there's nothing special about it. Doesn't matter what version we're talking about, it's just software. And no one understands what's going on in Drupal, except for Drupal developers. And not even all of them do, really. Maybe you're working with another system like Symphony. No one understands Symphony's quirks except for Symphony developers, and a lot of them don't get it either. No one understands PHP's weird quirks except PHP developers, and there's an awful lot of them that don't get them either. And believe me, there are plenty of quirks in PHP. Whatever system it is you're building, no one actually understands it except you. And probably, if it's been more than a week since you worked on it, neither do you. We all know the guy here on the left here, right? That's Caroline Nageshi, checks. One of Drupal's top developers, one of the lead people behind Drupal's five, six, and seven. Crazy smart guy, knows more about PHP than I've forgotten. He's a great guy, but doesn't matter how smart he is, John Resig can code rings around him when it comes to JavaScript. No matter how smart you are, and in whatever field you're working, there's someone who knows more.  Think about it, third gen languages, that means something higher than assembler, something more complex than assembler, have been around for 56 years. Who in this room has been around for 56 years? Uh-huh. No, nobody. PHP has been around for 18 years. I don't know about in the Czech Republic, in the US, it's now old enough to vote. I don't know, is it old enough to drink or vote in the, here? Okay, maybe. Drupal is 12 years old this year.  I mean, really. What are the odds you're doing something that in 56 years no one has managed to run into? Pretty darn small. Find existing tools that you can use instead. If you're looking for PHP code, use Composer, find code on packages that you don't have to develop, you can just use because it's already there and you don't have to do anything special with it. Look at the symphony two components. We did, it made Drupal 8 a lot better. Look at the Zen framework too. They've got good components there too. Maybe symphony doesn't do what you need, Zen does. Great, use that. If you're working, if you need a larger system, don't write your own platform. Build an application on symphony two. Build it on Zen framework. Build it on cake PHP. Build it on, you know, Laravel, on whatever system you want to work with. Find some base platform to work with. If you're doing a CMS type site, build it on Drupal absolutely. Don't write your own CMS. Good God, don't write your own CMS anymore. No one in the right mind writes their own CMS anymore. Do not write your own system from scratch when so many people have written so much good code before you got there that you can just use. That's the wonders of open source. Please take advantage of it. If you have to write something yourself, leverage existing standards. Look at the stuff that the FIG is putting out regarding interfaces, regarding coding conventions, regarding all these other things. Don't re-architect when you don't have to. Learn HTTP. Who here has ever read at least a slight piece of the HTTP spec? Who has read more than half of it? More hands should be up here. Everything we do on the web is based on HTTP. Learn how it works. It does a lot more than you think. It does a lot more than you think. And you can leverage that if you know it's there. If you need to do a web API of some kind, you wanna do it using REST. Why? Why would we bother using REST semantics and RESTful APIs in the first place? Why would we follow this existing prescribed pattern? What does REST actually stand for? REST stands for I can go home and take a nap because I can rest and not have to design the whole thing from scratch. You want caching for your API? HTTP has it built in. Use it. It's already been figured out. You need to do validation. It's already there. You need to handle authentication. There's multiple mechanisms built in. Don't reinvent the wheel. Just follow these patterns. You don't have to waste your time trying to redesign these things. Learn from existing tools. If you're actually doing to write new code, look at PECL, the PHP extension, something library, C plugins for the PHP language itself. Look at them and see what they're doing. Can you just use one of them? Maybe, if not, do a PHP user space version of it. If you're doing anything with JavaScript, look at jQuery. You can learn stuff about PHP from jQuery too. Learn from these other systems. Look at WordPress. It's fun to make fun of WordPress, but they have nine times the market share of Drupal. They must be doing something right. Look at their code and learn from it. Even if it's learn what not to do, you can still learn from it. Look at Symphony 2. Look at Xen. Look at these other popular PHP frameworks. Whether you use them directly or not, you can learn from them and that makes your code better. That means you don't have to invent as many things yourself. Look at Java. A lot of the documentation on Java, object-oriented techniques applies to PHP because PHP's object model was derived from Java's. It's evolved separately since then. Fine, cool, whatever. But there's still a lot of similarities. A lot of the documentation you find in the Java world applies just as well to PHP. Not all of it, but a lot of it. Look at these resources. Learn from them before you start down a road yourself. Look at design patterns. A lot of them talk about Java, but they apply generically. Look at these tools before you start designing so that you know what to do and what not to do. You know what paths are already trodden. There's probably a reason why the path less traveled is less traveled. Don't always follow that path if you don't have to. This is exactly what we did in Drupal 8. This is why Drupal 8 is such a radical departure. We are pulling in code from Symphony. We're pulling in code from Symphony CMF, from the Xen framework, from Doctrine. Guzzle from EZRDF, from Aesthetic. We're using Twig so that we don't have to reinvent these wheels because Symphony has a perfectly good routing system and a perfectly good core pipeline that is aware of HTTP, so we used it because Xen had a perfectly good RSS parser that is way better than the three different ones we had in Drupal and so we just used that one. Because let's face it, Twig beats the pants off a PHP template and is way better than us trying to come up with ourselves. Let's just use it. And by the way, all of these things have existing documentation we don't have to write that saves everybody time. Because really, there is a feature that absolutely no software project needs. Your code should never have this feature in it. Ego, it has no place in software development. Which leads us to Dyrton's Law. I don't care what you're doing. I don't care how cool it is. You are not a special and unique snowflake. Which leads us to our grand unified theory of API design. Let's bring everything together.  Well, guess what? You always know where you live, don't you?  And they're gonna be stuck with that and stuck dealing with whatever it is you gave them.  Plan accordingly. Some additional resources. I mentioned the book 97 Things Every Software Architecture. No, highly recommend reading that. It's a very easy read. People heard of the Daily WTF. It's a great research project. People think it's a humor site. It's actually a research project in software anti-patterns and process anti-patterns. Read this site, don't do what they do. It's a great way to learn what not to do. A lot of these quotes are also got from softwarequotes.com. Another good resource, I highly recommend it. Thank you very much. My name's Larry Garfield. Please review the session online. Also, two other announcements. One, this room, next session, read after the coffee break. There's a session by Anthony Ferrara talking on many of the same subjects. Stay in this room for the next session. And I expect you all at the sprint on Friday to help work on Drupal 8. Thank you. I think we've got about five, 10 minutes for questions. So this very nice gentleman down here with a microphone. If you have questions, please raise your hand. He'll come running. Yeah. Do you hear me? I was thought that you're the right person to ask them my question. I get an idea. Maybe I get support or denial. I was thinking if there will be a possibility of quotes or module sustainability like between the versions. Like say, you might hear that. Not, I spoke with other quarters which don't like the idea. And I think that it's not a good idea to lose that amount of good code, good modules during the version extensions. Come to my core conversation tomorrow, third session. I think it's next floor up. I can never remember which floor is which here. But yes, I'm talking about exactly that question. So I'll talk to you about it then. Okay, thank you. Other questions, somebody down here? Uh-oh. So we had those nice principles or aphorism or whatever.  Or you let someone else code it who is maybe just a trainee or someone and then you won't be happy with it, but it works and then you prepare for that at some day you have to do it in a different way. And shouldn't this be also part of the big theory that things evolve and you learn and not everything can be, also that I want to write a method. I think that could be a good idea to write this method. And I start writing and before I add the commands and everything I say, oh no, that was a bad idea. I remove it again. And so there's a question of the timing and when do you add your commands and how do you, do you want to start with something really ugly and then evolve from that? Or do you want to start with something over engineered and then it come back and it bounces to over engineered and to oversimplified and to something else? So there's a kind of process and you kind of just do it all at once and have all these principles filled in in the perfect way. Sure. So it is a balancing act. Another good aphorism plan to throw one away, whatever it is you write first is probably wrong. Do that in small chunks. Your code will be better if you can write it once, realize it's wrong, throw it away and redo it in bits and pieces rather than the entire system at once. That's another place where this divide and conquer makes sense and if you can say, if you have an interface on something and on that side of the interface, I know I've got crap. The code is a complete disaster but I know it and I know that it's hidden behind that interface. As long as that interface is decently designed, you can refactor that crap later. You can rewrite what your intern wrote, you can have your intern rewrite the crap that you wrote, whatever, as long as that interface is right, the rest of the code is fine. Keep getting that interface right. That's where the rule of three comes in. So write something, try it in a couple of situations, realize it's wrong, fix it, go through that process to let it stabilize. As for documentation, yes, just as you're writing, you probably don't wanna document every method the instant you write it. I would say before you commit, make sure you've documented. Just before you commit, yeah, you're gonna be throwing stuff away, writing, rewriting, whatever, don't bother. Document when you commit. Or at the very least, document before you push your branch. I would also say never leave something uncompunted at the end of the day. Tomorrow morning, you are not going to remember what you were thinking. Last thing you do on the day, go through your code, make sure you comment it, make sure you update any previous comments and doc blocks to make sure they're right, because that way, tomorrow you is going to thank you.  Does that make sense as a guideline? All right, over here. Hi, so you mentioned that we need to, we don't reinvent the wheel, like we have a lot of things out there and we need to use it, but if you look at Drupal and you listed like eight, 10 components, so as individual, yes, they are good. As a product, or maybe if you look at other way, we are taking few, you know, like a well-known stuff or working stuff and putting us and creating a new product like Drupal, and we are telling that it's gonna be fine, but how we validate that if we put these things together, they know each other and they work well. That's gonna vary widely with the system. In the case of, for example, symphony, what we wanted to make major changes to Drupal 8 and we knew we were gonna make major changes to Drupal 8 and realized, okay, the changes we wanna make, symphony is already done, so we can just skip over three years' worth of development and build stuff on top of that, that is probably gonna be similar to where we wanted to end up anyway, but we managed to skip three years' worth of development. In the case of Twig, we actually looked at it and said, all right, is this going to be compatible with our system? And it turns out a lot of stuff Twig wants you to do in order to set it up, Drupal was already doing, so it was a good fit. We probably could also look at other tools, like we looked at, Imagine, I think it's called, is an image manipulation library that wasn't following autoload standards, wasn't following modern conventions. We're like, okay, trying to use this library would be more trouble than it's worth. And so we passed on it and just kept doing our own thing there. So a lot of it does come down to case by case decisions. There will be cases where the existing code is not going to work, or where the existing code is far more than you need. That's okay, still do the research and look at it and say, okay, could I use this? Would this be better than writing it myself? Can I save myself time with this? The answer may be no, that's fine, but you have to ask the question first, honestly, and say, you know, is it worth my time to write my own thing, or is just using this library going to be better in the long run? And go with whatever works in that case. So there's a lot of case by case decision there. So there's some people in the Drupal community who might say, with documentation, I've written you this module, it's free, you know, I've done all the work on it, why should I have to sit there and document it? I've done enough already. How would you address those people? I didn't force you to release the module in the first place. You release the module because you want to help other people, you want to give back, you want to share. I mean, if you're releasing a module, it's a good thing if lots of people can use it. If you didn't consider it a good thing for lots of people to be able to use your module, why did you release it in the first place? So you already have the intent of other people benefiting from this module, from this code you're releasing. If that's your goal, documentation improves your ability to achieve that goal. Uncommented code that you just released out into the wild is useless, people can't use it. If that's the case, don't bother releasing it. This doesn't mean you have an obligation to maintain it for free for all time or anything like that, no. But if you are going to try and do the open source thing and release code to help other people, do it right and document it so other people know how to be helped by it. And if people know how to be helped by it, that means they also know how to contribute back more easily. And I would rather contribute to a module or a project that is very well documented because I know what's going on and I know how to extend it, I know how to improve it without breaking things, without breaking assumptions. And so you will get more and better contributors if that's what your goal is, if you have good documentation so people know what they're supposed to do with your code in the first place. Code on its own is not enough if that's your goal. If your goal is just I'm gonna write something and get it done and then go home and I don't actually care, don't bother releasing it. It's not worth the effort to generalize to release it. And that's okay too, but just be aware of which is which and when you're doing one or the other. Do you have any questions over on this side of the room? All right, thank you all for coming. Enjoy the rest of the conference. Please rate the session and I'll see you all tomorrow on Friday at the Code Sprints.


This is stock number 2-0J66A. We are here at Summit Automotive in Fond du Lac, Wisconsin. You're new and used Jeep headquarters. Today we are checking out this super clean 2017 Jeep Cherokee Trailhawk. This vehicle has the 3.2 liter v6 motor which gives you 271 horsepower and this one has been fully safety and inspected by our service shop. It has a fresh oil and filter change all the fluid tab and checked and topped off and this Jeep is 100% ready to go. Hydro blue metallic is the color we shoot all of our videos in 1080p. 60 frames per second. So if you have HD capabilities on your computer tablet or smartphone device turn them on right now because it is definitely your best way to check out the quality and condition of the vehicle before seeing it in person. Comes with the 17-inch painted and polished aluminum rims. Firestone Destination 245-65R17 tires with about I'd say 60 to 70 percent of the tread left maybe even a little bit more. Hydro blue one of my favorite colors on the Cherokees. Trailhawk is definitely my favorite package. Comes with the HID headlamps. These seven slotted granite crystal trim to grill. You get the black hood decal. That's to prevent glare when you're going down the mountain side. Off the hood. No dents or dings on that front fender. Very nice condition and the passenger side rim. No scuffs or scrapes on that. As you go down this side of the Jeep you can see just how clean the body is how reflective and mirror-like that paint is. We take these HD videos so if you are far away or even if you're close by and just cannot make the trip down you can still see the vehicle hear the vehicle and have confidence in what you're looking at before you even get here. So when you do get here, there's absolutely no surprises. In fact, we offer a summit auto fast-pass option in the upper right hand part of your screen. A link right to our website where you can apply for financing. Get pre-approved. See a payment quote. Even appraise a trade-all from the comfort of your own home. So when you get here, there's absolutely no surprises. Back tires have just as much tread as those front tires and that back rim is an excellent condition as well. As we come around to the back of the vehicle, you can see it does have the towing package, the dual rear exhaust which lets you know that it has the V6, the LED tail lamps, receiver hitch, four-pin and seven-pin wiring. The tailgate is an excellent condition and it does have the backup camera. This is a manual raised tailgate. You also get the trail-hawk off-road kit with this vehicle and you can see what this thing hooks on to that gate right there. You do get a spare tire with the jack tools and very, very clean back here as well. Those seats do fold down for extra storage. As you go down this side of the Jeep, just as clean as that passenger side, you can see the rear quarter. Absolutely perfect. You get the granite crystal roof rails and for full disclosure, this back rim is absolutely perfect as well. Down the rest of this side, very nice and clean. It does come with heated mirrors.  Trail-hawk stitched to the back rest, red stitching throughout, and your driver seat height adjuster. Factory all-weather floor mats, part of the cold weather group. You get auto headlamps and tilt and telescopic steering wheel. Power windows, power locks, power mirrors. And as we hop inside the vehicle here, you can see that this one has 29,139 miles. You get the 7-inch LCD display. Outside temp and compass display as well. The heated leather-wrapped steering wheel cruise controls on the right, Bluetooth and information center controls on the left, and audio controls on the back of the steering wheel. It comes with the 8.4 3C radio, AM, FM, and Sirius XM radio capabilities. You also have heated seats and heated steering wheel buttons, and you can do your climate control here as well. Now what's nice about this radio is that it does not have navigation, but if you wanted to add navigation to this radio, you can definitely do that for $595.00. See your sales professional for more details. Down here you can also do your climate control if you don't like doing it on the screen, and you have a start-stop and stability control buttons right there. So you can turn that start-stop feature off on the vehicle. Right here is what makes a trail-hawk a trail-hawk. You get the four-wheel drive low. The downhill assist control, the speed select crawl control, and the locking axle control right there as well. Auto snow, sport, sand mud, and rock features, and a neutral setting for flat towing. You get an SD card, AUGS, and USB. Nine-speed automatic transmission, and the factory all-weather floor-mount on the passenger side is in nice shape as well. In-seat storage on that passenger seat, the headliner is in excellent condition. And you do get map lights up here as well as 9-1-1 and assist buttons in the rear-view mirror. Those are features of the vehicle. I also want to show you that's where your backup camera shows up with the centerline for getting your hitch right up to the trailer or boat or whatever you may be towing. And it does have dynamic rid lines, meaning that they turn with the steering wheel as you turn the steering roll. We'll take a quick look at the back seats, and then we'll check out under the hood Back seats are just as clean as the front seats. No rips, no tears back here. It does have the latch child safety system. No rips or tears on the seats. Ten airbags in this vehicle, including rear knee bolster airbags. All other floor mats, and you do get another 115 volt, 150 watt plug-in back here. Get the child safety locks as well, and we'll take a quick look under the hood. I also turned the headlamps on so you can see that they are HID headlamps. So they started putting HIDs in these vehicles in 2017. So this is the first year that they came standing on the latitude and trailhawk. Under the hood we have the 3.2 liter V6 Pentastar motor 271 horsepower engine base. Very clean, runs very smooth. This Jeep has been fully safetyed and inspected by our service shop. Has a fresh oil and filter change. All the fluids have been checked and topped off. The vehicle has been gone through mechanically. 100%, and is 100% ready to go. I'd highly recommend this one from a quality and condition standpoint. And to see more pictures of this Jeep or one of our other 450 new and used cars, trucks, SUVs, minivans, wranglers, half-tons, three-quarter-tons, one-tons. You name it. We got it. Go to our website www.summitauto.com Full pictures and descriptions of every single vehicle from two locations all at summitauto.com. If you'd like to check out more HD videos, you can go to youtube.com slash summit auto. Remember to like, subscribe, and share on this video and all the videos that you see there. In fact, in a second you will see a link to subscribe to our YouTube channel on your left. A link to more used inventory videos like this one on your right. If you've not been to our website on the bottom link to this vehicle on our website, click those check us out. And we really look forward to helping you with this super clean 2017 Jeep Cherokee Trailhawk in Hydro Blue with the V6 and Cold Weather Group. Thanks again.


Think Tech Hawaii, civil engagement lives here. Aloha, and welcome to Talk Story with John Waihe. Today's guest is a professor at the University of Hawaii and actually becoming one of our political pundits here in Hawaii. You'll see him. You see him at every election. He's the guy that people turn to for any advice or any trends or anything dealing with politics. We are so lucky to have you back. You were here two, three weeks ago, and it was right after the debate at Kamehameha Schools, and we were talking about who were going to be the winners and losers and so forth. Now we know. At least we know from the primary election. So what are your thoughts in general? Tell us a little bit about this election. Well, I guess a lot of what we predicted was going to happen did happen, but it was really up and down. The most surprising thing, of course, is that Governor E. Gay won. He was down 20 points. Some internal polls had him down 24 points back in March and April, and he came back and he beat Colleen Honabusa by 7 percentage points. So in politics, that is really an incredible turnaround. That was pretty incredible, and he did it in a relatively short period of time. Exactly. Give me some of your thoughts on what are the factors that led to that. Sure. I think it's really two things led to this. The first was that Colleen Honabusa really didn't run a good campaign. I mean, it's difficult because there aren't big ideological differences between both of them. Yeah, that's one thing. I remember doing some interviews, and people asked me what the differences were, and I really, really, they weren't at all. Minor stuff. Minor ways of approaching it or something, but they were not ideologically too far apart. So really, it was a campaign based on personality, right? I mean, who do you trust more? And Colleen Honabusa wanted to frame this as really a referendum on E. Gay's leadership stemming from the false missile alert, and that was the darkest days of the E. Gay administration back in January, and he was still paying for it when those polls came out in March. The problem is, I think Colleen Honabusa and her team got a little complacent, maybe a little arrogant, certainly a little lazy. She made the decision not to resign from Congress, so she wasn't in the state for a crucial period, I think. And the way I can characterize the campaign, it seems like she was really harping on the missile alert. Then we almost didn't hear from her for several months, and then the campaign started up again in June, but in that time, E. Gay really was able to consolidate some support. I think she also got a little lucky, which is the second thing. I mean, I want to say lucky politically, not for the people who... Yeah, you're very careful how you say lucky. Right. Not lucky for everyone who had experienced, had to experience the floods on Kauai, or certainly the eruption on the Big Island, but for... Yeah. In fact, there was some pundits who said that Madam... Was that you? Who said Madam Pelly... I don't think it was me, but I agree with the sentiment that he... This allowed him to show leadership. He was on TV all the time. He was really visible in both of those disasters. So I think it caused some people to give him a second look. But also, I mean, really, Neil Abercrombie said this, and I agree with him, that David E. Gay can't win, but Colleen Honobusa can lose. And I think that kind of sums it up. I mean, it goes to show that a strong campaign is essential, even if you think you're going against an opponent who's really weak. It was amazing because, again, I don't have the stats, and you may eventually, or you may have it now, but it seemed like the amount of money that was spent on these... The governorship was actually a lot less than normal. It was less than normal. I mean, partly we're comparing it to when E. Gay defeated Abercrombie. Right. Abercrombie spent about $10 million. So that was... Yeah, Neil spent a lot of money. Yeah, that was a big money. And he was an incumbent, and you would expect an incumbent to have a lot of money. David didn't seem to know, frankly. And so you're right about that. I don't think people have talked about that much, but overall spending was lower. Really, when we talk about money and how that played a role in this race, you're really talking about one organization, which is the V-Change Now, the Carpenters, you know, and exactly.  But the Carpenters, in my opinion, were the real losers. Oh, really? Yeah. Because they were back in Hanabusa. Well, not only Hanabusa, but in general, you know, yeah, well, they won the Lieutenant Governor's Race. Right. I mean, they're in Dorsey won the Lieutenant Governor's Race. They spent a million bucks on that race. And there are some people, myself including, who are a little cynical, and we see that if you spend that much money to win that particular position, which comes with no immediate, you know, no immediate anything, authority, you must be... You can do name changes. That's really... You have, yeah. Well, at least in the past, when I was Lieutenant Governor, you could... You were in charge of elections. I was in charge of elections. So we had something to do.  Exactly. But nevertheless, so what are you doing? Well, the only thing it looks like you're investing in is the fact that the common governor can only serve one more term. Yeah. And I think that's the investment. Yeah. And so, you know, you're looking for... And so maybe that would, in the long run, make them, or strategically, a winner. But for all the other races that, where they went negative and so forth, I don't think... I don't know of a single one where they won. No, I think you're right about that. I mean, if you're talking about the two most high-profile ones, they lost the governor's race because they really didn't start funding Hanabusa until late in the game. I think because they thought she'd win, they didn't need her help. But the second big one is the city council race, Carol Fukunaga's... Oh, they really were really nasty with Carol. Yes. And she, as it turns out, actually won enough not to be in a runoff. And the Carpenters-backed candidate, Tyler de Santos-Tom, he got third. He came in third. And I think it was largely because of that. There was a huge miscarriage. Well, I think there was a reaction to it. Yeah, absolutely. And it might have been, I don't know what the future will hold for negative campaigning. It's too attractive a drug, you know, it seems very addictive. But at least in this election, it seemed like the voters just said, you know, we're not going to be taken in by all of that. Yeah, I think I mainly agree with that. I mean, that was true about the false misalert that the Carpenters were running against Igay at the end. It seems like people really returned off with that. They got tired of it. Yeah. You know, one of the things about Igay was that it turns out to be pretty hard to run a negative campaign against David. Sure. Because he's a nice guy. People like him. He's a nice guy. He hasn't done anything. He's a pretty ethical guy. He hasn't done anything that could be considered negative, you know? And so, what else you got besides the, you know, the missile crisis, and then he, and all of a sudden he's found his voice. Right. He's been much stronger. You know, I watched him over the course of the election, and he actually really grew in terms of public persona. I think so too. But the Igay people, they did a little bit of negative campaigning. I think it was more subtle, and it made it more effective. I mean, they were reminding people of this land deal in Koalina that happened a long time ago. Yes, yes, yes, yes, yes. They were subtly suggesting, maybe Hanabusa wasn't that trustworthy. You know what is so funny about that is that the land deal that happened really was built around the idea of building on the quarry. There you go. Right. Right.  But the many of the people or the organizations that were bringing that up in support of David, because I think there were some like pact-type suggestions, were people who had actually supported the deal. I didn't know that detail. That's great. That's the problem with building politics for too long. Were people who wanted the quarry, you know, and were lobbying for the tax. This is a kind of weird election. You know, the other ironic thing is a lot of the people on the Igay team were Abercrombie people. Well, almost a hundred percent. Almost a hundred. The people that the Igay, well, when Igay ran the first time, you know, you had Governor Ariyoshi and Governor Kaitano, and I was with Governor Igay, I mean Governor Abercrombie, you know, and along with all the people. And then when in this race, we all went over and actually helped Governor Igay. And so it says something about our party. I don't know what exactly. Maybe some scholar like you might find out, but it showed that there was flexibility in the situation anyway. It was surprisingly surprising. Well, for me personally, for me personally, I had a hard time in this election because I actually personally really like Congresswoman Honobusa. I actually helped her campaign twice. Yeah. And I am convinced that had she stayed in Congress, she would have evolved into one of the most, you know, most important people there. But on the other hand, you know, as with David Igay, he was the kind of person that actually grows. In my opinion, in the office, he actually visibly grew and doing this campaign he did too. But what about the lieutenant governor's race? Now outside of Josh Green, Josh, you know, Josh's, we were at the unity breakfast yesterday and I looked at the governor when Josh was up there giving his speech and I said, you're going to have a really interesting time in the campaign and later on. Because Josh is, well, he's a medical doctor, right? And he doesn't mind telling you that he is. No, I think it's every third sentence.  Right. And the state senator. And the state senator. And I'm thinking to myself, I remember when politicians were saying they didn't inhale, you know, and here we are all these years later and I said, this is going to be an interesting race. It is, it is. It's going to be an absolutely interesting race. I'll predict something though. I think that Andrea is not going to be someone that they can take for granted. Her party is in shambles. I don't know what kind of ground game if all that they have beyond a few, you know, probably district level people, but she is a very intelligent, very articulate. She connects well with people.  She really has a lot of local support. She's been involved in her community for years. Well, she does. She's not ideological. Yeah. She can make it pass any type of ideological, you know, ideological trap that's out there that may not fit with people in general in this state. But the Republicans just have, at least here, just have a terrible time running in any event. I mean, Kacinich was on television the other day and he was talking about this is a party that just a few years supported free trade. Yeah. And now they're putting tariffs on that used to be a Democrat position in a sense. Oh, yeah. It was the worst of all. It's what caused us to start losing elections was that we started to become protectionist. Exactly. And that's going on. He says, as a family-based, supposedly family-based party, we're sponsoring policies that separate children and families. Even if you're worried about immigration, why would you do that?  For no good reason. And so the parties really change, you know?  That's why I think that we had a discussion on the election night. I had a discussion. Oh, with Sam Sloan. Yeah, with Sam Sloan.  And then I, and Duke Iota was there, and he's a little to the left of Attila, but not much. And then they're going to have an interesting time trying to rebuild a party. Well, they're going to go from five seats now to four, because they're Republican candidate for Andrea's seat was disqualified because they don't even have somebody running. No, no, no, they can't win it. They have no one running. So no matter what the best case scenarios, they go to four. Well, I tell you, we're going to take a short break right now. We'll come back and we'll talk about more winners and losers and other except exciting issues with this recent primary election in Hawaii. Aloha. My name is Mark Shklav. I am the host of Think Tech Hawaii's Law Across the Sea. Law Across the Sea is on Think Tech Hawaii every other Monday at 11 a.m. Please join me where my guests talk about law topics and ideas and music and Hawaii Ana all across the sea from Hawaii and back again. Aloha. My name is Calvin Griffin, the host of Hawaii Uniform. And every Friday at 11 o'clock here on Think Tech Hawaii, we bring in the latest in what's happening within the military community. And we also invite all of your response to things that's happening here. For those of you who haven't seen the program before, again, we invite your participation. We're here to give information, not disinformation. And we always enjoy response from the public. Join us here, Hawaii Uniform, Fridays, 11 a.m. here on Think Tech Hawaii. Aloha. Aloha. And welcome back to Talk Story with John Wahee and my special guest, local political pundit, Colin Moore, professor at the University of Hawaii. And I guess you're the head of the public policy. Public policy. Yeah, so this becomes something that you should know a lot about. Yeah. Okay. Winners and losers. Okay.  Okay.  Losers are, well, certainly Colleen Honabusa, but beyond that, I think, is more generally, actually, the old Noe group of the old Noe political class here in Hawaii, actually, because Colleen Honabusa lost, Jiltacuta lost, who was also backed by some of the folks around Senator Inouye, strong political figures like Jennifer Sabas. And that I think is really, I mean, that's a big moment here, because those have been power players for a long time in the state. You know, that's right. That's right. And they have, yeah, they've been active. Oh, yeah. And all the people that they seem to be associated with didn't do well. And along with that, I mean, another person who is certainly an associate of the senator and a major political figure is Mayor Caldwell. I think he was a big loser last night, too, because the candidates he was backing, people like Bobby Bunda. Yeah, it's interesting. Colleen Waters didn't perform well. As a mayor, he went out and, you know, in a sense, tried to elect a council that was closer to himself politically, and that didn't happen. No. Frankly, there was one race that surprised me. Well, there were a couple of races that surprised me. But the one race that surprised me was Bobby Bunda losing on the North Shore. I didn't think that was possible. I didn't either. I mean, it's not that he lost. He lost badly. Right. It wasn't even close. And so maybe the third group, I'd say, of losers, are older established politicians trying to get back into politics. So you could say Clinton, he, Bobby Bunda, this sort of a group who joined Yukimura on Kauai. That's right. She's got third place against Kawakami, who dominated that election. Wow. So a lot of these old timers trying to get back in did not do well. How did Gary Hooser do? Or did he run at all? No, he didn't run. He didn't run. Okay. But he was actually smiling on election night and telling me that he was sort of happy with the results some of his progressives got, but I didn't see anything. So maybe, so the only person I can think of who would have been in that group who won is Amy Perusso, who won in District 45 or 42, which was filled by an appointee, Leigh Lermont. But that was a surprising victory, although overall I'd say the progressives didn't do well. I mean, so the most well-known who ran on that ticket is Kaniela Ng. Yeah. Kaniela was an interesting race, you know, because he took a lot of progressive positions. And I think that when the financial reports come in, he probably had a lot more money than people realize for a campaign that didn't take corporate contributions, which shows you the power of the internet, power of raising money. He was backed by national progressive organizations. I mean, the Democratic Socialists of America were increasingly influential. I mean, a lot of mainland interest in that race, who were convinced that he was going to perform well, but he got 6% of the vote. It wasn't even close. I know that for a lot of people that were early on thinking about, you know, giving him a chance at least, the whole episode on Danny Noy. Yeah, that was bad. The campaign spending violations. And the campaign spending violations. In fact, I heard some young people, which is, you know, I actually felt sorry for him on this, on that issue, but I heard some young people yesterday talking about the fact that, you know, if you're going to be a pure progressive, you better know something about your finances, you know. And what they were saying was they didn't vote for him because of that issue. And I said, well, you know, everybody ought to have a second chance. Which is, by the way, something that works better for the religious right, you know, because they start off thinking people are as sinful to begin with. And therefore, redemption can happen. The trouble with the left, the religious quote-unquote, the secular left, is that there's no redemption possibility. That's right, that's right. Yeah, yeah. He suffered with that. Although I'm not sure, no matter what, he would have been able to. What about the competitors and their guys? All right, so. Negative campaigning. Negative campaigning. A lot of negative campaigning with them.  Right. The candidate, they put him there. And it was the one candidate which was pretty much positive. It was all positive. I can't think of or remember a single Josh ad that was negative. It was all positive. I mean, it was Josh Green with babies. It was Josh Green at the hospital. It was Josh Green ad nausea. Yeah, yeah, looking like the greatest guy ever. And they didn't go negative in that race. I mean, they could have gone negative against Jill Takuta, because I think one of their motivations in backing Josh was that they were angry at Jill. So that worked for them. I mean, and in a crowded race like that, you're really talking, I mean, that's really a moment when money can make a huge difference. A lot of unknown candidates.  Oh, nobody knows who you are. So spending that kind of money can really raise your profile. I remember when I was the lieutenant governor, you know, my communications director was a gentleman called Chuck Friedman, who you might know. He works now for a set of shots. When I used to tell him, your job is to get me in the media every day. And then when I became governor, and he was my communications director, your job is to keep me out every day, you know, because politicians don't realize it. They think everybody knows who they are, but they really don't. And the cops did a good job with Josh Green's election. They did. But they didn't do a good job with everything. No, on the negative stuff, it just didn't work. It didn't work. It didn't work against EGAY, those false missile alert ads. I think they, in fact, what I heard from some internal polling was that actually it was hurting that those ads were less likely. Yeah, they were tiresome. And then they had this really brutal, I mean, one of the really dirtiest mailers I've seen in a long time against Carol Fukunaga. Oh, wow. Yeah, that was, you know, and that didn't work. And it hurt. In fact, it probably elected her. I think it did. I think she got more support. So it was a big failure. They endorsed Tyler, Dostoevostam. Who I thought, you know, as a young guy in the party, had a great future. He's a strong candidate. He's a strong candidate. And to have, you know, to see where he ended up, it's kind of surprising. It was to get third place. And I think that was due to that mailer. I really do. I think it hurt him. I don't know if people realize this, but isn't the first time that Carol had to face, not that particular issue, but a spirit-type campaign. In the first campaign she ran for the House of Representatives, it came right after the 78th Con Con. This is a little bit of history for you, history buffs. And she was in the crowded race in the Manoa Sea. And all of a sudden, her opponent, who was a protégé of one of the leading senators at the time. I'm not going to name names because we have all forgiven and forgotten each other. But anyway, they came out with a very negative ad accusing her of stealing furniture from the Constitutional Convention. Stealing furniture? Yeah, really, it's like incredible.  She really is. But fortunately for her, right after that happened, the news people interviewed her.  And she won the election. And so don't do that to her. Doesn't work. It doesn't work. OK, Ed Case. Ed Case. So no surprise that Ed Case won. Well, beautiful campaign. Yes. People talk about him going in late. That was all nonsense. He was running for at least three months before he filed. Absolutely. You know, Ed has ran before. And I never thought that he ran any campaign that was worthy of reproduction. But this time, he did everything almost perfect. And coming in late was a strategy. Look, none of those other candidates adapted to the reality that he was in the race. Plus, when he came alone, the day that he declared, the second later, his campaign was in full swing. Exactly. It wasn't one of these things where you declare and then you wait two or three weeks while you try to get it together. You know, he did it. And he was sign waving the next day. I saw him.  But you know, his son is at the University of Hawaii now. And I happened to be at a class that he was at. And I told him. I said, you know, your dad ran a good campaign. And congratulated him, really. And he also did something that I thought was really interesting.  And who were part of that group. In other words, they were part of the group that were Bernie Sanders's revolution. But they wanted to really work for somebody who, and I don't know what screening process they went through, but they ended up with it. With Ed. And they were, in my opinion, they are some of the best modern grassroots people that I know. Because I tell you, Bernie Sanders ran a great young people's campaign. And if we had to attract that, I might even decide to give him a second chance. I would have loved to have one time when we could have been campaigning at the same site. What do you think? So one question I wanted to ask you is the leadership of the legislature was against David Ige in this campaign. They all back clean. Do you think that's going to make it tough for him going forward? Well, I think that it would be both sides to forgive and forget and move on. And if I was David and if I were them, I would try to look for a coordinated package for the first session. I would try to meet together and go into some hard discussions and come out with a united package, which I did a few times when I was governor. But I would think if David had a chance he should do that. And if I was Scott Psyche, I would have tried to do that. Ron Cochie is probably more amenable to that sort of thing. He sort of stayed. He was with Hanabusa, saw it off. But not as deep as Psyche and Sylvia. It looks like they're gearing up for a fight, though, with these disputes about the amount of money requested by Harry Camp on the big island. That was really not. It didn't sound democratic. I mean, what you ought to say is we'll do whatever we can to help the people to be gone. You don't say, well, this is a payoff for this. Or we're going to make sure.  But maybe it's part of the maturation process. But if they want to be mature, then what we ought to do is have a democratic package. Well, anyway, thank you very much. My pleasure, my pleasure. And folks, we'll be back in two weeks. And maybe with more exciting political news and advice. Aloha.