Blog Moved

My blog has moved!

https://kmack.azurewebsites.net

Thursday, October 30, 2014

Staying Current

One topic I've written about before is this idea of staying current.  Don't believe me, see the following articles (here and here).  This industry is an industry that is constantly moving.  And I do mean constantly, and I think sometimes people on the outside looking in are unaware just how quickly it moves.  This is an industry where the tools, techniques and practices are changing daily, and if you don't make a consistent effort to keep up, you won't and you'll fall behind.  And once you start falling behind, its pretty easy to keep falling.

So what can you do?  I mean there's a lot of stuff out there, and sitting and reading through articles you find via google will only get you so far.  So what options are out there.  Well there are a wealth of resources out there.  I don't pretend to know them all but here's a list of some of the ones I use:


  • CodeProject:  A fantastic site with a great community (and I'm not just saying that cause I'm a contributor).  I say that because you receive a lot of updates and their articles are written by actual developers and then have an active community.
  • PluralSight:  A fantastic site with a HUGE library of training videos and courses.  They provide a bunch of topics everything from .net to beyond and provide new courses all the time.  It is a pay service, but it is well worth the money.
  • Microsoft Virtual Academy:  A great Microsoft supported site that provides a wealth of training videos including videos series around the MCSD.
  • Channel 9:  Another Microsoft Sponsored site that supports a large amount of Microsoft products.  They have regular shows beyond the virtual academy including videos about new releases.  
  • .NET Rocks:  A fantastic podcast where they cover the latest trends in the .NET and technology world.  Overall one of the best podcasts I've found for technology and the software industry.  
  • Gone Mobile:  A great podcast that covers topics relating to mobile application development using technologies such as Xamarin.  
  • Hanselminutes:  A great podcast by Technologist Scott Hanselman, who works for the Azure team for Microsoft.  
  • Central PA .net User Group:  User groups like this are a great way to meet and network with over developers and find out the kinds of things they are working on and resources they are using.  
These are just a few of the many resources I recommend, and options out there for a variety of even more resources.  Staying current is honestly the best habit you can get into to have along and prosperous career in this field.  The best way to learn in this field is by doing.  And the best way to do that is personal projects.  Now I know that sometimes its hard to come up with a personal project.  That's when I recommend sites like Code Chef, which is a great site that will give you problems to solve.  

Saturday, October 25, 2014

Angular.js and Recommendations

Also, while I'm at it, I did want to put a post out here about another technologies I've been researching for personal projects.  I've been researching client side frameworks for a new project I've been working on for my own company.  And in the process of doing so, I've been looking at building a SPA application.  Now there are lots of great frameworks out there for building SPA applications, and in my case this is something I have not had much of an opportunity to pursue in my professional life, so I'm definitely doing so in some personal projects.

In the process of researching Angular, I came across a great podcast of .NET Rocks, specifically with Dan Wahlin, where he talks Javascript and Angular, and he references a youtube series that he put together.  And it really is fantastic and I definitely recommend it to all that are interested.  And best of all it takes a little over an hour to complete all parts.

#1.  Part1
#2.  Part 2
#3. Part 3
#4. Part 4
#5. Part 5
#6. Part 6
#7. Part 7

Busy week and Azure

Hello All, so its been a really crazy week, as I ended up spending the majority of my week getting odd jobs done around the house, and ripping the carpet out of the first floor of our house.  And as my sister-in-law put it "strangely therapeutic", in an odd sort of way.

But more than that, I had a really good week professionally.  Outside of the normal good stuff at work, I also got to enjoy two fun new distractions.  The first being the that I attended our .NET User Group here in Central PA.  And this month the meeting was an open discussion forum.  A chance for developers to come and talk about a variety of topics and solicit feedback from other developers within the group, and discuss best practices.

It was really enlightening to hear the thoughts and feelings of developers around the area, and the different approaches they all use.  We had some interesting discussions about where the industry is headed and overall best practices.  I enjoyed it a lot more than I thought I would overall.

The other was that I actually got to talk to someone who was looking to make a career change, and we got to discuss the industry from an outsiders perspective.  And got to sort of compare notes and identify things he can do to help facilitate the career change and set himself up for success.  It gave me a lot of ideas for a potential post in the future here that I'm still putting together...more on that later.

But I wanted to post this week about some ideas and discuss a few keys points.  I've been doing a lot of research into Azure lately, and I gotta admit that it is something really fantastic to work with.  So far my experience with it has been quite exceptional.  And I wanted to share some courses I've taken on plural site that I found particularly helpful if you are looking to expand into Azure.

Introduction to Windows Azure Infrastructure as a Service by Vishwas Lele

Windows Azure Storage In-Depth by Alan Smith

Windows Azure Websites by Matt Milner

Windows Azure Service Bus by Scott Seely

SQL Azure by Scott Seely

Fundamentals of Azure Cloud Services and Storage by Matt Milner

Sunday, October 12, 2014

Making SaveChanges Work for You

Ok, so this update is going to be a short one, mainly cause I am in the process of researching for a longer blog post on Microsoft Azure, and a process article on implementing scrum into a young development team.

But those are topics for future articles, and will be released shortly, but I wanted to take a second to talk Entity Framework.  Entity Framework is a powerful tool, for creating and working with a data access layer of an application.  It allows developers to quickly and efficiently craft a data layer, and work with it through the use of tools like LINQ.

In my experience though, Entity Framework does have one drawback, and that's it does it's job a little too well.  And that's that it makes things a little too easy on many developers, and as a result this tool tends to be under-utilized.  In my experience developers tend to create their database, drop it into Entity Framework, and then start building a "Data" layer on top of it.  Which essentially is completely counter-productive.

One perfect example, is the idea of "Audit" fields.  Many of us have built the same audit fields into every table.  Things like "DateAdded", "AddedBy", "DateModified", and "ModifiedBy".  We build fields like these are standard practice to help identify and track data changes.  This can definitely help to keep data integrity.

I can't tell you how many times, I've worked on applications, where I see things like repositories that are built, on top of entity framework...say that there are 10 repositories, and every single one of them has an "Insert" method, and they all have logic to populate the "DateAdded", and "AddedBy".

Instead, what I'm advising is that "Entity Framework" doesn't have to be a "black box".  A good example is the use of these audit fields, and utilize "SaveChanges".

By overriding "SaveChanges", we have the ability to build this auditing functionality directly into entity framework.

The following code is from a personal project of mine.  And it outlines the process of leveraging entity framework to provide a single point for this operation instead of replicating it everywhere.

By utilizing an interface like the following:

public interface IEntity
    {
        DateTime CreatedDate { get; set; }
        string CreatedBy { get; set; }
        DateTime? ModifiedDate { get; set; }
        string ModifiedBy { get; set; }
    }
By implementing the above interface, on all data tables that have those fields.  It will then make it easier to identify them whenever needed.
public partial class TaskEntities
    {
        public override int SaveChanges()
        {
            var auditable = ChangeTracker.Entries<IEntity>().ToList();
            if (!auditable.Any()) return base.SaveChanges();

            foreach (var dbEntry in auditable)
            {
                switch (dbEntry.State)
                {
                    case System.Data.Entity.EntityState.Added:
                        dbEntry.Entity.CreatedDate = DateTime.Now;
                        dbEntry.Entity.CreatedBy = HttpContext.Current.User.Identity.Name;
                        break;
                    case System.Data.Entity.EntityState.Modified:
                        if (String.IsNullOrEmpty(dbEntry.Entity.CreatedBy))
                        {
                            dbEntry.Entity.CreatedDate = DateTime.Now;
                            dbEntry.Entity.CreatedBy = HttpContext.Current.User.Identity.Name;
                        }
                        dbEntry.Entity.ModifiedDate = DateTime.Now;
                        dbEntry.Entity.ModifiedBy = HttpContext.Current.User.Identity.Name;        
                        break;
                }
            }

            return base.SaveChanges();
        }
    }
In the above code, the web application checks all objects that are being saved and if they implement the IEntity interface, it populates the appropriate fields.  What this does is guarentee that the data layer handles this type of operation and prevents the developers from having to build extra logic to accomodate this requirement.  It also ensures that any new tables added can have this logic immediately added without extra knowledge or work on behalf of the developer.

This is only a single example of how we can extend Entity Framework further to better accomodate this type of work, without building redundant data layers on top of it.