Thursday, November 15, 2018

Diversity in tech is about more than gender

It's about a lot of things.
In the context of diversity within tech communities, here are two that I'm not hearing other people talk about: technology discrimination and alcohol.

Do you like my new T-shirts?

It's not about the technology used but what's done with it that counts

If you want to be part of a group of people that are just like you: who have similar experiences, interests, areas of technical focus, and goals, that's okay.
However, I think everyone benefits when a community is open and inviting to people with different backgrounds, interests, skills, and experiences. When there's variety in the room it provides the opportunity for us all to learn new things.

We all benefit when we are exposed to others who are different to us. It makes us better developers and better people.

If you want a community to grow. If you want new people to learn and adopt a technology so it becomes successful that requires that you help new people and make them feel welcome.

You mustn't make fun of people because of the programming language they currently use.
They may have had no say in this. They may be very successful with it and have created many popular, loved, and financially rewarding pieces of software with it. The programming language used to write a piece of software rarely plays a large part in the success or failure of that software. Don't pick on people because they use something that's older than what you use or that you have stopped using.

Do not make fun of people because of the platforms they build tech on.
Again, developers rarely have a say about the platforms they use, particularly in corporate environments. If developers only worked on the latest platforms or used the latest frameworks then the majority of software in the world wouldn't be being maintained or updated. If we want to keep society moving we can't abandon all old software and we can't constantly re-write everything that's in use.

I've seen the numbers. Most developers don't use the latest and greatest technologies or the hottest new language.
If you do, then congratulations. How about sharing your knowledge with others who haven't had that opportunity yet? Help them learn new things. Even if that means you have to help with "older" technologies.


Alcohol and a drinking culture

Not everyone wants to or can drink alcohol. Some people are unable to be around alcohol.
Even if someone who doesn't drink alcohol is in a place where alcohol is served they don't want to be made to feel different or left out.

As a user group organizer, I found people were really positive when we had more than just a small selection of beers to drink. More people were even more positive when I extended the range of soft drinks that were provided. When organizing an evening user group event and providing drinks, I now do one third as a mixture of alcoholic drinks, one third as soft drinks, and one third as fruit juices. Fruit juices were amazingly popular when we first started having them.

When holding evening events in offices or meeting rooms I'd often propose going to a bar afterward. This choice of location was chosen because it was easy and pretty much the only location available. Plus, "it was just what you do." I have the cultural experience where going to a pub to socialize is the norm. However, only a small percentage of people who came to the initial meeting would also come to the pub afterward. There are many reasons for this but I believe the location was one of them. Next time I run an evening event where we can't stay in the meeting venue indefinitely, I'll look harder for alternate locations where we can continue discussions afterward.

I don't drink alcohol. I choose not to based on past experiences and my levels of self-control. Other people don't drink alcohol for other personal or religious reasons.
I'm happy to be in places where alcohol is served and drunk. There are people who are not. Again, this could be for personal, religious, or other reasons. If you host an event involving alcohol it will automatically keep some people away. If an event is about technology, why use something unrelated (alcohol) to keep a large number of potential attendees away.

I've been to a number of events where the presence of alcohol made me (as a non-drinker of alcohol) seem less welcome.

  • I was at a conference party with multiple bars serving alcohol. There was only one serving soft drinks. I discovered this as I went round all the bars asking for soft drinks and it was only the last one I came to that had anything. The options were limited and hidden at the back while multiple alcoholic beverages were on display on the counter. The message I took from the conference was that my needs as an attendee were not important.
  • I was invited to an event where special, custom, themed, cocktails were being served. This was a tech event and the cocktails were free. I asked what non-alcoholic drinks they had but these were very limited and I had to pay (an unusually large amount) for a coke. The message I took from this was that this was an event for people who drank alcohol. Even though I'd been invited they didn't value me as much as other attendees.
  • I once attended a tech event in a bar and the only soft drink they had was coke. I was looked at like there was something wrong with me when I asked if they had any other non-alcoholic drinks. Just drinking cola all night can be unpleasant. Ensure there is more than one non-alcoholic option and don't make people feel uncomfortable if they don't want alcohol.
  • I've known tech events where the social aspect was a bar-crawl. Events that encourage lots of drinking (even if that's just implied by visiting lots of different places that serve alcohol) discourage some from attending. 
  • I've been at invite-only tech events where the social aspect of the event was beer and spirit tasting. Again, this is actively excluding people from something that was supposed to be tech related.
  • I've been to a tech event held in a brewery. A great way to exclude people who can't visit such locations.


I know it's hard to find locations for events. I know it's the norm to do these kinds of events. I know I may seem hypocritical for saying this as I've held events in pubs and bars.
However, if you reward or recognize people in your community with alcohol or events involving alcohol then you make people who don't drink alcohol or actively avoid it less welcome in your community.

If you're a leader or organizer and you want to grow your community (both in numbers and diversity) I hope you'll think about this.

Personally, I'd love to organize and attend more meetups in coffee shops and learn from people who use technologies I don't.


Wednesday, November 14, 2018

Another day another project: MultiLineStingAnalyzer

Today I had a lot of potentially tedious and error-prone work to do regarding changing some long string constants within some unit tests.

The tests (among a few other things) compare multi-line generated strings.

All had been good while it was only running on Windows, but now it needs to run regardless of the line-endings in use. This meant that everywhere there were implicit, multi-line strings, tests were failing.

The solution was to change all the tests so that they worked regardless of the line-endings of the machine they are running on.

To make this easier for me I created a tool.
It's probably easiest to show what it does.


It's a C# analyzer that makes changing multi-line strings to use environment appropriate line-endings much simpler and without the risk of manual error.

Just two clicks and it's all converted for me. And as I did this in 100's of places, even with the time spent creating the analyzer the conversion process was much quicker.

The chances are you'll never need it but if you have to do something like this is future it's here for you.
When I say here, I, of course, mean on GitHub.
Or you could install it as a NuGet package.



Tuesday, November 13, 2018

Announcing: UWP Essentials


I want to help make it easier to get started with UWP development.

In terms of the tools available to help UWP developers, there are two challenges.

1. Knowing what tools are available to help with development.
2. Getting everything available installed.

Visual Studio 2017 version 15.8 introduced new functionality to help with this. It's called Extension Packs and is a way to create an extension that bundles (or packs) together a number of other extensions.

So I made one for UWP developer tools.

Consider it a one-stop shop for setting up your machine for UWP development. You can be new to UWP development or just want an easy way to make sure all the useful tools are installed.

The first version contains these extensions:


I've published this myself, even though I'm not responsible for all the packages, but I'd love for this to be a community-supported resource and so I'm keen to hear if you have suggestions for other extensions that should be included as well.

Even if you don't want to install all the included extensions you can unselect what you don't want when you install.

Select what you want to include as part of the installer process 

You'll need to be using Visual Studio in version 15.8 or above for this to work.

Go get it from within VS or from the marketplace.


If you have suggestions for other tools that should be included raise an issue on GitHub.


Monday, November 12, 2018

Some quick notes on converting String operations to use Span

I was asked on Twitter , regarding String Resource Visualizer, whether "using Span for string operations [will] make it faster?"

My inclination was that potentially it would, but at a cost of code readability and I wasn't sure if it really needed the optimization.

Also, I'd read a bit about Span<T> when it was first announced and it all seemed very complicated and abstract. I assumed that it was more for low-level things and I could happily ignore it.

It nagged me though that the String Resource Visualizer was doing a lot every time the text of the editor window changed in VS. Yes, every time the screen is scrolled or the text changes. That's a LOT! In theory, any perf improvements would be a good thing as they could improve the UI responsiveness of Visual Studio. If someone had a slow or low-powered machine this could be important.

Today I had some time on my hands while installing some updates over my disappointingly slow internet connection. So I did some more research on Span<T>.
It turns out it's not as complicated as I thought so I decided it was worth investigating what, if any, improvement could be made from the change.

Because the actual code has some coupling that doesn't lead to easy benchmarking, I created a version of the important part of the code in a separate, console, app.

I then created another version that used ReadOnlySpan<char> instead of a string as much as possible.

All the code is here.


Cutting to the chase, here are the results of the benchmark test.


Or if the image is hard to see, here are the important numbers

        Method |     Mean |     Error |    StdDev |
-------------- |---------:|----------:|----------:|
   UsingString | 67.65 us | 0.4932 us | 0.4372 us |

 UsingSpanChar | 40.85 us | 0.1412 us | 0.1321 us |


Not using string was about one-third faster, but that's only approx. 27 microseconds.

Proportionally that's a lot but in real terms, not so much.


I'm left torn. 
- Making the code faster could be really important given that it potentially runs on every keystroke.
- It's not a lot of time though and no-one is complaining about performance. Could this be an unnecessary micro-optimization?
- There are other parts of the code when a definite performance improvement could be made by reducing IO. This seems a higher priority.
- Having spent years writing code that does string manipulation, I'm not yet ready to jump into making changes that will affect the readability of the code.


I'm going to wait and reflect on this before deciding what to do next.


Announcing String Resource Visualizer

If, like me, you work with code that contains placeholders (generated static properties) for localized resource strings (from .resx files), a codebase that contains a lot of these can be harder to work with than feels necessary. It can take longer to read as you have to look up what the placeholder represents and it's easy to use the wrong placeholder.

This is the scenario I encountered last week.
It got me wondering.

What if there was an extension that could show the text of the placeholder too?

I looked for one but couldn't find anything. Then I wondered.

Could I make one?

After a couple of hours of experimentation, I had the bones of something working.

I posted a screenshot on Twitter to see what others thought.



Based on the positive response the tweet received, I've put something more formal together.

Announcing String Resource Visualizer
It might not seem obvious but this is the VS image for ViewResources
Much like the screenshot in the tweet, it allows you to see the default text for a string resource above where it's used in your C# code.



The code is on Github and you can download the installer from the VS Marketplace. Got get it now and try it out.


There are a couple of known issues that I hope to address soon but I'm keen to hear any feedback or other suggestions for improvements.





Thursday, June 14, 2018

Revisiting the takeaways from WWDC 2018

I was reviewing the announcements from WWDC and thought that as my takeaways are likely to be different from those of other developers (and that I've seen them share) I'd thought I'd call out what I think is important.


  • Support the devices that the people using your apps have. What people use is more important than supporting the latest devices.
  • Shared experiences are important for people (group facetime) and the adoption of new technologies. (AR games)
  • Integration with the platform/OS (such as SIRI Shortcuts) helps people integrate the services and functionalities your app provides with the how people use their devices.
  • Platforms change, evolve and may not be around as long as your app. (end of OpenGL)  While using no 3rd party tools isn't an option, it's important to be aware of the wider ecosystems and changes around the tools and utilities you use so that if they go away or become deprecated in favor of a new alternative you won't be caught by surprise.
  • People are mobile, not just devices. People even move more than some (phone) devices. Your app experiences may be more useful if they exist on more than a single device type. That may mean using the same app (or an emulated version) or a customized version of it. 
  • Watch what is new and popular in competing apps/platforms and, if appropriate, replicate that functionality. (In Windows Dark Mode has been VERY popular with some people. It only makes sense for that to come to MacOS too.)






Thursday, May 10, 2018

Rapid XAML Toolkit - some questions answered

As I write this, Build has just finished. It's been a great three days but today has been the best. That's in most part due to the reception that my new project has received.


I made the repository for the Rapid XAML Toolkit public this morning.
I wrote a bit about it earlier, but here are the answers to some more questions I've repeatedly been answering today.

  • What is it? - It's the ability to generate a XAML UI from a data (or view) model based on some configurable rules. It can produce everything from the whole view, all the way down to the UI for a single property which you put where you want in an existing file. There are also some helpers for wiring up the data context (on the view or code-behind) as necessary.
  • Is it an app builder? - No, it is a developer tool. The aim is to give developers something to build upon or modify, rather than having to do everything themselves.
  • Why build it? - Lots of apps are created from the data up. They are forms on top of databases or web service requests. In these scenarios, a data model exists, and a corresponding UI is required. By removing some of the effort involved in creating the UI, hopefully, this will free more developer time to work on innovative features or fixing bugs. It's an indirect way to help more developers create better software.
  • Is it Windows/UWP only? - No, it's XAML focused and platform agnostic.
  • What does that mean? - UWP, WPF, and Xamarin.Forms!
  • It works with Xamarin? - Yes, but Xamarin.Forms only.
  • Does it work with Xamarin Native? - No, but the underlying generation engine could probably output some useful stuff. I just don't have the time to investigate how at the moment.
  • What about code-first UIs? - Again, the focus is on XAML, but it could probably generate something
  • Can it be used now? - Well, it's all open source, go for it. In reality, it's still in an Alpha stage.
  • How long until a proper release? - When it's ready. If you want to help, it'll be sooner. Hopefully not more than a couple of months though. There will be a proper beta first.
  • What about F# support? - No. It uses Roslyn CodeAnalysis to analyze the source, and this doesn't support F#. There may be some way around this, but there are other, more important things to do first. It is in the backlog, just don't hold your breath. It does work with VB though.
  • Why VB? - Because Windows.   As a tool that has a background in helping developers migrating older Windows apps to UWP, I recognize that a large number of them use VB and so I don't want to exclude them.
  • Will it work with Visual Studio for Mac? - No, just VS for Windows. This is because that's what supports development for all XAML platforms?
  • How to use it with WPF? - You'll need to create a profile first. I'll add some soon.
  • Is this a Microsoft thing? - Yes, and no. I don't work for Microsoft, but it is an open source project released under their GitHub organization. That means their name on the copyright, but it's also MIT licensed. Yes, this is unusual--it's the result of exceptional circumstances.
  • But you had a staff badge at Build? - Yes, I was working on the Windows Template Studio booth because I'm a significant contributor to that project. This is also why the development and configuration were done to support UWP first. RXT is a sister project to WTS.
  • Have there been any official announcements about this yet? - Not yet, but expect something in the next couple of weeks.
  • Are there any video, tutorials, etc.? - Not yet, but they will be coming.

Other points to note:
  • This is just the start. The name deliberately claims to be a toolkit. There are lots of other things planned, but the underlying engine opens a lot of opportunities and possibilities to build upon.
  • Yes, it would be cool to put some ML/AI in it ;) 


Go check it out now at https://aka.ms/rxt
Then ask me questions on twitter @mrlacey



Wednesday, May 09, 2018

I just "gave" a load of code to Microsoft

TLDR: Announcing a new open source project for making XAML development easier.


What's this about giving away code?

I had an idea for something, built a proof-of-concept that impressed and excited some people, and we decided that the best way to get it to lots of people quickly was for Microsoft to release it as an Open Source project. So, that means I've "given" the code to Microsoft on the basis that they'd make it open source and thereby giving it away to everyone. In practice, it means it's in a Microsoft owned repository but I'm an admin and main contributor.


What is this thing then?

Introducing the Rapid XAML Toolkit.

It's a Visual Studio extension that provides functionality to accelerate XAML development.
It's rare for developers to build the XAML UI for an app before having some sort of data model that the UI will represent and allow interaction with. It might be from a database, web service, or somewhere else but if you've got some code that describes what should be there, why not let the tool create it for you?


Of course, it's more than just a file. It contains suitable XAML that represents the ViewModel, wires up the bindings, and sets the data context. It's not going to be the final XAML you need but it's going to do in two clicks what could otherwise take a few minutes. Given the choice, would you rather have a blank page or something that works and you can just tweak to your needs?

As an example, given a class that looks like this:

    public class OrderDetailsViewModel : ViewModelBase
    {
        public int OrderId { get; private set; }
        public Guid CustomerId{ get; set; }
        public DateTimeOffset OrderDate { get; set; }
        public string OrderNotes { get; set; }
        public decimal OrderTotal { get; }
        public ObservableCollection<OrderLineItem> Items { get; set; }
    }

It could produce this:

    <StackPanel>
        <TextBlock Text="{x:Bind ViewModel.OrderId}" />
        <TextBlock Text="{x:Bind ViewModel.CustomerId}" />
        <DatePicker Date="{x:Bind ViewModel.OrderDate, Mode=TwoWay}" />
        <TextBox Text="{x:Bind ViewModel.OrderNotes, Mode=TwoWay}" />
        <TextBlock Text="{x:Bind ViewModel.OrderTotal}" />
        <ListView ItemsSource="{x:Bind ViewModel.Items}">
            <ListView.ItemTemplate>
                <DataTemplate x:DataType="OrderLineItem">
                    <StackPanel>
                        <TextBlock Text="{x:Bind OrderLineId}" />
                        <TextBlock Text="{x:Bind ItemId}" />
                        <TextBlock Text="{x:Bind ItemDescription}" />
                        <TextBlock Text="{x:Bind Quantity}" />
                        <TextBlock Text="{x:Bind UnitPrice}" />
                        <TextBlock Text="{x:Bind LineTotal}" />
                    </StackPanel>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>
    </StackPanel>


How does it know what XAML to create?

The generated XAML is based on the type and name of the property and whether it is read-only. There are some carefully chosen options provided by default but everything is configurable. In the future, it may also be powered by AI too ;)


How does it know where to put the created file?

It's based on conventions but is fully configurable. It even supports having the View and ViewModel in different projects if that's what you prefer.


That all sounds like one feature. Why call it a toolkit?

Because there are plans for much more. XAML generation is just the start, but it enables lots of scenarios and opportunities.

Even today, it doesn't just provide the ability to produce whole files. It also provides the ability to generate XAML without having to create the file. You can generate the XAML for an entire class, an individual property, or a selection of properties. This raises the question of where the XAML will go. We leave that up to you. The generated XAML can either be copied to the clipboard (so you can paste it wherever you wish) or sent to the clipboard (so you can drag it where you want it.)

The final part of setting up the basic association between VM and View is to ensure that the data context for the page is correctly set. If it's not, then it provides the option to do this for you.








Does it do X?

Probably not...yet! There are lots of features planned but if you've got a suggestion, please raise an issue in the GitHub repository.


How does this compare to Windows Template Studio?

Windows Template Studio will help you to scaffold a UWP app. The Rapid XAML Toolkit is a sister project and can help you once you've created the stub of your app, or if you have an existing app. It doesn't have to be a UWP app either. We hope this will be helpful to Xamarin developers too.


Wait, what's this about Xamarin? I thought it was a UWP thing.

Nope, it's a XAML thing!
While there may end up being some elements or features that are UWP only, the intention is that it will be beneficial to any developer who is working with XAML. This means Xamarin.Forms and WPF. (It will work with Silverlight too, but I'm just not providing any default configuration for it.)


Really, WPF?

Yes, WPF too.


Anything else?

Yes, it works with both C# AND VB.Net.


Really, VB.Net?

Yes, because all developers deserve nice things. Plus, we think this will be particularly beneficial to developers converting WinForms and WPF apps to UWP, and we know a lot of them use VB. If they're learning UWP, they shouldn't have to learn C# as well.


Where can people find out more?

GitHub is the place. Go to https://github.com/Microsoft/Rapid-XAML-Toolkit and check out the current features.


p.s. As you'd expect, I'll be sharing more details soon, but, if you're at //build, I can show you more. You'll find me at the Windows Template Studio & Community Toolkit booth.




Thursday, May 03, 2018

Personal mission statement

I've been thinking about creating a personal mission statement. Something that simply and clearly sets a guide for what I (want to) work on.
I've come up with this.

Help people create better software.

I think there are two aspects to this: Education and Tooling.

Education
People can't make better software if they don't know what makes better software or how to create it.
I'll do this by providing resources in the form of books, articles, etc.

Tooling
Creating/providing tooling that can help create better software will make it easier and faster for people to do so.


What do I mean by "better"?

- Easier to learn
- Easier to use
- Easier to support
- Usable by more people
- Fast
- Reliable
- Robust
- Secure
- more ...


Some practicalities
- I can't help everyone.
- I'll focus (at least initially) on areas where I have specific knowledge and opportunities.


Wednesday, April 25, 2018

WinAppDriver a base for testing

I've been doing some automated UI testing using WinAppDriver.

Here's a simple base class I've been using for my tests that takes care of ensuring that the service app is running when the tests start.



If you're writing tests using WinAppDriver and are fed up with tests not running or false negatives when the exe isn't running and listening for requests, then check it out.

The check for it being installed is also useful when you first run on a new machine.

You may need to allow for untrusted PowerShell scripts or have VS running as an admin for everything to work.



Friday, March 23, 2018

UWP vs Web development

I recently heard someone try and make this argument. (They were sucking up to Microsoft at the time.)
If I do web dev I have to learn at least 4 things, but for Windows, I can just learn UWP
Their thinking was that for web development they need to learn:

  • HTML
  • CSS
  • Javascript
  • Some framework (e.g. Angular)
  • Possibly more...

They argued that they could just learn "UWP".
But I think that means several things too:

  • XAML
  • C# (or VB, or C++)
  • An MVVM framework (MVVM Light, Caliburn.Micro, Prism, etc.)
  • The UWP app model and platform-specific APIs
  • possibly more...

I don't think this argument holds up.
The development of any piece of non-trivial software requires the use of multiple complementary technologies, skills, and techniques. If you ever think you can just learn one thing and then you'll be done, you're setting yourself up for disappointment and failure.

There's a similar thing I've heard from other developers and that's:
I don't need to learn Android (or iOS) I can just learn Xamarin.
That's equally flawed and in similar ways.


Friday, March 16, 2018

Did someone really design this ATM experience?

As I put my card in the ATM machine today I noticed a message on the screen that said
Receipts currently unavailable
I've seen it many times before. It means the roll of paper the receipts are printed on has run out. Not a problem, I just want cash.

After inserting my card and entering my PIN number, among the many options were two related to what I wanted:

- Cash with receipt
- Cash with no receipt

Yes, that first option makes no sense based on the message shown at the start. But wait.
I selected the second option and was then asked:
Do you want a receipt for your transaction?
- Yes
- No

I selected "No". I didn't want one and, based on what the machine had said moments ago, I knew it couldn't provide one even if I did want it.

I then selected the amount I wanted to withdraw.

All should have been good but then I was asked, again:
Do you want a receipt for your transaction?
- Yes
- No

Again I selected "No" and finally my money was dispensed.

Part of me was glad to finally get my money.
Part of me was tempted to try that again and see if what would happen if I chose some of the impossible options.
And another part of me was saddened by the process.

Here are my issues with what happened:

  • The software repeatedly provided options for things it had said were unavailable.
  • The software asked the same question multiple times, seemingly disregarding my past answers.
  • The software made the process longer and more complicated than was necessary.


Someone was paid to make this software.
Someone tested and approved this software.
Someone thinks this is a good experience to give to their customers.
Someone thinks that we should trust them with our money inside complex financial systems when they make what should be a simple piece of software unnecessarily complex.


You wouldn't build software that provided an experience like this.
Would you?

Tuesday, February 06, 2018

Create UWP apps with VB.Net and Windows Template Studio

The majority of my open source software contributions over the last few months have focused on adding VB.Net support to Windows Template Studio (WTS).

WTS is a Visual Studio extension that provides a better File>New experience when creating UWP apps.

The aim is to help new developers start in a structured, conventional way that will help in the future but they may not even know to consider.
It also aims to help all developers by removing some of the plumbing and code that is needed by every app.

Using the wizard is a simple, three-step process.

File>New Project dialog

Start by selecting the project type and the framework you want to use.

Then, add any of the predefined pages

Finally, add code to handle any extra features.


It can't do everything for you and there will be some things you need to do with the generated code before everything will work as you need. To address this, the code includes comments that explain what you need to do. You'll find them in the TaskList window.

Its usefulness doesn't just end once the project is first generated. It will also help you add to a project you've already created. Just right-click on the project in solution explorer and you can add a page or a feature.


That's still not the end. WTS already supports five frameworks when working with C# and there's much more planned for the future, including: Xamarin.Forms support; more pages; more features; and other exciting new functionality too.

To get started using Windows Template Studio, download and install the VSIX from https://aka.ms/wtsinstall

Or, learn more about the project on GitHub at https://aka.ms/wts