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.

No comments:

Post a Comment