Severity: Notice
Message: Only variable references should be returned by reference
Filename: core/Common.php
Line Number: 257
Severity: Notice
Message: Only variables should be assigned by reference
Filename: core/Loader.php
Line Number: 150
I reviewed the 3rd Edition of this work which is noted as being updated to cover Java 8. As with most of the books in the Cookbook series, this isn't for brand new beginners to the language. There are lots of books that serve that purpose and are in fact mentioned by the author in the Preface. As I mentioned on other Cookbook reviews, and still applies to this book as well, is that I am not sure that users will want to read straight through this entire book-I know that I would use it as a reference primarily. As for updates since the last edition (which covered Java 1.5), it seems that Chapter 9 and 6 are the main new sections that cover this new material with other sections being updated with new material in other chapters scattered throughout. Chapter 9 - focusing on functional programming is short in my option but I do think that the general intent of cookbook solutions should be to have a quick solution to a quick question and not spend too much time on trying to teach fundamentals that can (and do) fill entire other books about that topic alone. I will have to say that my preference would not be to have the author rely on his own created libraries to answer questions. Section 10.10-"Reading a File into a String" is one such frustrating use of this situation. I know if I was in a hurry and jumped to that section, I would want to look at code for ideas, not a utility to include. I also believe that there are a couple of ways that the solution could have been presented, including using well-known third-party jars like Apache Commons or Google Guava instead of his own api usage examples. In other words, solutions provided might help you solve your problem but might not be the most common solutions you would see in a development shop.
Overall conclusion: This work seems to follow along well with the Cookbook series and is a reference that I can see myself turning to when I need some ideas or suggestions to get a quick answer and to done quickly.
Check out other reviews and the O'Reilly page:At over 1,500 pages, this work can appear to be intimidating for some readers. However, Kerrisk does a great job of being thorough. I could see this work used as both a reference and as one that one could read an entire chapter at a time. As the title should hint at, this is for those who have a serious interest in LInux programming; it is not a light read for beginners in my opinion. The 64 chapters present a wide and in-depth look at system level programming and the Contents In Detail section make it relatively easy to jump to a specific subject of interest. There are exercises at the end of most of the chapters with selected answers in an Appendix section, but I still view this book at more of a reference book rather than a tutorial driven book to be clear. As other reviewers have stated, I am too impressed with the amount of work that likely had to go into this work to make it such a valuable resource on Linux and UNIX programming.
Overall conclusion: Clear material presented on many topics - a reader can learn a great deal from this work.
Check out other reviews and the O'Reilly page:As with most Cookbook format books, I am not sure that users will want to read straight through the entire book-I know that I would use it as a reference primarily. The entries usually have a Problem/Solution/Discussion section. I appreciate how the discussion sections generally do a good job of trying to explain various aspects of the solution. Even with what I would call an immediate level of Unix knowledge, I was able to learn some new commands. For example, I had not heard about zgrep until this book and had relied on multiple commands in past scripts when this could have done the work in only one. The chapter on secure shell scripts also included information I had not really taken the time to use in my personal scripts. I think that Chapter 12 was an interesting subject topic-End-User Tasks As Shell Scripts. It included solutions to topics like viewing photos in an album and burning a cd for example. While some of these scripts are indeed easily taken care of by free gui programs, it was nice to see examples of how bash scripts could be used in practical and different ways rather than the traditional work tasks alone. However, for the most part, I think that the beginning bash user will likely get the most out of this book. Some of the topics on shell scripting are good for beginners as well as those who haven't written shell scripts for a while and need a good refresher. For bash users looking to start automating parts of their work, this is a good reference to have handy and can help you get real work done with the tips included.
Overall conclusion: Lots of good examples and idea starters for automating your Unix/Linux tasks.
Check out other reviews and the O'Reilly page:Readers need to make sure and note the date of the publication is 2007 (at least the copy I reviewed was still noted as 2007 being the last published year). Of course in that time version numbers of the popular browsers has changed and so have some of the tools. I believe this is even pre-Chrome days (I didn't see it mentioned in this work at least). However, the key is to focus on the 14 rules that are presented and still apply mostly today. If anything, it really is nice to see the tools that have been created since then that have helped make some of these rules more automated for users/developers. If a user has started with Ruby on Rails or some other framework (or even used build tools) that have config options for compressing or combining javascript files for example, it might be enlightening for them to take the time to think about why this might be done while reading the book details. I was impressed to see that the links to the book's related website still were active. Of course performance is a moving target with constant changes in browser techniques and updates, so it is going to be up to the user in the end to measure whether these rules work for their situation. All of the rules presented seem very practical for users to try and provide insights on topics overall to think about when looking at performance. For example, reducing the number of http requests and caching are still very valid subject areas that are still a part of considerations today for web site devs. Tools used today still, like YSlow mentioned in this work, are also good places to start for users looking at performance analysis and an example of its usage is shown in Chapter 15. It is interesting how fast web development has changed in some regards, but most of these rules appear to be part of addressing questions on web performance today Souders' material was very relevant to me despite the 2007 publish date and shows how good the material was to still apply after 5+ years in my opinion.
Overall conclusion: While not very long in page length, this work delivers a lot for users to think about to help improve their web sites performance and proves that the number of pages aren't always the key to a valuable and significant work.
Check out other reviews and the O'Reilly page:This book is not for learning Ruby syntax or about building websites. Instead, it focuses on how Ruby does work under the covers. Explanations use diagrams and are clear overall. While the author does point out C files and some C code, understanding of the material does not depend on C knowledge as noted in the introduction. In my opinion, this is a great work for those trying to bridge the gap between using a programming language and really starting to think about how it works. I would say that the best audience for the book would be those who have some interest in compiler or language design. If you have already focused on such areas in formal course work, you probably won't come across as an in-depth theory approach, in my opinion, in this material (for example if you have the "Dragon Book" sitting on your reference shelf). However, the treatment is very approachable for the interested casual learner to pick up and understand subjects like tokenization and parsing and leave one with a solid foundation. The first 9 chapters focus on CRuby but chapters are also included on JRuby and Rubinius. I appreciated the author's use of "Experiments" such as showing how to use Ripper and RubyVM::InstructionSequence from your own Ruby programs. It's one thing to be able to see an example of YARV instructions for a canned book example but it is even more powerful to have the tools to get the output of your own custom scripts and modifications.
Overall conclusion: Very approachable look at Ruby language implementation. Having been interested in compliers, I found this a great introduction into this specific CS topic. It was also nice to see the book use a real language for the examples. I found the book unlike any other programming book I had read on Ruby and enjoyed the practical look under the hood of Ruby.
Check out other reviews and the O'Reilly page:With a background as a developer, I found this book very approachable having not touched R before this book. It remained close to the R language itself and did not veer too deep into statistics. For a programmer new to the language and the topic, I was fine with the subject matter depth. I really liked that the end of each chapter included a quiz as well as exercise portions. The answers are included as part of the Appendix and I think are a good reminder to readers to try out what they just learned. Part of learning new languages is finding out about different concepts or how data structures are implemented with different names, functions, or packages. Newer topics to me were data frames and factors. These concepts are explained very well and allowed for me to quickly apply existing knowledge from other languages to make the concepts clear. In my opinion, I really liked the chapters involving getting data and on cleaning and transforming. These chapters are very practical and apply to anyone who has had to parse data in one format to put it into another. Topics like loading packages and data and time coverage are sections that you would expect to be in a book for beginners new to the language and hint at the audience this book is geared toward. It is a good starting point for those totally new to the language who will use this as a foundation to dig deeper for specific tasks later.
Overall conclusion: Good for the programmer interested in learning the R language over in-depth statistics.
Check out other reviews and the O'Reilly page:Only having a basic understanding of REST, this book introduced many new concepts and topics to me. For example, I had never heard of the ColIection+JSON standard or JSON-LD. Hypermedia was also a topic that I had barely heard about but was introduced to in this book. I thought it was interesting how the author called out a short process for how to add hypermedia to an existing API as well as if it was worth the effort. These are important questions to ask rather than just suggesting everything needs to be rewritten to be new. Also, standards are mentioned and referred to in this work, which I am guessing is due to the writer's experience as noted on the back cover. Not a negative to include that information, but I was not used to seeing specification notes in many of the traditional tech books I have read recently. The material for me was overall about how to talk about and work with REST concepts correctly. Semantics are addressed as well as when you would probably use this over that, etc. Guidance also seems helpful in sections such as "What Hypermedia Is For". I do appreciate code from the book being out on Github as well as on the book's website. While the examples are in Node.js at this time - it looks like the website is asking for different programming language ports-so examples have the potential to be added/ported over time. In summary, this book is for those looking to really take time and think about their APIs and if they are working with proper (or I guess one could only say proper in the authors' experience) REST techniques. If you need a quick tutorial to get from zero to done fast, this probably is not the material for you. As a side note, I found Appendix A and B as useful and quick references for HTTP codes and headers, but ymmv.
Overall conclusion: I would see this being a good fit for a REST fan who is trying to get even deeper into the proper way to complete their work.
Check out other reviews and the O'Reilly page:I looked at the 4th Edition which is updated for Perl version 5.14 (as the cover states) and some notes on 5.16. This is not a tutorial or introduction book to the language and most beginners likely won't want to start with this as their first Perl book. It really is mostly a reference book on various topics on Perl in my opinion. Some readers might think that some topics are too brief and covered better in other works such as the regex chapter. This is probably true but I do like the different presentation. While the flow sort of seemed to wander around a little bit for my personal preference, it does seem like you are getting some really good advice from authors who know what they are talking about. Seeing brain d foy's name on the author list for this edition was a positive for me. He is highly involved in the Perl community and I have enjoyed his other works such as Mastering Perl. One minor thing that I found very handy is the List of Tables presented after the Table of Contents. I will be using this as a reference whenever I can not find the depth of information I need from command line tools.
Overall conclusion: Not an intro book-but a solid reference.
Check out other reviews and the O'Reilly page:If one has never seen the Head First series, readers who want a straight reference manual will likely find many of the jokes and diagrams to be distracting. Make sure you look at the sample pages or other references as some will note that the presentation just isn't for them. For me, it was nice to have a different layout for variety from the common format of most of the past few tech books I have read. Having some programming experience in various other languages, I approached this book trying to learn more about C# and the .NET ecosystem and experienced a gentle intro to the language overall. One of the things that I had heard about and was curious to dig into was LINQ. Chapter 14 gave some clear examples and explanations of the concepts involved and was good in for general knowledge since these concepts have been ported to other languages as well. Even though I was newer to the .NET ecosystem, this work gave me the knowledge to hit the ground running.
Overall conclusion: Lives up to the Head First series line of resources.
Check out other reviews and the O'Reilly page:I reviewed this upcoming fourth edition while it was part of O'Reilly's Early Release program. I had not seen previous editions of this book, but this edition appears to be updated to include newer Java apis when I reviewed the early release copy. General networking topics are covered in this book but it stays true to its Java language focus and users should not be surprised to see many examples and api signatures throughout the work. The readers that will likely get the most out of this book are Java programmers (with at least a basic knowledge of the language) who need a jump start on the topic of networking in your code. My favorite chapter was URLConnections. To me, it was directly related to practical work I had done in the past and gave me more details that I wish I had dug into at the time. The multiple socket chapters were also interesting reads for me. The more you get into any general programming language, you start to realize that their are many subtopics that one can drill down into and networking is one that deserves in-depth treatment that can be found in this book.
Overall conclusion: Overall conclusion: For the Java developer looking for more networking knowledge to add to their language skillset.
Check out other reviews and the O'Reilly page:As a programmer, I have always been curious about Lisp even though I have never used it in courses or even on hobby projects. This book seemed like a great way to get an intro to the language. I was very interested in what I had heard about Lisp macros and was glad to see an entire chapter discussing this topic that helped me expand my knowledge greatly in this area. The book is full of comics or hand drawn diagrams and while they didn't add much to the material for me, I could see how some readers might like the light-hearted treatment. As far as general format, I did appreciate the code examples with numbers that were referenced in the text. It made it easier to follow the description of the code and which line it was referring. Since I was interesting in learning about the language as a whole, I also enjoyed the start of the book in which it was more about Lisp itself and its history rather than syntax. I applaud the author for tackling this language and making it accessible to more readers.
Overall conclusion: Readers new to the language will need spend quality time with this work to get the most value out of it.
Check out other reviews and the O'Reilly page:When compared to other "Learning" titles in the O'Reilly series, this one can seem intimidating at first due to the number of pages alone. However, the material is still very approachable. While versions still matter for some in the Python community, this work has been updated for 2.7 and 3.3. Personally, i really liked the Test Your Knowledge sections in which questions and answers were presented at the end of chapters-they were quick topics to make you think about what you read. Brand new programmers might need certain chapters in this work more than programmers who are used to another language and vice versa. For example, chapter 2 and 3 are ones that can probably be skipped by experienced programmers about how to get a language up and running on their machines. Coverage of many topics are broad. I really enjoyed the chapters discussing generator functions and expressions. Part 8 of the book is titled 'Advanced Topics'. If I were a new programmer, I would consider skipping the deeper sections and coming back to them in time. It is nice that this book covers a lot of topics-it means that you might have some room to grow with this title as you learn more Python.
Overall conclusion: Consuming the more advanced sections as one learns more Python and the rest in small chucks makes this a solid work that has a lot of information to get one programming in Python.
Check out other reviews and the O'Reilly page:This cookbook seems to follow closely in the vein of other cookbooks in the series. Programmers with as least some experience with Python will likely get the most out of this material. Certain idioms are taught and it is nice to already have a foundation to build upon. Some of the recipes are better used as information from which to start a solution rather than the entire solution-i.e. readers should be able to use this starting point presented and be able to apply it to the specific context they are working in. It should be noted that this edition is geared for Python 3. The format of Problem, Solution, and then Discussion is followed in the recipes and I found most of the Discussion sections informative and worth taking time to read and consider the points presented. There are many practical recipes and I could see this being referenced when in need of a quick thought starter.
Overall conclusion: Solid cookbook that seems to follow the quality of most in the series.
Check out other reviews and the O'Reilly page:Fogus presented the sometimes tricky concepts of functional programming in clear language. It was also refreshing how Fogus explained that functional programming was not the only way to complete a task (and not a mandate that had to be the best solution)-but one way that can work in many situations. Decisions, like choosing Underscore.js, were explained and were welcome considering some books don't explain why they use the toolbox that they do to complete work. Partially applied functions and currying were interesting discussions and I was also glad to see a footnote at least talking about Function.bind performing partial application as well. It appears that Fogus is very current on the topics presented and active in coding work. Having a companion website in which one can open their devtools/console and step through examples right away is very handy as well as the source code being on Github. In my opinion, this book seems to be better suited for an immediate JavaScript programmer who wants to learn a different approach to solving problems. I plan to keep this book handy for reference when I start to think about practical implementations in future development work. Overall, one of the most interesting tech reads I have read recently.
Overall conclusion: Interesting introduction to functional techniques that usually makes the subject matter clear enough for beginner programmers to this subject area.
Check out other reviews and the O'Reilly page:This book served as an introduction into the world of security for me since I have never studied in this area. I like to see discussions involving code and that was one of the reasons I started this book as it seemed very practical. One of the items I could appreciate from this book is the use of scripts for automation-which this topic is of interest to me in my daily work. Since I am a new to most security topics, it was nice to see sections such as Understanding Exif Metadata. Exif was one of those topics that I had heard about and it was nice to see more detail provided in this work. I am not sure if all of these security topics are applicable/effective as others have mentioned since security is always a moving target. However, it is still a nice foundation to help the reader understand different components of what admins should be looking at overall. I am guessing that the use of many third-party libraries probably helps the author cover more material in less pages, so I believe research into those tools might be something readers might want to look into if they really want to dig into the details.
Overall conclusion: Interesting subject matter that kept me involved in reading this material.
Check out other reviews and the O'Reilly page:This book is ideal for the programmer who has only had a casual introduction to pointers. One example is that type size_t is explained and not just shown. Some of the tutorials I have seen use types like this in pointer discussions without giving the full explanation of what is going on. In my opinion, those looking to really understand programming are going to spend some time looking at memory models-and this work was a gentle introduction that was approachable on topics that included dynamic memory allocations. While it wasn't in depth, I also appreciated seeing a mention of the RAII technique and an approach in C. Some new programmers should also find the discussion about function pointers as eye-opening. The section titled "Using Pointers to Support Data Structures" was also full of good introduction material to seeing how pointers could be used to implement common data structures. New users to pointers will also likely be glad to see this book addresses good things as well as bad things to look out for in using pointers as well as examples of the why.
Overall conclusion: Would be a great resource for those looking to dig further into C and trying to master pointers.
Check out other reviews and the O'Reilly page:This isn't the book for you if you want to mainly do tutorials with Ruby. I see it as a good starter book for those really new to computer science as a topic or are just interested in maybe starting to program. I would have used this book when I first began if it were around, especially as a beginner that learned with a book before I had any other exposure to CS. This book would probably be best if it was read before a formal programming class as I would think that most introductory computer courses would cover this material. I really liked Section 7.2 Complexity Analysis at least being touched on in this book. Big O notation is seen referenced in scholastic works and google results-so it is nice to at least have an introduction to these topics. Discussions on sorting and searching are also good introductions to common topics that make for a gentle introduction to this specific area. It was also nice that the authors provide a web link to slides (as well as source code) that followed the chapters in the book. Also, there are Exercises at the end of the chapters, however, I would have liked to see answers for these since this was targeted at newer readers.
Overall conclusion: Would be excellent for the a beginning independent learner.
Check out other reviews and the O'Reilly page:Chris Seibold covers some interesting topics in this work. I agree with other reviews that I have seen in that potential buyers need to look at the Table of Contents and see the list of projects and if they are interesting enough for one to purchase. For example, since I prefer software, most of Chapter 11 about hardware are not likely projects that I would complete. I have no desire to dye my Mac but some users might find it exciting. This book is not specific to Macs completely. Subjects like using Tor and setting up your router are general topics that apply to various setups. I did enjoy learning more about PLIST and how to quit Finder and were items that I completed right as I read the book. I think that looking at the entire book-it is more about how to customize your setup and helps get you to think about making your workspace more enjoyable and moving beyond default settings if a user desired. Advanced computer users (in general) might not find much in this book,; however, newer Mac users or causal users might like this work in getting them more familiar with customizing their setups.
Overall conclusion: This work is for users looking for fun more than anything in my opinion.
Check out other reviews and the O'Reilly page:Matt Neuburg's book is not for the absolute beginner (or timid) as it covers a lot of material. This is not a cookbook and the reader will need to put effort into consuming the fundamentals presented in this book. One of my pet-peeves is books that tell you to go read another book before you start; in this regards, the reader might want to know some c programming before tackling this text. However, I wouldn't want to see the size the this book with more information crammed in-so I will let that one pass. The 3rd edition focuses on iOS 6.1 and Xcode 4.6. If you are looking for a book on a specific version of iOS, you might want to make sure you buy the right version of this book as the author makes it known that his primary concern is not in backwards-compatible code. Overall, it seems that the book is very similar in chapters and sections as the last edition, but was revised to have the newest code as part of all examples. It is refreshing to see a work totally reworked to reflect current coding versions and not just updated in various sections. The added sections on iCloud and Core Data were welcome additions to this version that also show value-added updates. Personally, my favorite by far of this book itself is Part 1-Language. Objective-C seems to have various treatments in texts and online, but these five chapters are a great and complete introduction to Objective-C in regards to both syntax and concepts.probably had a limited audience and I understand why it was likely removed.
Overall conclusion: Readers will need to approach this volume ready to spend some time with this reference.
Check out other reviews and the O'Reilly page:While not an important part of the book itself-the foreword was one of the best I have read in a technical book. It really describes how many people get started with PHP-it is accessible. This book provides a lot more structure than randomly placing PHP statements that have been googled together. I have not had the chance to review other editions, but it was noted that the material had been updated for the latest features of PHP version 5. With over 500+ pages, this feels like the O'Reilly books from the past that covered a lot of material and feels like a solid reference all around. One example was learning about Traits. While I knew of them from other languages, I had no clue that they were part of PHP until this book since I am only a causal user of the language. Chapter 7 dealing with Web Techniques will probably be immediately useful for someone trying to get a site out quickly. SQLite and MongoDB coverage was welcomed and showed that current updates are indeed included. While of course not complete by any means in scope, Chapter 12 Security was a great introduction to the various security concerns developers need to think about including XSS, filtering input, and session fixation to name a few. One minor complaint was the debugging chapter was very short and did not seem to add that much value to me. I would have liked to see the chapter about extending PHP with C from the 2nd edition, but that subject probably had a limited audience and I understand why it was likely removed.
Overall conclusion: Solid reference and learning guide for PHP. I don't think you could go wrong with "Programming PHP".
Check out other reviews and the O'Reilly page:Simon St. Laurent takes the reader for a gentle look at the Erlang language. I would recommend this for a programmer that knows or has a good foundation in any programming language as this is not meant to be a learning the basics of programming book. In other words, one should know what a loop is and flow control concepts before reviewing this book. While I did not have much exposure to Lisp, I did not have any trouble picking up the syntax from the book itself. This book is really about a quick introduction and it is then your job to dig into the additional resources or websites that you need to in order to learn more. One of the first things that I did after finishing this work was go out to GitHub and look at real Erlang projects which the author had suggested. I was impressed that I had a great foundation for being able to understand what was going on just from reading this book. For example, I saw the .hrl includes and knew right away that records would be defined in those files. I was also able to see the OTP templates being applied in code as well. I left this book wanting more knowledge about Erlang and looking for other books that would expand this knowledge. I would say that this book is really for those who are trying to invest time in learning more about the language beyond just a 30 web tutorial; however, one that is still only interested in an introduction.
Overall conclusion: If you want a brief introduction to Erlang-this is the book for you. If you need a complete reference or many detailed examples or tutorials: you might want to check out the other Erlang books out there.
Check out other reviews and the O'Reilly page:Cody Lindley takes the reader into the depths of the DOM with his work. This book does what it says it will in the beginning introduction by presenting a very terse cookbook: you won't be seeing tons of lengthy explanations. One of the best perks of this book was that in ebook form->the code was presented with links to code examples in jsFiddle (with Firebug lite) or github. This made it easy to run, modify, and look at the code in depth without even having to setup an environment or retype examples. Chapter 12 was also a nice addition to this book as it showed a short example of taking what you learned about in the previous chapters and thinking about the development of a dom library in many ways similar to what jQuery does today. While not very long, I also liked the chapter on DocumentFragments. It was nice to see that this often overlooked part of the DOM got some attention.
Overall conclusion: This book is great for a very specific niche. If you want to take a quick tour of the DOM-then this is the book for you. Don't expect long lectures on the topics-just short examples.
Check out other reviews and the O'Reilly page:As we try to get past the simple tutorials we find online and get to some real examples-I figured we could learn by looking under the covers at one of the most popular frameworks. By looking at an interesting function in jQuery you can see that while the inner workings of these functions do a lot, they still rely on the core of javascript. In other words, the magic really comes from putting multiple pieces all together.
This specific example is from the 1.7.1+ version. I encourage you to look at the api document for the function on. Past users might have used live or delegate. However, by looking at the code you the meat of the logic is passed on to a different method: on.
http://www.andismith.com/blog/2011/11/on-and-off/ is also a good article that talks about this. Buts lets find out about this how I did first->by looking at the code that is out there and availble for us all to look at.
bind: function( types, data, fn ) {
return this.on( types, null, data, fn );
},
live: function( types, data, fn ) {
jQuery( this.context ).on( types, this.selector, data, fn );
return this;
},
delegate: function( selector, types, data, fn ) {
return this.on( types, selector, data, fn );
},
You notice a common theme here...all of those methods are calling on.
BTW, you can find the on api document here: http://api.jquery.com/on/
Enough with all the documents-lets look at the code and find the interesting parts. I found this code out at:
https://github.com/jquery/jquery/blob/master/src/event.js
on: function( types, selector, data, fn, /*INTERNAL*/ one ) {
var origFn, type;
// Types can be a map of types/handlers
if ( typeof types === "object" ) {
// ( types-Object, selector, data )
if ( typeof selector !== "string" ) { // && selector != null
// ( types-Object, data )
data = data || selector;
selector = undefined;
}
for ( type in types ) {
this.on( type, selector, data, types[ type ], one );
}
return this;
}
if ( data == null && fn == null ) {
// ( types, fn )
fn = selector;
data = selector = undefined;
} else if ( fn == null ) {
if ( typeof selector === "string" ) {
// ( types, selector, fn )
fn = data;
data = undefined;
} else {
// ( types, data, fn )
fn = data;
data = selector;
selector = undefined;
}
}
if ( fn === false ) {
fn = returnFalse;
} else if ( !fn ) {
return this;
}
if ( one === 1 ) {
origFn = fn;
fn = function( event ) {
// Can use an empty set, since event contains the info
jQuery().off( event );
return origFn.apply( this, arguments );
};
// Use same guid so caller can remove using origFn
fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
}
return this.each( function() {
jQuery.event.add( this, types, fn, data, selector );
});
},
Lets take a step back and think about this code from a high level. Even if you are a beginner to Javascript: notice that most of this logic is what you learned in almost all basic tutorials. If, else if, the difference between === and ==, and typeof all take up a large part of this code base. This famous framework that is popular boils down to some pretty basic stuff. No disrespect to the creators and contributors to jQuery-I am just trying to let the beginner coders know that advanced and cool code is within their reach. Just think->the ability to add events to elements that you dynamically update your page (such as by ajax) that weren't even there when your page loaded is done with this logic.
How, lets look at the interesting parts (in my opinion that is!). While you may have seen it before: lines like this are cool: data = data || selector; You might wonder why this is being used since you are used to if being found in conditional statements. However, you can use this trick to check for checking for defined. If the variable data is undefined->then selector is assigned to data. This is a quick way in which you don't have to wrap an if statement around it.
Another interesting part of this code that might not be familiar to everyone is the call to apply. return origFn.apply( this, arguments ); Lets look at the apply function documentation: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/apply All this comes down to is an ability that the language itself gives you to take a function and using the object passed in, allows you to call that function you wrote once on whatever object you pass it. It also lets you give arguments to that function and is similar to the call() function.
Perhaps the most important line of this function is the following: jQuery.event.add( this, types, fn, data, selector ); This delegates most of the logic to another jQuery function event.add(). Guess what your assignment is->follow the source code to figure out where it goes from there ;)
In summary, the important thing to take from this is that cool things can be accomplished with just a little advanced knowledge. You see that most of the code is decision logic and formed from common and basic building blocks. And perhaps the best part of all of this is that the source code is out there for us to learn from. While it is even better to contribute if we can, until we fell comfortable-it is still doing a great service by being an example of what we can aspire to understand and accomplish.