Friday, April 29, 2016
I've started a C++ column in Visual Studio Magazine. I'm sure you've read plenty of C++ columns in your time - I sure have! I wanted this one to be a little different. So, here's what I've decided to do. For each column, I choose a guidelines from the C++ Core Guidelines, and then explain it. But the twist is that I'm not going through the guidelines from top to bottom - I'm picking guidelines whose explanations require a little language knowledge.
The first column just sets the stage and explains what I'm doing, and gives you a link to the Guidelines. The second, Don't Cast Away Const, explains the guideline, but also the consequences of const-correctness, a typical situation where you might find it hard to stay const-correct when you make a performance tweak to a running system, and the correct use of the mutable keyword. Not bad for explaining a four-word guideline!
I have a number of columns already written and plans to write more. Please check them out and spread the word!
Thursday, March 24, 2016
My latest Pluralsight course is live! It's called First Look: C++ Core Guidelines and the Guideline Support Library
and it introduces the guidelines and why you might want to use them, as well as some preliminary tool support. As always, if you need a free trial, use the link in the sidebar on the right.
Pluralsight courses now have trailers. This is my first course with one and it turned out a lot better than I expected. You don't need a subscription to watch the trailer - just go to the course page,
and over on the right side there are these downward pointing triangles next to time lengths. Click the one for Course Overview which is 1m 49s, and you'll see one entry under it that also says Course Overview 1m 49s.
Click that and the player will open and play the trailer. I did the voice recording, and some Pluralsight elves put together visuals (some are excerpts from demos) around it. I like it! Let me know what you think.
Monday, February 29, 2016
I’ve been hearing that the new search and browse
functionality on Pluralsight isn’t working for everyone, and that the sheer volume
of courses makes some hard to find. So I thought I’d make a list of my current
courses in the hope of simplifying things for those who want to learn something
Visual Studio 2015: Essentials to the Power-User
This is the most recent Visual Studio course and it starts
at the beginning and goes well past what most people know about Visual Studio.
I’m confident that even if you use Visual Studio every day, you’ll learn
something in this course that will make you more productive.
What's New for C++ Developers in Visual Studio 2015 Preview
This course was based on the preview, but works well against
the RTM version of Visual Studio 2015. It’s C++-focused and just shows you what’s
new compared to Visual Studio 2013.
Using StackOverflow and Other StackExchange Sites
Most developers find StackOverflow results whenever they do
a web search for a particular error message, or some API they’re having trouble
using. Many of them tell me that when they try to sign up and actually ask and
answer questions, they have an unpleasant experience. Often, it’s because their
mental model of the site does not match the way it actually works. This course
will show you how it works, so you can get the answers you need and not feel
rejected or hurt by the way these sites work.
Learn How to Program with C++
This course is aimed at people who have never programmed
before. If you’ve programmed, in any language, consider C++ Fundamentals
instead. If you don’t believe anyone can learn C++ as a first language, I’m
ready to argue with you. Modern C++ is a simple and useful language that a
beginner can learn and use well.
C++ Advanced Topics
This course is for the material I couldn’t fit into C++
Fundamentals. It’s presented as a number of things I want you to do, or stop
doing, when you write C++ today:
- Avoid Manual Memory Management
- Use Lambdas
- Use Standard Containers
- Use Standard Algorithms
- Embrace Move Semantics
- Follow Style Rules
- Consider the PImpl Idiom
- Stop Writing C With Classes
C++ Fundamentals and C++ Fundamentals - Part 2
These courses were written in 2011 but hold up well. Here is
where you’ll learn the basic syntax of the language and how everything works,
including templates, pointers, lambdas, and exceptions. Watch both parts to
learn the whole language, then dive into C++ Advanced Topics to round out your
I have other courses – on older versions of Visual Studio,
for example, but these are the “big” ones for me at the moment. I hope this
list helps you to find them. And remember, if you need a free trial, use this
Subscribe, then Start 10-Day Trial, and you’ll be all set.
Friday, February 26, 2016
longest-serving employee, Joyce MacDonald, has worked her last day with us.
She’s moving away to the other side of the country, where I don’t doubt another
firm will soon find themselves blessed with her skills. Joyce joined us full
time 16 years (and one month) ago, and had been working part time for us long
before that. From the very beginning, every task that she took on she
transformed and improved. We needed data entry when we were building a website
for a local real estate firm; she took the procedure for adding a listing and
kept streamlining it – open these three files at once, copy this once, then
paste it here, here, and here – until she had cut the target time in half and
then in half again. Later, she helped to develop our Quality Procedures and to
bring order to chaos in our software development process as we moved to agile
and changed our client mix. She helped our developers to become more organized,
to report progress more thoroughly, and to test before committing or deploying.
She trained our clients to think about what they really needed and to consider
the consequences of what they were asking for. I have never met anyone who
cared as much about the success of the firm as Joyce. We’ve employed dozens of
people who’ve done good work, worked hard, and cared about our clients. The
majority of them, like the majority of people everywhere, never gave much
thought to whether the company was doing well, except perhaps to wonder or
worry if their job was safe, or if there would be money to spend on perks. I’m
not complaining; I think that’s perfectly normal. Joyce is wired differently:
it’s fundamentally important to her that things are done right, that the client
gets what they want, and that the company makes a profit. That’s what just has
to happen, and it’s generally what she’s able to make happen.
started doing data entry and office administration but quickly moved into more
complicated tasks. She’s been managing projects and client interactions for a
long time. She also made sure that people did what they were supposed to do
when they were supposed to do it, and kept everyone informed and contented. If
you’ve ever called our office, you’ve probably talked to her. She’s probably
reassured you about something and made sure it got taken care of for you. She
has her PMP now, which formally recognizes how well she manages projects, gets
requirements out of customers and organized in a way we can all understand, and
builds appropriate processes for developers to follow. She’s taken on the challenge
of managing not just seasoned, well-behaved, adult developers, but also
students and our own grown children, who are not always easy to control. Let’s
just say they meet their deadlines for her .
Joyce to the west coast hasn’t been a total surprise for us. When we came back
from the epic Pacific trip, she got the opportunity to move and though she
delayed it, we rather knew it was inevitable. Over the past 6 months or so
we’ve adjusted the balance of work we take on so that our remaining clients
will be those I can handle client support for, and whose projects I can manage.
(Brian will continue to be an architect, developer, and star debugger who
doesn’t have to talk to the clients.) For our clients, nothing much will
change. For us, there will be a hole in our lives – personally and
professionally – that will take a while to settle down. When she joined us,
Joyce was a neighbor (I believe we first met in the summer of 92), and for a
long time she walked or rode her bike to work in the office attached to our
house. Our kids have grown up together. When stuff happens, Joyce is the one we
talk it through with – business and not-business. We were able to go to the
other side of the world for five weeks, often with no internet, knowing the
company would tick along fine without us. It’s going to be an adjustment not
having her with us every day, not having her to count on. Still, we know why
she’s moving, and we wish her all the best in this new phase of her life.
you’ve found this entry as part of due diligence in a hiring process, let me be
clear: Hire Her. You won’t regret it.
Monday, December 07, 2015
The first keynote at CppCon this year was Bjarne Stroustrup (who invented the C++ language) announcing the C++ Core Guidelines. They are on Github and once he announced them, as Herb Sutter reported in the second keynote the very next day, they quickly became a trending topic across all languages. Here is a description of the guidelines from there:
The C++ Core Guidelines are a collaborative effort led by Bjarne Stroustrup, much like the C++ language itself. They are the result of many person-years of discussion and design across a number of organizations. Their design encourages general applicability and broad adoption but they can be freely copied and modified to meet your organization's needs.
The aim of the guidelines is to help people to use modern C++ effectively. By "modern C++" we mean C++11 and C++14 (and soon C++17). In other words, what would you like your code to look like in 5 years' time, given that you can start now? In 10 years' time?
The guidelines are focused on relatively higher-level issues, such as interfaces, resource management, memory management, and concurrency. Such rules affect application architecture and library design. Following the rules will lead to code that is statically type safe, has no resource leaks, and catches many more programming logic errors than is common in code today. And it will run fast - you can afford to do things right.
To me, these guidelines are the key to getting across my fundamental message that C++ does not have to be hard, scary, complicated, or dangerous. The language may still say “it’s your foot!” but the guidelines, and the tools they can drive, are quite the opposite.
You probably know that Visual Studio has a static analyser built in. (You should, anyway, I’ve blogged about it.) It will catch things like this:
int* p = nullptr;
*p = 10;
But it doesn’t mind things like this:
int* p2 = arr;
Two lines, two violations of the guidelines – I’m not initializing any of the elements of arr, and then I am using its address as a regular old pointer. Now, there’s nothing wrong with regular old pointers – some people have got quite a hate on for them with the rise of genuinely smart pointers, but pointers are fine. Using pointers to control lifetime isn’t fine, because it’s impossibly difficult. But pointers themselves are fine. What’s not fine here is the “decay” of an array into a pointer – folks from other languages don’t expect that at all, and some marvelous bugs have hidden behind this simple bit of helpfulness from the compiler. So there’s a guideline that says don’t do that. Specifically:
(I’m giving you a picture of code because if you want to copy and paste you should go to the live, always updated, guidelines on github.)
This guideline is part of a “profile” – a particular set of rules that are designed to be enforced and that are supported by tools. Well, when I say tools I might be overstating the case a little. There’s just one tool at the moment, but that could be enough!
This tool, C++ Core Checker, is on the NuGet Gallery. You don’t have to get it from there though. You get it, and use it, from inside Visual Studio 2015. Any version will do. If you don’t use Visual Studio normally, just get and install the Community Edition, which is free and is ok to use for commercial purposes, from https://www.visualstudio.com/ . (Need the fine print? if you’re using it as a person, you can do whatever you like. If you work for a company with less than 250 PCs and less than a million dollars US in revenue, again you and up to 4 of your coworkers can use it for whatever you like. If you work for an “enterprise” company then any and all of the employees can still use it for learning purposes or to work on open source.) Note that Visual C++ isn’t part of the Typical install, so you’ll need to choose Custom and select Visual C++:
So once you have Community Edition or some edition of Visual Studio, make a console application and put in the two bad lines of code. Build it and then also run static analysis on it (On the Analyze menu, choose Run Code Analysis, On Solution.) You won’t get any warnings or errors. That’s your pre-guidelines life. You’re doing something inappropriate and nobody is telling you.
Now, add the checker to your solution. This is solution-by-solution, not a change to how Visual Studio does static analysis. On the Tools menu, choose NuGet Package Manager, Package Manager Console. In the console window that appears, type Install-Package Microsoft.CppCoreCheck and press enter. You will see output like this:
Attempting to gather dependencies information for package 'Microsoft.CppCoreCheck.14.0.23107.2' with respect to project 'ConsoleApplication1', targeting 'native,Version=v0.0'
Attempting to resolve dependencies for package 'Microsoft.CppCoreCheck.14.0.23107.2' with DependencyBehavior 'Lowest'
Resolving actions to install package 'Microsoft.CppCoreCheck.14.0.23107.2'
Resolved actions to install package 'Microsoft.CppCoreCheck.14.0.23107.2'
Adding package 'Microsoft.Gsl.0.0.1' to folder 'c:\users\kate\documents\visual studio 2015\Projects\ConsoleApplication1\packages'
Added package 'Microsoft.Gsl.0.0.1' to folder 'c:\users\kate\documents\visual studio 2015\Projects\ConsoleApplication1\packages'
Added package 'Microsoft.Gsl.0.0.1' to 'packages.config'
Successfully installed 'Microsoft.Gsl 0.0.1' to ConsoleApplication1
Adding package 'Microsoft.CppCoreCheck.14.0.23107.2' to folder 'c:\users\kate\documents\visual studio 2015\Projects\ConsoleApplication1\packages'
Added package 'Microsoft.CppCoreCheck.14.0.23107.2' to folder 'c:\users\kate\documents\visual studio 2015\Projects\ConsoleApplication1\packages'
Added package 'Microsoft.CppCoreCheck.14.0.23107.2' to 'packages.config'
Successfully installed 'Microsoft.CppCoreCheck 14.0.23107.2' to ConsoleApplication1
This changes your project settings so that analysis runs this Core Checker for you. Repeat the analysis step and this time the new tool will run and you will get output like this:
------ Rebuild All started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
ConsoleApplication1.vcxproj -> c:\users\kate\documents\visual studio 2015\Projects\ConsoleApplication1\Debug\ConsoleApplication1.exe
c:\users\kate\documents\visual studio 2015\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(9): warning C26494: Variable 'arr' is uninitialized. Always initialize an object. (type.5: http://go.microsoft.com/fwlink/p/?LinkID=620421)
c:\users\kate\documents\visual studio 2015\projects\consoleapplication1\consoleapplication1\consoleapplication1.cpp(10): warning C26485: Expression 'arr': No array to pointer decay. (bounds.3: http://go.microsoft.com/fwlink/p/?LinkID=620415)
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
Where it says "type.5" and there's a link, that's to the specific rule in the "type" profile that this code breaks. And where it says "bounds.3", the same - I showed a picture of bounds.3 up above.
Isn’t that great? Come on, it’s great! The tool will add more rules as we move through 2016. I’m going to have a lot more to say about the Guidelines as well. But this is a great place to start.Why not point it at some of your own code and see what happens?
Thursday, November 26, 2015
If you have an MSDN subscription, you know that it provides a number of benefits besides software licenses - you get Azure hours, you can use Visual Studio Online, and so on. Those are well worth the price of the subscription. But it also gives you access to a number of Pluralsight courses, completely free. If you have a Professional Subscription, you get access to 30 courses, and if you have an Enterprise subscription, you get access to 45 courses. (You want one of the over 4500 other courses? You'll need a full subscription, but you can buy that at 30% off, which helps.)
And yes, my latest course, Visual Studio 2015: Essentials to the Power-User is one of the ones you'll get access to. So go, check it out!
Monday, November 09, 2015
I have a new Pluralsight course on Visual Studio called Visual Studio 2015: Essentials to the Power-User. It starts at the beginning, so if you're new to Visual Studio it will help you get started, but carries on "to 11" as it were, covering things many everyday users of Visual Studio don't know. Here are the modules, each with their length:
- Getting Started (42:08)
- Projects and Solutions (13:23)
- Namespaces, Folders, and Files(27:03)
- Understanding and Personalizing Visual Studio UI Components (26:57)
- Exploring Relationships in Your Code(36:41)
- Using Search and Find Effectively(28:15)
- Letting Visual Studio Help You (46:28)
- Basic Debugging Features (24:04)
- Additional Debugging Features (44:30)
- Working with Designers (39:37)
- Useful Extensions (39:54)
- IntelliTrace and Code Map (25:57)
If you don't have a Pluralsight subscription, click the Author link over on the right hand side of this blog - click Subscribe, then Start 10-Day trial. That should give you a good idea of how valuable the subscriptions can be. (My company buys subscriptions for my staff, and I use my free author one all the time. It's a great way to learn a new technology.)
My main goal in this course was to have Visual Studio make sense to the learner. There are so many ways to do any action that sometimes when you learn something it seems pointless, and you quickly get tired of learning an endless parade of similar features. I worked hard to put these into an order that would lead naturally through the capabilities of the tool, and put things in context. If you watch all 12 modules, you'll know more Visual Studio than most developers - and you'll have a productivity boost to show for it that should be pretty impressive! Please do give it a try.
Thursday, October 08, 2015
On the Pluralsight platform, subscribers can access a discussion area for each course. The traffic in mine is light enough that I have set up an alert to send me an email for each new comment. I just got one for my StackExchange course that brought a huge smile to my face:
I have actually tried not to use Stack Exchange and stick to other sites. I had several bad experiences and have not gained any reputation at all on any questions that I asked. I have even deleted questions due to downvotes or other negative activity. Well after watching this, I understand the problems that I have had in the past. I really enjoyed hearing this and knowing the mechanics of how this works [...] I now know more about it to help me find the answers that I need when I am head scratching my way through coding.
When I first started reading I was thinking "here's a comment about how StackExchange is horrible and why have a course on it" - something I hear from some of my friends. But then it took a sharp right turn to the exact reason why I wrote the course. I mean this is exactly the persona I had in mind - someone who needs answers, but because of not knowing the way the sites work, not only isn't getting them, but is having an unpleasant experience and ends up avoiding the sites.
When I decide to write a course I let myself imagine some possible outcomes. This comment is just the sort of outcome I was hoping for. It keeps me motivated to create more
© Copyright 2021 Kate Gregory
Theme design by Bryan Bell
newtelligence dasBlog 2.3.9074.18820
| Page rendered at Friday, October 15, 2021 10:39:03 PM (Eastern Daylight Time, UTC-04:00)
On this page....
Pluralsight Free Trial