Tuesday, July 22, 2014

Entity Framework - Compiling transformation warnings

I started getting Compiling transformation warnings when updating my Entity Framework Model.edmx file with new columns in 2 of the tables I was working on.  I managed to find the error online and discovered that the warnings don't cause problems and that Microsoft knows of and has no plans of fixing them.  I thought this was very interesting.  It gives a little glimpse into how a major company prioritizes the bugs/issues that they work on fixing within a piece of software.

The following two warnings show up in my Model.tt when building a VB edmx: 

Compiling transformation: Variable 'errors' is passed by reference before it has been assigned a value. A null reference exception could result at runtime. (line 622) 

Compiling transformation: Variable 'lazyLoadingAttributeValue' is passed by reference before it has been assigned a value. A null reference exception could result at runtime. (line 676)

Closed Sep 25, 2013 at 5:08 PM by RoMiller
EF Team Triage: As we start to plan the releases that follow EF6 we are doing a large triage effort on our backlog of bugs, features and tasks. Our aim is to have our backlog be a realistic representation of what we (or our contributors) may add to EF in the future.

This reduces the number of issues we need to sift thru as we plan each release. For example, coming into the planning for the set of releases after EF6 we had 600+ items on the backlog. A large number of these items are very low priority and will realistically never be addressed.

As a result of this we are closing a number of items as “Won’t Fix”. These items fall into one of the following buckets:
  • Items that are either low priority or expensive to implement and we don’t believe provide enough benefit to outweigh the cost of implementing (given that time spent implementing them would detract from implementing other features).
  • Items created by a member of the EF Team that we have not seen customers asking for and we don’t believe would provide significant benefit to customers.
  • Bugs that only manifest in corner cases and have workarounds.
These decisions are not final, if you disagree with this resolution for an item feel free to let us know.

Friday, July 18, 2014

Week 2

I am learning that one of the biggest things I need to do, which takes up more time than I think it ought to, is access data from the database.  For the iServer project I have tried to keep the data separate in a Data class.  After researching it more on the internet, it looks like there might be a better way using entities.  According to Wikipedia, "an entity is something that exists in itself, actually or hypothetically." In programming, an entity is an object and is usually tied to a concept or business logic. It is often used to map the correlation between a database table and a class object. (Paliath 2010)  I remember talking a little bit about Microsoft's Entity Framework (EF) in class.  Entity Framework is Microsoft's "recommended data access technology for new applications." I tried start the project over using EF, but I must still need to install something, because it didn't work for me.  My only real hesitation with using it is possibly not having enough control over how it accesses the database.  I learned a lot from my SQL Server instructor, Patrick Callahan and would like to be able to use some of the stored procedures he taught for inserting into the database. Otherwise, it looks like it will greatly streamline the creation of a project that uses a database.

Now, for the most frustrating thing that I had happen to me this week.  I had been working on logging error information to a table and it suddenly stopped working.  As I was using the Visual Studio debugger, I noticed that my Device class didn't look like my Notification class or Server class when it initialized.  The other classes showed {WindowsApplication1.Notification} when I moved the mouse over them in debug mode.  When I moved the mouse over a Device it just showed { }.  I thought somehow I had broken the Device class.  I tried copying all the code from the class, delete the class and then recreate it.  I tried creating a whole new project and copying all the code back into it.  Nothing seemed to work.  I did notice that I was still getting back some data that could only happen by going through a device object, but I was still stuck on the idea that I had "broken" the class.  I finally started commenting out big blocks of the Device class and narrowed it down to my overrided ToString function.  Wow! A couple of hours wasted on something to which I now say, "Duh!" From this, I learned two valuable lessons.  First, the debugger displays an object's ToString value, which for user defined classes is the class name.  Initially, my device classes showed an empty string. The second lesson was not to get let yourself get too focused on one idea for a problem, especially when there is information that contradicts your initial thinking.

Saturday, July 12, 2014

Week 1

My first week as a programmer is behind me!  First of all, it is a lot quieter in my little cubicle than it was out on the 911 dispatch floor. I will miss the excitement of 911 calls and the constant interaction with co-workers.  I know they will continue to do an excellent job over there and I will miss them all! (Good thing I still get to come back and harass them on weekends.)

Task number 1 was to get me set up on a computer.  Who knew that would end up taking a day and a half.  Seems that our software source control program, SourceSafe 2005 doesn't play well with Windows 7. From this experience I have learned two things.  First, SourceSafe is no longer supported.  From what I can tell, SourceSafe started out as a good source control program, but per Jeff Atwood's blog, it "was never updated architecturally to reflect modern source control practices." I'm thinking that Microsoft's Team Foundation Server would be the most likely upgrade for us. Second, source control is very important if you have more than one person working on source code at a time.  A SCM (Source Code Management) tool allows coders to "check out" files, work on them and then "check in" the files to update the source code. The SCM tool manages multiple people working on the same files at the same time and allows everyone to have the most updated version of the code. The other important thing a SCM tool does is to keep a history of all the changes made.  You can use the history to go back to previous versions to see when or why something was changed.  You could roll back a bug fix if it has unintended consequences.  And most importantly, you can go back to your original version to reminisce on what your "baby" looked like in its infancy.

Task number 2 was my first chance to write code in my new occupation.  Most everything here is written in visual basic and uses SQL server.  The program makes requests using sockets for temperature, humidity and dew point from 31 iServer units throughout the county.  It's most important task is then to check and see if those values fall within acceptable limits for each device. If they don't, it sends a notification by email or page to all parties wanting a notification.  This function is not currently working and I was given the task of rewriting it.  The program's original author, Gary was a very nice hippie looking gentleman with a well styled pony tail. He was on the tonight show in his youth in a 1960's version of a boy band.  He also received commendations for his work on writing a management program for the local veterans agency. For all his wonderful qualities, I'm not sure Gary thought too much about someone else having to figure out his code later on. I must say, though, that it was a good learning opportunity as I had to work through following his code line by line and looking up things I didn't understand as I went.  Although Gary's code uses classes, it feels to have been written in more of a linear fashion.  I have been trying to rewrite it following object oriented standards.  I took all the code to access the database and put it in a separate class. There is a class for each of the iServers, one for the measurements for each device (temperature and humidity) and one for the notifications.  The data class populates all the data for the servers, measurements and notifications and then the server class takes over getting readings and sending out notifications.  I do feel like it has been a bit of slow go for me, as I still have the notification of the users to write.  The program originally used a lot of threads, which is where my boss believes the problem stems from.  I can see why Gary used threads, though.  Making request to the sockets is very time intensive and keeps the program from doing anything else while it waits for the requests to come back.  Right now, requesting temperature and humidity from all 31 servers takes just over 7 minutes.  Gary had written another program which showed all the readings in near real time and it would only take about 10-30 seconds to get all the readings.  So, we shall see if my program works.  In the future I would like to learn how to write it using async and await, but I think that will have to wait until we are using Visual Studio 2012 or higher.