This presentation comes with many additional notes (pdf): http://de.slideshare.net/nicolayludwig/7-c-sharp-introductionadvanvcedfeaturespartii-38640489
Check out these exercises: http://de.slideshare.net/nicolayludwig/6-7-c-sharp-introductionadvancedfeaturespartipartiiexercises
- Object-based and generic Collections
- Delegates and Events
- Custom Attributes
- Reflection
This presentation comes with many additional notes (pdf): http://de.slideshare.net/nicolayludwig/4-collections-algorithms-38613530
- Object-based vs. generic Collections
-- Generics Types in Java
- Sequential and associative Collections
- Associative Collections
-- Equivalence-based associative Collections: .Net's SortedDictionary
-- Operations on .Net's IDictionarys
-- Comparison and Implementation of .Net's Interfaces IComparable and IComparer
This presentation comes with many additional notes (pdf): http://de.slideshare.net/nicolayludwig/4-collections-algorithms-38613530
- Object-based vs. generic Collections
-- Generics Types in Java
- Sequential and associative Collections
- Associative Collections
-- Equivalence-based associative Collections: .Net's SortedDictionary
-- Operations on .Net's IDictionarys
-- Comparison and Implementation of .Net's Interfaces IComparable and IComparer
Qcon2011 functions rockpresentation_scalaMichael Stal
This is the part I of the tutorial I planned to give at QCon 2011 on Functional Programming with Scala. It also includes Scala 2.8 as well as upcoming features
This is a little presentation for those interested in learning C#. I find it useful to present this to new clients to see where they are at in the the programming curve.
slide1: the content of functons
slide2: Introduction to function
slide3:function advantages
slide4 -5: types of functions
slide6: elements of user defined functions
A- Storage classes in C
B- Automatic variables
C- External variables or Global variable
D- Static variables
E- Register variables
Problem when extern is not used
Example Using extern in same file
Check out these exercises: http://de.slideshare.net/nicolayludwig/3-cpp-procedural-programmingexercises
- Procedural Programming
- Predefined and User defined Functions
- Declaration and Definition of Functions
- Procedural and recursive Function Calling
- Namespaces and separated Function Definitions
- A Glimpse of Separated Compilation and Translation Units
Qcon2011 functions rockpresentation_scalaMichael Stal
This is the part I of the tutorial I planned to give at QCon 2011 on Functional Programming with Scala. It also includes Scala 2.8 as well as upcoming features
This is a little presentation for those interested in learning C#. I find it useful to present this to new clients to see where they are at in the the programming curve.
slide1: the content of functons
slide2: Introduction to function
slide3:function advantages
slide4 -5: types of functions
slide6: elements of user defined functions
A- Storage classes in C
B- Automatic variables
C- External variables or Global variable
D- Static variables
E- Register variables
Problem when extern is not used
Example Using extern in same file
Check out these exercises: http://de.slideshare.net/nicolayludwig/3-cpp-procedural-programmingexercises
- Procedural Programming
- Predefined and User defined Functions
- Declaration and Definition of Functions
- Procedural and recursive Function Calling
- Namespaces and separated Function Definitions
- A Glimpse of Separated Compilation and Translation Units
This is a beginner's guide to Java 8 Lambdas, accompnied with executable code examples which you can find at https://github.com/manvendrasinghkadam/java8streams. Java 8 Streams are based on Lambdas, so this presentation assumes you know Lambdas quite well. If don't then please let me know I'll create another presentation regarding it with code examples. Lambdas are relatively easy to use and with the power of stream api you can do functional programming in Java right from start. This is very cool to be a Java programmer now.
Goal The goal of this assignment is to help students understand the.pdfarsmobiles
Goal: The goal of this assignment is to help students understand the use of JUnit to test Java
code.
Description: In this assignment you will create a set of unit tests, to test the behavior of the code
written for Assignment 1. To keep things consistent, please use the solution to assignment 1
provided by the instructor. You can find the solution on TRACS, under Resources >
Assignment-related material > Assignment
Solution
s.
A unit test is an automated piece of code that invokes a unit of work in the system and then
checks a single assumption about the behavior of that unit of work. A unit of work is a single
logical functional use case in the system that can be invoked by some public interface (in most
cases). A unit of work can span a single method, a whole class or multiple classes working
together to achieve one single logical purpose that can be verified.
Think of unit testing as a way to test the behavior of the code (or parts of the code) written,
without actually having to run the program. For example, in the case of assignments 1, assume
that the front-end (console user interface) part of the program and the back-end part of the
program (dealership database management) are written by two different developers. How would
the developer of the back-end be able to ensure that the code he/she has written does what it is
supposed to do without having access to the front-end?
A good unit test is:
• Able to be fully automated
• Has full control over all the pieces running.
• Can be run in any order, if part of many other tests
• Runs in memory (no DB or File access, for example)
• Consistently returns the same result (You always run the same test, so no random numbers, for
example.)
• Runs fast
• Tests a single logical concept in the system
• Readable
• Maintainable
• Trustworthy (when you see its result, you don’t need to debug the code just to be sure)
In this assignment, you are asked to create JUnit tests to test the classes and methods written for
assignment 1. First you should consider testing the behavior of theses classes/methods under
normal operation scenarios. For example, to test the method findCar(String vin) of the class
Dealership, you may need to create a test method, which creates a mock Car object and adds it to
the carList before the method findCar can be called to search for it. To ensure that everything
worked as planned, you can then search for the car using its VIN and see if the correct car is
found. Mock objects can be created either in the same test method or before any test methods are
run, using the @BeforeClass annotation.
Subsequently, you can consider creating test cases for unusual scenarios, e.g. when a certain
input or behavior is expected to cause an exception to be thrown, or when a user input is not as
expected.
At the end create a TestRunner class, which has a main method that runs the unit tests that you
have created, and prints out the test results.
Tasks:
1. Implement the JUnit tests to test only the.
(7) cpp abstractions inheritance_part_iiNico Ludwig
- C++11: Explicit Overrides and final Methods
- Run Time Type Identification (RTTI) and dynamic_cast
- protected Members
- Abstract Types with pure virtual Member Functions
- Virtual Destructors
- Inheritance and Operators
Similar to (7) c sharp introduction_advanvced_features_part_ii (20)
Von Gleichungen zu Funktionen
Überblick über ganzrationale Funktionen
Koordinatensysteme für Graphen ganzrationaler Funktionen mit Excels Liniendiagrammen erstellen
Einfache Analyse ganzrationaler Funktionen anhand deren Graphen
Von linearen zu quadratischen Gleichungssystemen
Verschiedene Möglichkeiten quadratische Gleichungssysteme grafisch zu lösen
Koordinatensysteme für quadratische Graphen mit Excels Liniendiagrammen erstellen und Gleichungen damit grafisch lösen
Grafische Interpretation der Lösungen von Normalparabel-Gerade Kombinationen
Diagramme
Einführung linearer Gleichungssysteme mit zwei Unbekannten
Rechnerische und grafische Lösung linearer Gleichungssysteme
Wertetabellen mit Excel erstellen
Koordinatensysteme und lineare Graphen mit Excels Liniendiagrammen erstellen und Gleichungen damit grafisch lösen
Mit großen Tabellen arbeiten
Sortieren und Filtern
Objekte einfügen
Formeln und rechnen mit Excel, insbesondere Zahlen und Textbearbeitung
Relative und absolute Zellbezüge
Funktionen: SUMME(), ANZAHL(), MIN(), MAX(), MITTELWERT(), JETZT(), HEUTE(), ZUFALLSZAHL(), PI() und SUMMEWENN()
Mathematische Probleme in Tabellenform
Geschichtliche Entwicklung
Grundlegende Konzepte und Begriffe in Excel
Selektion, Dateneingabe und Datentypen
Zellformatierung und Inhaltsformatierung
- Vector- and Raster-based Graphics
-- Idea behind Vector- and Raster-based Graphics
-- Crispness
-- Overview of Raster-based Drawing APIs
- Platform independent Graphics and GUIs in the Web Browser
-- Bare HTML Pages
-- Plugins and Problems
-- From rich Content to HTML 5
- Drawing with HTML 5 Canvas
-- Continuous, Event driven and free Drawing
-- Basic Drawing "How does Drawing work with JavaScript?"
-- Interaction with Controls
- Vector- and Raster-based Graphics
-- Idea behind Vector- and Raster-based Graphics
-- Crispness
-- Overview of Raster-based Drawing APIs
- Platform independent Graphics and GUIs in the Web Browser
-- Bare HTML Pages
-- Plugins and Problems
-- From rich Content to HTML 5
- Drawing with HTML 5 Canvas
-- Continuous, Event driven and free Drawing
-- Basic Drawing "How does Drawing work with JavaScript?"
-- Interaction with Controls
- Wires and Bulbs
- Batch Processing
- Terminal and Mainframe
- From the Command-Line to Killer Applications
- Vector Displays and Raster Displays
- Color Displays
- The Mouse and the Takeoff of Interactivity
- The Desktop Metaphor
- Wires and Bulbs
- Batch Processing
- Terminal and Mainframe
- From the Command-Line to Killer Applications
- Vector Displays and Raster Displays
- Color Displays
- The Mouse and the Takeoff of Interactivity
- The Desktop Metaphor
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...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.
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
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.
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.
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.
Welocme to ViralQR, your best QR code generator.ViralQR
Welcome to ViralQR, your best QR code generator available on the market!
At ViralQR, we design static and dynamic QR codes. Our mission is to make business operations easier and customer engagement more powerful through the use of QR technology. Be it a small-scale business or a huge enterprise, our easy-to-use platform provides multiple choices that can be tailored according to your company's branding and marketing strategies.
Our Vision
We are here to make the process of creating QR codes easy and smooth, thus enhancing customer interaction and making business more fluid. We very strongly believe in the ability of QR codes to change the world for businesses in their interaction with customers and are set on making that technology accessible and usable far and wide.
Our Achievements
Ever since its inception, we have successfully served many clients by offering QR codes in their marketing, service delivery, and collection of feedback across various industries. Our platform has been recognized for its ease of use and amazing features, which helped a business to make QR codes.
Our Services
At ViralQR, here is a comprehensive suite of services that caters to your very needs:
Static QR Codes: Create free static QR codes. These QR codes are able to store significant information such as URLs, vCards, plain text, emails and SMS, Wi-Fi credentials, and Bitcoin addresses.
Dynamic QR codes: These also have all the advanced features but are subscription-based. They can directly link to PDF files, images, micro-landing pages, social accounts, review forms, business pages, and applications. In addition, they can be branded with CTAs, frames, patterns, colors, and logos to enhance your branding.
Pricing and Packages
Additionally, there is a 14-day free offer to ViralQR, which is an exceptional opportunity for new users to take a feel of this platform. One can easily subscribe from there and experience the full dynamic of using QR codes. The subscription plans are not only meant for business; they are priced very flexibly so that literally every business could afford to benefit from our service.
Why choose us?
ViralQR will provide services for marketing, advertising, catering, retail, and the like. The QR codes can be posted on fliers, packaging, merchandise, and banners, as well as to substitute for cash and cards in a restaurant or coffee shop. With QR codes integrated into your business, improve customer engagement and streamline operations.
Comprehensive Analytics
Subscribers of ViralQR receive detailed analytics and tracking tools in light of having a view of the core values of QR code performance. Our analytics dashboard shows aggregate views and unique views, as well as detailed information about each impression, including time, device, browser, and estimated location by city and country.
So, thank you for choosing ViralQR; we have an offer of nothing but the best in terms of QR code services to meet business diversity!
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
(7) c sharp introduction_advanvced_features_part_ii
1. 1
(7) Introduction of C# Basics – Advanced Features
– Part II
Nico Ludwig (@ersatzteilchen)
2. 2
TOC
● (7) Introduction of C# – Advanced Features – Part II
– Object-based and generic Collections
– Delegates and Events
– Custom Attributes
– Reflection
3. 3
Collections
● Collections are types that represent a set of other objects (elements or items).
– Certain Collections differ in the way they manage access to their items.
– Roughly we tell sequential from associative Collections.
– Examples from namespace System.Collections: ArrayList, Hashtable, Queue or Stack.
● .Net collections manage references to objects, not the objects itself.
– Value type objects are being boxed into objects, when they are added.
● object-based Collections are not typesafe!
– One can easily introduce run time errors.
4. 4
Type Problems in Collections
// A collection of Objects (the static type of those is System.Object).
ArrayList aList = new ArrayList();
// One can add any type of Object into this collection.
aList.Add(new Bus());
// If we want to access the contained object's interface, we have probably
// to cast down to the dynamic type's interface.
object anObject = aList[0];
VintageCar aVintageCar = (VintageCar)anObject;
//... but we can fail here, e.g. if the actual dynamic type differs from the
// assumed dynamic type. -> Bus is a System.Object, but not a VintageCar!
// This cast will end in an InvalidCastException!
// We'll never reach this line:
double estimatedPrize = aVintageCar.EstimatedPrize;
5. 5
Generic Collections to the Rescue
● Generic collections allow to specify the type of the managed items.
– They live in the namespace System.Collections.Generic.
– A type name is used as argument for a generic type.
– The type names are specified in angle brackets: List<int> -> a list of int.
● Arrays act also like generic collections, but employ another syntax.
● Benefits compared to object-typed Collections:
– With generic types the compiler can check typesafety.
– Downcasting is not required.
● It is also possible to create own generic types:
– Generic classes, interfaces etc.
– The range of allowed generic types can be controlled with constraints.
6. 6
Generic Collections in Action
// A collection of VintageCars (static type).
List<VintageCar> aList = new List<VintageCar>(42);
// We can add any type of VintageCar into this collection.
aList.Add(new VintageCar());
// We can not add Cars, this is a too common type.
aList.Add(new Car()); // Compile time error
// We can not add Buses, this type is no kind of VintageCar.
aList.Add(new Bus()); // Compile time error
// If we want to access the contained object's interface,
// downcasting is not required, the assignment can not fail.
VintageCar aVintageCar = aList[0];
double estimatedPrize = aVintageCar.EstimatedPrize;
7. 7
Delegates
● Often there exist root-algorithms that call other sub-algorithms.
– The root-algorithm is always identical.
– Only the sub-algorithms are a matter of change.
– Example: The root-algorithm "Sort" has a fix structure, but it calls compare-algorithms to compare objects. For each object type
the compare-algorithm is probably different.
● The idea of root- and sub-algorithms make up some kind of "template".
– Root-algorithms such as "Sort" have a fix structure, the sub-algorithms vary.
– For sub-algorithms, interfaces must be defined that fit into that "template".
● .Net introduces the delegate concept to describe the interface of sub-algorithms in a type save manner.
– In C/C++ we have a similar the concept with function pointers.
8. 8
Example of Almost identical Algorithms
public void SortInts(List<int> elements) {
for (int x = 0; x < elements.Count - 1; ++x) {
for (int y = 0; y < elements.Count - 1 - x; ++y) {
if (elements[y] > elements[y + 1])
{
Swap(y, y + 1, elements);
}
}
}
}
public void SortStrings(List<string> elements) {
for (int x = 0; x < elements.Count - 1; ++x) {
for (int y = 0; y < elements.Count - 1 - x; ++y) {
if (0 < string.Compare(elements[y], elements[y + 1]))
{
Swap(y, y + 1, elements);
}
}
}
}
9. 9
Steps to improve the SortXXX Methods
● The comparison expression is the only difference in the implementations!
● Extract this sub-algorithm as method and define its signature as delegate:
public delegate int Compare<T>(T left, T right);
● Sort() gets passed a parameter of delegate type that represents a Compare() method implementation.
● Within Sort() the passed delegate is invoked and its returned value is analyzed.
– I.e. we'll pass another method as argument to the method Sort().
● In effect, the method Sort() is much more useful: it can sort any kinds of objects!
– The programmer has to define a suitable Compare() method.
– The Compare() method's identifier must be passed as argument.
10. 10
The same Algorithm with Delegates
// Definition of the signature of delegate methods:
public delegate int Compare<T>(T left, T right);
// Definition of the "template" algorithm:
public void Sort<T>(List<T> elements, Compare<T> cmp)
{
for (int x = 0; x < elements.Count - 1; ++x)
{
for (int y = 0; y < elements.Count - 1 - x; ++y)
{
// Here the delegate is called:
if (0 < cmp(elements[y], elements[y + 1]))
{
Swap(y, y + 1, elements);
}
}
}
}
11. 11
Delegates in Action
public static void Main(string[] args) {
List<string> sList = new List<string>(2);
sList.Add("World");
sList.Add("Hello");
List<int> iList = new List<int>(2);
iList.Add(2);
iList.Add(17);
// Here the method identifiers are passed as arguments, the Compare-
// operation is delegated to these methods.
Sort<string>(sList, CompareStrings);
Sort<int>(iList, CompareInts);
}
// Two methods with the signature of the delegate Compare:
public int CompareStrings(string s1, string s2) {
return string.Compare(s1, s2);
}
public int CompareInts(int i1, int i2) {
return i1.CompareTo(i2);
}
12. 12
Events
● Sometimes it is useful to get notified, when an object's state is updated.
– E.g. in Cars a notification when the Tank is almost empty is useful.
● Such notifications are implemented as events in the .Net framework.
– Syntactically events are special fields within a type that can refer to functions.
● Observers register to events:
– Registering to an event means to register a delegate instance to an event.
– E.g. the Driver object can register to Car's event TankEmpty to get notified.
– More than one observer can register to the event TankEmpty (multicasting).
● Observed objects can raise events:
– The event's type is a delegate that will be invoked from within the object.
– On raising the event, arguments can be passed as well.
13. 13
Class Car with the Event TankEmpty
// Define the delegate type for the event handler:
public delegate void TankEmptyEventHandler(string info);
public class Car {
// Define the event TankEmpty like a field in Car:
public event TankEmptyEventHandler TankEmpty;
public void EngineRunning() {
if (_tankRunningEmpty && null != TankEmpty) {
// Raise the event:
TankEmpty("Tank less than 5L!");
}
}
}
14. 14
Events in Action
// Two methods that may act as handler for TankEmpty event instances of
// TankEmptyEventHandler.
public static void ReportToConsole(string info) {
public static void Main(string[] args) {
Car car = new Car(); // Object car is being observed here.
// Register the two handlers (use operator -= to unregister). When the
// event is raised these two handlers (the observers) are being called.
car.TankEmpty += ReportToConsole;
car.TankEmpty += DashBoardSignal;
while (true) {
car.EngineRunning();
}
}
Console.WriteLine(info);
}
public static void DashBoardSignal(string info) {
TankEmptySignal.Set(true);
}
15. 15
Custom Attributes
● In C# .Net types and members can be annotated with C# attributes.
– E.g.: private, sealed or readonly.
● Custom attributes allow to add more metadata for a .Net element into IL.
– Declarative nature: A type's behavior is modified without modifying the type itself.
– Consumption: During run time this metadata can be read and interpreted via reflection.
● There exist many predefined run time and compile time custom attributes.
– Examples: FlagsAttribute, ConditionalAttribute, TestAttribute
– How to annotate: Custom attributes can be placed via direct or targeted syntax.
● Programmers can also define custom attributes.
– Custom attributes have to derive from System.Attribute.
16. 16
Compile Time Attribute “Conditional” in Action
public class Debug
{
// The method WriteLine is annotated with ConditionalAttribute("DEBUG"):
[System.Diagnostics.Conditional("DEBUG")]
public static void WriteLine(string message) { /*pass */ }
}
private void F()
{
// Due to the compile time ConditionalAttribute("DEBUG"), this method
// call is only compiled in the "DEBUG" configuration:
System.Diagnostics.Debug.WriteLine("Hello out there!");
}
17. 17
Reflection
● The .Net framework allows to analyze types during run time via reflection.
● Reflection is needed:
– If code must handle unknown types (members, hierarchies etc.).
● This was addressed with dynamic typing in .Net 4 as well.
– If code has to decide upon type features.
● E.g., if code has to analyze custom attributes.
● Reflection is accessible via the type Type and the namespace System.Reflection.
● Reflection should be used sparingly, because it is rather expensive.
– Better use polymorphism and design patterns.
18. 18
Reflecting Type "String"
public void Main() {
// Getting the type of String to start reflection:
Type theStringType = typeof(string);
// Reflecting all custom attributes (also the inherited ones) of the type string:
object[] customAttributes = theStringType.GetCustomAttributes(true);
for (int i = 0; i < customAttributes.Length; ++i) {
Attribute attribute = (Attribute)customAttributes[i];
Console.WriteLine(attribute);
}
// Reflecting all methods of the type String:
object[] methods = theStringType.GetMethods();
for (int i = 0; i < methods.Length; ++i) {
System.Reflection.MethodInfo methodInfo = (System.Reflection.MethodInfo)methods[i];
Console.WriteLine(methodInfo);
}
}
19. 19
C# Features not Covered in this Course
● Operator overloading and user defined indexers.
● Generics in depth.
● Nullable types.
● Iterators and yielding.
● LINQ and Lambda expressions.
● Dynamic typing.
● Programming of: (Web)Services, (Web)Applications with GUI and Concurrent code.
Another perception of generic types/Collections: They define a structure and some or all data types in that structure may change.
Mind that the differences between both algorithms are very small.
The definition of a Delegate type looks a little bit like a typedef in C/C++.
According Compare&lt;T&gt;():
What is the meaning of the T?
Events are like interrupts.
What are interrupts?
Interrupts are interrupting &quot;notifications&quot; issued by the hardware, e.g. I/O.
What are alternative techniques?
Primarily &quot;polling&quot;. Polling means to use software to ask for new events periodically.
The methods ReportToConsole() and DashBoardSignal() are the event handlers. Sometimes such methods are called &quot;callback functions&quot;.
Callback functions implement what we call the &quot;Hollywood principle&quot;: &quot;Don&apos;t call us, we&apos;ll call you!&quot;, they are also an incarnation of the &quot;Inversion of Control” paradigm.
We want to analyze (reflect) the type System.String.
(A good German word for reflection is &quot;Selbstauskunft&quot;.)
Iterate over its custom attributes.
Iterate over its methods.