Implementing Microsoft Design Guidelines with Codeit.Right

Total Page:16

File Type:pdf, Size:1020Kb

Implementing Microsoft Design Guidelines with Codeit.Right Microsoft Design Guidelines with CodeIt.Right http://submain.com/webcasts/microsoft-design-guidelines-with-codeit.right/ for the webcast recording and slides download 6/3/2014 Webcast Housekeeping Audio Connect via VoIP Plug in a headset or turn up your speakers Select “Headset/Mic” in Audio Options Connect via Phone Select “Dial In” in Audio Options Call 1 (949) 229-4400 PIN: 1066921# Asking A Question Use the Ask a Question button in the top left corner Questions will be addressed at the end of the webcast Recording A recording download link will be sent to all registrants within a few days 6/3/2014 Copyright © SubMain 2014 2 Introduction Presenter (g)host David McCarter Serge Baranovsky Microsoft MVP Principal, SubMain 6/3/2014 Copyright © SubMain 2014 3 David McCarter [email protected] @realdotnetdave davidmccarter C# Microsoft MVP Developer/ Architect/ Consultant & Professional Code Reviewer Rock The Nation Conference Tour http://bit.ly/dNdRTNT David McCarter’s .NET Coding Standards http://bit.ly/dpmbooks dotNetTips.com 700+ Tips, Tricks, Articles, Links! Open Source Projects: CODEPLEX.COM/DOTNETTIPS 6/3/2014 Copyright © SubMain 2014 4 Why We Need Coding Standards (Guidelines) 6/3/2014 Copyright © SubMain 2014 5 Benefits Code Clarity/Easier to Understand Easier to Maintain Reduce Bugs Simplify Code Reviews Shorter learning curve for new team members Consistency across large and distributed teams Comply with internal or regulatory quality initiatives Produces more stable and reliable code 6/3/2014 Copyright © SubMain 2014 6 Business Benefits Improve software quality Accelerate time to market Enhance customer satisfaction Reduce long term cost Improve productivity 6/3/2014 Copyright © SubMain 2014 7 Why Coding Standards Fail Developers kept forgetting to abide the 35% guidelines Resistance among the team members 23% Couldn't get a concensus on which standard 26% to follow Management thought is was too expensive 10% and not worth the investment Other 6% Source: SubMain survey of developers and teams 6/3/2014 Copyright © SubMain 2014 8 Implement Coding Standards 1. Get the business owner’s buy-in 2. Get initial consensus 3. Choose a base standard to follow a. Customize the standard (optional) 4. Create our own team guidelines document a. Prioritize what’s most important 5. Implement Code Reviews 6. Use code generation 7. Review status and give feedback http://submain.com/webcasts/coding-standards-in-the-real-world/ for the webcast recording, slides and ebook download 6/3/2014 Copyright © SubMain 2014 9 Microsoft Design Guidelines Overview 6/3/2014 Copyright © SubMain 2014 10 Overview Guidelines for designing libraries that interact with the .NET Framework Most code should be in DLL’s (libraries), not in the application http://submain.com/fwlink/std/ms Most popular coding standard among C# and VB teams Not just for frameworks and libraries Unified programming model Microsoft uses for .NET Framework itself Guidelines are organized: Do, Consider, Avoid, Do Not 6/3/2014 Copyright © SubMain 2014 11 Categories Naming Guidelines Design Guidelines for Exceptions Naming assemblies, namespaces, types, Designing, throwing, and catching and members in class libraries exceptions Type Design Guidelines Usage Guidelines Using static and abstract classes, interfaces, enumerations, structures, and Using common types such as arrays, other types attributes, and collections, supporting serialization, and overloading equality Member Design Guidelines operators Designing and using properties, methods, constructors, fields, events, operators, Common Design Patterns and parameters Choosing and implementing dependency properties and the dispose pattern Designing for Extensibility Subclassing, using events, virtual members, and callbacks, and explains how to choose the mechanisms that best meet your framework's requirements 6/3/2014 Copyright © SubMain 2014 12 What is CodeIt.Right Automated way to ensure your source code adheres to (your) predefined design requirements style guidelines best coding practices Static Code Analysis and Metrics Automatic and safe refactoring of issues into conforming code Automated Code Review process 6/3/2014 Copyright © SubMain 2014 13 What is CodeIt.Right - continued Instant Code Review – real-time code checking OnDemand Analysis Source Control Check-In Policy Build Process Integration Hundreds of rules Security, Performance, Usage, Design, Maintainability, Exception Handling, Globalization, Async, and more 6/3/2014 Copyright © SubMain 2014 14 Microsoft Design Guidelines 6/3/2014 Copyright © SubMain 2014 15 Naming Guidelines Capitalization Rules PascalCasing – used on all public member, type & namespaces camelCasing – parameter names Use “_” (underscore) to prefix private field names. Not “m_”. Namespaces and Assemblies <Company>.(<Product>|<Technology>)[.<Feature>][.<Subnamespace>] Microsoft.Advertising.Mobile.UI dotNetTips.Utility.Portable.Windows.Extensions Don’t forget about spelling of types! Can’t be changed (easily) after going into production. 6/3/2014 Copyright © SubMain 2014 16 Type Design Guidelines Leave at default type of Int32 Enum default value Use the value 0 and set it to a “not chosen” value Public Enum WorkItemStatus Undetermined 0 value Completed Queued Executing Aborted End Enum 6/3/2014 Copyright © SubMain 2014 17 Member Design Guidelines Do not call code from constructor Only set parameters Incorrect public class FileCache { public FileCache() { var cacheDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); if (Directory.Exists(cacheDir) == false) { Directory.CreateDirectory(cacheDir); } } } 6/3/2014 Copyright © SubMain 2014 18 Member Design Guidelines Do not call code from constructor Only set parameters Correct public class FileCache { public string FilePath {get; private set}; public FileCache(string path) { this.FilePath = path; No code called } } 6/3/2014 Copyright © SubMain 2014 19 Designing for Extensibility Sealed Classes Don’t seal classes unless they are: Static class public sealed class Person {} Stores sensitive data Inherits many virtual members (makes sealing members easier) Class is an attribute that requires fast runtime look-up Sealed classes could provide some performance improvement but limits developers from inheriting that type Do not declare protected members Used for inheritance only 6/3/2014 Copyright © SubMain 2014 20 Design Guidelines for Exceptions Use the “newer” TryParse method on value types to avoid Exceptions DateTime dateValue if (DateTime.TryParse("11/11/14", out dateValue)) { Console.WriteLine("{0}).", dateValue); } else { Console.WriteLine("Unable to parse string."); } 6/3/2014 Copyright © SubMain 2014 21 Usage Guidelines Overload Equality & Hashtag Operators on Types class Point { protected int x, y; public Point(int xValue, int yValue) { x = xValue; y = yValue; } public override bool Equals(Object obj) { if (obj == null || GetType() != obj.GetType()) {return false;} Point p = (Point)obj; return (x == p.x) && (y == p.y); } public override int GetHashCode() { return x ^ y; } } 6/3/2014 Copyright © SubMain 2014 22 Common Design Patterns using(var sqlDataReader = new SqlDataReader) Make sure you call { Dispose on types that //SqlDataReader code goes here implement using(var connection = new SqlConnection) IDisposable! { Can create virtual //SqlConnection code goes here memory leaks using(var BMSConnection = new SqlConnection) • Use the “using” { statement //SqlConnection codes here } Calls Dispose on BMSConnection } Calls Dispose on connection } Calls Dispose on sqlDataReader 6/3/2014 Copyright © SubMain 2014 23 Common Design Patterns - continued public class Base: IDisposable • Implement { public void Dispose() IDisposable type { • To ensure resources Dispose(true); are cleaned up GC.SuppressFinalize(this); Signals Garbage Collector } protected virtual void Dispose(bool disposing) { if (disposing) { // Free other state (managed objects) } } ~Base() Garbage Collector Will Call { Dispose (false); } } 6/3/2014 Copyright © SubMain 2014 24 Notes for VB Developers Enable Object Strict Insures strict object checking is on… just like it always is on in C# NO Goto statements! Dim sum as Integer Use Exit statements Dim number as Integer Exit Do Do number = number + 1 Exit While sum = sum + number Exit For If number = 100 Exit Do Exit Sub, Function End If Loop 6/3/2014 Copyright © SubMain 2014 25 And not only VB Developers Use Case instead of chains of If statements If value = 1 Then Select Case value ‘’ Do work Case 1 Else If value = 2 Then ‘’ Do work ‘’ Do Work Case 2 Else If value = 3 Then ‘’ Do work ‘’ Do Work Case 3 End If ‘’ Do work End Select Select Case Put the normal case first - both more readable and more efficient Order cases by frequency - cases evaluated in the order that they appear in the code 6/3/2014 Copyright © SubMain 2014 26 Refactoring to Patterns - CodeIt.Right 6/3/2014 Copyright © SubMain 2014 27 Serialization Pattern - Demo Not as easy as you might think Any class that might be serialized must be marked with SerializableAttribute Applies to serializing to disk, via a service To control serialization process implement ISerializable Implement GetObjectData Populates SerializationInfo with data needed to serialize object There is more to do it properly… 6/3/2014 Copyright © SubMain 2014 28 Asynchronous Programming Microsoft Async – originally designed for EAP – “event- based pattern” – no more, don’t do that! Current
Recommended publications
  • Solid Code Ebook
    PUBLISHED BY Microsoft Press A Division of Microsoft Corporation One Microsoft Way Redmond, Washington 98052-6399 Copyright © 2009 by Donis Marshall and John Bruno All rights reserved. No part of the contents of this book may be reproduced or transmitted in any form or by any means without the written permission of the publisher. Library of Congress Control Number: 2008940526 Printed and bound in the United States of America. 1 2 3 4 5 6 7 8 9 QWT 4 3 2 1 0 9 Distributed in Canada by H.B. Fenn and Company Ltd. A CIP catalogue record for this book is available from the British Library. Microsoft Press books are available through booksellers and distributors worldwide. For further infor mation about international editions, contact your local Microsoft Corporation office or contact Microsoft Press International directly at fax (425) 936-7329. Visit our Web site at www.microsoft.com/mspress. Send comments to [email protected]. Microsoft, Microsoft Press, Active Desktop, Active Directory, Internet Explorer, SQL Server, Win32, Windows, Windows NT, Windows PowerShell, Windows Server, and Windows Vista are either registered trademarks or trademarks of the Microsoft group of companies. Other product and company names mentioned herein may be the trademarks of their respective owners. The example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious. No association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred. This book expresses the author’s views and opinions. The information contained in this book is provided without any express, statutory, or implied warranties.
    [Show full text]
  • Comparative Studies of Programming Languages; Course Lecture Notes
    Comparative Studies of Programming Languages, COMP6411 Lecture Notes, Revision 1.9 Joey Paquet Serguei A. Mokhov (Eds.) August 5, 2010 arXiv:1007.2123v6 [cs.PL] 4 Aug 2010 2 Preface Lecture notes for the Comparative Studies of Programming Languages course, COMP6411, taught at the Department of Computer Science and Software Engineering, Faculty of Engineering and Computer Science, Concordia University, Montreal, QC, Canada. These notes include a compiled book of primarily related articles from the Wikipedia, the Free Encyclopedia [24], as well as Comparative Programming Languages book [7] and other resources, including our own. The original notes were compiled by Dr. Paquet [14] 3 4 Contents 1 Brief History and Genealogy of Programming Languages 7 1.1 Introduction . 7 1.1.1 Subreferences . 7 1.2 History . 7 1.2.1 Pre-computer era . 7 1.2.2 Subreferences . 8 1.2.3 Early computer era . 8 1.2.4 Subreferences . 8 1.2.5 Modern/Structured programming languages . 9 1.3 References . 19 2 Programming Paradigms 21 2.1 Introduction . 21 2.2 History . 21 2.2.1 Low-level: binary, assembly . 21 2.2.2 Procedural programming . 22 2.2.3 Object-oriented programming . 23 2.2.4 Declarative programming . 27 3 Program Evaluation 33 3.1 Program analysis and translation phases . 33 3.1.1 Front end . 33 3.1.2 Back end . 34 3.2 Compilation vs. interpretation . 34 3.2.1 Compilation . 34 3.2.2 Interpretation . 36 3.2.3 Subreferences . 37 3.3 Type System . 38 3.3.1 Type checking . 38 3.4 Memory management .
    [Show full text]
  • Deferred Cancellation
    Deferred Cancellation A behavioral pattern Philipp Bachmann Institute for Medical Informatics and Biostatistics Clarastrasse 12 CH–4058 Basel, BS Switzerland [email protected] ABSTRACT General Terms People who design their own pool of worker threads [33, Design pp 290–298] or processes have to consider how to shut down the workers again or how to dynamically adapt the num- Keywords ber of workers to varying load. Especially with regard to application termination you may have the choice between an Patterns, Destructor, Actor, Reliability, Portability immediate destruction of the pool and a more graceful shut- down. The pattern proposed helps to portably implement Sir, my need is sore. such termination and load adaptation mechanisms that as- Spirits that I’ve cited My commands ignore. sume you voted for the second choice. The main area of application are the internals of active objects [40] and Johann Wolfgang von Goethe: The Sorcerer’s similar designs that delegate work to a pool of threads or Apprentice [23] processes to execute service requests asynchronously from their actual invocation. For the pattern proposed we identified usage examples in 1. INTENT popular existing applications or libraries. Safely shut down pools of worker threads [33, pp 290– Both a real world example and sample code accompany 298] or processes without resource leakages and premature the pattern presentation. This sample code is in C++. rollback of transactions. The design proposed aims at The presentation of the pattern follows the style portability. well known from [11] and [44]. This pattern is based upon other patterns. Typographic conventions for references to other patterns are similar to [3].
    [Show full text]
  • FORTH-ICS / TR 381 July 2006 'An Informal Proof on the Contradictory
    FORTH-ICS / TR 381 July 2006 ‘An Informal Proof on the Contradictory Role of Finalizers in a Garbage Collection Context’ Anthony Savidis ABSTRACT Garbage collection in OOP languages provides facilities to hook code that is executed upon object finalization. Semantically, the point in time that finalizer code is executed is not determined by the application logic, but by the garbage collection system. This fact renders a potential mismatch, since application-specific code, i.e. the finalizer implementation, normally affecting program state and control flow, is called automatically at a point in time that is indifferent to the application semantics. Although an analogous situation is observed in event-based systems, since event processors are called-back asynchronously by the underlying system, there is a fundamental difference: while event generation is essentially nondeterministic, originated from external event sources, object destruction is a semantic action that is always decided by applications. In summary, the mismatch is that although applications decide if and when destruction occurs, the garbage collector is responsible to commit the relevant code. We prove that this mismatch is due to the contradictory presence of finalizers in a garbage collection context. Page 1 Introduction Preface This technical report has been also motivated by requests from colleagues to report the informal proof for the contradictory role of finalizers in garbage collection, simply relying on informal common software engineering principles. Additionally, the reporting has been also motivated by arguments that came to my attention via personal communication that either the claim cannot be proved (I assume that “cannot prove” arguments are subject to formal proofs, so such arguments are more weak than the claim they attack), or that the claim is trivial requiring essentially no proof (intuitively true, but does not explain why Java, C#, Python, just to name a few languages, still adopt finalizers).
    [Show full text]
  • Sams Teach Yourself Visual C# 2010 in 24 Hours
    Praise for Sams Teach Yourself Visual C# 2010 in 24 Hours “The Teach Yourself in 24 Hours series of books from Sams has been a staple of anyone wanting to quickly come up-to-speed on a new technology. This book is not just a simple refresh of last year’s book, Scott has written it from the ground up for the Visual Studio 2010 and .NET 4.0 release. From the C# type system, to events and data, from ASP.NET Web to WPF Windows applications, Sams Teach Yourself Visual C# 2010 in 24 Hours will provide any developer new to the C# language a great foundation to build upon.” —Shawn Weisfeld, Microsoft Visual C# MVP “The key to learning software development is to have a great foundation. Sams Teach Yourself Visual C# 2010 in 24 Hours is a must-read for anyone who wants to learn C# from the beginning, or just brush up on its features. Scott Dorman brings a very knowledgeable, yet casual approach to his book that anyone with the desire to learn to program in .NET can be inspired by. I found a few gems that will enhance my future programming projects.” —Chris “Woody” Woodruff, Co-Host of Deep Fried Bytes Podcast “This book is an excellent resource for anyone who is learning C# for the first time, migrating from Visual Basic, or catching up on the latest features of C#. It is full of information and should be on the desks of any developer who is becoming familiar with C# 2010.” —Jeff Julian, Managing Partner, AJI Software, Founder of GeeksWithBlogs.NET “Scott Dorman has written an excellent reference book that not only covers the basic fundamentals of .NET 4.0 C# development, but also includes instruction and guidance on the finer points of advanced C# and development with Visual Studio 2010.
    [Show full text]
  • NET Framework Guidelines and Best Practices
    DBHDS Business Solution Development Jefferson Building, 5rd Floor [email protected] .NET Framework Guidelines and Best Practices Application Architect: Mario Epps DBHDS Business Solution Development Jefferson Building, 5rd Floor [email protected] Department of Behavioral Health and Developmental Services - Abstract Abstract This document describes the coding style guidelines for native .NET (C# and VB.NET) programming used by the Business Solutions Development team. Application Architect: Mario Epps .NET Framework Guidelines and Best Practices Contents Department of Behavioral Health and Developmental Services - Abstract ......................................................... 2 Overview .............................................................................................................................................................. 3 1.1 Principles & Themes 3 General Coding Standards................................................................................................................................... 5 2.1 Clarity and Consistency 5 2.2 Formatting and Style 5 2.3 Using Libraries 7 2.4 Global Variables 7 2.5 Variable Declarations and Initializations 7 2.6 Function Declarations and Calls 8 2.7 Statements 10 2.8 Enums 11 2.8.1 Flag Enums 14 .NET Coding Standards ..................................................................................................................................... 18 3.1 Design Guidelines for Developing Class Libraries 18 3.2 Files and Structure 18 3.3 Assembly
    [Show full text]
  • A Hands-On Guide with Real-World Examples — Vaskaran Sarcar Foreword by Priya Shimanthoor
    Design Patterns in C# A Hands-on Guide with Real-World Examples — Vaskaran Sarcar Foreword by Priya Shimanthoor www.EBooksWorld.ir Design Patterns in C# A Hands-on Guide with Real-World Examples Vaskaran Sarcar Foreword by Priya Shimanthoor www.EBooksWorld.ir Design Patterns in C# Vaskaran Sarcar Whitefield, Bangalore, Karnataka, India ISBN-13 (pbk): 978-1-4842-3639-0 ISBN-13 (electronic): 978-1-4842-3640-6 https://doi.org/10.1007/978-1-4842-3640-6 Library of Congress Control Number: 2018946636 Copyright © 2018 by Vaskaran Sarcar This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the author nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made.
    [Show full text]
  • NET Design Patterns
    .NET Design Patterns Duration: 3 days CAC Noida is an ISO 9001:2015 certified training center with professional experience that dates back to 2005. The vision is to provide professional education merging corporate culture globally to the youth through technology resourcing and knowledge consulting with emerging technologies. Quality assurance parameters for each stage of training and development are ensured at all levels. The operating office is solely based Noida (U.P) India. CAC Noida is the well-known .NET Design Patterns training center in Noida with high tech infrastructure and friendly environment. We provide hands on practical knowledge and full job assistance with basic as well as advanced level CAC Noida is one of the best .NET Design Patterns training institute in Noida with 100% placement record. CAC Noida has well defined courses and modules with training sessions for developers. At CAC Noida, .NET Design Patterns training is conducted by specialist Trainers having experience of more than 10+ years. CAC Noida is well-equipped .NET Design Patterns training center in Noida and we offer job oriented .NET Design Patterns training program keeping an eye on industry requirements and future prospects. Each and every one who is part of “CAC Noida” is important to us. Every student has the freedom to discuss and learn. We always take care that right student choose right course. .NET Design Patterns is the one of high in demand course today and CAC Noida provides practical exposure to all the concepts, contents are well-structured to meet the industry requirements. We are confident that .NET Design Patterns training we deliver is at a fantastic standard and are constantly striving to improve and become even better.
    [Show full text]
  • Smart Client Architecture and Design Guide
    Smart Client Architecture and Design Guide Foreword by Mark Boulter Smart Client Architecture and Design Guide patterns & practices David Hill, Microsoft Corporation Brenton Webster, Microsoft Corporation Edward A. Jezierski, Microsoft Corporation Srinath Vasireddy, Microsoft Corporation Mo Al-Sabt, Microsoft Corporation Blaine Wastell, Ascentium Corporation Jonathan Rasmusson, ThoughtWorks Paul Gale, ThoughtWorks Paul Slater, Wadeware LLC Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e-mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. © 2004 Microsoft Corporation. All rights reserved. Microsoft, MS-DOS, Windows, Windows NT, Windows Server, Active Directory, BizTalk, InfoPath, MSDN, Outlook, Visual Basic, Visual C++, Visual C#, Visual Studio, and Win32 are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.
    [Show full text]
  • Java Network Programming
    www.it-ebooks.info www.it-ebooks.info FOURTH EDITION Java Network Programming Elliotte Rusty Harold www.it-ebooks.info Java Network Programming, Fourth Edition by Elliotte Rusty Harold Copyright © 2014 Elliotte Rusty Harold. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/ institutional sales department: 800-998-9938 or [email protected]. Editor: Meghan Blanchette Indexer: Judy McConville Production Editor: Nicole Shelby Cover Designer: Randy Comer Copyeditor: Kim Cofer Interior Designer: David Futato Proofreader: Jasmine Kwityn Illustrator: Rebecca Demarest October 2013: Fourth Edition Revision History for the Fourth Edition: 2013-09-23: First release See http://oreilly.com/catalog/errata.csp?isbn=9781449357672 for release details. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. Java Network Programming, the image of a North American river otter, and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc., was aware of a trade‐ mark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein.
    [Show full text]
  • C++/CLI Overview WG21 N1557 = J16 03-140 Herb Sutter
    C++/CLI Overview WG21 N1557 = J16 03-140 Herb Sutter C++/CLI Overview Herb Sutter Architect Microsoft Visual C++ Quake II Takeaways 960x720 + software-rendered on 1.2GHz PIII-M + Fx 1.1.4322 1. It’s easy to run existing C/C++ code on CLI: 100% JITted (IL) code; still native data. • Just rebuild with /clr. • 1 day to port the entire Quake 2 source base. (Nearly all of the effort was to translate from C to C++, and had nothing to do with our compiler or the CLI platform.) 2. It’s not hard to extend existing code with CLI types. • 2 days to implement the radar extension using Fx (gradient brushes, window transparency/opacity, Matrix.RotateAt). 3. It needs to be still easier, more natural, 2 and “first-class” to use C++ on the CLI. of 67 1 C++/CLI Overview WG21 N1557 = J16 03-140 Herb Sutter Some Definitions ECMA: European Computer Manufacturers’ Association. • Accredited ISO fast-track submitter. • TC39: Programming language technical committee. (“SC22”) CLI: Common Language Infrastructure. • The ECMA- and ISO-standardized part of the CLR (Common Language Runtime, virtual machine with garbage collection), Base Class Library (BCL), and Frameworks (Fx). – ECMA TC39/TG3: TG maintaining the CLI standard. IL: Intermediate language. • The instruction set of the virtual machine. IL has OO concepts baked in: Base classes, virtual function dispatch, casting, etc. JIT: Just-in-time compilation to native machine code. Verifiability: Code that can be proven “correct.” 3 of • Examples: No type errors, no array overruns. 67 Overview 1. Rationale and Goals 2.
    [Show full text]
  • C++/CLI Language Specification
    ECMA-372 1st Edition / December 2005 C++/CLI Language Specification Standard ECMA-372 st 1 Edition / December 2005 C++/CLI Language Specification Ecma International Rue du Rhône 114 CH-1204 Geneva T/F: +41 22 849 6000/01 www.ecma-international.org . Table of Contents Table of Contents Introduction...................................................................................................................................................xii 1. Scope............................................................................................................................................................. 1 2. Conformance ............................................................................................................................................... 2 3. Normative references .................................................................................................................................. 3 4. Definitions .................................................................................................................................................... 4 5. Notational conventions................................................................................................................................ 7 6. Acronyms and abbreviations ..................................................................................................................... 8 7. General description....................................................................................................................................
    [Show full text]