The document discusses different approaches for designing APIs in iOS development. It begins by examining a subclass approach that limits flexibility but is simple to use. It then explores using a category/extension which allows the API to work on any class but cannot add properties. The document dives into implementing properties by associating objects at runtime, but notes this leads to a lot of boilerplate code that does not scale well. Overall, the document evaluates tradeoffs between approaches for building APIs.
Ask the AEM Community Expert : May Session. This session will cover in depth sling concepts such as Sling Selectors, Default Sling Post Servlet, Sling Models, and the Sling API.
Ask the AEM Community Expert : May Session. This session will cover in depth sling concepts such as Sling Selectors, Default Sling Post Servlet, Sling Models, and the Sling API.
These are the presentation slides demonstratingseven versions of the UI of same HTML5 application using various libraries and frameworks. This application is described in detail in the O'Reilly book "Enterprise Web Development"
A gentle introduction on the use of implicit values & conversions in Scala.
It also introduces some design patterns for which implicit(s) are the building blocks.
http://blog.stratio.com/developers-guide-scala-implicit-values-part/
Some javascript testing patterns that has made writing tests at Refinery29 more maintainable. Covered in this presentation is userContext (or let) in Jasmine, lazy evaluation and shared behavior.
Slide del corso di AngularJs Intermediate tenuto da LinkMe. Si affronteranno argomenti come l’estensione dell’html tramite direttive, la gestione di chiamate a un server API, crud e non solo, gestione di errori del server, validazione di form e alcuni principi del testing automatico.
Java is a programming language designed for use in the distributed environment of the Internet.
Programming language developed for the Web.
Programming language Developed by James Gosling.
Sun Microsystems released java in 1995 as a core component of Sun Java technology.
Java is very versatile, efficient, platform independent and secure.
Java is write once and run anywhere.
About 2 billion Devices using Java in various applications.
Java is used in Embedded devices, Mobile phones, Enterprise Servers, Super computers, Web Servers and Enterprise Appls.
These features makes java technology ideal for network computing.
Effective Java, Third Edition - Keepin' it EffectiveC4Media
Video and slides synchronized, mp3 and slide download available at URL https://bit.ly/2uOURQH.
Joshua Bloch covers some highlights from the third edition of “Effective Java”, concentrating on streams and lambdas. The recently released edition of Effective Java contains one new chapter, fourteen new items, and numerous changes to existing items. Filmed at qconnewyork.com.
Joshua Bloch is the author of Effective Java and coauthor of Java Puzzlers and Java Concurrency in Practice. He was formerly the chief Java architect at Google, a distinguished engineer at Sun Microsystems. He led the design and implementation of numerous Java platform features, including the Java 5 language enhancements and the Java Collections Framework.
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
- Talk from FrontConf Munich 2017
- https://frontconf.com/talks/09-12-2017/reactive-type-safe-webcomponents
Abstract:
You know the drill right? new cool framework/library appears... boom! new Datepicker in that framework follows and soon enough whole UI libraries, again and again....
It's 2017 and it's time to stop this madness once and for all! How you ask?
In this talk we will go through implementation of an app via vanilla web components and explore all the pain points with all these low level primitives that we have natively in the browser.
In the end we will build our custom super tiny reactive type-safe library which will allow us to build web components with a breeze
Write once, use everywhere by using the platform + abstraction for great Developer experience.
Rewrite few familiar Cocoa Touch code examples from Obj-C to Swift by learning to use Closures, Enums, Switch-Case with Pattern matching, Singleton, GCD, CoreGraphics.
Presented at Tel Aviv iOS Developers Meetup.
These are the presentation slides demonstratingseven versions of the UI of same HTML5 application using various libraries and frameworks. This application is described in detail in the O'Reilly book "Enterprise Web Development"
A gentle introduction on the use of implicit values & conversions in Scala.
It also introduces some design patterns for which implicit(s) are the building blocks.
http://blog.stratio.com/developers-guide-scala-implicit-values-part/
Some javascript testing patterns that has made writing tests at Refinery29 more maintainable. Covered in this presentation is userContext (or let) in Jasmine, lazy evaluation and shared behavior.
Slide del corso di AngularJs Intermediate tenuto da LinkMe. Si affronteranno argomenti come l’estensione dell’html tramite direttive, la gestione di chiamate a un server API, crud e non solo, gestione di errori del server, validazione di form e alcuni principi del testing automatico.
Java is a programming language designed for use in the distributed environment of the Internet.
Programming language developed for the Web.
Programming language Developed by James Gosling.
Sun Microsystems released java in 1995 as a core component of Sun Java technology.
Java is very versatile, efficient, platform independent and secure.
Java is write once and run anywhere.
About 2 billion Devices using Java in various applications.
Java is used in Embedded devices, Mobile phones, Enterprise Servers, Super computers, Web Servers and Enterprise Appls.
These features makes java technology ideal for network computing.
Effective Java, Third Edition - Keepin' it EffectiveC4Media
Video and slides synchronized, mp3 and slide download available at URL https://bit.ly/2uOURQH.
Joshua Bloch covers some highlights from the third edition of “Effective Java”, concentrating on streams and lambdas. The recently released edition of Effective Java contains one new chapter, fourteen new items, and numerous changes to existing items. Filmed at qconnewyork.com.
Joshua Bloch is the author of Effective Java and coauthor of Java Puzzlers and Java Concurrency in Practice. He was formerly the chief Java architect at Google, a distinguished engineer at Sun Microsystems. He led the design and implementation of numerous Java platform features, including the Java 5 language enhancements and the Java Collections Framework.
This is an intermediate conversion course for C++, suitable for second year computing students who may have learned Java or another language in first year.
- Talk from FrontConf Munich 2017
- https://frontconf.com/talks/09-12-2017/reactive-type-safe-webcomponents
Abstract:
You know the drill right? new cool framework/library appears... boom! new Datepicker in that framework follows and soon enough whole UI libraries, again and again....
It's 2017 and it's time to stop this madness once and for all! How you ask?
In this talk we will go through implementation of an app via vanilla web components and explore all the pain points with all these low level primitives that we have natively in the browser.
In the end we will build our custom super tiny reactive type-safe library which will allow us to build web components with a breeze
Write once, use everywhere by using the platform + abstraction for great Developer experience.
Rewrite few familiar Cocoa Touch code examples from Obj-C to Swift by learning to use Closures, Enums, Switch-Case with Pattern matching, Singleton, GCD, CoreGraphics.
Presented at Tel Aviv iOS Developers Meetup.
Presented on 8/14/2012 at BostonRb. This talk provides a nice intro and overview of what RubyMotion is and whether or not it's worth incorporating into your development toolkit.
Swift’s design promotes language features like generics and first-class protocols as key architectural components in application development. However, many of the logical patterns that arise, including ones imported from Objective-C, don’t work as we expect them to. In many cases, Swift’s type system resists certain straightforward patterns, such as constraining a property to both a class and a protocol. This talk will highlight several of these challenges, discuss the underlying cause, and evaluate workarounds.
Meet Elcodi, the flexible e-commerce components built on Symfony2Aldo Chiecchia
Elcodi is a suite of bundles for Symfony2 which aim to help developers build and quickly scale e-commerce websites. It is written in a clean, straightforward way to ease and smooth the learning curve and it promotes development productivity, SOLID, DRY principles without adding too many layers of indirection. Some of the goals we think we've reached: Balance between flexibility and development speed, Reusable components and foundations for writing custom Model. We'd like to share some insights on how we are approaching those topics by using rigorous coding standards, enforcing coherence and loose coupling, aiming for comprehensible and self-explaining code. See how you can leverage Symfony components for addressing similar challenges and let's discuss the rationales behind some good practices. And above all, see how to do it without pain, because we think that coding should always be a pleasure and crafting developer-friendly software is in our DNA!
Sharing thoughts about migrating from Objective-C to Swift.
Why, How and What. This presentation was held on Munich iOS Meetup 12/02/15. http://www.meetup.com/de/The-Munich-iOS-Developers-Meetup/events/226586543/
Unethical JavaScript - Giorgio Natili - Codemotion Rome 2017Codemotion
As Douglas Crockford said, JavaScript is one of the most misunderstood languages. Also if the new standardizations brought to a more cohesive lingo, there are still development habits that create unpredictable effects and unreadable code. During this session, we'll dive in those habits discussing how the most recent versions of ECMA script help to write a cleaner and more sustainable JavaScript.
Compose is stable, it's time to integrate it into our apps! But it can be harder than expected and there are some questions to answer. Can the same architecture of a View-based app be reused or should we change it? Should the Compose code be aware of the architecture at all? And should the non UI code be changed to start using Compose? What can be replaced with a Composable, only the layouts or also something else?
Probably the best answer to all these questions is “it depends”, in this talk we’ll see some reasons and how to leverage Compose and the other tools to create a good architecture. Compose is more than just a UI framework and it can seem appealing to use it in a big portion of an app, a good architecture can be useful to limit this portion and use it only when necessary.
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
zkStudyClub - Reef: Fast Succinct Non-Interactive Zero-Knowledge Regex ProofsAlex Pruden
This paper presents Reef, a system for generating publicly verifiable succinct non-interactive zero-knowledge proofs that a committed document matches or does not match a regular expression. We describe applications such as proving the strength of passwords, the provenance of email despite redactions, the validity of oblivious DNS queries, and the existence of mutations in DNA. Reef supports the Perl Compatible Regular Expression syntax, including wildcards, alternation, ranges, capture groups, Kleene star, negations, and lookarounds. Reef introduces a new type of automata, Skipping Alternating Finite Automata (SAFA), that skips irrelevant parts of a document when producing proofs without undermining soundness, and instantiates SAFA with a lookup argument. Our experimental evaluation confirms that Reef can generate proofs for documents with 32M characters; the proofs are small and cheap to verify (under a second).
Paper: https://eprint.iacr.org/2023/1886
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
PHP Frameworks: I want to break free (IPC Berlin 2024)Ralf Eggert
In this presentation, we examine the challenges and limitations of relying too heavily on PHP frameworks in web development. We discuss the history of PHP and its frameworks to understand how this dependence has evolved. The focus will be on providing concrete tips and strategies to reduce reliance on these frameworks, based on real-world examples and practical considerations. The goal is to equip developers with the skills and knowledge to create more flexible and future-proof web applications. We'll explore the importance of maintaining autonomy in a rapidly changing tech landscape and how to make informed decisions in PHP development.
This talk is aimed at encouraging a more independent approach to using PHP frameworks, moving towards a more flexible and future-proof approach to PHP development.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Le nuove frontiere dell'AI nell'RPA con UiPath Autopilot™UiPathCommunity
In questo evento online gratuito, organizzato dalla Community Italiana di UiPath, potrai esplorare le nuove funzionalità di Autopilot, il tool che integra l'Intelligenza Artificiale nei processi di sviluppo e utilizzo delle Automazioni.
📕 Vedremo insieme alcuni esempi dell'utilizzo di Autopilot in diversi tool della Suite UiPath:
Autopilot per Studio Web
Autopilot per Studio
Autopilot per Apps
Clipboard AI
GenAI applicata alla Document Understanding
👨🏫👨💻 Speakers:
Stefano Negro, UiPath MVPx3, RPA Tech Lead @ BSP Consultant
Flavio Martinelli, UiPath MVP 2023, Technical Account Manager @UiPath
Andrei Tasca, RPA Solutions Team Lead @NTT Data
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Enhancing Performance with Globus and the Science DMZGlobus
ESnet has led the way in helping national facilities—and many other institutions in the research community—configure Science DMZs and troubleshoot network issues to maximize data transfer performance. In this talk we will present a summary of approaches and tips for getting the most out of your network infrastructure using Globus Connect Server.
The Metaverse and AI: how can decision-makers harness the Metaverse for their...Jen Stirrup
The Metaverse is popularized in science fiction, and now it is becoming closer to being a part of our daily lives through the use of social media and shopping companies. How can businesses survive in a world where Artificial Intelligence is becoming the present as well as the future of technology, and how does the Metaverse fit into business strategy when futurist ideas are developing into reality at accelerated rates? How do we do this when our data isn't up to scratch? How can we move towards success with our data so we are set up for the Metaverse when it arrives?
How can you help your company evolve, adapt, and succeed using Artificial Intelligence and the Metaverse to stay ahead of the competition? What are the potential issues, complications, and benefits that these technologies could bring to us and our organizations? In this session, Jen Stirrup will explain how to start thinking about these technologies as an organisation.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
6. showyoucarewithyourAPI
- But just sharing your design isn’t enough
- You have to make it easy for people to use it
- But this reminds me of a great quote from Kent Beck…
7. “🙅”
-KentBeck
- Everything is a tradeoff. (paraphrasing here)
- What makes a good API? There are very few clear answers, instead we have to evaluate tradeoffs
16. - MHTextField provides a next/previous input accessory view and scrolling, but is also a subclass
- Subclasses force us to choose one over the other
17. - MHTextField provides a next/previous input accessory view and scrolling, but is also a subclass
- Subclasses force us to choose one over the other
18. @interface UITextField (JVFloatLabeledTextField)
@property (nonatomic, assign)
CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong)
UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong)
UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR;
@end
@interface JVFloatLabeledTextField : UITextField
- A category in ObjC, or an extension in Swift, allows people to use the implementation with *any* text field
- But we can’t add properties on categories/extensions
19. @interface UITextField (JVFloatLabeledTextField)
@property (nonatomic, assign)
CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong)
UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong)
UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR;
@end
- A category in ObjC, or an extension in Swift, allows people to use the implementation with *any* text field
- But we can’t add properties on categories/extensions
20. @interface UITextField (JVFloatLabeledTextField)
@property (nonatomic, assign)
CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong)
UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong)
UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR;
@end
- A category in ObjC, or an extension in Swift, allows people to use the implementation with *any* text field
- But we can’t add properties on categories/extensions
21. @interface UITextField (JVFloatLabeledTextField) {
CGFloat _floatingLabelYPadding;
}
@property (nonatomic, assign)
CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR;
@end
- More precisely, defining a property automatically synthesizes an instance variable
- Can’t do that on a category/extension
22. @interface UITextField (JVFloatLabeledTextField) {
CGFloat _floatingLabelYPadding;
}
@property (nonatomic, assign)
CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR;
@end
- More precisely, defining a property automatically synthesizes an instance variable
- Can’t do that on a category/extension
23. const void * const YPaddingKey = &YPaddingKey;
- (void)setFloatingLabelYPadding:(CGFloat)yPadding {
objc_setAssociatedObject(
self,
YPaddingKey,
@(yPadding),
OBJC_ASSOCIATION_RETAIN_NONATOMIC
);
}
- (CGFloat)floatingLabelYPadding {
return [objc_getAssociatedObject(self, YPaddingKey)
floatValue];
}
- An ivar won’t be auto synthesized if you define custom setters and getters
- We can dynamically tack on objects using the runtime
24. const void * const YPaddingKey = &YPaddingKey;
- (void)setFloatingLabelYPadding:(CGFloat)yPadding {
objc_setAssociatedObject(
self,
YPaddingKey,
@(yPadding),
OBJC_ASSOCIATION_RETAIN_NONATOMIC
);
}
- (CGFloat)floatingLabelYPadding {
return [objc_getAssociatedObject(self, YPaddingKey)
floatValue];
}
- An ivar won’t be auto synthesized if you define custom setters and getters
- We can dynamically tack on objects using the runtime
25. const void * const YPaddingKey = &YPaddingKey;
- (void)setFloatingLabelYPadding:(CGFloat)yPadding {
objc_setAssociatedObject(
self,
YPaddingKey,
@(yPadding),
OBJC_ASSOCIATION_RETAIN_NONATOMIC
);
}
- (CGFloat)floatingLabelYPadding {
return [objc_getAssociatedObject(self, YPaddingKey)
floatValue];
}
- An ivar won’t be auto synthesized if you define custom setters and getters
- We can dynamically tack on objects using the runtime
26. @interface UITextField (JVFloatLabeledTextField)
@property (nonatomic, assign)
CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong)
UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong)
UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR;
@end
- So we just do the same for every property, right?
27. @interface UITextField (JVFloatLabeledTextField)
@property (nonatomic, assign)
CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong)
UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong)
UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR;
@end
- So we just do the same for every property, right?
28. const void * const YPaddingKey = &YPaddingKey;
const void * const FontKey = &FontKey;
const void * const TextColorKey = &TextColorKey;
- (void)setFloatingLabelYPadding:(CGFloat)yPadding {
objc_setAssociatedObject(
self,
YPaddingKey,
@(yPadding),
OBJC_ASSOCIATION_RETAIN_NONATOMIC
);
}
- (CGFloat)floatingLabelYPadding {
return [objc_getAssociatedObject(self, YPaddingKey)
floatValue];
}
- Results in a ton of code for only 3 properties
29. }
- (UIFont *)floatingLabelFont {
return objc_getAssociatedObject(self, FontKey);
}
- (void)setFloatingLabelTextColor:(UIColor *)color {
objc_setAssociatedObject(
self,
TextColorKey,
color,
OBJC_ASSOCIATION_RETAIN_NONATOMIC
);
}
- (UIColor *)floatingLabelTextColor {
return objc_getAssociatedObject(self, TextColorKey);
}
- Results in a ton of code for only 3 properties
30. extension UITextField {
var floatingLabelYPadding: CGFloat {
set {
objc_setAssociatedObject(
self,
YPaddingKey,
newValue,
UInt(OBJC_ASSOCIATION_ASSIGN)
)
}
get {
if let padding = objc_getAssociatedObject(
self, YPaddingKey) as? CGFloat {
return padding
} else {
return 0
}
- In Swift, it’s worse—notice we have to be explicit about the fact that the assoc object might not be set, or may not be the
right type.
- And so much code!
31. extension UITextField {
var floatingLabelYPadding: CGFloat {
set {
objc_setAssociatedObject(
self,
YPaddingKey,
newValue,
UInt(OBJC_ASSOCIATION_ASSIGN)
)
}
get {
if let padding = objc_getAssociatedObject(
self, YPaddingKey) as? CGFloat {
return padding
} else {
return 0
}
- In Swift, it’s worse—notice we have to be explicit about the fact that the assoc object might not be set, or may not be the
right type.
- And so much code!
33. doesn’tscale
- Defining two methods for every new property is nuts
- Too much boilerplate code, but also…
34. // objc4-532/runtime/objc-references.mm
// class AssociationsManager manages a lock / hash table
// singleton pair. Allocating an instance acquires the
// lock, and calling its assocations() method
// lazily allocates it.
class AssociationsManager {
static OSSpinLock _lock;
// associative references:
// object pointer -> PtrPtrHashMap.
static AssociationsHashMap *_map;
public:
AssociationsManager() { OSSpinLockLock(&_lock); }
~AssociationsManager() { OSSpinLockUnlock(&_lock); }
};
- Associated objects are stored in a global hashmap
- The more you add, the worse performance/memory usage gets
- Of course, reference counting also works this way, but…
35. CGFloat *floatingLabelYPadding
UIFont *floatingLabelFont
UIColor *floatingLabelTextColor
UIColor *floatingLabelActiveColor
BOOL animateEvenIfNotFirstResponder
UITextField
(JVFloatLabeledTextField)
- Instead, we can encapsulate these properties in a single “options”, or “configuration” object
36. CGFloat *floatingLabelYPadding
UIFont *floatingLabelFont
UIColor *floatingLabelTextColor
UIColor *floatingLabelActiveColor
BOOL animateEvenIfNotFirstResponder
JVFloatLabeledOptions
- Instead, we can encapsulate these properties in a single “options”, or “configuration” object
37. CGFloat *floatingLabelYPadding
UIFont *floatingLabelFont
UIColor *floatingLabelTextColor
UIColor *floatingLabelActiveColor
BOOL animateEvenIfNotFirstResponder
JVFloatLabeledOptions
UITextField
(JVFloatLabeledTextField)
JVFloatLabeledOptions *options
- Instead, we can encapsulate these properties in a single “options”, or “configuration” object
40. @interface JVFloatLabeledOptions : NSObject
@property (nonatomic, assign)
CGFloat floatingLabelYPadding UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong)
UIFont *floatingLabelFont UI_APPEARANCE_SELECTOR;
@property (nonatomic, strong)
UIColor *floatingLabelTextColor UI_APPEARANCE_SELECTOR;
@end
- From within the implementation, we can access properties on this object
- They’re ordinary properties—no runtime
41. 🙅
- So what are the tradeoffs of using categories over subclasses?
42. composemultiplecategories
- You don’t have to choose between one set of functionality or another
- You don’t have to choose floating labels *or* a cool input accessory—you can have both
44. - I used this and other patterns in an open-source UI library I developed last year, MDCSwipeToChoose
- Category on UIView
45. - I used this and other patterns in an open-source UI library I developed last year, MDCSwipeToChoose
- Category on UIView
46. MDCSwipeOptions *options = [MDCSwipeOptions new];
options.threshold = 130.f;
options.onPan = ^(MDCPanState *state) {
if (state.direction == MDCSwipeDirectionLeft) {
bookmarkView.alpha = 0.f;
dontBookmarkView.alpha = state.thresholdRatio;
} else if (state.direction == MDCSwipeDirectionRight) {
bookmarkView.alpha = state.thresholdRatio;
dontBookmarkView.alpha = 0.f;
}
};
[webView mdc_swipeToChooseSetup:options];
- Add swiping behavior to any view—here a web view
- We create the options object and set its properties
- Then we setup the view using the options—this can only be done once, so the properties can’t be changed—a killer
feature
47. MDCSwipeOptions *options = [MDCSwipeOptions new];
options.threshold = 130.f;
options.onPan = ^(MDCPanState *state) {
if (state.direction == MDCSwipeDirectionLeft) {
bookmarkView.alpha = 0.f;
dontBookmarkView.alpha = state.thresholdRatio;
} else if (state.direction == MDCSwipeDirectionRight) {
bookmarkView.alpha = state.thresholdRatio;
dontBookmarkView.alpha = 0.f;
}
};
[webView mdc_swipeToChooseSetup:options];
- Add swiping behavior to any view—here a web view
- We create the options object and set its properties
- Then we setup the view using the options—this can only be done once, so the properties can’t be changed—a killer
feature
48. MDCSwipeOptions *options = [MDCSwipeOptions new];
options.threshold = 130.f;
options.onPan = ^(MDCPanState *state) {
if (state.direction == MDCSwipeDirectionLeft) {
bookmarkView.alpha = 0.f;
dontBookmarkView.alpha = state.thresholdRatio;
} else if (state.direction == MDCSwipeDirectionRight) {
bookmarkView.alpha = state.thresholdRatio;
dontBookmarkView.alpha = 0.f;
}
};
[webView mdc_swipeToChooseSetup:options];
- Add swiping behavior to any view—here a web view
- We create the options object and set its properties
- Then we setup the view using the options—this can only be done once, so the properties can’t be changed—a killer
feature
49. MDCSwipeOptions *options = [MDCSwipeOptions new];
options.threshold = 130.f;
options.onPan = ^(MDCPanState *state) {
if (state.direction == MDCSwipeDirectionLeft) {
bookmarkView.alpha = 0.f;
dontBookmarkView.alpha = state.thresholdRatio;
} else if (state.direction == MDCSwipeDirectionRight) {
bookmarkView.alpha = state.thresholdRatio;
dontBookmarkView.alpha = 0.f;
}
};
[webView mdc_swipeToChooseSetup:options];
- Add swiping behavior to any view—here a web view
- We create the options object and set its properties
- Then we setup the view using the options—this can only be done once, so the properties can’t be changed—a killer
feature
50. MDCSwipeOptions *options = [MDCSwipeOptions new];
options.threshold = 130.f;
options.onPan = ^(MDCPanState *state) {
if (state.direction == MDCSwipeDirectionLeft) {
bookmarkView.alpha = 0.f;
dontBookmarkView.alpha = state.thresholdRatio;
} else if (state.direction == MDCSwipeDirectionRight) {
bookmarkView.alpha = state.thresholdRatio;
dontBookmarkView.alpha = 0.f;
}
};
[webView mdc_swipeToChooseSetup:options];
- Add swiping behavior to any view—here a web view
- We create the options object and set its properties
- Then we setup the view using the options—this can only be done once, so the properties can’t be changed—a killer
feature
51. MDCSwipeOptions *options = [MDCSwipeOptions new];
options.threshold = 130.f;
options.onPan = ^(MDCPanState *state) {
if (state.direction == MDCSwipeDirectionLeft) {
bookmarkView.alpha = 0.f;
dontBookmarkView.alpha = state.thresholdRatio;
} else if (state.direction == MDCSwipeDirectionRight) {
bookmarkView.alpha = state.thresholdRatio;
dontBookmarkView.alpha = 0.f;
}
};
[webView mdc_swipeToChooseSetup:options];
- Add swiping behavior to any view—here a web view
- We create the options object and set its properties
- Then we setup the view using the options—this can only be done once, so the properties can’t be changed—a killer
feature
52. MDCSwipeOptions *options = [MDCSwipeOptions new];
options.threshold = 130.f;
options.onPan = ^(MDCPanState *state) {
if (state.direction == MDCSwipeDirectionLeft) {
bookmarkView.alpha = 0.f;
dontBookmarkView.alpha = state.thresholdRatio;
} else if (state.direction == MDCSwipeDirectionRight) {
bookmarkView.alpha = state.thresholdRatio;
dontBookmarkView.alpha = 0.f;
}
};
[webView mdc_swipeToChooseSetup:options];
- Add swiping behavior to any view—here a web view
- We create the options object and set its properties
- Then we setup the view using the options—this can only be done once, so the properties can’t be changed—a killer
feature
53. - The view category is configured has a threshold—when the center of the view moves out of the threshold, it gets swiped
offscreen
- I don’t have to worry about the threshold changing, or the pan block, or anything
54. - The view category is configured has a threshold—when the center of the view moves out of the threshold, it gets swiped
offscreen
- I don’t have to worry about the threshold changing, or the pan block, or anything
55. - The view category is configured has a threshold—when the center of the view moves out of the threshold, it gets swiped
offscreen
- I don’t have to worry about the threshold changing, or the pan block, or anything
56. MDCSwipeOptions *options = [MDCSwipeOptions new];
options.threshold = 130.f;
options.onPan = ^(MDCPanState *state) {
if (state.direction == MDCSwipeDirectionLeft) {
bookmarkView.alpha = 0.f;
dontBookmarkView.alpha = state.thresholdRatio;
} else if (state.direction == MDCSwipeDirectionRight) {
bookmarkView.alpha = state.thresholdRatio;
dontBookmarkView.alpha = 0.f;
}
};
[webView mdc_swipeToChooseSetup:options];
- Another thing to note: the pan block takes a single parameter
57. MDCSwipeOptions *options = [MDCSwipeOptions new];
options.threshold = 130.f;
options.onPan = ^(MDCPanState *state) {
if (state.direction == MDCSwipeDirectionLeft) {
bookmarkView.alpha = 0.f;
dontBookmarkView.alpha = state.thresholdRatio;
} else if (state.direction == MDCSwipeDirectionRight) {
bookmarkView.alpha = state.thresholdRatio;
dontBookmarkView.alpha = 0.f;
}
};
[webView mdc_swipeToChooseSetup:options];
- Another thing to note: the pan block takes a single parameter
59. // AFNetworking/AFSecurityPolicy.m
- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust {
return [self evaluateServerTrust:serverTrust
forDomain:nil];
}
- (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust
forDomain:(NSString *)domain {
// ...
}
- With public methods, you can define new methods, and have the old call the new with default parameters
62. options.onPan = ^(UIView *view,
MDCSwipeDirection direction) {
if (direction == MDCSwipeDirectionLeft) {
// ...panning to the left.
}
};
- Obj-C or Swift, block params and delegate callbacks lock you into an API
- So if we add a parameter here…
63. options.onPan = ^(UIView *view,
MDCSwipeDirection direction,
CGFloat thresholdRatio) {
if (direction == MDCSwipeDirectionLeft) {
// ...panning to the left.
}
};
- Obj-C or Swift, block params and delegate callbacks lock you into an API
- So if we add a parameter here…
66. options.onPan = ^(UIView *view,
MDCSwipeDirection direction,
CGFloat thresholdRatio) {
if (direction == MDCSwipeDirectionLeft) {
// ...panning to the left.
}
};
- Instead, you could encapsulate params in an object
67. options.onPan = ^(UIView *view,
MDCSwipeDirection direction,
CGFloat thresholdRatio) {
if (direction == MDCSwipeDirectionLeft) {
// ...panning to the left.
}
};
options.onPan = ^(MDCPanState *state) {
if (state.direction == MDCSwipeDirectionLeft) {
- Instead, you could encapsulate params in an object
68. @interface MDCPanState : NSObject
@property (nonatomic, strong, readonly)
UIView *view;
@property (nonatomic, assign, readonly)
MDCSwipeDirection direction; DEPRECATED_ATTRIBUTE
@property (nonatomic, assign, readonly)
CGFloat thresholdRatio;
@end
- This is a design pattern that Martin Fowler calls “parameter objects”
- One benefit is that it’s easy to change
- Deprecation can help you slowly phase out APIs
69. @interface MDCPanState : NSObject
@property (nonatomic, strong, readonly)
UIView *view;
@property (nonatomic, assign, readonly)
MDCSwipeDirection direction; DEPRECATED_ATTRIBUTE
@property (nonatomic, assign, readonly)
CGFloat thresholdRatio;
@end
- This is a design pattern that Martin Fowler calls “parameter objects”
- One benefit is that it’s easy to change
- Deprecation can help you slowly phase out APIs
70. options.onPan = ^(MDCPanState *state) {
if (state.direction == MDCSwipeDirectionLeft) {
// ...panning to the left.
}
};
- Users will see a warning when they attempt to use the deprecated property
71. options.onPan = ^(MDCPanState *state) {
if (state.direction == MDCSwipeDirectionLeft) {
// ...panning to the left.
}
};
- Users will see a warning when they attempt to use the deprecated property
72. @protocol MDCSwipeToChooseDelegate <NSObject>
@optional
- (void)swipeToChooseView:(UIView *)view
wasChosenWithDirection:(MDCSwipeDirection)direction;
@end
- Same goes for delegates and other protocols—changing params is a major version bump
- Use parameter object for future-proofing
73. @protocol MDCSwipeToChooseDelegate <NSObject>
@optional
- (void)swipeToChooseView:(UIView *)view
wasChosenWithDirection:(MDCSwipeDirection)direction
momentum:(CGFloat)momentum;
@end
- Same goes for delegates and other protocols—changing params is a major version bump
- Use parameter object for future-proofing
74. @protocol MDCSwipeToChooseDelegate <NSObject>
@optional
- (void)swipeToChooseView:(UIView *)view
wasChosenWithParameters:(MDCChosenParameters *)params;
@end
- Same goes for delegates and other protocols—changing params is a major version bump
- Use parameter object for future-proofing
75. 🙅
- So what are the tradeoffs of parameter objects?