The Art of Readable Code by Boswell Dustin Foucher Trevor & Trevor Foucher
Author:Boswell, Dustin, Foucher, Trevor & Trevor Foucher [Dustin Boswell]
Language: eng
Format: epub
Tags: COMPUTERS / General
ISBN: 9781449314217
Publisher: O'Reilly Media
Published: 2011-11-02T16:00:00+00:00
Other General-Purpose Code
When debugging JavaScript, programmers often use alert() to pop up a message box that displays some information to the programmer, the Web’s version of “printf() debugging.” For example, the following function call submits data to the server using Ajax and then displays the dictionary returned from the server:
ajax_post({ url: 'http://example.com/submit', data: data, on_success: function (response_data) { var str = "{\n"; for (var key in response_data) { str += " " + key + " = " + response_data[key] + "\n"; } alert(str + "}"); // Continue handling 'response_data' ... } });
The high-level goal of this code is, Make an Ajax call to the server, and handle the response. But a lot of the code is solving the unrelated subproblem, Pretty-print a dictionary. It’s easy to extract that code into a function like format_pretty(obj):
var format_pretty = function (obj) { var str = "{\n"; for (var key in obj) { str += " " + key + " = " + obj[key] + "\n"; } return str + "}"; };
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Coding Theory | Localization |
Logic | Object-Oriented Design |
Performance Optimization | Quality Control |
Reengineering | Robohelp |
Software Development | Software Reuse |
Structured Design | Testing |
Tools | UML |
Deep Learning with Python by François Chollet(12609)
Hello! Python by Anthony Briggs(9931)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9806)
The Mikado Method by Ola Ellnestam Daniel Brolund(9797)
Dependency Injection in .NET by Mark Seemann(9354)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8317)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7775)
Grails in Action by Glen Smith Peter Ledbrook(7708)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7573)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(7239)
Microservices with Go by Alexander Shuiskov(7001)
Practical Design Patterns for Java Developers by Miroslav Wengner(6913)
Test Automation Engineering Handbook by Manikandan Sambamurthy(6866)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6430)
Angular Projects - Third Edition by Aristeidis Bampakos(6280)
The Art of Crafting User Stories by The Art of Crafting User Stories(5798)
NetSuite for Consultants - Second Edition by Peter Ries(5725)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(5547)
Kotlin in Action by Dmitry Jemerov(5078)
