This session will guide any level of programmer to greater productivity by providing the information needed to write consistent, maintainable code. Learn about project setup, assembly layout, code style, defensive programming and much, much more. We will even go over some real in production code and see what the programmer did wrong in "What's Wrong With this Code?". Code tips are included to help you write better, error free applications. Lots of code examples in C# and VB.NET.
Building nTier Applications with Entity Framework Services (Part 2)David McCarter
Learn how to build real world nTier applications with the new Entity Framework and related services. This second part to the series will focus on using the Entity Framework in an nTier/ SOA world by separating out the different layers using T4 templates and using the new WCF Data Services to easily expose entity models via REST and to Silverlight clients.
Building nTier Applications with Entity Framework Services (Part 1)David McCarter
Learn how to build real world nTier applications with the new Entity Framework and related services. With this new technology built into .NET, you can easily wrap an object model around your database and have all the data access automatically generated or use your own stored procedures and views. The session will demonstrate how to create and consume these new technologies from the ground up and focus on database modeling including views and stored procedures along with coding against the model via LINQ. Dynamic data website will also be demonstrated.
Building nTier Applications with Entity Framework ServicesDavid McCarter
Learn how to build real world nTier applications with the Entity Framework and related services. With this new technology built into .NET, you can easily wrap an object model around your database and have all the data access automatically generated or use your own stored procedures and views. Then learn how to easily and securely expose your object model using WCF with just a few line of code using ADO.NET Data Services. The session will demonstrate how to create and consume these new technologies from the ground up.
This is an introduction session about Microsoft Entity Framework 4.0 (year 2011), since then the technology has evolved and matured in many ways and some of the limitations had been mitigated.
Building nTier Applications with Entity Framework Services (Part 2)David McCarter
Learn how to build real world nTier applications with the new Entity Framework and related services. This second part to the series will focus on using the Entity Framework in an nTier/ SOA world by separating out the different layers using T4 templates and using the new WCF Data Services to easily expose entity models via REST and to Silverlight clients.
Building nTier Applications with Entity Framework Services (Part 1)David McCarter
Learn how to build real world nTier applications with the new Entity Framework and related services. With this new technology built into .NET, you can easily wrap an object model around your database and have all the data access automatically generated or use your own stored procedures and views. The session will demonstrate how to create and consume these new technologies from the ground up and focus on database modeling including views and stored procedures along with coding against the model via LINQ. Dynamic data website will also be demonstrated.
Building nTier Applications with Entity Framework ServicesDavid McCarter
Learn how to build real world nTier applications with the Entity Framework and related services. With this new technology built into .NET, you can easily wrap an object model around your database and have all the data access automatically generated or use your own stored procedures and views. Then learn how to easily and securely expose your object model using WCF with just a few line of code using ADO.NET Data Services. The session will demonstrate how to create and consume these new technologies from the ground up.
This is an introduction session about Microsoft Entity Framework 4.0 (year 2011), since then the technology has evolved and matured in many ways and some of the limitations had been mitigated.
Learn Entity Framework in a day with Code First, Model First and Database FirstJibran Rasheed Khan
Learn Entity Framework in a day with Code First, Model First and Database First
•Introduction to Entity Framework (EF)
•Architecture
•What’s new!
•Different approaches to work with (Code first, Database first and model first)
•Choosing right work model
•Pictorial Tour to each model
•Features & Advantages
•Question & Answer
for any help and understanding feel free to contact
thank you
Entity Framework, Code First, Database First, TPH, TPT, TPC. Table Per Type, Table Per Hierarchy, Table Per Concrete Class, EF Concurrency, EF Relationship, Code First Conventions
Learn about how object-relational mapping works to provide data access and understand what the Entity Framework is and how it can provide robust data access services to applications.
Building nTier Applications with Entity Framework Services (Part 1)David McCarter
Learn how to build real world nTier applications with the new Entity Framework and related services. With this new technology built into .NET, you can easily wrap an object model around your database and have all the data access automatically generated or use your own stored procedures and views. The session will demonstrate how to create and consume these new technologies from the ground up and focus on database modeling including views and stored procedures along with coding against the model via LINQ. Dynamic data website will also be demonstrated. Lots of code! Make sure to attend Part 2.
Learn Entity Framework in a day with Code First, Model First and Database FirstJibran Rasheed Khan
Learn Entity Framework in a day with Code First, Model First and Database First
•Introduction to Entity Framework (EF)
•Architecture
•What’s new!
•Different approaches to work with (Code first, Database first and model first)
•Choosing right work model
•Pictorial Tour to each model
•Features & Advantages
•Question & Answer
for any help and understanding feel free to contact
thank you
Entity Framework, Code First, Database First, TPH, TPT, TPC. Table Per Type, Table Per Hierarchy, Table Per Concrete Class, EF Concurrency, EF Relationship, Code First Conventions
Learn about how object-relational mapping works to provide data access and understand what the Entity Framework is and how it can provide robust data access services to applications.
Building nTier Applications with Entity Framework Services (Part 1)David McCarter
Learn how to build real world nTier applications with the new Entity Framework and related services. With this new technology built into .NET, you can easily wrap an object model around your database and have all the data access automatically generated or use your own stored procedures and views. The session will demonstrate how to create and consume these new technologies from the ground up and focus on database modeling including views and stored procedures along with coding against the model via LINQ. Dynamic data website will also be demonstrated. Lots of code! Make sure to attend Part 2.
Back-2-Basics: .NET Coding Standards For The Real World (2011)David McCarter
Revamped for 2011 (90% new material), this session will guide any level of programmer to greater productivity by providing the information needed to write consistent, maintainable code. Learn about project setup, assembly layout, code style, defensive programming and much, much more. Code tips are included to help you write better, error free applications. Lots of code examples in C# and VB.NET. This session is based off my latest book, David McCarter's .NET Coding Standards.
Stopping the Rot - Putting Legacy C++ Under TestSeb Rose
Presentation given at the ACCU 2011 Conference in Oxford, UK.
Case study of applying unit test to the DOORS codebase. Includes a quick overview of unit test & the Google Test and Mock libraries. Also 3 specific refactoring examples shown.
Some of the most common and easy-to-calculate/easy-to-measure code metrics. Understanding these can help you make your code better: avoiding code rot and writing maintainable code all starts here. Content is created for C# .net, however, the underlying principles apply to other languages/frameworks as well.
This presentation introduces the principles of high-quality programming code construction during the software development process. The quality of the code is discussed in its most important characteristics – correctness, readability and maintainability. The principles of construction of high-quality class hierarchies, classes and methods are explained. Two fundamental concepts – “loose coupling” and “strong cohesion” are defined and their effect on the construction of classes and subroutines is discussed. Some advices for correctly dealing with the variables and data are given, as well as directions for correct naming of the variables and the rest elements of the program. Best practices for organization of the logical programming constructs are explained. Attention is given also to the “refactoring” as a technique for improving the quality of the existing code. The principles of good formatting of the code are defined and explained. The concept of “self-documenting code” as a programming style is introduced.
Best Coding Practices For Android Application DevelopmentKetan Raval
Learn how to make coding at the time of android application development. Best practices for coding for android app development. Points to take care at the time of development application.
10 years after the release of the original book Domain Driven Design by Eric Evans we are seeing more and more applications built on the core concepts of DDD. Still, there is a long way to go before we fully grasp all its potential. First we need to change the way we do things in our projects. In this session I will show a possible implementation in C# that I've been using in many projects.
Have you ever not gotten a job because you weren’t prepared for the interview? Would you like a big raise? Do you need motivation to rock your career? I’ve interviewed 100’s of software developers and will share my knowledge on how to survive, what we look for and even divulge some of the secrets we use during the process. Whether you are looking for a new position within your company or at a new company. This session will include crazy and strange interview stories from engineers just like you! This session includes tips to get you started, working with recruiters, getting prepared, the technical interview and more. You will also learn what is the #1 question you need to ask during an interview… it’s a game changer!
This session will introduce developers to the new powerful new feature that is part of the .NET 4.5 framework called Code Contracts. Code Contracts brings the advantages of design-by-contract programming to .NET programming. Contracts are used to improve testing via run-time checking, enable static contract verification, and documentation generation.
This session will introduce developers to the new powerful new feature that is part of the .NET 4.5 framework called Code Contracts. Code Contracts brings the advantages of design-by-contract programming to .NET programming. Contracts are used to improve testing via runtime checking, enable static contract verification, and documentation generation.
.NET Coding Standards For The Real World (2012)David McCarter
Revamped for 2012, this session will guide any level of programmer to greater productivity by providing the information needed to write consistent, maintainable code. Learn about project setup, assembly layout, code style, defensive programming and much, much more. Code tips are included to help you write better, error free applications. Lots of code examples in C# and VB.NET. This session is based off my latest book, David McCarter's .NET Coding Standards.
Have you ever not gotten a job due to not being prepared for the technical interview? I've have interviewed 100's of software developers and will share my knowledge on how to survive, what we look for and even divulge some of the secrets we use during the process.
Real World API Design Using The Entity Framework ServicesDavid McCarter
In this session I will show you how I used the Entity Framework Services to design and create an API servicing layer to expose back end data to partners. We will dive into using the Entity Framework (data layer), WCF Data Services (service layer), T4 templates (business entities), WCF Message Inspectors (security) and more.
Back-2-Basics: Exception & Event Instrumentation in .NETDavid McCarter
This session will instruct any level of programmer on how to easily use tracing that is built into .NET to log and analyze Exceptions and events that occur during application runtime. This is invaluable to fix bugs that only happen while the application is running. .NET TraceListeners will be discussed in detail along with how to write your own custom TraceListeners. I will also discuss and provide code for my centralized exception/ event logging system that allows applications at customer sites or on multiple servers to log to central database. Developers or technical support personal can then view these entries via an ASP.NET web site.
Building nTier Applications with Entity Framework Services (Part 2)David McCarter
Learn how to build real world nTier applications with the new Entity Framework and related services. Make sure to attend Part 1. This second part to the series will focus on using the Entity Framework in an nTier/ SOA world by separating out the different layers using T4 templates and using the new WCF Data Services to easily expose entity models via REST and to Silverlight clients. Lots of code!
Back-2-Basics: .NET Coding Standards For The Real WorldDavid McCarter
This session will guide any level of programmer to greater productivity by providing the information needed to write consistent, maintainable code. Learn about project setup, assembly layout, code style, defensive programming and much, much more. We will even go over some real in production code and see what the programmer did wrong in "What's Wrong With this Code?". Code tips are included to help you write better, error free applications. Lots of code examples in C# and VB.NET.
Back-2-Basics: Exception & Event Instrumentation in .NETDavid McCarter
This session will instruct any level of programmer on how to easily use tracing that is built into .NET to log and analyze Exceptions and events that occur during application runtime. This is invaluable to fix bugs that only happen while the application is running. .NET TraceListeners will be discussed in detail along with how to write your own custom TraceListeners. I will also discuss and provide code for my centralized exception/ event logging system that allows applications at customer sites or on multiple servers to log to central database. Developers or technical support personal can then view these entries via an ASP.NET web site.
Building N Tier Applications With Entity Framework Services 2010David McCarter
Learn how to build real world nTier applications with the new Entity Framework and related services introduced in .NET 3.5 SP1. With this new technology built into .NET, you can easily wrap an object model around your database and have all the data access automatically generated or use your own stored procedures and views. Then learn how to easily and securely expose your object model using WCF with just a few line of code using ADO.NET Data Services. The session will demonstrate how to create and consume these new technologies from the ground up. Lots of code!
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
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.
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
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!
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
Why You Should Replace Windows 11 with Nitrux Linux 3.5.0 for enhanced perfor...SOFTTECHHUB
The choice of an operating system plays a pivotal role in shaping our computing experience. For decades, Microsoft's Windows has dominated the market, offering a familiar and widely adopted platform for personal and professional use. However, as technological advancements continue to push the boundaries of innovation, alternative operating systems have emerged, challenging the status quo and offering users a fresh perspective on computing.
One such alternative that has garnered significant attention and acclaim is Nitrux Linux 3.5.0, a sleek, powerful, and user-friendly Linux distribution that promises to redefine the way we interact with our devices. With its focus on performance, security, and customization, Nitrux Linux presents a compelling case for those seeking to break free from the constraints of proprietary software and embrace the freedom and flexibility of open-source computing.
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
GridMate - End to end testing is a critical piece to ensure quality and avoid...ThomasParaiso2
End to end testing is a critical piece to ensure quality and avoid regressions. In this session, we share our journey building an E2E testing pipeline for GridMate components (LWC and Aura) using Cypress, JSForce, FakerJS…
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. What’s changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
UiPath Test Automation using UiPath Test Suite series, part 5DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 5. In this session, we will cover CI/CD with devops.
Topics covered:
CI/CD with in UiPath
End-to-end overview of CI/CD pipeline with Azure devops
Speaker:
Lyndsey Byblow, Test Suite Sales Engineer @ UiPath, Inc.
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
3. Check Out Your Local User Groups! San Diego Cloud Computing User Group www.azureusergroup.com/group/sandiegoazureusergroup San Diego .NET Developers Group www.sddotnetdg.org San Diego .NET User Group www.sandiegodotnet.com San Diego SQL Server User Group www.sdsqlug.org
4. Win Free Software! Rules Provide your business card (or email and name)* Indicate on the back what software you are interested in Otherwise I will pick Winners will be picked next week *Yes, most likely I’m going to send you and email about my user group (sddotnetdg.org) and or web site (dotNetTips.com) Prizes CodeRush and Refactor Pro from DevExpress (4) SecondCopy (automatic backup software) (5) * CodeIt.Right Standard from SubMain (4) *Requires mailing address and phone number
7. Why Do You Need Standards? First, you might not agree witheverything I say… that’s okay! Pick a standard for your company Every programmer on the same page Easier to read and understand code Easier to maintain code Produces more stable, reliable code Stick to the standard!!!
8. After Selecting a Standard Make sure it’s easily available to each programmer Print or electronically Enforce via code reviews Provide programs to make it easier for programmers to maintain: StyleCop – Free for C# programmers. CodeIt.Right – Enterprise edition shares profiles. Can create custom profiles for your company.
9. Real World Analysis Example Scenario: In production Client Server Application with millions in sales Nine projects of 183,177 lines of .NET code written by multiple programmers (junior to principal) StyleCop Analyze Code.It Right 7,076 < 1,100 6,216 < 2,527 5,091 < 1,837 This is why you need to follow good coding practices throughout the lifecycle of the project!
12. General Assembly Tips Never hardcode strings that might change based on deployment such as connection strings Best place to put them are in user or application level Settings in your application. Remember to save on exit and load on start! Automatic in VB.NET Other locations can include: Registration Database, Databases and more… DEMO
13. General Assembly Tips Sign (strong name) your assemblies, including the client applications. Also, sign interop assemblies with the project’s .snk file Name assemblies in the following format: <Company>.<Component>.dll Project names should be named the same. Microsoft.VisualBasic.dll dotNetTips.Utility.dll Acme.Services.References.dll
14. Mark as CLS Compliant Forces your assembly to be compliant with the Common Language Specification (CLS). Assemblies, modules, and types can be CLS-compliant even if some parts of the assembly, module, or type are not CLS-compliant, as long as these two conditions are met: If the element is marked as CLS-compliant, the parts that are not CLS-compliant must be marked using CLSCompliantAttribute with its argument set to false. A comparable CLS-compliant alternative member must be supplied for each member that is not CLS-compliant. DEMO
16. Elements of the Same Type Should appear in this order: public elements protected elements internal elements private elements Use #region/ #endregion to group namespace-level and class-level elements Use separate regions to organize the private, protected, and internal members.
17. Namespaces The general rule for naming namespaces is to use the company name followed by the technology name and optionally the feature and design CompanyName.TechnologyName[.Feature][.Design]
18. Enums Use abbreviations sparingly for Enums and their values Do not use an Enum suffix on Enum type names Use a singular name for most Enum types, but use a plural name for Enum types that are bit fields
19. Enums Always add the FlagsAttribute to a bit field Enum type Avoid providing explicit values for Enums (unless necessary) Avoid specifying a type for an Enum Public Enum WebServiceAction GetCurrentMode PauseService ResumeService StartService StopService End Enum
20. Interfaces Prefix interface names with the letter “I” Do not use the underscore character. Use abbreviations sparingly. Challenging to version over releases The smaller, more focused the interface the better public interface IDisposable { // Methods
void Dispose(); }
21. Classes Use a noun or noun phrase to name a class. Avoid putting multiple classes in a single file. A file name should reflect the class it contains. Provide a default private constructor if there are only static methods and properties on a class. Use Static Class in C# or a Module in VB.NET
22. Events Use Pascal case Use an EventHandler suffix on event handler names. Name an event argument class with the EventArgs suffix. Use EventHandler<> to declare handlers. Be careful with non-UI threads calling back to the UI! Use the BackgroundWorker Control in Windows Forms DEMO
23. Member Variables (Fields) Use camel case as a rule, or uppercase for very small words Prefix private variables with a "_” Member variables should not be declared public Use a Property instead Const member variables may be declared public
24. Properties Use Pascal case Use a noun or noun phrase to name properties Properties that return arrays or collections should be methods. Do not use write-only properties Consider providing events that are raised when certain properties are changed. Name them <Property>Changed
25. Properties Properties should not have dependencies on each other Setting one property should not affect other properties Properties should be settable in any order. DEMO
26. Constructors Do not call code from a constructor! Can cause Exceptions. Capture parameters only. Provide a constructor for every class. Do not use the this./ Me. reference unless invoking another constructor from within a constructor. Provide a protected constructor that can be used by types in a derived class.
27. Destructors Avoid using destructors! It is not possible to predict when garbage collection will occur. The garbage collector has no knowledge of unmanaged resources such as window handles, or open files and streams. Implement IDisposible if you do! Use the try/finally (or Using) to make sure that unmanaged resources are disposed of even if an exception interrupts your application. DEMO
28. Methods Use Pascal case Use verbs, verb phrases or verb-object pair to name methods Always mark public and protected methods as virtual/Overridable in a non-sealed class. Methods with return values should have a name describing the value returned DEMO
29. Method Overloading Use method overloading to provide different methods that do semantically the same thing. Use method overloading instead of allowing default arguments. Overloaded methods should call the most complete method If you provide the ability to override a method, make only the most complete overload virtual and define the other operations in terms of it DEMO
30. Do Not Expose Generic List List is a generic collection designed for performance not inheritance and Applies to public API’s Does not contain any virtual members Can not tell when updated Use Instead: System.Collections.ObjectModel.Collection System.Collections.ObjectModel.ReadOnlyCollection System.Collections.ObjectModel.KeyedCollection Use Interfaces: IDictionary DEMO
32. Prevent Exceptions Practice Defensive Programming! Any code that might cause an exception (accessing files, using objects like DataSets etc.) should check the object (depending on the type) so an Exception is not thrown For example, call File.Exists to avoid a FileNotFoundException Check and object for null Check a DataSet for rows Check an Array for bounds Check String for null or empty DEMO
33. Parameters Always check for valid parameter arguments Perform argument validation for every public or protected method Throw meaningful exceptions to the developer for invalid parameter arguments Use the System.ArgumentException class Or your own class derived from System.ArgumentException DEMO
34. Enums Never assume that Enum arguments will be in the defined range. Enums are just an Int32, so any valid number in that range could be sent in! Always use Enum.IsDefined to verify value before using! DEMO
35. TryParse Use the .TryParse method on value types when assigning from a string. WILL NOT cause an exception! Returns result of True/False DEMO
36. Exceptions When doing any operation that could cause an exception, wrap in Try - Catch block Use System.Environment.FailFast instead if unsafe for further execution Do not catch non-specific exceptions (for common API’s) Use Finally for cleanup code When throwing Exceptions try using from System instead of creating custom Exceptions Use MyApplication_UnhandledException event in VB.NET WinForm apps Use Application_Error event in ASP.NET apps
38. Variables Avoid single character variable names i, t etc. Do not abbreviate variable words (such as num, instead of number) Unless they are well known like Xml, Html or IO If deriving from a core type, add the suffix of the identify type. ArgumentException or FileStream Use camel case for local variables firstName
39. Accessing Class Member Variables Preface all calls to class members with this./Me., and place base./MyBase. before calls to all members of a base class Class BaseClass Public Sub ProcessData() End Sub End Class Class MainClass Inherits BaseClass Public Sub AnalyzeData() End Sub 'Correct usage of this. and base. Public Sub Good() Me.AnalyzeData() MyBase.ProcessData() End Sub 'Incorrect usage. Public Sub Bad() AnalyzeData() ProcessData() End Sub End Class
40. Strings When building a long string, always (almost) use StringBuilder, not string! C# StringBuilder builder = new StringBuilder("The error "); builder.Append(errorMessage); // errorMessage is defined elsewhere builder.Append("occurred at "); builder.Append(DateTime.Now); Console.WriteLine(builder.ToString()); VB Dim builder As New StringBuilder("The error ") builder.Append(errorMessage) 'errorMessage is defined elsewhere builder.Append("occurred at ") builder.Append(DateTime.Now) Console.WriteLine(builder.ToString()) DEMO
41. Parameters Use descriptive parameter names Parameter names should be descriptive enough such that the name of the parameter and its value can be used to determine its meaning in most scenarios Do not prefix parameter names with Hungarian type notation Public Function ManageIIs(ByVal server As String, ByVal userName As String, ByVal password As System.Security.SecureString, ByVal domain As String, ByVal instance As String, ByVal action As IIsWebServiceAction) As Int32 End Function
42. Generic Type Parameters If possible use descriptive type parameters for generic parameters Prefix with T Use only T, K etc if is self-explanatory C# public static string ConvertArrayToString<TArray>(TArray[] array) where TArray : IEnumerable { } VB Public Shared Function ConvertArrayToString(Of TArray As {IEnumerable})(ByVal array As TArray()) As String End Function DEMO
43. Commenting Comment your code! While coding or before Keep it short and understandable Mark changes with explanation, who changed it and the date (if that is your company standard) NEVER WAIT UNTIL AFTER YOU ARE DONE CODING!
44. Xml Commenting Now supported by VB.NET and C#! Comment all public classes and methods! XML can be turned into help docs, help html with applications like Sandcastle http://sandcastle.notlong.com Very useful for teams and documentation for users. Make this easy by using GhostDoc http://ghostdoc.notlong.com DEMO
45. Let’s See What We Have Learned/ Know What’s Wrong With This Code?
46. Constructor public class FileCache { public FileCache(string tempPath) { var appData = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),Global.UserDataFolder); var cacheDir = Path.Combine(appData, tempPath); if (Directory.Exists(cacheDir) == false) { Directory.CreateDirectory(cacheDir); } } } public class FileCache { public FileCache(string tempPath) { this.TempPath = tempPath; } } 46
47. Method public static string SQLValue(string parameter, string value) { if (String.IsNullOrEmpty(parameter)) { throw new ArgumentNullException("parameter"); } if (string.IsNullOrEmpty(value)) return (parameter + " = NULL"); else return (parameter + " = '" + value.Trim() + "'"); } public static string SQLValue(string parameter, string value) { if (String.IsNullOrEmpty(parameter)) { throw new ArgumentNullException("parameter"); } if (string.IsNullOrEmpty(value)) return (String.Format("{0} = NULL", parameter)); else return (String.Format("{0} = '{1}'", parameter, value.Trim())); } public static string CreateSQLParameter(string name, string value) { if (String.IsNullOrEmpty(name)) { throw new ArgumentNullException(”name"); } return string.IsNullOrEmpty(value) ? (String.Format("{0} = NULL", name)) : (String.Format("{0} = '{1}'", name, value.Trim())); } public static string SQLValue(string name, string value) { if (string.IsNullOrEmpty(value)) return (name + " = NULL"); else return (name + " = '" + value.Trim() + "'"); }
49. Structure Public Structure UserInfo Private _contactName As String Public Property ContactName() As String Get Return _contactName End Get Set(ByVal value As String) _contactName = value End Set End Property Private _email As String Public Property Email() As String Get Return _email End Get Set(ByVal value As String) _email = value End Set End Property Public Overrides Function ToString() As String Return Me.ContactName End Function Public Overloads Overrides Function GetHashCode() As Integer Return Me.ContactName.GetHashCode Or Me.Email.GetHashCode End Function Public Overloads Overrides Function Equals(ByVal obj As [Object]) As Boolean Dim testObject As UserInfo = CType(obj, UserInfo) If Me.ContactName = testObject.ContactName AndAlso Me.Email = testObject.Email Return True Else Return False End If End Function End Structure Public Structure UserInfo Private _contactName As String Public Property ContactName() As String Get Return _contactName End Get Set(ByVal value As String) _contactName = value End Set End Property Private _email As String Public Property Email() As String Get Return _email End Get Set(ByVal value As String) _email = value End Set End Property Public Overrides Function ToString() As String Return Me.ContactName End Function Public Overloads Overrides Function GetHashCode() As Integer Return Me.ContactName.GetHashCode Or Me.Email.GetHashCode End Function End Structure Public Structure UserInfo Private _contactName As String Public Property ContactName() As String Get Return _contactName End Get Set(ByVal value As String) _contactName = value End Set End Property Private _email As String Public Property Email() As String Get Return _email End Get Set(ByVal value As String) _email = value End Set End Property Public Overrides Function ToString() As String Return Me.ContactName End Function End Structure Public Structure UserInfo Private _contactName As String Public Property ContactName() As String Get Return _contactName End Get Set(ByVal value As String) _contactName = value End Set End Property Private _email As String Public Property Email() As String Get Return _email End Get Set(ByVal value As String) _email = value End Set End Property End Structure
54. Products To Help Out StyleCop http://stylecop.notlong.com CodeIt.Right http://codeitright.notlong.com FXCop http://fxcop.notlong.com Or Use Analyze in VS Team Systems Refactor Pro! For Visual Studio http://refactorpro.notlong.com I Use All 4! 54
55. Resourses (Besides My Book) Design Guidelines for Class Library Developers http://DGForClassLibrary.notlong.com .NET Framework General Reference Naming Guidelines http://namingguide.notlong.com
Editor's Notes
C# Use Style Cope to enforce.
DEMO: DefensiveProgramming.vb - SafeIntegerSet
The original exception object should not be re-throwed explicitly. Violation of this rule will complicate debugging and ruin the exception's stack trace.