The document discusses the Objective-C runtime and provides an overview of its main components and functions. It describes how the runtime works with classes, instances, methods, and message passing. It also covers topics like method resolution, forwarding, and method swizzling. Code examples are provided to illustrate concepts like forwarding messages and swizzling methods. URLs are included for additional Objective-C runtime references and documentation.
A class is a code template for creating objects. Objects have member variables and have behaviour associated with them. In python a class is created by the keyword class.
An object is created using the constructor of the class. This object will then be called the instance of the class.
The document discusses basic inheritance in Python. It explains that all classes inherit from the base Object class. Inheritance allows creating subclasses that inherit attributes and methods from a parent superclass. This allows code reuse and adding specialized behavior. An example creates a Contact class to store names and emails, with a Supplier subclass that adds an "order" method. A SupplierCheck subclass then overrides the order method to check the customer balance before processing orders.
The document discusses exporting models trained with S4TF to CoreML format in Swift.
It provides code to:
1. Generate Swift data structures from CoreML protobuf definitions to represent models
2. Export an S4TF model defined with layers, weights, and hyperparameters to the CoreML format
3. Compile, make predictions, and perform personalization/training using the exported CoreML model
The personalization process involves:
1. Generating training data
2. Preparing batch providers for input/output
3. Configuring and running a training task on the CoreML model
4. Saving the retrained model
The document suggests automating the export process by extending S
This document provides an overview of Metro style apps and the C++ language features for building them. It compares the architecture and frameworks of Metro style apps to desktop apps. It then summarizes key C++ language features for Metro style development including reference types, memory management, pointers, events, generics and libraries. The document promotes C++ for building high performance Metro style apps and provides examples of key language concepts.
The document discusses clean coding practices for Java developers. It covers topics such as choosing meaningful names for variables, methods, and classes; writing code that is easy for others to understand; breaking methods down into single logical steps; and using fluent APIs to make code more readable. The presentation provides examples of clean code and ways to refactor code to follow best practices.
This document discusses classes and objects in Python. It defines a Calculator class and demonstrates how to create class attributes, methods, and instances. It explains the __init__ method, self keyword, and how to access attributes and methods. It also covers data attributes versus class attributes, inheritance, method overriding, and calling parent methods. The document provides examples to illustrate these object-oriented programming concepts in Python.
The document provides an overview of the Swift Foundation framework. It discusses key types in Foundation like AffineTransform, CharacterSet, Data, Date, DateComponents, Decimal, FileManager, IndexPath, Measurement, Notification, NSError, URL, and URLComponents. The document also briefly mentions the purpose of each type.
The document provides templates and examples for creating Swing-based GUI applications, servlets, Java Server Pages (JSP), Java Database Connectivity (JDBC), Java Server Faces (JSF), Enterprise Java Beans (EJB), Hibernate, Struts, and web services in Java. It includes templates for common GUI components, servlets, JSP tags, database queries, managed beans, navigation rules, entity beans, Hibernate mappings, actions, and web service providers/consumers.
A class is a code template for creating objects. Objects have member variables and have behaviour associated with them. In python a class is created by the keyword class.
An object is created using the constructor of the class. This object will then be called the instance of the class.
The document discusses basic inheritance in Python. It explains that all classes inherit from the base Object class. Inheritance allows creating subclasses that inherit attributes and methods from a parent superclass. This allows code reuse and adding specialized behavior. An example creates a Contact class to store names and emails, with a Supplier subclass that adds an "order" method. A SupplierCheck subclass then overrides the order method to check the customer balance before processing orders.
The document discusses exporting models trained with S4TF to CoreML format in Swift.
It provides code to:
1. Generate Swift data structures from CoreML protobuf definitions to represent models
2. Export an S4TF model defined with layers, weights, and hyperparameters to the CoreML format
3. Compile, make predictions, and perform personalization/training using the exported CoreML model
The personalization process involves:
1. Generating training data
2. Preparing batch providers for input/output
3. Configuring and running a training task on the CoreML model
4. Saving the retrained model
The document suggests automating the export process by extending S
This document provides an overview of Metro style apps and the C++ language features for building them. It compares the architecture and frameworks of Metro style apps to desktop apps. It then summarizes key C++ language features for Metro style development including reference types, memory management, pointers, events, generics and libraries. The document promotes C++ for building high performance Metro style apps and provides examples of key language concepts.
The document discusses clean coding practices for Java developers. It covers topics such as choosing meaningful names for variables, methods, and classes; writing code that is easy for others to understand; breaking methods down into single logical steps; and using fluent APIs to make code more readable. The presentation provides examples of clean code and ways to refactor code to follow best practices.
This document discusses classes and objects in Python. It defines a Calculator class and demonstrates how to create class attributes, methods, and instances. It explains the __init__ method, self keyword, and how to access attributes and methods. It also covers data attributes versus class attributes, inheritance, method overriding, and calling parent methods. The document provides examples to illustrate these object-oriented programming concepts in Python.
The document provides an overview of the Swift Foundation framework. It discusses key types in Foundation like AffineTransform, CharacterSet, Data, Date, DateComponents, Decimal, FileManager, IndexPath, Measurement, Notification, NSError, URL, and URLComponents. The document also briefly mentions the purpose of each type.
The document provides templates and examples for creating Swing-based GUI applications, servlets, Java Server Pages (JSP), Java Database Connectivity (JDBC), Java Server Faces (JSF), Enterprise Java Beans (EJB), Hibernate, Struts, and web services in Java. It includes templates for common GUI components, servlets, JSP tags, database queries, managed beans, navigation rules, entity beans, Hibernate mappings, actions, and web service providers/consumers.
The document contains details of 9 practical assignments for an Advance Java course. Each practical assignment involves developing a Java program or application to demonstrate a concept. For example, Practical 01 involves creating a program to select stationary products and display prices; Practical 02 creates an editable employee table; Practical 03 uses a split pane to display planet images; and so on. The final practical involves developing a room reservation system using Enterprise Java Beans.
The document discusses principles of writing clean code, including:
- Using consistent code style and formatting through style guides and linters.
- Avoiding duplicate code through principles like DRY.
- Using intention-revealing names for variables, functions, and classes.
- Writing small, single-purpose functions at the same level of abstraction.
- Adding guard clauses and error handling to make code logic cleaner.
- Configuring code through object properties rather than hardcoding values.
JavaScript is the programming language of the web. It can dynamically manipulate HTML content by changing element properties like innerHTML. Functions allow JavaScript code to run in response to events like button clicks or timeouts. JavaScript uses objects and prototypes to define reusable behaviors and properties for objects. It is an important language for web developers to learn alongside HTML and CSS.
Javascript allows interactive content on web pages and control of the browser and document. It is an interpreted scripting language that is cross-platform but support varies. Javascript can provide interactive content, control document appearance and content, and interact with the user through event handlers.
The document discusses different ways to implement threading in Java programs. It provides code examples to demonstrate creating threads by extending the Thread class and implementing the Runnable interface. The code examples show printing output from both the main thread and child threads to illustrate threading concepts. Socket programming and RMI examples are also provided with code to implement client-server applications using threads.
The document provides an overview of fundamental JavaScript concepts such as variables, data types, operators, control structures, functions, and objects. It also covers DOM manipulation and interacting with HTML elements. Code examples are provided to demonstrate JavaScript syntax and how to define and call functions, work with arrays and objects, and select and modify elements of a web page.
JavaScript is a scripting language used to make web pages interactive. It was created in 1995 and standardized as ECMAScript. JavaScript can access and modify the content, structure, and style of documents. It is used to handle events, perform animations, and interact with forms on web pages. Common uses of JavaScript include form validation, navigation menus, lightboxes, and sliders on websites.
This document discusses best practices for writing JavaScript code, including using object-oriented patterns, object hierarchies, and the prototype property to organize code and prevent naming collisions. It also recommends writing reusable code by parameterizing functions, using object literals as flexible parameters, and loading JavaScript on demand. Additionally, it suggests separating content, CSS and JavaScript into different files and reducing file sizes for production.
Important java programs(collection+file)Alok Kumar
The document contains 6 Java programming questions and solutions:
1. A program to find unique and duplicate items in an array.
2. A Product class with properties and methods to sort objects.
3. A program to merge contents of two text files into a third file.
4. A program to count the occurrences of specific words in a file.
5. A program to read a file, add contents to an ArrayList, and write to a new file.
6. A program to print consecutive characters in a string and their frequency.
Java tutorial for Beginners and Entry LevelRamrao Desai
This document provides an overview of key Java concepts including classes, objects, inheritance, interfaces, exceptions, and more. It begins with a roadmap and definitions of object-oriented concepts like class and object. It then covers class variables and methods, visibility, static vs non-static, constructors, and the this keyword. The document also discusses inheritance, polymorphism, interfaces, exceptions, and error handling in Java.
This document discusses JavaScript objects and methods for manipulating strings and performing mathematical calculations. It introduces the Math object which allows common mathematical operations and contains constants like PI. It also covers the String object which allows manipulating and processing strings, including character-level methods, searching/extracting substrings, and generating XHTML tags. Methods like split(), indexOf(), toLowerCase() are described.
The document discusses the Objective-C runtime system. It describes the runtime as an operating system for the Objective-C language that allows interacting with classes, objects, and methods through direct calls or NSObject methods. Key concepts covered include classes, metaclasses, messaging, dynamic method resolution, message forwarding, method swizzling, and key-value observing. The runtime provides low-level access to aspects of Objective-C normally hidden from programmers.
scala.concurrent.Future is familiar to nearly all Scala devs.
This presentation first talks about referential transparency and the IO Monad in general. (Monix Task is an impl of the IO Monad.)
Then it compares Future Monix 3.x Task with their Pros and Cons.
Interop with Future: As Scala's Future is used in many environments and libraries, we look at the conversion from Task to Future and - vice versa - from Future to Task.
I will also take a look at Task evaluation, cancelation and memoization as well as tail recursive loops and asynchronous boundaries.
The presentation will include a comparative discussion on ExecutionContext (required for Future) and Scheduler (required for Task, but only to run it).
Often recurring on the valuable Monix Task doumentation at https://monix.io/docs/3x/eval/task.html the presentation can also be seen as an introduction to Monix Task.
Building l10n Payroll Structures from the Ground upOdoo
The Payroll flow of 13.0 has been functionally and technically improved with new features. The document describes the new payroll structure types and rules that define compensation calculations. Salary rules can include Python code for evaluation that has access to contextual objects like categories, rules, payslips, worked days, and inputs to retrieve necessary values and perform calculations in the payroll process.
JavaScript is a client-side scripting language that can be inserted into HTML pages to make them interactive. It allows dynamic validation of forms, changing HTML element properties like visibility, and reacting to user events like clicks or form submissions. The Document Object Model (DOM) represents an HTML or XML document as a tree structure, allowing JavaScript to programmatically access and modify the content, structure, and styling of the document. Common built-in JavaScript objects include String, Date, Array, Math, and Boolean, which provide properties and methods for manipulating text, dates, lists of values, numbers, and true/false values.
This document provides an overview of Objective-C, including key concepts like runtime, objects, classes, memory management, class interfaces and implementations, protocols, properties, and selectors. It discusses how Objective-C performs tasks at runtime and uses object-oriented programming principles. Methods are invoked by sending object messages, and classes define object types. Memory is managed using reference counting or a garbage collector. The document also provides examples of class interfaces and implementations, as well as using properties and protocols.
This document summarizes key concepts in Ruby including variables, data types, operators, and expressions. It discusses global, instance, and class variables. It also covers local variables, constants, and pseudo-variables. The document explains string concatenation and interpolation. It provides details on arithmetic, comparison, boolean, and ternary operators. It also discusses ranges and the associativity of operators.
This document provides an overview of key concepts that will be covered in Lecture 2 of a Javascript course, including arrays, expressions and operators, functions, if/else and switch constructs, and loop constructs like for, while, and do-while loops. It also discusses data types in Javascript like integers, characters, strings, floats, and booleans. The summary defines arrays as collections of data of the same type with indexes starting at 0. It explains that functions are reusable blocks of code that can accept parameters and return values. Conditionals like if/else and switch-case are covered as constructs to control program flow based on conditions.
Objective-C is an object-oriented programming language that uses message passing to communicate between objects. Objects are represented as C structs with a pointer to their class. The class struct contains metadata about the class like its name, methods, and properties. Objective-C uses a dynamic runtime that allows objects to be modified at runtime via mechanisms like method swizzling and isa swizzling.
The document contains details of 9 practical assignments for an Advance Java course. Each practical assignment involves developing a Java program or application to demonstrate a concept. For example, Practical 01 involves creating a program to select stationary products and display prices; Practical 02 creates an editable employee table; Practical 03 uses a split pane to display planet images; and so on. The final practical involves developing a room reservation system using Enterprise Java Beans.
The document discusses principles of writing clean code, including:
- Using consistent code style and formatting through style guides and linters.
- Avoiding duplicate code through principles like DRY.
- Using intention-revealing names for variables, functions, and classes.
- Writing small, single-purpose functions at the same level of abstraction.
- Adding guard clauses and error handling to make code logic cleaner.
- Configuring code through object properties rather than hardcoding values.
JavaScript is the programming language of the web. It can dynamically manipulate HTML content by changing element properties like innerHTML. Functions allow JavaScript code to run in response to events like button clicks or timeouts. JavaScript uses objects and prototypes to define reusable behaviors and properties for objects. It is an important language for web developers to learn alongside HTML and CSS.
Javascript allows interactive content on web pages and control of the browser and document. It is an interpreted scripting language that is cross-platform but support varies. Javascript can provide interactive content, control document appearance and content, and interact with the user through event handlers.
The document discusses different ways to implement threading in Java programs. It provides code examples to demonstrate creating threads by extending the Thread class and implementing the Runnable interface. The code examples show printing output from both the main thread and child threads to illustrate threading concepts. Socket programming and RMI examples are also provided with code to implement client-server applications using threads.
The document provides an overview of fundamental JavaScript concepts such as variables, data types, operators, control structures, functions, and objects. It also covers DOM manipulation and interacting with HTML elements. Code examples are provided to demonstrate JavaScript syntax and how to define and call functions, work with arrays and objects, and select and modify elements of a web page.
JavaScript is a scripting language used to make web pages interactive. It was created in 1995 and standardized as ECMAScript. JavaScript can access and modify the content, structure, and style of documents. It is used to handle events, perform animations, and interact with forms on web pages. Common uses of JavaScript include form validation, navigation menus, lightboxes, and sliders on websites.
This document discusses best practices for writing JavaScript code, including using object-oriented patterns, object hierarchies, and the prototype property to organize code and prevent naming collisions. It also recommends writing reusable code by parameterizing functions, using object literals as flexible parameters, and loading JavaScript on demand. Additionally, it suggests separating content, CSS and JavaScript into different files and reducing file sizes for production.
Important java programs(collection+file)Alok Kumar
The document contains 6 Java programming questions and solutions:
1. A program to find unique and duplicate items in an array.
2. A Product class with properties and methods to sort objects.
3. A program to merge contents of two text files into a third file.
4. A program to count the occurrences of specific words in a file.
5. A program to read a file, add contents to an ArrayList, and write to a new file.
6. A program to print consecutive characters in a string and their frequency.
Java tutorial for Beginners and Entry LevelRamrao Desai
This document provides an overview of key Java concepts including classes, objects, inheritance, interfaces, exceptions, and more. It begins with a roadmap and definitions of object-oriented concepts like class and object. It then covers class variables and methods, visibility, static vs non-static, constructors, and the this keyword. The document also discusses inheritance, polymorphism, interfaces, exceptions, and error handling in Java.
This document discusses JavaScript objects and methods for manipulating strings and performing mathematical calculations. It introduces the Math object which allows common mathematical operations and contains constants like PI. It also covers the String object which allows manipulating and processing strings, including character-level methods, searching/extracting substrings, and generating XHTML tags. Methods like split(), indexOf(), toLowerCase() are described.
The document discusses the Objective-C runtime system. It describes the runtime as an operating system for the Objective-C language that allows interacting with classes, objects, and methods through direct calls or NSObject methods. Key concepts covered include classes, metaclasses, messaging, dynamic method resolution, message forwarding, method swizzling, and key-value observing. The runtime provides low-level access to aspects of Objective-C normally hidden from programmers.
scala.concurrent.Future is familiar to nearly all Scala devs.
This presentation first talks about referential transparency and the IO Monad in general. (Monix Task is an impl of the IO Monad.)
Then it compares Future Monix 3.x Task with their Pros and Cons.
Interop with Future: As Scala's Future is used in many environments and libraries, we look at the conversion from Task to Future and - vice versa - from Future to Task.
I will also take a look at Task evaluation, cancelation and memoization as well as tail recursive loops and asynchronous boundaries.
The presentation will include a comparative discussion on ExecutionContext (required for Future) and Scheduler (required for Task, but only to run it).
Often recurring on the valuable Monix Task doumentation at https://monix.io/docs/3x/eval/task.html the presentation can also be seen as an introduction to Monix Task.
Building l10n Payroll Structures from the Ground upOdoo
The Payroll flow of 13.0 has been functionally and technically improved with new features. The document describes the new payroll structure types and rules that define compensation calculations. Salary rules can include Python code for evaluation that has access to contextual objects like categories, rules, payslips, worked days, and inputs to retrieve necessary values and perform calculations in the payroll process.
JavaScript is a client-side scripting language that can be inserted into HTML pages to make them interactive. It allows dynamic validation of forms, changing HTML element properties like visibility, and reacting to user events like clicks or form submissions. The Document Object Model (DOM) represents an HTML or XML document as a tree structure, allowing JavaScript to programmatically access and modify the content, structure, and styling of the document. Common built-in JavaScript objects include String, Date, Array, Math, and Boolean, which provide properties and methods for manipulating text, dates, lists of values, numbers, and true/false values.
This document provides an overview of Objective-C, including key concepts like runtime, objects, classes, memory management, class interfaces and implementations, protocols, properties, and selectors. It discusses how Objective-C performs tasks at runtime and uses object-oriented programming principles. Methods are invoked by sending object messages, and classes define object types. Memory is managed using reference counting or a garbage collector. The document also provides examples of class interfaces and implementations, as well as using properties and protocols.
This document summarizes key concepts in Ruby including variables, data types, operators, and expressions. It discusses global, instance, and class variables. It also covers local variables, constants, and pseudo-variables. The document explains string concatenation and interpolation. It provides details on arithmetic, comparison, boolean, and ternary operators. It also discusses ranges and the associativity of operators.
This document provides an overview of key concepts that will be covered in Lecture 2 of a Javascript course, including arrays, expressions and operators, functions, if/else and switch constructs, and loop constructs like for, while, and do-while loops. It also discusses data types in Javascript like integers, characters, strings, floats, and booleans. The summary defines arrays as collections of data of the same type with indexes starting at 0. It explains that functions are reusable blocks of code that can accept parameters and return values. Conditionals like if/else and switch-case are covered as constructs to control program flow based on conditions.
Objective-C is an object-oriented programming language that uses message passing to communicate between objects. Objects are represented as C structs with a pointer to their class. The class struct contains metadata about the class like its name, methods, and properties. Objective-C uses a dynamic runtime that allows objects to be modified at runtime via mechanisms like method swizzling and isa swizzling.
PYTHON-Chapter 3-Classes and Object-oriented Programming: MAULIK BORSANIYAMaulik Borsaniya
Classes and Object-oriented Programming:
Classes: Creating a Class, The Self Variable, Constructor, Types of Variables, Namespaces, Types of Methods (Instance Methods, Class Methods, Static Methods), Passing Members of One Class to Another Class, Inner Classes
Inheritance and Polymorphism: Constructors in Inheritance, Overriding Super Class Constructors and Methods, The super() Method, Types of Inheritance, Single Inheritance, Multiple Inheritance, Method Resolution Order (MRO), Polymorphism, Duck Typing Philosophy of Python, Operator Overloading, Method Overloading, Method Overriding
Abstract Classes and Interfaces: Abstract Method and Abstract Class, Interfaces in Python, Abstract Classes vs. Interfaces,
탑크리에듀교육센터(www.topcredu.co.kr)제공
스프링프레임워크 & 마이바티스(Spring Framework, MyBatis)
18번째 자료입니다. 참고하시어 많은 도움되셨길 바랍니다.
교육 및 수강문의/기타문의사항은 홈페이지(www.topcredu.co.kr)를 통하여 하실 수 있습니다.^^
«Objective-C Runtime в примерах» — Алексей Сторожев, e-Legione-Legion
Цель доклада — вдохновить разработчиков на более глубокое изучение возможностей Objective-C Runtime, показать способы исследования системы, воодушевить аудиторию на эксперименты.
В докладе показаны несколько примеров использования Objective-C Runtime для решения нетипичных задач. Первый пример - реализация простого KVO своими руками тремя способами. Вторым примером показана полезность исследования приватных классов. Рассказано, как во время работы программы получить информацию о протянутых IBOutlet и IBAction в xib и storyboard. В каждом примере присутствуют особенности реализации, на которых сделан акцент и показаны варианты решения или обхода.
The document provides an overview of various Objective-C concepts including classes, objects, methods, properties, protocols, categories, dictionaries, property lists, user defaults, errors, delegates, callbacks, and table views. It discusses core classes like NSString, NSArray, NSDictionary, and NSMutableDictionary. It covers concepts like inheritance, polymorphism, and memory management using retain, release, and autorelease. The document also provides examples of declaring and defining classes, creating class instances, and implementing table views with custom cells.
A lot of people using PHPunit for testing their source code. While I was observing my team
I recognized most of them are only using the standard ssertions like 'assertEquals()' or
'assertTrue()' and are complaining about how hard it is to test the code even when the tests are written first. This talk is about all the stuff not used on a daily basis. It shows you some nice features of PHPUnit and how to use them for your benefit.
Когда тестировать, что тестировать, как тестировать, Как ускорить тесты и упростить их написание. Отказываемся от классических фикстур в пользу динамически создаваемых моделей.
international PHP2011_Bastian Feder_The most unknown Parts of PHPUnitsmueller_sandsmedia
PHPUnit provides many features beyond just testing code including:
- Command line options like --testdox to generate styled reports and --filter to select specific tests.
- Annotations like @covers and @group to document and organize tests.
- Various assertion methods like assertContains(), assertType(), and assertSelectRegExp() to validate test conditions.
- Test listeners that get called at different test execution stages to add functionality.
- Ways to test exceptions like @expectedException and try/catch blocks.
- Mocking features to isolate tests from external dependencies using callbacks and return values.
A lot of people using PHPunit for testing their source code. While I was observing my team I recognized most of them are only using the standard assertions like 'assertEquals()' and are complaining about how hard it is to test the code even when the tests are written first. This talk is about all the stuff not used on a daily basis and it digs deep into uncommon features of PHPUnit.
The document discusses functions and objects in JavaScript. It defines a function as a reusable block of code that performs operations to fulfill a specific task. Functions can be invoked to execute their code. Objects are collections of properties and methods that represent real-world entities. The document describes how to create user-defined functions and objects in JavaScript, including defining properties and methods. It also provides examples of the built-in String and Math objects and their properties and methods.
This document discusses integrating the JRebel plugin with NetBeans by patching NetBeans platform classes at load time. Specifically, it covers adding buttons, menus, and options to NetBeans, integrating with the NetBeans debugger and server adaptors, and programmatically patching NetBeans classes using Javassist to inject JRebel JVM arguments into the server launch process.
1. Job scheduling in PowerShell allows running jobs at scheduled times using triggers and the Register-ScheduledJob cmdlet. An example schedules a daily backup job to run at 3am.
2. The PipelineVariable parameter lets you save command output as a variable accessible in the remainder of the pipeline.
3. Starting in PowerShell 4.0, dynamic method invocation allows calling methods using variable names, and requiring administrator privileges uses a #Requires statement.
The document discusses various features and capabilities of PHPUnit for testing PHP code. It covers command line options for PHPUnit like filters and coverage reports. It also covers different types of assertions for validating test expectations, using annotations to organize tests, and special tests for things like exceptions. The document aims to explain some of the more advanced but lesser known aspects of using PHPUnit for testing.
The document discusses using annotations in Java, providing examples of annotations for servlets, EJBs, web services, CDI, and using frameworks like JUnit, Spring, Javassist, and ASM. It presents code samples to define servlets, session beans, RESTful and SOAP web services, and component injection using annotations instead of XML configurations. The document also demonstrates how to programmatically read annotation values and metadata using reflection, Javassist, and ASM.
This document provides a beginner's guide to unit testing and mocking in Python. It discusses:
1) Using the Mock class to create basic mocks and set mock attributes and return values.
2) Using patch to mock imports when mocks cannot be passed directly. Patch is used to mock methods like requests.post.
3) Best practices for mocking like using spec or spec_set to define the mock's interface and make invalid attribute access raise AttributeError.
4) Common mock assertions like assert_called_once_with to validate mocks are used as expected.
5) Examples patching requests.post to mock network requests and control return values and exceptions.
The document discusses abstract syntax tree (AST) transformations in Groovy and Java. It covers several tools and techniques for AST transformations including Lombok, Groovy, CodeNarc, IntelliJ IDEA, Mirah macros, and how they allow generating code, performing static analysis, and rewriting code at compile time through analyzing and modifying the AST. The key topics are how these tools work by compiling code to an AST, analyzing and modifying the AST nodes, and sometimes generating source code from the transformed AST.
1) The document describes a MOP-based DSL for testing Java programs using OCL specifications.
2) The DSL uses OCL pre and post conditions to specify tests in an @MSpec block, and @Test blocks to define test cases calling multiple @MSpecs.
3) The approach maps Java classes to XMF metaclasses, allowing OCL to access Java objects and invoke methods, handling different implementations like Java or EMF.
Implicit parameters, when to use them (or not)!Julien Truffaut
Implicits values are one of the unique features of Scala but they are very complex and easy to misuse. So in this talk we will discuss various valid use cases and anti-pattern for implicits.
You don’t need to be a Scala expert, I will also present how implicit works at high level.
Have Your Cake and Eat It Too: Meta-Programming Techniques for JavaHoward Lewis Ship
The document discusses meta-programming in Java using bytecode manipulation libraries like ASM. It describes how ASM works by allowing the reading, modification, and writing of Java bytecode. This enables dynamically rewriting classes by adding, removing, or modifying fields and methods at runtime. The document provides an example of using ASM to add a private field to a class. It also discusses how meta-programming techniques can be used to implement features like aspect-oriented programming and dynamic proxies in Java.
9. Instance of Example Class Example Metaclass Example
isa isa
Class BaseExample
isa
Class NSObject
isa
Metaclass
BaseExample
Metaclass NSObject
super_class
super_class
super_class
super_class
Class hierarchy
10. struct objc_method {
SEL method_name; // signature of method
char *method_types; // types of the parameters to the method
IMP method_imp; // memory address of the start of code block
};
typedef struct objc_method *Method;
A selector is the name used to select a method to execute for an object, or the
unique identifier that replaces the name when the source code is compiled.
Selector – C-string;
IMP - typedef id (*IMP)(id self,SEL _cmd,...);
Method
11. NSString *result = [example execWithParam:@"param"];
id objc_msgSend(id self, SEL op, ...)
result = objc_msgSend(example, @selector(execWithParam:), @"param");
Tail-call: typedef id (*IMP)(id self,SEL _cmd,...);
void objc_msgSend(void /* id self, SEL op, ... */ )
NSString *result = ((NSString* (*)(id, SEL, NSString *))objc_msgSend)(example,
@selector(execWithParam:), @"param");
Sending Messages
12. id objc_msgSend(id self, SEL op, ...)
Sends a message with a simple return value to an instance of a class.
double objc_msgSend_fpret(id self, SEL op, ...)
Sends a message with a floating-point return value to an instance of a class.
void objc_msgSend_stret(void * stretAddr, id theReceiver, SEL theSelector, ...)
Sends a message with a data-structure return value to an instance of a class.
id objc_msgSendSuper(struct objc_super *super, SEL op, ...)
Sends a message with a simple return value to the superclass of an instance of a class.
void objc_msgSendSuper_stret(struct objc_super *super, SEL op, ...) Sends a message with a
data-structure return value to the superclass of an instance of a class.
objc_msgSend
14. resolveInstanceMethod
1. Class cache -> class dispatch table -> all super classes
2. resolveInstanceMethod for @dynamic properties
id dynamicGetter(id self, SEL _cmd);
void dynamicSetter(id self, SEL _cmd, id value);
+ (BOOL)isDynamicProperty:(NSString *)selectorString;
+ (BOOL)resolveInstanceMethod:(SEL)sel {
NSString *selectorString = NSStringFromSelector(sel);
if ([self isDynamicProperty:selectorString]) {
if ([selectorString hasPrefix:@"set"]) {
class_addMethod(self, sel, (IMP)dynamicSetter, "v@:@");
} else {
class_addMethod(sel, sel, (IMP)dynamicGetter, "@@:");
}
return YES;
}
return [super resolveInstanceMethod:sel];
}
// "v@:@", "@@:" - Objective-C type encodings
15. forwardingTargetForSelector
3. The Runtime then calls forwardingTargetForSelector
Returns the object to which unrecognized messages should first be directed.
- (id)forwardingTargetForSelector:(SEL)aSelector {
if (aSelector == @selector(magicMethod:)) {
return magicObject;
} else {
return [super forwardingTargetForSelector:aSelector];
}
}