Object Oriented got a lot easier since Moose came around.
This keynote is a one-day advanced Moose workshop covering (almost) everything Moose has to offer perl developers
This document provides an introduction and overview of Moose, a modern object framework for Perl 5. It begins with background on the author and a brief history of object oriented programming in Perl 5. It then explains what Moose is, including that it handles object overhead, allows for introspection, and is used in production software. Examples are provided of basic class creation and usage with Moose as well as more advanced features like attributes, types, subclassing, roles, method modifiers, and introspection. The benefits of Moose are summarized as writing less code and avoiding implementation details to have a better object model.
Moose is an object framework for Perl 5 that simplifies object-oriented programming. It allows classes to be defined declaratively using attributes like 'has' and inheritance is implemented with 'extends'. Attributes can have types, defaults, and delegated accessors. Roles provide reusable traits and are composed into classes using 'with'. Moose supports features like multiple inheritance, method overriding, and required interface methods.
Moose is an object framework for Perl that provides:
1) Full-featured object-oriented programming with attributes, inheritance, roles, and hooks
2) Powerful attribute features like types, defaults, builders, and more
3) A clean and stable API for defining and working with objects
This document introduces object oriented programming in Perl using Moose. It discusses what objects are, how they are commonly created with Moose, and how Moose handles attributes and delegation. Moose provides features like type constraints and immutability out of the box to reduce code and improve performance compared to implementing object oriented code without Moose. The document also covers testing objects and using roles to take on features from multiple packages.
Drupal 8: A story of growing up and getting off the islandAngela Byron
The document discusses Drupal's transition from Drupal 7 to Drupal 8. It describes how Drupal 8 modernized by adopting PHP best practices like Composer, OOP, and external libraries. This required rewriting large parts of the codebase. The transition was challenging due to technical debt from the past and fears about change. Lessons learned include setting goals, gaining buy-in through transparency, incremental changes, and addressing fears through support. While the transition is not complete, Drupal 8 has rejoined mainstream PHP development practices.
CoffeeScript is a programming language that compiles to JavaScript. It adds syntactic sugar that makes JavaScript cleaner and adds features inspired by Python and Ruby. Key features include cleaner syntax for functions, objects, conditionals, loops, and classes. CoffeeScript code compiles directly to equivalent JavaScript code, so it can be used anywhere JavaScript is used like web browsers and Node.js. To use CoffeeScript, install the CoffeeScript compiler and use it to compile CoffeeScript files to JavaScript for use in projects.
jQuery is drawing newcomers to JavaSCript in droves. As a community, we have an obligation -- and it is in our interest -- to help these newcomers understand where jQuery ends and JavaScript begins.
Python's "batteries included" philosophy means that it comes with an astonishing amount of great stuff. On top of that, there's a vibrant world of third-party libraries that help make Python even more wonderful. We'll go on a breezy, example-filled tour through some of my favorites, from treasures in the standard library to great third-party packages that I don't think I could live without, and we'll touch on some of the fuzzier aspects of the Python culture that make it such a joy to be part of.
The document discusses CoffeeScript, a programming language that compiles to JavaScript. It was designed to have cleaner syntax than JavaScript and be easier to read and write. CoffeeScript code compiles directly to equivalent JavaScript code. Using CoffeeScript can help developers write less code that is more readable and maintainable while still being able to use existing JavaScript libraries. The document provides examples of CoffeeScript code and the equivalent JavaScript output. It also discusses how to use CoffeeScript with Ruby on Rails projects by adding the Barista gem.
Backbone.js is a JavaScript MVC framework that allows developers to build single page applications. It includes models, views, and controllers (routers). Models represent data, views display models, and routers handle navigation between views. Collections are groups of models that can be filtered, sorted, and manipulated. Views can display both individual models and entire collections. Events can be bound to views to handle user interactions. The framework uses a client-side routing system to change views based on the URL hash fragment.
BioPerl is an open source collection of Perl modules for bioinformatics. It contains over 550 modules covering tasks like sequence analysis, multiple sequence alignment, and working with common file formats. The modules provide reusable subroutines and methods to parse data, access databases, and perform other common bioinformatics operations. BioPerl code is portable and can be easily incorporated into scripts and programs. The modules are organized into groups and adhere to object-oriented principles in Perl, with classes, methods, and object blessed references.
This document discusses various data types and data structures in Perl, including scalars, arrays, hashes, references, and object-oriented programming. It provides examples of creating sequences and sequence objects using BioPerl, parsing multi-line sequence data, and accessing GenBank sequence data through the Bio::DB::GenBank module.
This document discusses prototypal inheritance in JavaScript. It explains that objects are hashes, and prototypes allow objects to inherit properties from parent objects. The document demonstrates how to define prototypes using Object.create, and shows how this allows child objects to access properties from parents in the prototype chain even if they are not directly defined on the child. It also discusses how classes are an "inconvenient fiction" in JavaScript and are simply constructor functions with methods added to the prototype.
The document discusses James' preferences for API design based on his experience working with many APIs. He likes APIs from Ruby's standard library like FileUtils and OpenURI that provide familiar and easy to use functionality. He also likes APIs that take fresh approaches like Pathname and Pstore. James dislikes APIs that are missing features or documentation like some S3 libraries. He strongly dislikes APIs that produce many warnings like Fog.
This document discusses Ruby on Rails extensions provided by ActiveSupport. It explains that ActiveSupport provides Ruby extensions, utility classes, and other features used across Rails. It then summarizes some common extensions, including methods added to all objects like blank?, present?, and try. The document provides code examples for how these extensions work and which ActiveSupport files define them.
Coffeescript: No really, it's just JavascriptBrian Mann
This document provides an overview of CoffeeScript, which is a programming language that compiles to JavaScript. It discusses CoffeeScript's syntax and features like removing semicolons, optional parentheses and curly braces, simplified object and function syntax, string interpolation, and destructuring assignment. The presentation covers CoffeeScript's flow control structures like if/else and unless, operators like is and isnt, existential operators, and comprehensions. It also addresses criticisms of CoffeeScript like performance and debugging challenges, and argues that productivity gains outweigh these issues. In the end, CoffeeScript is described as a way to expose the good parts of JavaScript and enhance readability and productivity while compiling directly to plain JavaScript.
Objective-C & iPhone for .NET DevelopersBen Scheirman
This document provides an introduction to developing iPhone applications for .NET developers. It covers the basics of Objective-C, the programming language used for iPhone development, including defining classes, methods, properties, memory management using retain/release, and the model-view-controller pattern. It also discusses Xcode, the integrated development environment, Interface Builder for building user interfaces, and Instruments for debugging.
This document discusses different approaches to persisting domain objects, including direct database usage, using an ORM tool, and implementing a "domain-driven persistence" approach. It describes domain-driven concepts like entities, value objects, aggregates, and repositories for encapsulating persistence concerns separately from domain logic.
These slides show a high level architecture of Ruby MagLev as well as a small example to illustrate how easy it is to have transparent object persistence in Ruby.
Slides from my PyCon 2011 talk, "Exhibition of Atrocity," a confessional of my sins against the Python programming language.
Abstract: http://us.pycon.org/2011/schedule/presentations/138/
Video: http://www.pycon.tv/#/video/49
This document discusses learning jQuery and provides summaries of 5 sections:
1. Ready handlers, selectors, CSS, effects, events, and method chaining
2. Attributes, classes, HTML manipulation, and value manipulation
3. Event handling and samples for events like click and tab
4. Using AJAX with load() and get() methods
5. Plugins for thickbox, colorbox, fancybox and traversing DOM elements.
Everything is Permitted: Extending Built-insAndrew Dupont
Adding methods to built-in objects: it’s one of JavaScript’s most powerful features. It’s also a great way to offend the sensibilities of your colleagues. We all hear that it’s irresponsible, that it’s sloppy, that it’s flat-out bad practice and should be avoided.
I’m tired of this one-sided battle. In this talk, I’m going to push back against whatever blog post you read that told you that extending built-ins was unconditionally and universally bad. I’m gonna go all Howard Beale on your asses.
The document discusses memory management in Objective-C for iPhone applications. It covers key concepts like reference counting, object ownership, autorelease pools, and common mistakes to avoid. The document also provides examples of proper memory management techniques like retaining objects, releasing objects, and using autorelease to avoid memory leaks.
This document discusses mocks and stubs in RSpec testing and provides examples of their usage. It defines that a mock object supports message expectations and method stubs, while a method stub returns a pre-determined value. Examples are given of declaring method stubs in different ways and using a mock object to test that a method receives and returns expected values. Resource links are also included for learning more about expectations, matchers, and mocks in RSpec testing.
Drupal 8: A story of growing up and getting off the islandAngela Byron
The document discusses Drupal's transition from Drupal 7 to Drupal 8. It describes how Drupal 8 modernized by adopting PHP best practices like Composer, OOP, and external libraries. This required rewriting large parts of the codebase. The transition was challenging due to technical debt from the past and fears about change. Lessons learned include setting goals, gaining buy-in through transparency, incremental changes, and addressing fears through support. While the transition is not complete, Drupal 8 has rejoined mainstream PHP development practices.
CoffeeScript is a programming language that compiles to JavaScript. It adds syntactic sugar that makes JavaScript cleaner and adds features inspired by Python and Ruby. Key features include cleaner syntax for functions, objects, conditionals, loops, and classes. CoffeeScript code compiles directly to equivalent JavaScript code, so it can be used anywhere JavaScript is used like web browsers and Node.js. To use CoffeeScript, install the CoffeeScript compiler and use it to compile CoffeeScript files to JavaScript for use in projects.
jQuery is drawing newcomers to JavaSCript in droves. As a community, we have an obligation -- and it is in our interest -- to help these newcomers understand where jQuery ends and JavaScript begins.
Python's "batteries included" philosophy means that it comes with an astonishing amount of great stuff. On top of that, there's a vibrant world of third-party libraries that help make Python even more wonderful. We'll go on a breezy, example-filled tour through some of my favorites, from treasures in the standard library to great third-party packages that I don't think I could live without, and we'll touch on some of the fuzzier aspects of the Python culture that make it such a joy to be part of.
The document discusses CoffeeScript, a programming language that compiles to JavaScript. It was designed to have cleaner syntax than JavaScript and be easier to read and write. CoffeeScript code compiles directly to equivalent JavaScript code. Using CoffeeScript can help developers write less code that is more readable and maintainable while still being able to use existing JavaScript libraries. The document provides examples of CoffeeScript code and the equivalent JavaScript output. It also discusses how to use CoffeeScript with Ruby on Rails projects by adding the Barista gem.
Backbone.js is a JavaScript MVC framework that allows developers to build single page applications. It includes models, views, and controllers (routers). Models represent data, views display models, and routers handle navigation between views. Collections are groups of models that can be filtered, sorted, and manipulated. Views can display both individual models and entire collections. Events can be bound to views to handle user interactions. The framework uses a client-side routing system to change views based on the URL hash fragment.
BioPerl is an open source collection of Perl modules for bioinformatics. It contains over 550 modules covering tasks like sequence analysis, multiple sequence alignment, and working with common file formats. The modules provide reusable subroutines and methods to parse data, access databases, and perform other common bioinformatics operations. BioPerl code is portable and can be easily incorporated into scripts and programs. The modules are organized into groups and adhere to object-oriented principles in Perl, with classes, methods, and object blessed references.
This document discusses various data types and data structures in Perl, including scalars, arrays, hashes, references, and object-oriented programming. It provides examples of creating sequences and sequence objects using BioPerl, parsing multi-line sequence data, and accessing GenBank sequence data through the Bio::DB::GenBank module.
This document discusses prototypal inheritance in JavaScript. It explains that objects are hashes, and prototypes allow objects to inherit properties from parent objects. The document demonstrates how to define prototypes using Object.create, and shows how this allows child objects to access properties from parents in the prototype chain even if they are not directly defined on the child. It also discusses how classes are an "inconvenient fiction" in JavaScript and are simply constructor functions with methods added to the prototype.
The document discusses James' preferences for API design based on his experience working with many APIs. He likes APIs from Ruby's standard library like FileUtils and OpenURI that provide familiar and easy to use functionality. He also likes APIs that take fresh approaches like Pathname and Pstore. James dislikes APIs that are missing features or documentation like some S3 libraries. He strongly dislikes APIs that produce many warnings like Fog.
This document discusses Ruby on Rails extensions provided by ActiveSupport. It explains that ActiveSupport provides Ruby extensions, utility classes, and other features used across Rails. It then summarizes some common extensions, including methods added to all objects like blank?, present?, and try. The document provides code examples for how these extensions work and which ActiveSupport files define them.
Coffeescript: No really, it's just JavascriptBrian Mann
This document provides an overview of CoffeeScript, which is a programming language that compiles to JavaScript. It discusses CoffeeScript's syntax and features like removing semicolons, optional parentheses and curly braces, simplified object and function syntax, string interpolation, and destructuring assignment. The presentation covers CoffeeScript's flow control structures like if/else and unless, operators like is and isnt, existential operators, and comprehensions. It also addresses criticisms of CoffeeScript like performance and debugging challenges, and argues that productivity gains outweigh these issues. In the end, CoffeeScript is described as a way to expose the good parts of JavaScript and enhance readability and productivity while compiling directly to plain JavaScript.
Objective-C & iPhone for .NET DevelopersBen Scheirman
This document provides an introduction to developing iPhone applications for .NET developers. It covers the basics of Objective-C, the programming language used for iPhone development, including defining classes, methods, properties, memory management using retain/release, and the model-view-controller pattern. It also discusses Xcode, the integrated development environment, Interface Builder for building user interfaces, and Instruments for debugging.
This document discusses different approaches to persisting domain objects, including direct database usage, using an ORM tool, and implementing a "domain-driven persistence" approach. It describes domain-driven concepts like entities, value objects, aggregates, and repositories for encapsulating persistence concerns separately from domain logic.
These slides show a high level architecture of Ruby MagLev as well as a small example to illustrate how easy it is to have transparent object persistence in Ruby.
Slides from my PyCon 2011 talk, "Exhibition of Atrocity," a confessional of my sins against the Python programming language.
Abstract: http://us.pycon.org/2011/schedule/presentations/138/
Video: http://www.pycon.tv/#/video/49
This document discusses learning jQuery and provides summaries of 5 sections:
1. Ready handlers, selectors, CSS, effects, events, and method chaining
2. Attributes, classes, HTML manipulation, and value manipulation
3. Event handling and samples for events like click and tab
4. Using AJAX with load() and get() methods
5. Plugins for thickbox, colorbox, fancybox and traversing DOM elements.
Everything is Permitted: Extending Built-insAndrew Dupont
Adding methods to built-in objects: it’s one of JavaScript’s most powerful features. It’s also a great way to offend the sensibilities of your colleagues. We all hear that it’s irresponsible, that it’s sloppy, that it’s flat-out bad practice and should be avoided.
I’m tired of this one-sided battle. In this talk, I’m going to push back against whatever blog post you read that told you that extending built-ins was unconditionally and universally bad. I’m gonna go all Howard Beale on your asses.
The document discusses memory management in Objective-C for iPhone applications. It covers key concepts like reference counting, object ownership, autorelease pools, and common mistakes to avoid. The document also provides examples of proper memory management techniques like retaining objects, releasing objects, and using autorelease to avoid memory leaks.
This document discusses mocks and stubs in RSpec testing and provides examples of their usage. It defines that a mock object supports message expectations and method stubs, while a method stub returns a pre-determined value. Examples are given of declaring method stubs in different ways and using a mock object to test that a method receives and returns expected values. Resource links are also included for learning more about expectations, matchers, and mocks in RSpec testing.
This document discusses immutability and immutable data structures in programming. It begins by explaining that immutable objects cannot be changed or modified over time, similar to constants. This ensures security since the data cannot be accidentally altered. The document then discusses how Cocoa frameworks like NSArray use immutable data structures to avoid issues with shared mutable state. It also covers techniques like copy and mutableCopy to derive new objects in a safe way without modifying existing objects.
The document discusses the agenda for an Enterprise JavaScript session, which includes recapping functions, exceptions, and the history object in JavaScript. It then goes into detail on the typeof operator, function properties like arguments and this, and how to use the call and apply methods. Hands-on exercises demonstrate working with arguments and exceptions. Finally, the document explains how the history object works and how HTML5 introduced new methods like pushState and replaceState to programmatically modify the browser history.
This document provides an overview of JavaScript basics including data types, strings, objects, arrays, functions, and closures. It discusses the history and evolution of JavaScript, from its origins as LiveScript in 1995 to the modern ECMAScript standard. Various JavaScript operators, methods, and built-in objects like window and document are also explained at a high level.
The document discusses various techniques for optimizing a multisite WordPress architecture for a high-traffic music website including: using caching (APC, Memcached, Batcache), output buffering, CDNs, regionalized content/caching, shared content across sites, custom post types, web services, and configuration files. It also covers database scaling, PHP optimizations, and using Amazon services like EC2 and S3.
The document discusses the mobile backend platform Parse. It provides an overview of Parse's features including data storage, queries, push notifications, user management, geopoints, and files. The founders of Parse are also mentioned. Steps for getting started with Parse and integrating it into an Android mobile app are outlined, including permissions, imports, and initialization. Facebook authentication with Parse is demonstrated.
Ruby 2.0 / Rails 4.0, A selection of new features.lrdesign
The document discusses several new features in Ruby 2.0 and Rails 4.0, including:
1) Refinements which allow monkeypatches to be applied only when "using" a module, improving on the previous approach that mutated core classes for all code.
2) Keyword arguments for methods to avoid the problems of option hashes.
3) Improved fragment caching that generates cache keys by concatenating an array of objects rather than separate cache calls, allowing caching of nested fragments.
This document contains a presentation on writing flexible and scalable Puppet modules. The presentation discusses common issues that arise when modules are not designed to be flexible, such as unexpected changes in operating systems or use cases. It provides guidance on how to design modules to be more modular, parameterized, and able to handle unexpected changes over time through techniques like using Hiera for configuration, separating logic into submodules, and favoring composition over inheritance. The goal is to create modules that can be easily adapted and improved by both their original authors and other users.
This document summarizes a presentation about writing flexible and scalable Puppet modules. The presenter discusses common issues that can arise when modules are not designed to adapt to changes. He provides guidance on parameterizing classes, outsourcing logic to submodules, limiting inheritance, and protecting against unintended defaults to create modules that can flexibly handle new operating systems, versions, and use cases. The overall message is to anticipate change and design modules to be dynamically configurable rather than relying on hard-coded assumptions.
The document discusses the history and evolution of programming languages from Assembly to modern languages like JavaScript. It notes that each language was created to solve specific problems in different domains. It then discusses object oriented programming concepts like classes in different languages and how they relate to earlier concepts from Plato and Darwin. It concludes by describing how Koding was built using technologies like CoffeeScript, Bongo, and Kite to provide an environment for developers.
The updated version of this is over here: http://www.slideshare.net/nadavoid/upgrades-and-migrations-bad-camp. I updated it for BAD Camp 2013.
You have an aging Drupal 6 or even a Drupal 5 site. You know it's time to move up to Drupal 7. Now, how? There are two main ways to get there. You can perform a traditional upgrade, or you can migrate the data from the old site to a brand new site. In this session I will show how you can use these methods and discuss their benefits and drawbacks, including a thought process to go through when evaluating these options, drawing from some recent projects.
The document provides an agenda for a talk on effective Scala programming. The agenda covers basic Scala concepts like the REPL and expressions vs statements. It then covers object orientation topics like case classes and composition over inheritance. Later sections will cover implicits, type traits, collections, pattern matching and functional programming.
Lead Developer of WordPress Mark Jaquith explains the philosophy and goals behind WordPress development outlines areas where it has fallen short, and exhorts others to action.
The document provides an agenda and notes for a session on building JavaScript applications. The agenda includes discussing namespacing, design patterns like the singleton and observer patterns, performance techniques like Big O notation and measuring performance, and debugging. Hands-on exercises are also included to demonstrate namespacing and using the observer pattern. The presenter introduces themselves and provides an overview of namespaces like using object literals and nested namespacing. Common design patterns like the singleton, chaining, and observer pattern are also explained. Performance topics cover Big O notation, measuring performance with Date objects, and five tips including using few files.
Optimizing WordPress Performance on Shared Web HostingJon Brown
This document discusses performance tweaks that can be made for WordPress sites on shared hosting. It is divided into three acts: inside WordPress, on the shared server, and off the shared server. Inside WordPress, it recommends right-sizing images, checking for 404 errors, keeping the database under control, and using caching plugins. On the shared server, it suggests updating to newer PHP versions, cleaning up the database, and using CloudFlare. Off the server, it only recommends using CDNs like CloudFlare for their free benefits.
This document provides an overview of regular expressions (regex). It begins by stating that regex can help find patterns in text and briefly outlines the history of regex from mathematics to its introduction in Unix. It then explains that regex can be used as an alternative to shell wildcards and that many Unix tools incorporate regex. The document proceeds to list programming languages that use regex and provides some basic regex rules including matching single characters, character classes, quantifiers, and assertions. It provides examples to demonstrate matching patterns using these rules.
This document provides an overview of front-end HTML5 web development, including its history from 2004 to becoming a W3C recommendation in 2014. It discusses using new HTML5 features to build complex client-side apps and focuses on teaching attendees how to write front-end code focused on JavaScript to develop modern web applications, demonstrating examples along the way.
The document discusses various statistics related to website load times and how they impact user behavior and business metrics. It states that 47% of consumers expect a page to load within 2 seconds and 73% of mobile users have encountered sites that were too slow. A 1 second delay can result in a 7% loss in conversions. It also discusses studies by Glasses Direct, Walmart and Google on how delays of 50-400 milliseconds can negatively impact conversion rates. The document emphasizes that page load time affects bounce rates, time on site, conversions, user satisfaction and that businesses should care about and measure load times.
This document outlines a course on responsive web design for mobile. The goals are to build a responsive website that works well on any device, understand responsive tools, and learn responsive design techniques. Students should know HTML for content and CSS for styling. The course includes three mobile design challenges to complete the learning.
How to write multi threaded applications using Qt:
In the slides you'll learn about 3 alternatives, all of which allow running tasks simultaneously in Qt applications, and understand the use cases leading to choosing each.
This document discusses improving text editing for Perl developers. It outlines some annoyances with basic text editors like slowing down development. An effective text editor can help developers by providing code snippets, file templates, auto-completion and other features to reduce typing and errors. The document recommends using the Janus text editor plugin collection for Vim, which provides these kinds of features to make editing Perl code faster and easier. It provides instructions for installing Janus and highlights some of its initial capabilities.
This 24-hour course covers the architectural differences system analysts must consider when designing mobile or mobile web applications. It discusses topics like the mobile ecosystem, application layers, device layers, communication networks, and security. The course will help participants understand how to manage sessions, use location services, send push notifications, optimize for networks and address vulnerabilities, through in-depth topics, real-world case studies and a suggested 6-session schedule.
The document discusses key differences between developing for mobile versus desktop. Mobile devices are always connected, have limited battery life, and users expect seamless app switching. Developers must consider interruptions and optimize for battery usage. Each mobile app runs in a sandbox and can communicate through URL schemes or by integrating with OS services. Background execution is more limited on iOS but both platforms allow some background activities like downloading content or playing audio. Developers must respect user expectations and not abuse background capabilities.
This document discusses optimizing mobile networks and applications for speed. It begins with an overview of networking basics and how mobile networks work. It then discusses factors that affect speed like latency, bandwidth, TCP protocols, and cellular network routing. The document provides recommendations for optimizing like leveraging WiFi, anticipating latency, saving bandwidth and battery. It also covers HTTP optimizations, browser APIs and protocols like XHR, SSE and WebSockets. The goal is to understand how networks impact applications and how to design for optimal mobile performance.
The document discusses mobile web architecture and hybrid mobile applications. It begins with an introduction to hybrid apps and PhoneGap. It then covers various HTML5 features that are useful for building hybrid apps like users and sessions, location services, cameras, videos, audio and push notifications. It explains the hybrid architecture of combining web views with native wrappers. It also provides examples of implementing location services, cameras, audio/video and push notifications in a hybrid mobile app.
This document discusses misusing cryptography. It begins with an agenda covering why cryptography is misused and how random number generators and crypto algorithms can be misused. It then discusses examples of what can go wrong, such as a game developer unintentionally allowing hackers to easily determine the secret code protecting scores. The document emphasizes that cryptography is complex and should not be casually misused, as failures can result in compromises like hacked systems and lost jobs. It provides recommendations for proper cryptographic practices.
This document provides an introduction to Selenium, an open source tool for automating web application testing. Selenium allows testing of web applications across different browsers without needing to modify the source code. It works by issuing commands to browser drivers to simulate user interactions such as clicking links, filling forms, and verifying page content. The document outlines how to set up and run automated tests using the Selenium Ruby bindings and RSpec testing framework.
Slides cover how to get started testing your web application. Technologies and concepts explained:
- Unit tests (mocha, jasmine, karma)
- System tests (Selenium)
- Code coverage (istanbul)
- CI servers
This document discusses web accessibility and provides guidance on making websites accessible to people with disabilities. It covers goals of accessibility, challenges for different disabilities, relevant laws, and technical details on how to make elements like images, audio, video, forms, tables, and overall site structure and navigation accessible. The document provides guidelines on topics like alt text, captions, text size and color contrast, keyboard navigation, time limits, languages, and using semantic HTML.
The document provides an overview and introduction to AngularJS. It discusses key Angular concepts like data binding, directives, filters, controllers and scopes. It also covers using Angular for client-side routing and communicating with servers to retrieve data. Example code snippets are provided to demonstrate concepts like controllers, directives and routing. Labs and exercises are included to apply the concepts by building sample Angular applications.
This document discusses JavaScript memory management and common memory leaks. It covers topics like memory lifecycle, garbage collection, detecting memory leaks using dev tools, and ways to minimize memory usage like avoiding global variables and detached DOM nodes. Common sources of memory leaks are discussed such as unbound arrays and objects, multiple copies of functions, and detached DOM nodes not removed from memory. Tools for profiling memory usage like the Chrome Task Manager and Heap Profiler are also presented.
Design Patterns help us solve problems in tried and tested ways.
Turns out they also help us understand our framework better, for framework developers also use patterns.
In these slides you'll see how Design Patterns are implemented by Qt framework, to better both understand patterns and Qt
#StandardsGoals for 2025: Standards & certification roundup - Tech Forum 2025BookNet Canada
Book industry standards are evolving rapidly. In the first part of this session, we’ll share an overview of key developments from 2024 and the early months of 2025. Then, BookNet’s resident standards expert, Tom Richardson, and CEO, Lauren Stewart, have a forward-looking conversation about what’s next.
Link to recording, transcript, and accompanying resource: https://bnctechforum.ca/sessions/standardsgoals-for-2025-standards-certification-roundup/
Presented by BookNet Canada on May 6, 2025 with support from the Department of Canadian Heritage.
DevOpsDays Atlanta 2025 - Building 10x Development Organizations.pptxJustin Reock
Building 10x Organizations with Modern Productivity Metrics
10x developers may be a myth, but 10x organizations are very real, as proven by the influential study performed in the 1980s, ‘The Coding War Games.’
Right now, here in early 2025, we seem to be experiencing YAPP (Yet Another Productivity Philosophy), and that philosophy is converging on developer experience. It seems that with every new method we invent for the delivery of products, whether physical or virtual, we reinvent productivity philosophies to go alongside them.
But which of these approaches actually work? DORA? SPACE? DevEx? What should we invest in and create urgency behind today, so that we don’t find ourselves having the same discussion again in a decade?
Artificial Intelligence is providing benefits in many areas of work within the heritage sector, from image analysis, to ideas generation, and new research tools. However, it is more critical than ever for people, with analogue intelligence, to ensure the integrity and ethical use of AI. Including real people can improve the use of AI by identifying potential biases, cross-checking results, refining workflows, and providing contextual relevance to AI-driven results.
News about the impact of AI often paints a rosy picture. In practice, there are many potential pitfalls. This presentation discusses these issues and looks at the role of analogue intelligence and analogue interfaces in providing the best results to our audiences. How do we deal with factually incorrect results? How do we get content generated that better reflects the diversity of our communities? What roles are there for physical, in-person experiences in the digital world?
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfSoftware Company
Explore the benefits and features of advanced logistics management software for businesses in Riyadh. This guide delves into the latest technologies, from real-time tracking and route optimization to warehouse management and inventory control, helping businesses streamline their logistics operations and reduce costs. Learn how implementing the right software solution can enhance efficiency, improve customer satisfaction, and provide a competitive edge in the growing logistics sector of Riyadh.
HCL Nomad Web – Best Practices und Verwaltung von Multiuser-Umgebungenpanagenda
Webinar Recording: https://www.panagenda.com/webinars/hcl-nomad-web-best-practices-und-verwaltung-von-multiuser-umgebungen/
HCL Nomad Web wird als die nächste Generation des HCL Notes-Clients gefeiert und bietet zahlreiche Vorteile, wie die Beseitigung des Bedarfs an Paketierung, Verteilung und Installation. Nomad Web-Client-Updates werden “automatisch” im Hintergrund installiert, was den administrativen Aufwand im Vergleich zu traditionellen HCL Notes-Clients erheblich reduziert. Allerdings stellt die Fehlerbehebung in Nomad Web im Vergleich zum Notes-Client einzigartige Herausforderungen dar.
Begleiten Sie Christoph und Marc, während sie demonstrieren, wie der Fehlerbehebungsprozess in HCL Nomad Web vereinfacht werden kann, um eine reibungslose und effiziente Benutzererfahrung zu gewährleisten.
In diesem Webinar werden wir effektive Strategien zur Diagnose und Lösung häufiger Probleme in HCL Nomad Web untersuchen, einschließlich
- Zugriff auf die Konsole
- Auffinden und Interpretieren von Protokolldateien
- Zugriff auf den Datenordner im Cache des Browsers (unter Verwendung von OPFS)
- Verständnis der Unterschiede zwischen Einzel- und Mehrbenutzerszenarien
- Nutzung der Client Clocking-Funktion
Special Meetup Edition - TDX Bengaluru Meetup #52.pptxshyamraj55
We’re bringing the TDX energy to our community with 2 power-packed sessions:
🛠️ Workshop: MuleSoft for Agentforce
Explore the new version of our hands-on workshop featuring the latest Topic Center and API Catalog updates.
📄 Talk: Power Up Document Processing
Dive into smart automation with MuleSoft IDP, NLP, and Einstein AI for intelligent document workflows.
Massive Power Outage Hits Spain, Portugal, and France: Causes, Impact, and On...Aqusag Technologies
In late April 2025, a significant portion of Europe, particularly Spain, Portugal, and parts of southern France, experienced widespread, rolling power outages that continue to affect millions of residents, businesses, and infrastructure systems.
Semantic Cultivators : The Critical Future Role to Enable AIartmondano
By 2026, AI agents will consume 10x more enterprise data than humans, but with none of the contextual understanding that prevents catastrophic misinterpretations.
Procurement Insights Cost To Value Guide.pptxJon Hansen
Procurement Insights integrated Historic Procurement Industry Archives, serves as a powerful complement — not a competitor — to other procurement industry firms. It fills critical gaps in depth, agility, and contextual insight that most traditional analyst and association models overlook.
Learn more about this value- driven proprietary service offering here.
Book industry standards are evolving rapidly. In the first part of this session, we’ll share an overview of key developments from 2024 and the early months of 2025. Then, BookNet’s resident standards expert, Tom Richardson, and CEO, Lauren Stewart, have a forward-looking conversation about what’s next.
Link to recording, presentation slides, and accompanying resource: https://bnctechforum.ca/sessions/standardsgoals-for-2025-standards-certification-roundup/
Presented by BookNet Canada on May 6, 2025 with support from the Department of Canadian Heritage.
What is Model Context Protocol(MCP) - The new technology for communication bw...Vishnu Singh Chundawat
The MCP (Model Context Protocol) is a framework designed to manage context and interaction within complex systems. This SlideShare presentation will provide a detailed overview of the MCP Model, its applications, and how it plays a crucial role in improving communication and decision-making in distributed systems. We will explore the key concepts behind the protocol, including the importance of context, data management, and how this model enhances system adaptability and responsiveness. Ideal for software developers, system architects, and IT professionals, this presentation will offer valuable insights into how the MCP Model can streamline workflows, improve efficiency, and create more intuitive systems for a wide range of use cases.
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPathCommunity
Join this UiPath Community Berlin meetup to explore the Orchestrator API, Swagger interface, and the Test Manager API. Learn how to leverage these tools to streamline automation, enhance testing, and integrate more efficiently with UiPath. Perfect for developers, testers, and automation enthusiasts!
📕 Agenda
Welcome & Introductions
Orchestrator API Overview
Exploring the Swagger Interface
Test Manager API Highlights
Streamlining Automation & Testing with APIs (Demo)
Q&A and Open Discussion
Perfect for developers, testers, and automation enthusiasts!
👉 Join our UiPath Community Berlin chapter: https://community.uipath.com/berlin/
This session streamed live on April 29, 2025, 18:00 CET.
Check out all our upcoming UiPath Community sessions at https://community.uipath.com/events/.
Designing Low-Latency Systems with Rust and ScyllaDB: An Architectural Deep DiveScyllaDB
Want to learn practical tips for designing systems that can scale efficiently without compromising speed?
Join us for a workshop where we’ll address these challenges head-on and explore how to architect low-latency systems using Rust. During this free interactive workshop oriented for developers, engineers, and architects, we’ll cover how Rust’s unique language features and the Tokio async runtime enable high-performance application development.
As you explore key principles of designing low-latency systems with Rust, you will learn how to:
- Create and compile a real-world app with Rust
- Connect the application to ScyllaDB (NoSQL data store)
- Negotiate tradeoffs related to data modeling and querying
- Manage and monitor the database for consistently low latencies
Mobile App Development Company in Saudi ArabiaSteve Jonas
EmizenTech is a globally recognized software development company, proudly serving businesses since 2013. With over 11+ years of industry experience and a team of 200+ skilled professionals, we have successfully delivered 1200+ projects across various sectors. As a leading Mobile App Development Company In Saudi Arabia we offer end-to-end solutions for iOS, Android, and cross-platform applications. Our apps are known for their user-friendly interfaces, scalability, high performance, and strong security features. We tailor each mobile application to meet the unique needs of different industries, ensuring a seamless user experience. EmizenTech is committed to turning your vision into a powerful digital product that drives growth, innovation, and long-term success in the competitive mobile landscape of Saudi Arabia.
12. Example: Getting Info
package Pet;
use Moose;
has 'name', is => 'ro', isa => 'Str', default => 'Lassy';
has 'past_owners', is => 'ro', isa => 'ArrayRef[Str]';
package main;
my $dog = Pet->new( past_owners => ['James', 'Mike'] );
# show dog's info. No need to import Data::Dumper
warn $dog->dump;
# DOES returns true for objects of the class, subclasses or
# implementors of the role
print "Good boy" if $dog->DOES('Pet');
Friday, July 6, 12
13. Class Construction
package main;
• new method is automatically # Pass a hash ref to prevent copying
generated. my $enterprise = Starship->new( {
captain => 'James T Kirk',
crew => ['Dr. McCoy',
• Takes parameters hash or 'Scott', 'Lt. Uhura'],
hash ref });
Friday, July 6, 12
14. Class Construction
• Construction hooks:
• BUILD
• BUILDARGS
• attribute builders
Friday, July 6, 12
15. Class Construction
• BUILD is called every time a new object is created
• If inheritance is in effect, parent’s BUILD is called before child
BUILD is called automatically
• Used for:
• Object state validation (whole object)
• Tracking objects creation
Friday, July 6, 12
16. Object State Validation
package Starship;
use Moose;
has 'captain', is => 'ro', isa => 'Str', required => 1;
has 'crew', is => 'rw', isa => 'ArrayRef[Str]', required => 1;
sub BUILD {
my $self = shift;
if ( $self->captain ~~ $self->crew ) {
my $captain = $self->captain;
die "Validation Error: Cannot use $captain for both Captain and Crew";
}
}
package main;
# Validation error
my $enterprise = Starship->new( {
captain => 'James T Kirk',
crew => ['Dr. McCoy', 'Scott', 'Lt. Uhura', 'James T Kirk'],
});
Friday, July 6, 12
17. BUILDARGS
• Used to manipulate arguments before object creation
• Takes the arguments hash as input, returns hashref
• Wrap in ‘around’ modifier to change
• Used for:
• Single arguments ctor
Friday, July 6, 12
18. BUILDARGS Example
package Person;
use Moose;
has 'name', is => 'ro', isa => 'Str', required => 1;
around BUILDARGS => sub {
my $orig = shift;
my $class = shift;
my @params = @_;
# Sole parameter that is not a ref
# is considered the name
if ( ( @params == 1 ) && ( ! ref $params[0] ) ) {
return $class->$orig( name => $params[0] );
} else {
return $class->$orig ( @params );
}
}; # Watch the semicolon
Friday, July 6, 12
19. Class Destruction
• Moose implemented DESTROY, which will call your
DEMOLISH
• It handles inheritance correctly: demolish child before super
Friday, July 6, 12
20. Class Destruction
package Foo;
use Moose;
sub DEMOLISH { warn 'Foo::Demolish' }
• When program package Bar;
ends, prints out: use Moose;
extends 'Foo';
Bar::Demolish sub DEMOLISH { warn 'Bar::Demolish' }
Foo::Demolish package main;
my $b = Bar->new;
Friday, July 6, 12
21. Construction
Destruction
Do’s and Don’ts
Friday, July 6, 12
22. Do
• Provide reasonable validations with BUILD
Friday, July 6, 12
23. Do
• Use warn( $obj->dump ) for debug
Friday, July 6, 12
24. Do
• Consider namespace::autoclean to remove Moose sugar
methods from your classes (has, with, etc.)
Friday, July 6, 12
25. Do
• Consider using:
__PACKAGE__->meta->make_immutable;
• To improve performance of objects creation
• Consider MooseX::AutoImmute
Friday, July 6, 12
26. Don’t
• Never override new ( it’ll break stuff down the road )
Friday, July 6, 12
27. Don’t
• Don’t use BUILD when attribute builders are sufficient
Friday, July 6, 12
28. Don’t
• Never call $self->SUPER::BUILD
• Moose does that for you
Friday, July 6, 12
29. Don’t
• Don’t apply a method modifier
(before, after, around) to BUILD
Friday, July 6, 12
30. Don’t
• Don’t write BUILD method for your roles ( Moose
ignores them )
Friday, July 6, 12
31. after
package Secret;
use Mouse;
has 'message', is => 'ro',
required => 1,
clearer => 'reset';
• Add code after a method is has 'counter', is => 'rw', default => 3;
executed after 'message' => sub {
my $self = shift;
$self->counter( $self->counter - 1 );
• Receives: method name and if ( $self->counter <= 0 ) {
$self->reset;
subroutine to add }
};
package main;
my $secret = Secret->new(
message => 'This message will self destroy');
print $secret->message, "n" for (1..5);
Friday, July 6, 12
32. What Is Printed ?
package Foo;
use Moose;
sub DEMOLISH { warn 'Foo::Demolish' }
sub BUILD { warn 'Foo::Build' }
package Bar;
use Moose;
extends 'Foo';
sub DEMOLISH { warn 'Bar::Demolish' }
sub BUILD { warn 'Bar::Build' }
package main;
my $b = Bar->new;
Friday, July 6, 12
33. Method Modifiers
• Alter code by injecting other code before or after the
modified method
• Can use from roles, subclasses or class itself
Friday, July 6, 12
34. before
package Logger;
use Mouse;
sub log {
my $self = shift;
• Before lets us inject code my ($msg) = @_;
before a method is called print $msg;
}
before 'log' => sub { select *STDERR };
• Spot the bug on the right after 'log' => sub { select *STDOUT };
package main;
my $log = Logger->new;
$log->log("hellon");
Friday, July 6, 12
35. around
• around has two more advantages:
• Can use return value of original method
• Can skip calling original method altogether
• You have the power
Friday, July 6, 12
36. around
• First parameter: original package AroundExample;
use Mouse;
method as CODE ref use feature ':5.10';
sub foo { print "In Foon" }
• Second parameter is the around 'foo' => sub {
my $orig = shift;
object my $self = shift;
say "Around: before calling method";
• Can call $self->$orig to get
$self->$orig(@_);
say "Around: after calling method";
requested functionality };
Friday, July 6, 12
37. around
package User;
use Mouse;
use DateTime;
sub login { warn 'Welcome' }
around 'login' => sub {
my $now = DateTime->now;
if ( $now->hour < 12 ) {
• Forbid login before noon my $orig = shift;
my $self = shift;
$self->$orig(@_);
}
};
Friday, July 6, 12
39. Moose Roles
An alternative to deep hierarchies and base classes
Friday, July 6, 12
40. Role
• Encapsulates behavior. Something that classes do
• Cannot be instansiated
• Classes consume roles - which means everything in the role is
copied into the class
Friday, July 6, 12
41. Classes & Roles
Person Computer Chicken
Alive Alive
Think Think
Friday, July 6, 12
42. Roles Example
package Breakable;
use Moose::Role;
package Glass;
has 'is_broken', is => 'rw', isa => 'Bool';
use Moose;
sub break {
my $self = shift; with 'Breakable';
print "Ouchn" if ! $self->is_broken;
$self->is_broken(1);
} package main;
my $g = Glass->new;
sub fix {
my $self = shift;
print "Works nown" if $self->is_broken; $g->break;
$self->is_broken(0); $g->fix;
}
Friday, July 6, 12
43. Moose Roles
• Use Moose::Role to define a role
• Use ‘with’ to consume a role
• Inside a role, define methods, attributes and modifiers
• Use ‘does’ to find out if an object implements a role
Friday, July 6, 12
44. Partial Implementation
• Use ‘requires’ in a role to force your consumer to define a
method
• Useful for:
• Partial implementations (template method)
• Abstract Base Class
Friday, July 6, 12
45. Partial Implementation
package MultipleFileUploader;
use Moose::Role;
requires 'upload_file';
sub upload_files {
my $self = shift;
my @success;
foreach my $f ( @_ ) {
die "Invalid file: $f" if ! $f->DOES('File');
$self->upload_file ( $f ) && push @success, $f;
}
return @success;
}
Friday, July 6, 12
46. Method Conflicts
• Consuming two roles with the same method names results in
a conflict
• Class must then implement the conflicted method on its own
• Can call role implementation using their namespace
Friday, July 6, 12
47. Method Conflicts
package R1; package Test;
use Moose::Role; use Moose;
sub foo { with qw/R1 R2/;
warn 'R1::foo'
}
package R2;
Compilation Error
use Moose::Role;
sub foo {
warn 'R2::foo'
}
Friday, July 6, 12
48. Method Conflict
• Can use -alias to make a copy of a role’s method by
another name
• Can use -excludes to avoid consuming a specific method
• Combine both to work around a conflict
Friday, July 6, 12
50. Dynamic Roles
• Roles can be added to instances after creation
• Usage: debug tracing on specific obejct, dynamically change
objects by configuration
• Code:
use Moose::Util qw( apply_all_roles );
my $car = Car->new;
apply_all_roles( $car, 'Breakable' );
Friday, July 6, 12
51. Lab
• Implement a Comparable role which requires a single method:
compare($other) - returns -1 if $other is greater than $self; 0 if
they are equal and +1 if $self is greater.
• Use compare to implement the following:
greater_than, greater_or_equal, less_than, less_or_equal
• Implement a class that consumes the role
Friday, July 6, 12
54. Moose Attributes
• An attribute is a property that every member of a class has
• Some attributes are optional (e.g. some people have a middle
name)
Friday, July 6, 12
55. Attribute Options
• is, reader, writer
• isa
• required, default, builder
• lazy
Friday, July 6, 12
56. Readers & Writers
package Product;
use Moose;
• Use ‘is’ to auto generate
has 'name' => (
reader/writer is => 'rw',
reader => 'get_name',
• Use ‘writer’ to specify writer => '_set_name',
);
writer’s name
has 'price' => (
is => 'rw',
• Use ‘reader’ to specify reader => 'get_price',
reader’s name writer => 'set_price',
);
Friday, July 6, 12
57. Isa
• Use isa to force a type constraint
• Available Types include: Bool, Str, Num, Int, ScalarRef, ArrayRef,
HashRef, CodeRef
• Can use another object as type constraint
• Many more type constraints with option to extend the list
yourself
Friday, July 6, 12
58. Isa
package Store;
use Moose;
use Client;
use Product;
has 'owner', is => 'ro', isa => 'Str';
has 'clients', is => 'rw', isa => 'ArrayRef[Client]';
has 'products', is => 'rw', isa => 'ArrayRef[Product]';
has 'revenue', is => 'rw', isa => 'Num';
1;
Friday, July 6, 12
59. Subtypes
• Use subtypes to easily define new constraints:
use Moose::Util::TypeConstraints;
subtype 'Age',
as 'Int',
where { $_ >= 0 && $_ <= 120 },
message { "Invalid Age: $_ "};
Friday, July 6, 12
60. Enumerations
• Use enum function to declare an enum subtype
• An enum takes a single value from a predefined list
enum 'EyeColor', [qw/green blue brown gray/];
Friday, July 6, 12
61. Required / Default / Builder
• Use required for fields that take their value from “outside”
• Use default / builder for everything else
Friday, July 6, 12
62. Builder
package Person;
use Moose;
has 'pet', is => 'ro', builder =>
'_build_pet';
• Use builder for more has 'age', is => 'rw', required => 1;
complex initialization logic sub _build_pet {
my $self = shift;
if ( $self->age < 13 ) {
return "None";
• builder works better than } else {
return "Dog";
default for inheritance }
}
package main;
my $p = Person->new(age => 10);
print $p->pet;
Friday, July 6, 12
63. lazy
package Person;
use Moose;
has 'pet', is => 'ro', lazy_build => 1;
has 'age', is => 'rw', required => 1;
sub _build_pet {
• Create your attributes only my $self = shift;
if ( $self->age < 13 ) {
when they are needed return "None";
} else {
return "Dog";
• Use lazy_build to type less }
}
package main;
my $p = Person->new(age => 10);
print $p->pet;
Friday, July 6, 12
64. Dependency Injection
•A technique used in testing to build more testable versions of
your classes
• If an attribute has both a builder AND was passed externally,
external value wins
Friday, July 6, 12
65. Lab
• Implement a Logger class with one method: log. In the ctor,
logger can take a file name
• If no arguments passed, create a screen logger (write all
output to screen)
• If a file name was provided, write to that file
• Use dependency injection to test your Logger
Solution: https://gist.github.com/3029901
Friday, July 6, 12
66. Delegation
•A relationship between classes. A class attribute is an object of
a different class
• Can then redirect all calls on containing object to the attribute
- thus delegating specific methods
Friday, July 6, 12
67. Delegation
Send Mail Send Mail
Contact Email
Call
Call
Phone
Friday, July 6, 12
68. Delegation
package Contact;
use Moose;
• Moose handles delegation
for you has 'email' => (
is => 'ro',
handles => [ qw/send_mail/ ]
• Attribute should declare );
“handles” option
Friday, July 6, 12
69. Delegate
• Another option is to has 'uri' => (
is => 'ro',
delegate an entire role isa => 'URI',
handles => 'HasURI',
);
• Moose will delegate all
methods in the role
automatically
Friday, July 6, 12
70. Native Delegation
• Give your object “native” feel by using standard data type
methods
• Currently supported: Array, Hash, Number, String, Bool,
Counter
• Useful for: Fields that should “work like” the native data type
Friday, July 6, 12
71. Native Delegation
has 'q' => (
is => 'ro',
isa => 'ArrayRef[Int]',
default => sub { [] },
• Native arrays have push, traits => [qw/Array/],
pop, shift, unshift and more handles => {
add_item => 'push',
next_item => 'shift',
• Can now use: },
$q->add_item );
to add an item to
package main;
the queue my $q = Queue->new;
$q->add_item(10, 20);
Friday, July 6, 12
75. Predicates & Clearers
• User can upload photos, Uploading Image
other users can “like” No likes yet
• Every photo starts with 0
likes
Image Online
• How many “likes” do you 0 Likes.
have before the image is
online ? Go find more friends
Friday, July 6, 12
76. Predicates & Clearers
package Photo;
use Moose;
has 'likes' => (
• Provide two new methods is => 'rw',
on $self: unpublish and clearer => 'unpublish',
predicate => 'is_published',
is_published );
• Setting value to undef does sub publish {
my $self = shift;
not affect predicate $self->likes ( 0 );
}
Friday, July 6, 12
77. Predicates & Clearers
sub like {
my $self = shift;
die 'Cannot like an Unpublished photo'
if ! $self->is_published;
$self->likes ( $self->likes + 1 );
}
Friday, July 6, 12
78. Constructor Parameters
• Sometimes the name of the attribute is not the same as the
name of the constructor param
•A possible workaround is BUILDARGS, but that’s too tedious
•A better way: Use init_arg
• Usage: modify constructor param name, prevent dependency
injection
Friday, July 6, 12
79. Example: init_arg
• Use to modify constructor
parameter name
has 'bigness' => (
is => 'ro',
• Attribute name is size, while init_arg => 'size',
);
object creation is performed
with:
Cls->new( bigness => 7 )
Friday, July 6, 12
80. Example: init_arg
• Use init_arg => undef to has '_genetic_code' => (
prevent dependency is => 'ro',
lazy_build => 1,
injection init_arg => undef,
);
• Use with caution
Friday, July 6, 12
81. Weak References
Student Student Student
Learns At
Course
Friday, July 6, 12
82. Weak References
• When an object leaves scope, it’s ref-count decreases
• Circular references cause objects to remain in memory
• Weak references to the rescue
Friday, July 6, 12
83. Weak Ref
• When a Course object
leaves the last scope - it will
package Student;
now be deleted use Moose;
has 'name',
• When Course object leaves is => 'ro', required => 1;
scope, Moose will has 'learns_at',
automatically clear all is => 'rw', weak_ref => 1;
“learns_at” attributes of
students
Full Example: https://gist.github.com/3031636
Friday, July 6, 12
84. Triggers
• Called when attribute value has 'size' => (
is set is => 'rw',
trigger => &_size_set,
);
• Called when set from new
or explicitly sub _size_set {
my ( $self, $size, $old_size ) = @_;
}
• Is not called when set from
default or builder
Friday, July 6, 12
88. What is MOP
• An abstraction to build abstractions - or simply put - an API to
build an object system
• Moose is one object system built upon Class::MOP
• Understanding Class::MOP and Moose’s use of it reveals new
features in Moose
Friday, July 6, 12
89. MOP Parts
• The Class protocol
• The Attribute protocol
• The Method protocol
• The Instance protocol
Friday, July 6, 12
90. Moose and Class::MOP
• Moose is built on top of Class::MOP
• Prefixed Moose::Meta (for example Moose::Meta::Class)
• Get with $self->meta
Friday, July 6, 12
91. What Meta Can Do For You
• Class and Object Introspection
• Modify objects and classes dynamically (add/remove methods,
attributes, roles)
• Add more information to attributes (label, persistent)
Friday, July 6, 12
92. Object Introspection
package main;
my $z = Zombie->new;
for my $attr ( $z->meta->get_all_attributes ) {
say $attr->name;
}
for my $method ( $z->meta->get_all_methods ) {
say $method->fully_qualified_name;
}
if ( $z->meta->has_method( 'eat_brain' ) ) {
$z->eat_brain;
}
Full Source: https://gist.github.com/3032056
Friday, July 6, 12
93. Object Introspection
• All meta methods listed under:
Class::MOP::Class and Moose::META::Class
• In most cases, using roles is a better idea than dynamic
checking
Friday, July 6, 12
94. Validate Type Constraints
• Use $self->meta->get_attribtue(attr)->type_constraint to get
meta object of type constraints
• $constraint->check( $value )
• $constraint->validate( $value )
or die $constraint->get_message( $value );
• $constraint->assert_valid( $value )
Friday, July 6, 12
95. Class Modification
• $meta->add_attribute
• $meta->remove_attribute
• $meta->add_method
• $meta->remove_method
• $meta->make_immutable
Friday, July 6, 12
96. Moose::Util
•A bundle of useful functions that take away some of the pain
of working with meta
• Start here before implementing your own.
Friday, July 6, 12
99. Moose Types
Customizable Type System
Friday, July 6, 12
100. Moose Type System
• Verify attribute values are “valid” - of a certain type
• Types have names, so they can be reused
• Type checking is just sugar for method arguments validation.
Perl does not associate types with variables
• Earlier error detection
Friday, July 6, 12
102. Type Registry
•A type is an instance of
Moose::Meta::TypeConstraint
• All types are stored in the type registry. Use
get_type_constraint_registry from
Moose::Util::TypeConstraints to get it
Friday, July 6, 12
103. Example: Print All Constraints
use v5.14;
use Data::Dumper;
use Moose::Util::TypeConstraints;
my $registry =
Moose::Util::TypeConstraints::get_type_constraint_registry();
print Dumper($registry->type_constraints);
Friday, July 6, 12
104. Extending The Type System
• Every Moose object is a new type
• There are also helper methods to create new types
•A new type can be named or anonymous
Friday, July 6, 12
105. Named Subtypes: enum
use v5.14;
package Person::Types;
use Moose::Util::TypeConstraints;
enum 'Person::Types::EyeColor', [qw/gray brown green blue/];
package Person;
use Moose;
use Moose::Util::TypeConstraints;
has 'eyecolor' => (
is => 'ro',
isa => 'Person::Types::EyeColor',
);
Friday, July 6, 12
106. Anonymous Subtypes: enum
use v5.14;
package Person;
use Moose;
use Moose::Util::TypeConstraints;
has 'eyecolor' => (
is => 'ro',
isa => enum [qw/gray blue brown green/],
);
Friday, July 6, 12
107. More Subtypes
• subtype( %opts ) - Create a new subtype
• role_type ‘barks’, { role => ‘Some::Library::Role::Barks’ }
• union ‘UnionName’, [qw/Str ArrayRef/]; - Create a new
subtype that can hold either string or an array
Friday, July 6, 12
108. Subtypes
• Provide ‘as’ to specify base
type subtype 'NaturalLessThanTen',
as 'Natural',
where { $_ < 10 },
• Provide ‘where’ to add message {
constraint on the base type "This number ($_) is
not less than ten!"
};
• Provide your own error
message with ‘message’
Friday, July 6, 12
109. Subtypes Do’s
• Define all your subtype in a single module for code reuse. Use
that module from every Moose class
Friday, July 6, 12
110. Subtypes Do’s
• Prefer namespaced subtypes:
ZombieApocalipse::Human::EyeColor is better than
EyeColor
• Zombies may have different eye color ...
Friday, July 6, 12
111. Type Coercion
Proceed With Caution
Friday, July 6, 12
112. Type Coercion
• Automatically convert invalid data to valid
• Int ------> ArrayRef[Int]
• Str ------> Person
• High risk - an invalid value could coerce thus skipping type
validation
Friday, July 6, 12
113. Type Coercion
use v5.14;
package Student;
use Moose;
use Moose::Util::TypeConstraints;
subtype 'GradesArray', as 'ArrayRef[Int]';
coerce 'GradesArray', from 'Int', via { [ $_ ] };
has 'grades', is => 'ro', isa => 'GradesArray', coerce => 1;
package main;
my $s = Student->new( grades => 77 );
print $s->dump;
Friday, July 6, 12
114. Coercion Don’ts
• Don’t add coercion on Moose’s subtypes
(unfortunately it’ll work)
• Generally, try to avoid coercions
Friday, July 6, 12
118. eXtending Moose
• Moose is (relatively) easy to change and extend
• Writing extensions can take some time and effort BUT
• There are tons of Moose Extensions on CPAN
• Prefixed MooseX, they provide extra or modified functionality
Friday, July 6, 12
121. MooseX::StrictConstructor
package Contact;
use Moose;
use MooseX::StrictConstructor;
has 'email', is => 'ro';
has 'name', is => 'ro';
• Throw exception if
constructor was passed an package main;
unexpected argument # Throw an exception
Contact->new(
name => 'Bob',
emial => '[email protected]');
Friday, July 6, 12
122. MooseX::Singleton
package App;
use MooseX::Singleton;
package main;
• Create only one instance of
a class {
my $app = App->instance;
}
• Has initialization method to
pass arguments if needed {
# same one
my $app = App->instance;
}
Friday, July 6, 12
123. MooseX::FollowPBP
• Use set_x and get_x as
default reader and writer
• SEE ALSO: Perl::Critic
Friday, July 6, 12
124. MooseX::SingleArg
use v5.14;
package Contact;
use Moose;
use MooseX::SingleArg;
• Easily create single arg
single_arg 'name';
constructor (without has 'name', is => 'ro';
wrapping BUILDARGS)
package main;
my $c = Contact->new('Mike');
say $c->name;
Friday, July 6, 12
125. MooseX::HasDefaults
• Automatically use:
use v5.14;
is => ‘ro’ package Point;
use Moose;
use MooseX::HasDefaults::RO;
or:
has ['x', 'y', 'z'];
is => ‘rw’
Friday, July 6, 12
126. MooseX::Privacy
use MooseX::Privacy;
• Restrict visibility of methods
has config => (
is => 'rw',
• private can only be called isa => 'Some::Config',
from within the class traits
);
=> [qw/Private/],
• protected can only be private_method foo => sub {
return 23;
called from within the class };
or any of its subclasses
protected_method bar => sub {
return 42;
• Doesn’t work for roles };
Friday, July 6, 12
127. Heavy Lifting
• Logging: Log4perl
• MooseX::APIRole
• MooseX::Declare
• MooseX::MultiMethods
Friday, July 6, 12
128. Log4perl
• Logging is all about keeping a record of your info at runtime
• Log4perl lets you control how your application logs its data
• Perl’s implementation of log4j
Friday, July 6, 12
129. Log4perl alternatives
• print/warn debug messages: Too simple for real apps
• roll-your-own: Too much work...
• Log4perl is currently the best logging solution for medium-
large perl applications
Friday, July 6, 12
130. Log4perl and Moose
package MyApp;
• Use use Moose;
MooseX::Log:: with 'MooseX::Log::Log4perl';
Log4perl role sub go {
in your class my $self = shift;
$self->log->debug('Starting method go');
• New $self->log->info('Go go go');
attributes: log
$self->log('IO')->info('reading data');
and logger }
Friday, July 6, 12
131. Log4perl Output
• Completely customizable
• Output log to: Screen, File, Socket, DBI, and more
• Example:
[2012/07/06 14:54:34] 130.pl MyApp::go 130.pl (9) MyApp - Starting method go
[2012/07/06 14:54:34] 130.pl MyApp::go 130.pl (10) MyApp - Go go go
[2012/07/06 14:54:34] 130.pl MyApp::go 130.pl (12) IO - reading data
Friday, July 6, 12
135. MooseX::APIRole
package Logger;
use Moose;
• Automatically create a role use MooseX::APIRole;
out of a class sub info { }
sub error { }
• all subroutines become make_api_role 'Logger::API';
‘requires’
package Test;
use Moose;
• Easy to use and very # Fails - Test does not implement
powerful # required methods
with 'Logger::API';
Friday, July 6, 12
136. MooseX::Declare
• Use modern OO syntax for your moose objects
• ‘class’ keywordsdeclares a class. Inside,
MooseX::Method::Signatures is in effect.
• ‘role’ keyword declares a role
Friday, July 6, 12
137. MooseX::Declare
use MooseX::Declare;
class BankAccount {
has 'balance' => ( isa => 'Num', is => 'rw', default => 0 );
method deposit (Num $amount) {
$self−>balance( $self−>balance + $amount );
}
method withdraw (Num $amount) {
my $current_balance = $self−>balance();
( $current_balance >= $amount )
|| confess "Account overdrawn";
$self−>balance( $current_balance − $amount );
}
}
Friday, July 6, 12
138. MooseX::Declare
• Still experimental, API could change
• Inside a method $self is already defined for you, as well as
other input parameters
• Awesome. perldoc MooseX::Declare for more
Friday, July 6, 12
139. MooseX::MultiMethods
• Allow multi methods dispatcher based on input arguments
• Define multiple handlers instead of long if-else blocks
Friday, July 6, 12
140. MooseX::MultiMethods
package Paper; use Moose;
package Scissors; use Moose;
package Rock; use Moose;
package Game;
use Moose;
use MooseX::MultiMethods;
multi method play (Paper $x, Rock $y) { 1 }
multi method play (Scissors $x, Paper $y) { 1 }
multi method play (Rock $x, Scissors $y) { 1 }
multi method play (Any $x, Any $y) { 0 }
my $game = Game->new;
# 1, Paper covers Rock
print $game->play(Paper->new, Rock->new);
Friday, July 6, 12