The document discusses different approaches for handling asynchronous code in JavaScript, including callbacks, promises, and async/await. It provides examples of each approach, such as using callbacks for sequential asynchronous functions, chaining promises together, and using async/await to write asynchronous code that looks synchronous. It also addresses error handling with each approach, noting that while async/await code looks cleaner, error handling can be more complex so different options like try/catch blocks are demonstrated.
How do you measure the quality of your code? Performance and testing are just one aspect of code, in order to meet deadlines and make maintenance quicker you also need your code to be readable, decoupled and generally easier to comprehend and work with. This talk will go over tips and exercises to help you identify trouble areas, refactor them and train you to write better code in future projects. Come make your code look and function better.
The document discusses the history and evolution of jQuery, including major releases and changes over time. It describes how jQuery moved from a concatenated file structure to using RequireJS and module dependencies. It also covers changes in licensing between versions. Finally, it provides examples of how jQuery handles different selector types and error checks selector input.
As presented at ZendCon 2014, AmsterdamPHP, PHPBenelux 2014, Sweetlake PHP and PHP Northwest 2013, an overview of some different patterns for integrating and managing logic throughout your application.
This document summarizes a presentation about remote code execution in WordPress. It discusses how PHP object injection can allow arbitrary code execution by abusing PHP's unserialize function. It explains how a vulnerability in WordPress' user meta data serialization could allow storing a serialized PHP object in the database that executes code upon unserialization. The presentation provides details on UTF-8 encoding issues in MySQL that can be leveraged as part of an exploit. It then demonstrates a proof-of-concept exploit that uses custom PHP classes to write a file upon page load via callback functions.
This document discusses exploiting PHP unserialization vulnerabilities. It begins by introducing the presenter and explaining what unserialization is and how it can be insecure if magic methods like __wakeup or __destruct are executed after unserialization. Potential vulnerabilities are demonstrated through examples. The document then discusses more complex chains that can be used to exploit unserialization, including examples from real-world projects like Kohana and exploiting serialized data stored in databases. It describes building a tool to automatically find chains in PHP code that could be exploited via unserialization and demonstrates its use on sample code. The document concludes by noting the challenges of automatically generating exploits due to the lack of static analysis in the tool.
Performance and testing are just one aspect of code, to really be successful your code needs to be readable, maintainable and generally easier to comprehend and work with. This talk draws from my own experience in applying the techniques of object calisthenics and code readability, within an existing team. It will help you identify trouble areas, learn how to refactor them and train you to write better code in future projects avoiding common pitfalls.
This document discusses JavaScript generators and how they can be used to simplify asynchronous code. It begins with a simple generator example and then explores more complex use cases like yielding promises, error handling, and parallel processing. Generators allow long-running operations to be written in a synchronous-looking way and are useful for tasks like I/O. When combined with co-routines, they provide a clean way to write asynchronous code that looks synchronous.
As developers we write code everyday, only to frown at it a week after that. Why do we have such a hard time with code written by others and ourselves, this raging desire to rewrite everything we see? Writing code that survives the test of time and self judgment is a matter of clarity and simplicity. Let's talk about growing, learning and improving our code with calisthenics, readability and good design.
This document discusses best practices for developing a chess game app called ChessMate. It covers topics like architecture patterns, design principles, testing practices, code quality, and project organization. Examples are provided to illustrate concepts like separation of concerns, dependency injection, protocol-oriented programming and value types vs reference types. The goal is to build a well-designed, extensible and maintainable chess app following industry standards.
Workshop JavaScript Testing. Frameworks. Client vs Server Testing. Jasmine. Chai. Nock. Sinon. Spec Runners: Karma. TDD. Code coverage. Building a testable JS app. Presentado por ing: Raúl Delgado y Mario García
Presentation made at GTA meetup in 2012-02-07. Object Calisthenics is a set of exercise rules to reach better code, maintainable, testable and readable.
JavaScript is one of the most popular skills in today’s job market. It allows you to create both client- and server-side applications quickly and easily. Having a solid understanding of this powerful and versatile language is essential to anyone who uses it. “Practical JavaScript Programming” does not only focus on best practices, but also introduces the fundamental concepts. This course will take you from JavaScript basics to advanced. You’ll learn about topics like Data Types, Functions, Events, AJAX and more.
Have you ever used PHP's built in reflection, only to find you can't do quite what you wanted? What about finding types for parameters or properties? What about reflecting on classes that aren't loaded, so that you can modify them directly? Better Reflection is an awesome new library that uses magical time-warp techniques* (*actual magic or time-warp not guaranteed) to improve on PHP's built-in reflection by providing additional functionality. In this talk we'll cover what reflection is all about, explore the cool features of Better Reflection already implemented, the difficulties we faced actually writing the thing, and how you can use Better Reflection in your projects to maximise your reflection-fu.
The document provides advice and best practices for writing code that lasts over time. It discusses improving code through practices like making it more comprehensible, flexible, tested, and refactorable. Specific techniques mentioned include object calisthenics exercises like limiting indentation levels and instance variables, using first class collections, and avoiding getters/setters. The document emphasizes continuously improving code through practices like reading and sharing code with others.
As presented at Dutch PHP Conference 2015, an introduction to command buses, how to implement your own in PHP and why they're both useful but unimportant.
The document discusses various techniques in Perl for dealing with reference cycles and memory leaks caused by strong references, including using weak references, extracting needed data from objects before destroying them, and passing objects into subroutines to avoid capturing them. It also discusses analogous techniques used in Objective-C like weak references and guard objects to break cycles.
In a world where users have ever higher expectations from the apps they use, having data always available, even when the device is offline, has become increasingly important. In this talk you will learn how thinking "offline first" not only makes your app architecture better but also result in cleaner code and happier users. I will introduce Realm, a new database for easy persistence, and demonstrate how it enables truly reactive UI's by fitting seamlessly into the standard network stack of Retrofit and RxJava. Finally we will take a look at the new Realm Mobile Platform, which provides real-time synchronization between devices, enabling features previously out of reach for many development teams.
The document provides an introduction to asynchronous JavaScript. It discusses callbacks and their disadvantages like callback hell. Promises are introduced as a better way to handle asynchronous code by making it easier to write and chain asynchronous operations. Async/await is described as syntactic sugar that allows asynchronous code to be written more readably in a synchronous style using await and try/catch. Key aspects like the event loop, microtask queue, and Promise methods like all and race are explained. Overall the document aims to help understand what makes asynchronous code different and newer methods like promises and async/await that improve handling asynchronous operations in JavaScript.
Jasmine is a BDD framework for testing JavaScript code. It does not depend on other frameworks and does not require a DOM. Jasmine uses specs, expectations, suites, and matchers to define tests and make assertions. It also supports features for testing asynchronous code and spying on functions. Jasmine provides tools like spies, stubs, fakes, and mocks to help test code behavior.
Basic JavaScript Object Oriented Best Practices Library MVC Performance Debug Documentation Tools
Structure and architecture, API, security, asynchronity, routing, middlewares, data access, memory, cpu, state management, etc.
In a world where users have ever higher expectations from the apps they use, having data always available, even when the device is offline has become increasingly important. In this talk we will go through different ways of saving data on the phone and introduce Realm as a replacement for SQLite and ORM's. Through an example app it will be demonstrated that thinking "Offline first" not only affects your apps architecture for the better, but also results in happier users.
Learn what's new in Project Wonder's ERRest framework. Also, see some tips about security and versioning for your REST services, and learn how you can use HTML routing to build Web apps with ERRest.
My attempts to make my experience developing Play 2 web-applications (in Scala) more Rails-like. I show 3 frameworks employed that draw nearer to the Ruby/Rails spirit than Play's default offerings.
This document provides an overview of how to build applications with React Native. It discusses React Native's core components like React, ReactDOM and React Native. It also covers topics like JavaScript implementation, building components, styles, platform specific code, animations, navigation libraries and working with data using Redux.
The document discusses the lifecycle of code under test, including defining inputs and outputs, initial testing with positive and negative cases, handling bugs, refactoring code, adding abstraction, how future work may affect tests, and handling legacy code. It provides an example of a function to add two strings, injecting a bug, and walking through testing the code at different stages of the lifecycle from initial testing to refactoring and abstraction.
The document summarizes an upcoming Java user group meeting to discuss Java 7 features. It will cover new language features in Java 7 like binary literals, string switches, and try-with-resources statements. It will also cover parallel programming enhancements like Fork/Join and NIO.2. The meeting will include hands-on demos of Java 7 features and a discussion of upcoming Java 8 features. Refreshments will be provided by meeting sponsor Ovialis.
The document discusses different patterns for handling asynchronous code in JavaScript: callbacks, promises, and AMD (Asynchronous Module Definition). It outlines issues with nested callbacks and inflexible APIs. Promises and AMD aim to address these by allowing composition of asynchronous operations and defining module dependencies. The document provides examples of implementing PubSub with events, making and piping promises, and using AMD to load dependencies asynchronously. It concludes that callbacks should generally be avoided in favor of promises or AMD for asynchronous code.
There are more smart people building software now than there have been at any point in the past, which means that it's more important than ever to stay on top of new developments, libraries, frameworks, and everything else. To really take advantage of this wealth of innovation, however, you've got to look beyond your normal community -- what's going on in Python? And how can we use that to make our Ruby lives easier? In this session, we'll explore that question. We'll look at actual examples of code and concepts borrowed and reimplemented to form a better idea of when it's appropriate and when it'll fall flat.
The document discusses FuseJS, a JavaScript framework that aims to improve performance and compatibility across browsers. It includes sandboxed native objects to prevent namespace pollution, modular builds, and various selector engines. It also details optimizations for quirks mode, events, caching, and performance benchmarks showing FuseJS has lower execution times than other frameworks.
This talk takes a deep dive into asynchronous programming patterns and practices, with an emphasis on the promise pattern. We go through the basics of the event loop, highlighting the drawbacks of asynchronous programming in a naive callback style. Fortunately, we can use the magic of promises to escape from callback hell with a powerful and unified interface for async APIs. Finally, we take a quick look at the possibilities for using coroutines both in current and future (ECMAScript Harmony) JavaScript.
The document discusses various approaches for leveraging parallelism and concurrency including multithreading, fork/join, actors, dataflow, and software transactional memory. It notes that while multithreading is challenging, other approaches like actors, dataflow, and STM can allow for writing concurrency-agnostic code. It promotes the GPars library for its implementations of various parallel and concurrent programming abstractions in Java and Groovy.
Redux-observable allows combining RxJS and Redux by introducing Epics. Epics are Observable streams that handle asynchronous logic in response to Redux actions. This avoids callback hell and enables features like cancellation. An Epic takes an action stream, performs asynchronous operations like AJAX calls using RxJS, and dispatches result actions. This keeps Redux synchronous while managing complex async flows in a declarative and reusable way.
Why is data validation important? What are effective ways to ensure data is valid? In this session we'll explore how data validation is directly linked to security, stability and developer productivity when dealing with untrusted or unknown data sources. We'll discuss the dangers of code that does not validate its data - everything from injection to DOS attacks. We'll go hands on with joi (https://github.com/hapijs/joi) and Express (http://expressjs.com/) to see how data validation can make code easier to work with. No more "Uncaught ReferenceError" or if null checks littered around the code base. In the end, we'll see how code can be secure, stable and magically awesome to work with.
This document provides an introduction and overview of Node.js. It discusses that Node.js is asynchronous and event-driven, uses non-blocking I/O, and is well-suited for data-intensive real-time applications that run across distributed devices. It also provides instructions on getting started with Node.js, including installing it, basic usage like importing modules and writing files, how to create a simple web server, working with event-driven libraries, and popular Node.js projects like Express and Socket.IO.
Why is data validation important? What are effective ways to ensure data is valid? In this session we’ll explore how data validation is directly linked to security, stability and developer productivity when dealing with untrusted or unknown data sources. We’ll discuss the dangers of code that does not validate its data - everything from injection to DOS attacks. We’ll go hands on with joi (https://github.com/hapijs/joi) and Express (http://expressjs.com/) to see how data validation can make code easier to work with. No more "Uncaught ReferenceError" or if null checks littered around the code base. In the end, we’ll see how code can be secure, stable and magically awesome to work with.