Monday, September 18, 2017

Using images as resources in C# WPF

To use images as embedded resouces in C# WPF (Visual Studio 2017):
  1. Go to Project properties / Resources tab.
  2. At the tab top menu, click the down arrow to the right of Add Resource and click Add Existing File.
  3. Select image files on disk. The files will be displayed on resouces tab. You will also notice that a Resources folder has been created in solution explorer.
  4. In solution explorer, select the image files under Resources and right click, select Properties
  5. Change Build Action to Resource
  6. In your code: MyImage.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/" + imgFileName)
  7. Clean Solution, Build Solution
  8. Now your code will run correctly. The image files will be embedded into the exe file, you won't need to distribute the images as separate files.

Friday, September 15, 2017

Software in the loop simulation

When developing software that will interact with electronic hardware, it is important to have abstractions for hardware, i.e. software modules that mimic hardware behavior. Electronic components can have many problems that are not related to logic, e.g. loose components, need to reset from time to time, delays and data loss. With software abstraction, you can test 90% of logic without dealing with hardware complexities. Even better, you can easily automate your tests.


Once you establish that you are 90% correct, you can start testing with hardware to tease out the remaining 10% of bugs (real time issues etc.). The cost of software abstraction is that your design gets a little more complex and you need to write a couple of additional classes and interfaces to simulate the hardware logic. But it is well worth the effort because it decouples you from the hardware, saving you lots of work and frustration.

As an example, I am currently developing a desktop software that will be used to configure an electronic card through the serial port. I wrote a CardSimulator class and implemented the response of the electronic card to inputs from desktop in that class. On startup, my software can be configured to run in simulated or real mode, real mode meaning working with the real card. I have unit tests providing me with confidence that the desktop side of the equation is correct and when there is a problem, we only need to focus on the electronic card side.

Sunday, July 16, 2017

CI for C# projects: AppVeyor

I tried Travis CI for continuous integration of a C# WPF project and it failed because Travis CI uses Mono and that is not sufficent for WPF apps. So I tried AppVeyor and was successful. My minimalist appveyor.yml file is as follows:
image: Visual Studio 2017
configuration: Debug
before_build:
  - nuget restore

Friday, July 07, 2017

Difference between novice and experienced engineers

It has been said that good/experienced software engineers can be several orders of magnitude (i.e. 10x-100x) more productive than novice engineers. I think the main productivity improvement is the fact that experienced engineers are much better at detecting/avoiding bullshit:
It’s far more dangerous to assume people know what they’re talking about, than it is to assume they don’t and let them prove you wrong.
When I was a fresh engineer, I naturally did the work given to me by other people, without questioning if it was worth doing. As I got more experienced, I realized that most of the time people don't have thought through the job they are assigning to others. This results in getting stuck in dead ends, doing things that have no importance which result in lost time and motivation.

Nowadays, I am in my 20th year as an engineer. I pride myself in my analysis skills, ability to see signal through the noise and avoiding waste of resources. A lot of times I finish a job by demonstrating that the job in question is worthless/wrong. If you compare my lines of code per unit time, a novice might produce more. But that usually means producing garbage at a faster pace, creating more problems than solutions. That is why experienced people are worth their weight in gold.

Saturday, July 01, 2017

Using Travis CI for Java Projects

When using Travis CI for automated testing / continuous integration of Java projects created with the NetBeans IDE you have to do the following:
  • On NetBeans, Project/Properties/Sources make Source/Binary Format equal to JDK7. If you use JDK8, Travis CI ant will fail.
  • You must have at least one JUnit test.
  • You have to copy Junit and Hamcrest jars to project directory and add them under Libraries in NetBeans. If you leave them under Test Libraries, Travis CI won't be able to find them.
  • Commit changes to GitHub.
  • Add .travis.yml file to your github project root with the line language: java
  • Go to Travis CI and sign in with your GitHub account. 
  • Click on your Travis CI profile picture / Accounts. Your open source GitHub projects will be listed.
  • Enable your project for CI by clicking the button to its left.
  • Click on the project to go to build page which kicks off build.
  • If you have done everything correctly, you should see a success message at the end of the build page.
  • To add the build banner on top of build page, click on the banner, select Markdown and copy the link. 
  • On your GitHub page, edit README.md, paste the link and commit. 
You can see the build results for my snake project here.

Tuesday, June 20, 2017

JIRA for project finish time estimation

Software projects are notorious for their schedule overruns. One of the reasons is that project finish dates are usually based on wishful thinking.

Herewith I propose a data driven approach using JIRA: The most important thing is to have enough issues in place to make statistical analysis meaningful, let's say at least 30 issues. After that, we need to make sure that we close issues faster than we create them. Only after we satisfy these two conditions can we talk about reasonable finish time estimations.

Below is my proposed project status page that updates whenever issues change, i.e. you do not need to ask people about when the project will finish or what the completion percentage is, it is all done instantly and automatically. The manager will always have up to date estimations. Only after your team has sufficient practice with this system should you worry about velocity/burndown etc. charts.


Calculation of parameters:

Enough issues = Total nb of issues > 30 ? Green : Red

Issues decreasing = (nb of closed issues in last 3 months) > (nb of created issues in last 3 months) ? Green : Red

Avg. nb of issues closed per month = (nb of issues closed) / (nb of months passed from project start)

Months required to finish project = (nb of open issues)/(avg. nb of issues closed per month)

Estimated finish date = Todays date + Months required to finish project

Estimated completion = (nb of closed issues) / (total nb of issues) *100