The document summarizes several new features in C# 6, including the nameof() operator, auto-property initialization, indexed initializer lists, the using static directive, method and property expressions, string interpolation, enhanced exception filtering, and the null conditional operator (?.). Some key features allow getting a string representation of an identifier with nameof(), initializing auto-properties to non-default values more easily, using indexers for initialization lists, importing static members to simplify code, string interpolation for building strings with values inline, filtering exceptions based on logical conditions, and safely accessing members and indexers of objects that may be null with the null conditional operator. Overall, the new features add syntactic sugar to help reduce boilerplate code and improve readability
We've all seen the big "macro" features in .NET, this presentation is to give praise to the "Little Wonders" of .NET -- those little items in the framework that make life as a developer that much easier!
C# is a great programming language for modern development. Like any language, however, there are parts of the language and BCL that can trip you up if you have invalid assumptions as to what is going on behind the scenes. This presentation discusses a few of these pitfalls and how to avoid them.
A small presentation I developed that introduces lambda expressions and many of the common LINQ extension methods for a group of developers that were less familiar with these concepts.
Why I use C# lambdas all the time and for everything and so should you.
A presentation on how to use functional programming techniques effectively in C#
We've all seen the big "macro" features in .NET, this presentation is to give praise to the "Little Wonders" of .NET -- those little items in the framework that make life as a developer that much easier!
C# is a great programming language for modern development. Like any language, however, there are parts of the language and BCL that can trip you up if you have invalid assumptions as to what is going on behind the scenes. This presentation discusses a few of these pitfalls and how to avoid them.
A small presentation I developed that introduces lambda expressions and many of the common LINQ extension methods for a group of developers that were less familiar with these concepts.
Why I use C# lambdas all the time and for everything and so should you.
A presentation on how to use functional programming techniques effectively in C#
This slide is prepared from an interview perspective, to help others answer the very famous question "Difference between Comparable and Comparator and when to use which?"
Maintaining the product is one (if not the most) expensive area of the overall product costs. Writing clean code can significantly lower these costs, making it more efficient during the initial development and results in more stable code. In this session participants will learn how to apply C# techniques in order to improve the efficiency, readability, testability and extensibility of code.
Automating C# Coding Standards using StyleCop and FxCopBlackRabbitCoder
As organizations grow they usually seek to build a set of coding standards to enforce uniformity and increase the maintainability of their code base. Unfortunately, this often creates a lot of churn in the code review process for simple style issues. This presentation was a session I gave at St. Louis Day of .NET 2010 and talks about how to automate many of the coding standards using two readily available tools.
Effective Java - Chapter 3: Methods Common to All Objectsİbrahim Kürce
Although object is a concrete class, it is designed primarily for extension.
All of its nonfinal methods (equals, hashCode, toString, clone, and finalize) have explicit general contracts because they are designed to be overridden.
This chapter tells you when and how to override the nonfinal Object methods. The finalize method is omitted from this chapter because it was discussed in Item 7. While not an Object method, Comparable.compareTo is discussed in this chapter because it has a similar character.
JAVA Tutorial- Do's and Don'ts of Java programmingKeshav Kumar
Whether you program regularly in Java, and know it like the back of your hand, or whether you’re new to the language or a casual programmer, you’ll make mistakes. The purpose of this webinar is to talk about some Do's and Don'ts of Java programming.
The webinar will cover the following areas:
- Top 10 mistakes made by Java programmers – How to avoid them
- Core Java- Best Practices – This covers good and bad practices both
- How to prepare for Java Interviews and Sun Java Exams
- Q&A
Key learnings from this webinar:
- It will benefit both junior and senior java professionals so that they don’t make common errors
- Clarity of concepts of Java
- Better awareness of best practices of Java
OCP Java (OCPJP) 8 Exam Quick Reference CardHari kiran G
If you are preparing to appear for Oracle Certified Professional Java SE 8 Programmer (OCPJP 8) certification exam, this a reference card (sort of long cheat sheet) meant to help you. You may want to print this reference card for your easy and quick reference when you prepare for your exam.
Swift Tutorial Part 2. The complete guide for Swift programming languageHossam Ghareeb
Part 2 of The complete guide for Swift programming language. In this part we introduced:
Classes
Inheritance
Computed Properties
Type Level
Lazy
Property Observers
Structures
Equality Vs Identity
Type Casting
Any Vs AnyObject
Protocols
Delegation
Extensions
Generics
Operator Functions
A glimpse at some of the new features for the C++ programming languages that will be introduced by the upcoming C++17 Standard.
This talk was given at the Munich C++ User Group Meetup.
We've all seen the big "macro" features in .NET, this presentation is to give praise to the "Little Wonders" of .NET -- those little items in the framework that make life as a developer that much easier!
This slide is prepared from an interview perspective, to help others answer the very famous question "Difference between Comparable and Comparator and when to use which?"
Maintaining the product is one (if not the most) expensive area of the overall product costs. Writing clean code can significantly lower these costs, making it more efficient during the initial development and results in more stable code. In this session participants will learn how to apply C# techniques in order to improve the efficiency, readability, testability and extensibility of code.
Automating C# Coding Standards using StyleCop and FxCopBlackRabbitCoder
As organizations grow they usually seek to build a set of coding standards to enforce uniformity and increase the maintainability of their code base. Unfortunately, this often creates a lot of churn in the code review process for simple style issues. This presentation was a session I gave at St. Louis Day of .NET 2010 and talks about how to automate many of the coding standards using two readily available tools.
Effective Java - Chapter 3: Methods Common to All Objectsİbrahim Kürce
Although object is a concrete class, it is designed primarily for extension.
All of its nonfinal methods (equals, hashCode, toString, clone, and finalize) have explicit general contracts because they are designed to be overridden.
This chapter tells you when and how to override the nonfinal Object methods. The finalize method is omitted from this chapter because it was discussed in Item 7. While not an Object method, Comparable.compareTo is discussed in this chapter because it has a similar character.
JAVA Tutorial- Do's and Don'ts of Java programmingKeshav Kumar
Whether you program regularly in Java, and know it like the back of your hand, or whether you’re new to the language or a casual programmer, you’ll make mistakes. The purpose of this webinar is to talk about some Do's and Don'ts of Java programming.
The webinar will cover the following areas:
- Top 10 mistakes made by Java programmers – How to avoid them
- Core Java- Best Practices – This covers good and bad practices both
- How to prepare for Java Interviews and Sun Java Exams
- Q&A
Key learnings from this webinar:
- It will benefit both junior and senior java professionals so that they don’t make common errors
- Clarity of concepts of Java
- Better awareness of best practices of Java
OCP Java (OCPJP) 8 Exam Quick Reference CardHari kiran G
If you are preparing to appear for Oracle Certified Professional Java SE 8 Programmer (OCPJP 8) certification exam, this a reference card (sort of long cheat sheet) meant to help you. You may want to print this reference card for your easy and quick reference when you prepare for your exam.
Swift Tutorial Part 2. The complete guide for Swift programming languageHossam Ghareeb
Part 2 of The complete guide for Swift programming language. In this part we introduced:
Classes
Inheritance
Computed Properties
Type Level
Lazy
Property Observers
Structures
Equality Vs Identity
Type Casting
Any Vs AnyObject
Protocols
Delegation
Extensions
Generics
Operator Functions
A glimpse at some of the new features for the C++ programming languages that will be introduced by the upcoming C++17 Standard.
This talk was given at the Munich C++ User Group Meetup.
We've all seen the big "macro" features in .NET, this presentation is to give praise to the "Little Wonders" of .NET -- those little items in the framework that make life as a developer that much easier!
How to make fewer errors at the stage of code writing. Part N3.PVS-Studio
This is the third article where I will tell you about a couple of new programming methods that can help you make your code simpler and safer. You may read the previous two posts here [1] and here [2]. This time we will take samples from the Qt project.
Objectives Assignment 09 Applications of Stacks COS.docxdunhamadell
Objectives
Assignment 09: Applications of Stacks
COSC 2336: Data Structures and Algorithms Fall 2020
• More practice with recursion.
• Practice writing some template functions.
• Use stack ADT to implement given algorithms.
• Practice using Stack class container given as a library in a separate file. • Look at some common applications of stacks.
Description
In this assignment, you will be using the Stack abstract data type we developed for this unit and discussed in our lectures, to implement 4 functions that use a stack data type to accomplish their algorithms. The functions range from relatively simple, straight forward use of a stack, to a bit more complex. But in all 4 cases, you should only need to use the abstract stack interface functions push(), pop(), top(), and isEmpty() in order to successfully use our Stack type for this assignment and the function you are asked to write.
NOTE
You are to use the Stack ADT abstraction give to you for this assignment. If you are familiar with STL stack containers, you are not to use them for this assignment. Part of the assignment is to look over and learn the Stack ADT implementation we give you here based on our textbook Stack examples.
Setup
For this assignment you will be given the following files:
File Name
assg09-tests.cpp assg09-stackfun.hpp assg09-stackfun.cpp Stack.hpp
Stack.cpp
Description
Unit tests for the member functions
you are to write.
Header file where function prototypes for the functions you write using stacks should go. Implementaiton file, the implementation of the 4 functions you write for this assignment go here. Header file defining a Stack ADT for use in implementing the functions for this assignment. You will not make any modifications in this file, you are only going to be using the given Stack. Implementation file for the Stack ADT
template class. You also do not make any changes in this file either.
Set up a multi-file project to compile the .cpp source files and run them as shown for the class. The Makefile you were given should be usable to create a build project using the Atom editor as required in this class. You will only be adding code to the assg09-stackfun.[hpp|cpp] file in this assignment. The Stack.[hpp|cpp] file contains a Stack container. You are to use this Stack ADT for the 4 functions you are to write for this assignment.
1
The general approach you should take for this assignment, and all assignment is:
Set up your project with the given starting code. The files should compile and run, but either no tests will be run, or tests will run but be failing.
For this project, start by uncommenting the first TEST_CASE in the assg09-tests.cpp file. These are the unit tests to test the functionality of your doParenthesisMatch() function, the member function you are to implement.
AddthecorrectfunctionprototypeforthedoParenthesisMatch()memberfunctionintheassg09-stackfun.hpp header file. The prototyp.
Abstract Data Types (a) Explain briefly what is meant by the ter.pdfkarymadelaneyrenne19
Abstract Data Types
(a) Explain briefly what is meant by the term abstract data type (ADT). Give two
reasons why use of ADTs is good programming practice.
(b) Write out a signature, or interface, that defines the operations of a stack ADT.
(c) Consider a string of characters of the form
... (.( ... ).) ...
where ... indicates an arbitrary sequence of characters (except for parentheses),
(.( indicates an arbitrary number (one or more) of opening parentheses, and
similarly ).) indicates an arbitrary number of closing parentheses.
Using only the stack abstraction operations defined above, write pseudocode for
an algorithm that determines, using a stack, whether or not the number of closing
parentheses is the same as the number of opening parentheses.
You may assume the existence of a function read(str,ch) that reads the next character
of string str into ch.
You may also assume that you can invoke a function reportFail, that will cause
termination with failure, and similarly, reportSuccess causes termination with a
success indication.
Further, you may also assume that you can call a function newStack(S) to create
a new empty stack S, and eos(str) that returns false when you reach the end of
the string.
Solution
(a) Explain briefly what is meant by the term abstract data type (ADT). Give two
reasons why use of ADTs is good programming practice.
A data type is a collection of values and a set of operations on those values. That collection and
these operations form a mathematical construct that may be implemented with the use of a
particular hardware or software data structure. The term abstract data type (ADT) refers to the
basic mathematical concept that defines the data type. We have discussed four different
implementations of the list data structure.
In case of implementation of the list with the use of an array, the size of the array gives difficulty
if increased.
To avoid this, we allocate memory dynamically for nodes before connecting these nodes with the
help of pointers.
For this purpose, we made a singly linked list and connected it with the next pointer to make a
chain.
Moving forward is easy but going back is a difficult task.
To overcome this problem, we made a doubly linked list using prev andnext pointers. With the
help of these pointers, we can move forward and backward very easily. Now we face another
problem that the prev pointer of first node and the next pointer of the last node are NULL.
Therefore, we have to be careful in case of NULL pointers. To remove the NULL pointers, we
made the circular link list by connecting the first and last node.
The program employing the list data structure is not concerned with its implementation.
We do not care how the list is being implemented whether through an array, singly linked list,
doubly linked list or circular linked list. It has been witnessed that in these four implementations
of the list, the interface remained the same i.e. it implements the same methods like add, get,
next, start a.
This slide begins your formal investigation of the C# programming language by presenting a number
of bite-sized, stand-alone topics you must be comfortable with as you explore the .NET Framework.
I am Stuart M. I am a C++ Homework Expert at cpphomeworkhelp.com. I hold a Masters in Programming from, the University of Greenwich, UK. I have been helping students with their homework for the past 6 years. I solve homework related to C++. Visit cpphomeworkhelp.com or email info@cpphomeworkhelp.com. You can also call on +1 678 648 4277 for any assistance with C++ Homework.
Globus Connect Server Deep Dive - GlobusWorld 2024Globus
We explore the Globus Connect Server (GCS) architecture and experiment with advanced configuration options and use cases. This content is targeted at system administrators who are familiar with GCS and currently operate—or are planning to operate—broader deployments at their institution.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
Prosigns: Transforming Business with Tailored Technology SolutionsProsigns
Unlocking Business Potential: Tailored Technology Solutions by Prosigns
Discover how Prosigns, a leading technology solutions provider, partners with businesses to drive innovation and success. Our presentation showcases our comprehensive range of services, including custom software development, web and mobile app development, AI & ML solutions, blockchain integration, DevOps services, and Microsoft Dynamics 365 support.
Custom Software Development: Prosigns specializes in creating bespoke software solutions that cater to your unique business needs. Our team of experts works closely with you to understand your requirements and deliver tailor-made software that enhances efficiency and drives growth.
Web and Mobile App Development: From responsive websites to intuitive mobile applications, Prosigns develops cutting-edge solutions that engage users and deliver seamless experiences across devices.
AI & ML Solutions: Harnessing the power of Artificial Intelligence and Machine Learning, Prosigns provides smart solutions that automate processes, provide valuable insights, and drive informed decision-making.
Blockchain Integration: Prosigns offers comprehensive blockchain solutions, including development, integration, and consulting services, enabling businesses to leverage blockchain technology for enhanced security, transparency, and efficiency.
DevOps Services: Prosigns' DevOps services streamline development and operations processes, ensuring faster and more reliable software delivery through automation and continuous integration.
Microsoft Dynamics 365 Support: Prosigns provides comprehensive support and maintenance services for Microsoft Dynamics 365, ensuring your system is always up-to-date, secure, and running smoothly.
Learn how our collaborative approach and dedication to excellence help businesses achieve their goals and stay ahead in today's digital landscape. From concept to deployment, Prosigns is your trusted partner for transforming ideas into reality and unlocking the full potential of your business.
Join us on a journey of innovation and growth. Let's partner for success with Prosigns.
Check out the webinar slides to learn more about how XfilesPro transforms Salesforce document management by leveraging its world-class applications. For more details, please connect with sales@xfilespro.com
If you want to watch the on-demand webinar, please click here: https://www.xfilespro.com/webinars/salesforce-document-management-2-0-smarter-faster-better/
Providing Globus Services to Users of JASMIN for Environmental Data AnalysisGlobus
JASMIN is the UK’s high-performance data analysis platform for environmental science, operated by STFC on behalf of the UK Natural Environment Research Council (NERC). In addition to its role in hosting the CEDA Archive (NERC’s long-term repository for climate, atmospheric science & Earth observation data in the UK), JASMIN provides a collaborative platform to a community of around 2,000 scientists in the UK and beyond, providing nearly 400 environmental science projects with working space, compute resources and tools to facilitate their work. High-performance data transfer into and out of JASMIN has always been a key feature, with many scientists bringing model outputs from supercomputers elsewhere in the UK, to analyse against observational or other model data in the CEDA Archive. A growing number of JASMIN users are now realising the benefits of using the Globus service to provide reliable and efficient data movement and other tasks in this and other contexts. Further use cases involve long-distance (intercontinental) transfers to and from JASMIN, and collecting results from a mobile atmospheric radar system, pushing data to JASMIN via a lightweight Globus deployment. We provide details of how Globus fits into our current infrastructure, our experience of the recent migration to GCSv5.4, and of our interest in developing use of the wider ecosystem of Globus services for the benefit of our user community.
Atelier - Innover avec l’IA Générative et les graphes de connaissancesNeo4j
Atelier - Innover avec l’IA Générative et les graphes de connaissances
Allez au-delà du battage médiatique autour de l’IA et découvrez des techniques pratiques pour utiliser l’IA de manière responsable à travers les données de votre organisation. Explorez comment utiliser les graphes de connaissances pour augmenter la précision, la transparence et la capacité d’explication dans les systèmes d’IA générative. Vous partirez avec une expérience pratique combinant les relations entre les données et les LLM pour apporter du contexte spécifique à votre domaine et améliorer votre raisonnement.
Amenez votre ordinateur portable et nous vous guiderons sur la mise en place de votre propre pile d’IA générative, en vous fournissant des exemples pratiques et codés pour démarrer en quelques minutes.
Navigating the Metaverse: A Journey into Virtual Evolution"Donna Lenk
Join us for an exploration of the Metaverse's evolution, where innovation meets imagination. Discover new dimensions of virtual events, engage with thought-provoking discussions, and witness the transformative power of digital realms."
OpenMetadata Community Meeting - 5th June 2024OpenMetadata
The OpenMetadata Community Meeting was held on June 5th, 2024. In this meeting, we discussed about the data quality capabilities that are integrated with the Incident Manager, providing a complete solution to handle your data observability needs. Watch the end-to-end demo of the data quality features.
* How to run your own data quality framework
* What is the performance impact of running data quality frameworks
* How to run the test cases in your own ETL pipelines
* How the Incident Manager is integrated
* Get notified with alerts when test cases fail
Watch the meeting recording here - https://www.youtube.com/watch?v=UbNOje0kf6E
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
Exploring Innovations in Data Repository Solutions - Insights from the U.S. G...Globus
The U.S. Geological Survey (USGS) has made substantial investments in meeting evolving scientific, technical, and policy driven demands on storing, managing, and delivering data. As these demands continue to grow in complexity and scale, the USGS must continue to explore innovative solutions to improve its management, curation, sharing, delivering, and preservation approaches for large-scale research data. Supporting these needs, the USGS has partnered with the University of Chicago-Globus to research and develop advanced repository components and workflows leveraging its current investment in Globus. The primary outcome of this partnership includes the development of a prototype enterprise repository, driven by USGS Data Release requirements, through exploration and implementation of the entire suite of the Globus platform offerings, including Globus Flow, Globus Auth, Globus Transfer, and Globus Search. This presentation will provide insights into this research partnership, introduce the unique requirements and challenges being addressed and provide relevant project progress.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Globus Compute wth IRI Workflows - GlobusWorld 2024Globus
As part of the DOE Integrated Research Infrastructure (IRI) program, NERSC at Lawrence Berkeley National Lab and ALCF at Argonne National Lab are working closely with General Atomics on accelerating the computing requirements of the DIII-D experiment. As part of the work the team is investigating ways to speedup the time to solution for many different parts of the DIII-D workflow including how they run jobs on HPC systems. One of these routes is looking at Globus Compute as a way to replace the current method for managing tasks and we describe a brief proof of concept showing how Globus Compute could help to schedule jobs and be a tool to connect compute at different facilities.
Developing Distributed High-performance Computing Capabilities of an Open Sci...Globus
COVID-19 had an unprecedented impact on scientific collaboration. The pandemic and its broad response from the scientific community has forged new relationships among public health practitioners, mathematical modelers, and scientific computing specialists, while revealing critical gaps in exploiting advanced computing systems to support urgent decision making. Informed by our team’s work in applying high-performance computing in support of public health decision makers during the COVID-19 pandemic, we present how Globus technologies are enabling the development of an open science platform for robust epidemic analysis, with the goal of collaborative, secure, distributed, on-demand, and fast time-to-solution analyses to support public health.
1. The Little Wonders of C# 6
James Michael Hare
Microsoft Visual C# MVP
4/27/2015
http://www.blackrabbitcoder.net/
@BlkRabbitCoder
2. The CTP for VS2015 is available for download
Includes the CTP for C# 6
Several new language features
No earth-shaking changes
Still compatible with .NET 4.5
Syntactical sugar to help reduce boiler-plate code
Helps improve code readability and maintainability
Visual Studio 2015 is Upon Us!
3. The nameof() operator
Auto-property initialization
Indexed initializer lists
The using static directive
Method and property expressions
String interpolation
Enhanced exception filtering
The null conditional operator (?.)
New C# 6 Features
4. Sometimes we want the name of an identifier as a string
The nameof() Operator
5. We can hard-code, but if we rename the variable, we
have to remember to update the string:
The nameof() Operator (cont)
6. Now, you can get a string representation of an
identifier with nameof():
The nameof() Operator (cont)
7. Before, if you wanted to default an auto-property to a
non-default value, there wasn’t a simple way.
Either:
Create a backing field with initializer, then wrap in
property
Or create an auto-property and then assign a value in
the constructor
This should really be a simple, one-step process.
Auto-Property Initialization
8. Now instead of this:
Auto-Property Initialization (cont)
10. We can now do this!
Reduces several lines of boiler-plating.
Auto-Property Initialization (cont)
11. In addition, you can use it even if the property has no
setter (i.e. a truly read-only property):
Auto-Property Initialization (cont)
12. Initializer lists now allow you to use indexers if the
container supports them.
For example, you used to have to initialize a
dictionary like this:
Indexed Initialization Lists
13. But now you can use the indexer syntax instead:
The syntax is much cleaner and clearly identifies
which string is the key and which is the value.
Indexed Initialization Lists (cont)
14. Warning: just because a container supports indexing doesn’t
mean initializing with it will always be logically sound…
For example:
What’s wrong with this?
Indexed Initialization Lists (cont)
15. It is legal and compiles with no errors.
However, you are attempting to set elements that are
beyond the list size, which List<T> doesn’t allow.
This is the same as doing this:
Indexed Initialization Lists (cont)
16. So remember, it’s just syntactical sugar, it won’t stop
you from performing a run-time illegal action.
To make that example work, you’d have to do
something like:
Indexed Initialization Lists (cont)
17. There are many static methods where the enclosing
class mainly acts as an organization point (e.g. Math).
Sometimes, these class names give context to the
static member being called.
Other times, they become repetitive clutter.
The using static declaration allows you to import the
static members of a type into your namespace.
Also allows you to limit extension methods imported.
The using static Directive
18. Consider the following:
A lot of these class names we can assume from
context or are just organizational clutter.
The using static Directive (cont)
19. If our program is a console app, we can probably
assume the Console.
Similarly, the Math and Enumerable classes don’t add
much. We already know what Pow() and Range() do.
Now, we can import the static members of these
types with using static:
The using static Directive (cont)
20. This would simplify our code to be:
We’ve removed a lot of redundant code without
obscuring the clarity.
The using static Directive (cont)
21. It’s not just for classes, you can import the static
members of structs or enums.
For example, doing this:
Would allow us to do this:
The using static Directive (cont)
22. Warning: just because you can do this doesn’t mean
you always should.
Consider if you ran across this code:
There’s no context, so what the heck are we creating?
Here, the type would have given meaningful context:
The using static Directive (cont)
23. Sometimes, we have properties or methods that are
so simple, the body is mostly boilerplate
Method and Property Expressions
24. You can now simplify with lambda expression syntax:
Handy for simple get-only properties, reduces the
boilerplate around the get { } syntax.
Somewhat reduces syntax burden on methods.
Method and Property Expressions
(cont)
25. Consider building a string in a single statement with
multiple components.
Typically we either use concatenation:
Or string formatting:
String Interpolation
26. The problem with concatenation is that it breaks up
the flow of the string you are building and makes it
harder to envision the result.
Formatting helps solve this, but it removes the actual
values from the string and makes it harder to visualize
where the arguments will be placed.
In addition, if you specify the wrong indexes of
placeholders you will get a runtime error.
String Interpolation (cont)
27. String interpolation fixes this, it allows us to use the
actual values as the placeholders inside the string.
You simply use $ as a string prefix to signal the
compiler to use interpolation, then enclose the values
with curly brackets.
Behind the scenes, the compiler will generate the
appropriate string format expression for you.
Gives you all the power of string formatting, with
ability to visualize the values in the string itself.
String Interpolation (cont)
28. So now, our example becomes:
In addition, all string formatting options are available:
String Interpolation (cont)
29. .NET has long had exception filtering:
Enhanced Exception Filtering
30. Standard exception filtering is fine when you just care
about the type of the exception thrown.
If you needed to make a decision to catch or not
based on logic – instead of type -- it’s clunky.
For example, let’s assume we are dealing with a data
layer that throws a dependency exception with an
IsRetryable property.
You may want to catch and handle if the exception is
retryable, but let it bubble up if not.
Enhanced Exception Filtering (cont)
32. To catch only retryable exceptions, we used to do this:
Enhanced Exception Filtering (cont)
33. Now, with C# 6, you can specify a logical filter as well:
Enhanced Exception Filtering (cont)
34. Now, you can have multiple catches on same type:
Enhanced Exception Filtering (cont)
35. Filtering conditions do not have to involve the
exception, they can be any condition.
Filters are checked in order for the same type, this
means that an unfiltered catch for a type must be
after all filtered catches for that type.
Filter only evaluated if that exception type is thrown.
If exception does not meet the filter, it is not
rethrown behind the scenes, it is simply not caught.
Enhanced Exception Filtering (cont)
36. Have you ever consumed a web method (or other
API) with a deeply nested response?
To be safe you have to do several layers of null checks
before getting to what you really want to check:
Null Conditional Operator
37. C# 6 adds a new null conditional operator (?.) to
access a member if not null, or cascade if null.
This would make our logic:
In the above example, if response is null, or
response.Results is null, the whole result will be null.
Null Conditional Operator (cont)
38. Note that all of these are legal, but different:
The first throws if response null but cascades if
Results is null, the second cascades if response is null
but throws if Results is null, the third cascades both.
Null Conditional Operator (cont)
39. A null-cascade that results in a value type will result in
a nullable value type:
Though you can couple with the null-coallescing
operator (??) to provide a default if null.
Null Conditional Operator (cont)
40. The null conditional operator is not just for
properties, you can use it for method calls as well.
Null Conditional Operator (cont)
42. So what if you want to check for null before invoking
an indexer on an array, List<T>, etc?
C# 6 has a syntax for null cascade on indexers (?[…]):
Null Conditional Operator (cont)
43. C# 6 adds a lot of syntactical sugary goodness.
Some of the features are more powerful than others,
but all have power to help increase maintainability
and readability of your code.
Like any tools, know when to use them and when you
are overusing them.
Visual Studio 2015 is currently in CTP6, moving to RC.
Summary