Allen Conway's .NET Weblog

Exploring all things .NET and beyond...

Visual Studio Live! is Heading Back to Microsoft Campus this August!


Visual Studio Live! is heading back to Microsoft campus on August 19-23 in Redmond, WA. Surrounded by your fellow developers, Visual Studio Live! provides you with immediately usable education that will keep you relevant in the workforce.

SPECIAL OFFER: As a reader of my blog, I can extend $500 savings on the 5-day package. Register here: http://bit.ly/RDS_Reg and use code RDS1.

Learn how you can Code like a Rockstar at Visual Studio Live! Redmond — bring the issues that keep you up at night and prepare to leave this event with the answers, guidance and training you need.  Register now: http://bit.ly/RDS_Reg

Using Postman for Google Chrome to call REST and OData Services

A tool I heard mentioned at the recent online DotNetConf virtual conference and have begun using recently is the 'Postman' developer tool for Google Chrome. You can find it on the Chrome Store at the following URL: Postman for Google Chrome This tool is another client utility to make HTTP calls to REST based services. Open a new tab in Google and you will see it as an option to open:

Interestingly, the side chat for DotNetConf contained a brief conversation about Fiddler vs. Postman. Most folks were fond of Postman and preferred it over Fiddler for basic HTTP calls because of its refined and smooth interface (in fact I think these were the paraphrased sentiments of Scott Hanselman in the conversation). While Postman is not by any means a replacement for the rich feature functionality of Fiddler, it certainly has a bit more polished UI and easier to use for constructing basic GET and POST calls. If you are not doing any special debugging, I would probably use Postman 1st and Fiddler in other scenarios.

The main features I like about Postman are the following:
  • History of calls down the left-hand pane for easy access to recall recent GET, POST, etc.
  • Ability to add in Basic Authentication Headers in their raw form without having to Base64 encode them 1st (Postman will do this for you)
  • Simplicity to add custom headers
  • Ability to have the URL contain spaces instead of having to encode the query string with %20. This is key for creating OData calls using OData commands.
  • Smooth, refined, easy to use interface
Below are the security option tabs across the top of the product. Often you will use 'Normal' or 'Basic Auth'. Normal would be used if you are not adding any authentication information to the headers. 


Basic Auth is used when adding HTTP Basic Authentication information to the request headers. As you can see you can enter in the credentials directly without having to encode the information manually:


Once you press the 'Refresh headers' button, the encoded basic authentication information will be added for you! Saves a bit of time as opposed to having to do this through a site, test harness, or code. 

You can also easily add custom headers by simply typing in he 'Header' and 'Value' text boxes and again pressing the 'Refresh headers' button. It's nice and organized and makes sure the headers are added properly to the request and reduces chances you might add the header values incorrectly.


As far as using OData command parameter, notice in my query string how I do not have to encode the 'spaces' in the URL. The tool will construct and encode the URL for me, making writing OData queries much easier. You can add the commands directly to the URL or type them in the 'URL Parameter Key' and 'Value' text boxes:


One other nicety to mention is if constructing a traditional query string parameter, you can add those parameters easily too, and Postman will make sure the query string is constructed properly.


This was just a brief introduction to Postman, but I highly recommend it's usage for OData service calls or any other REST based calls. It makes constructing OData queries easier, and its user friendly interface is a great choice for traditional REST based calls.

Dealing With Case Sensitivity in OData Queries

If you are calling a OData service whether hosted via WCF or Web API (for us .NET folks, or some other hosting mechanism for other technologies), you will find out quickly that the queries may not be returning the expected results or even no results at all. Hopefully it didn't take you too long to jump over to SQL, run the equivalent TSQL query (that is if you own the service and back end), and realized you have a case sensitivity issue.

The solution is to use either of the following supported OData functions:

string tolower(string p0)


string toupper(string p0)

What you should do to take the case sensitivity out of the equation so that you get all results back is to use either of the functions on the field name in question, similar to the query below:

http://localhost/MyService/api/odata/Locations()?$filter=State eq 'FL' and tolower(City) eq 'ft. myers'

Notice how the 'tolower()' function was used to allow all results to be displayed. This would ensure that results with either 'Ft. Myers' or 'FT. MYERS' or any combination thereof be returned.

For a list of all of the OData functions, see Section 4.5 of the following link:

OData URI Conventions

My Experiences and Guidance for Software Engineers on Beginning Your Career

Over the Easter holiday weekend recently my family was invited to a friends house to spend the day, where I was speaking with a gentleman that was about to graduate with a masters in CS. I struck up a conversation about software engineering and briefly provided some suggestions about kicking off the job hunt and career. I soon came to realize how much the information I was providing was appreciated, and guess I forget a bit about trying to get my foot in the door. I had no one offering me 1st hand advice upon leaving college in the sea of graduates all competing for jobs. Therefore I though it might be helpful to recollect and offer a fresh perspective to those starting out their professional career as a software engineer. Just remember, take the free advice for what it's worth; obviously everyone could have variations on this topic.


I have been a software engineer focused with technologies on the Microsoft stack for almost 11.5 years at the time of this writing. While by no means I'm a 30 year veteran of this field, I'm also no newbie to this game either. Holding (3) professional jobs in this time span has allowed me to work with a slew of diverse professionals and allowed me to soak up and experience a lot about being a software engineer too. Since my experience roughly dates to the new millennium, I feel a lot of what I have to say holds relevant today as opposed to experience from writing on a mainframe system at IBM in 1984. Not that it doesn't hold water, but most of the technologies used on day 1 of my professional career are still widely used today.

Here is a list of advice I compiled for new software engineer professionals that I thought might help you get started on the right path. It's not inclusive of every fine grained detail, but it should be enough to get you on your way to your 1st job.


Advice #1: Gain experience early. If at all possible try to get an internship doing some actual coding. I was not able to do this but it will pay dividends for not only the experience but the networking connections you will have made. Depending on where you are going to school this might not be possible if there are no jobs or internships in the area. Don't worry it's not a show stopper as evidence by my own experience but it helps.


Advice #2: Stick to your guns. If at all possible, make sure your 1st professional job is one in a true programming / software engineering role. I've met many of people wanting to take a shortcut into getting 'experience' and went the role of a Helpdesk or Support Engineer. Here are folks with a degree in CS, taking phone calls on fixing Outlook. My advice, gain experience coding and don't pick the wrong fork in the road down a different path in the IT world. This again assuming you want to be a software engineer. When I graduated the '.com bust' had just occurred and programming jobs were tough to come by if you did not have experience. At the time I was working at Blockbuster Video as an assistant manager and did not have the help of any internship or the like on my resume. Essentially there was nothing computer related attached to me other than my degree. I was told at one point to take any job that can get the work 'computer' on the resume. Even if that meant plugging in computer in an office. I would have gone down this path but what a mistake that would have been. Stick to your guns and get your foot in the door with a programming job and settle for nothing less if at all possible. It's a slippery slope if you start down the wrong path and try to unwind that new experience after a few years to get back into software engineering.


Advice #3: Build your profile. So there are a few key online sites that seem to circulate in the community when looking for jobs or researching someones public background. The biggest one for professional use is probably LinkedIn. I didn't use it for years as I misunderstood it's use and didn't see it catching on well. However I've seen it gain momentum in the last several years. Get your complete profile built and begin to network by adding known contacts. However, LinkedIn is not Facebook. This is a professional networking site. I would say 95% of my contacts are in the field of software engineering. I have a few family members and friends in non-related fields but I keep this to a minimum. If you want friends for social networking use Facebook. If you are building a professional profile use LinkedIn. Heck, if you are a software engineer in the industry feel free to connect with me if you wish (see: LinkedIn Profile). You can also get 20 connections out of the gate if you accept requests from recruiters.  Just be careful not to bloat your connections with too many recruiters as they act like computer viruses that spread to your other contacts so they can build a portfolio and get their take on landing someone a job. A quick note on professional recruiters - later in your career you might be able to fly solo on job searches because of experience, but recruiters can be a valuable resource early in your career. There motive is to get you a job so they can make money. They almost act as your personal agent, trying very hard to find you a job. They do not cost anything, so feel free to reach out to a few. It will not be long before your name is in a dozen databases and you are getting several callas and emails about job positions.


Advice #4: Get your resume online. Best site for software engineering jobs IMO: Dice.com. Followed behind this I like Monster.com. (There is also Stack Overflow careers, but I believe it's by invitation only. In the future, consider getting a Stack Overflow account, and begin building reputation to get an invitation to this site as well.) Both Dice and Monster have search agents that you can set up that will send you emails of new jobs in search areas and locations you specify (i.e. Orlando, FL .NET Software Engineering Jobs). Let the results come to you rather than constantly pulling them. You can fine tune the search agents so you do not get bombarded with Senior level positions requiring 10 years of experience. Jump on the opportunity to be the 1st to send in your application and resume for new positions. Believe it or not, many companies will look to fill positions where a tenured employee has just left and a replacement is needed quickly. Remember the old saying, "the early bird gets the worm". Looking around at jobs on these sites will help you get a feel of requirements, salary, location, etc. Be forewarned that filling out all of the information on these sites is time consuming, so be prepared to set aside some time. However the effort could pay dividends in getting that job you desire.


Advice #5: Get formal and take the interviewing process seriously. Look like something the cat dragged in right out of a few too many parties in college or with friends? Get cleaned up and dust off that old suit (or go and get one). The competition will be stiff for those entry level positions, so take interviewing seriously. Sometimes making the right 1st impression can make all of the difference between (2) similar candidates. I know because I have assisted with interviewing candidates over the years. Interviewing is a presentation of the most formal version of 'you'. This is no time for t-shirts, feet on the table, and over confidence. Things like firm hand shakes, eye contact, cleanliness, speaking well (notice I didn't say 'speaking good?' If you think that's appropriate pick up a remedial English book), sending thank you follow-up emails, and being respectful and appreciative go a long way to landing you a job. Obviously there is still the technical aspect and depth of your skills which is important too, but you might be surprised how many companies look for 'the right fit to the team' being as important or more than the skills. I've heard time and time again about how it's possible to grow someone's skills, but it's extremely challenging to work with a know-it-all with a difficult personality. Bottom line, bring your 'A' game to interviews with a smile, be personable and presentable. At the end of the day you are selling yourself to the company and need to prove why they should hire you.


Advice #6: Cramming for an interview or job skill is not taboo. Want to know which comment I made that helped me get my 1st job as a programmer? I told the interviewer (and soon to be my 1st boss) the following as a response to "Do you know Microsoft Access (VBA)?": "No, I did not use it in college as we were mostly working on a Unix platform, but I understand the mechanics and basics of software engineering. It just a matter of syntactical differences between languages, but I understand the concepts well." Two things at play here; one I showed that I was not taught 'applied programming' as many in fields like MIS majors are. They might be taught VB.NET as applied in business, but couldn't explain thing 1 about databases, architecture, structure, or mechanics of building applications. Good Great engineers will not rely on a single language as their understanding but rather understand software engineering as a whole. The second thing at play was that come time for day 1 at that job, I was going to know better about Microsoft Access. I remember New Years eve 2001, skipping a vacation with my fiancé, I spent reading a book on Access 2000 (which I still have to this day) as part of a multi-week cram on learning a new technology. Know what, by the time I went through my interviews, landed the job, and began the job, I hit the ground running. Putting in this effort, not only will bring you up to speed on a technology, but it displays the type of passion desired by both parties to land the job. Lesson here, be prepared to on board new technology for either the interview process or new job and don't expect the employer to give you gobs of time to learn it; that's your job.


Advice #7: Gravitate toward the best at your 1st job. There is a reason we have 2 ears and only 1 mouth. Do yourself a favor and learn as much as you can from the seasoned professionals once you being your job. Don't overburden them, but soak up as much from them as you can. If you show respect, there are likely to open the door for you to ask even more questions  I had the privilege of being around many seasoned professionals in my 1st job that were heavy into OO programming. I was carved from that block and is at the root of my DNA as a developer. These folks will help you move along in your career quickly as opposed to you trying to figure out everything on your own.


Advice #8: Make a conscious decision on technology path. One of the reasons I have been mildly successful in my career is because I have stuck with the Microsoft stack of technologies in programming since day 1. If you already have a passion for Java vs. .NET vs. something lower level like C++ then you might want to focus in on jobs in the technology / languages of your choice. However if the job market is competitive or tight you might not have a choice. Changing technology directions during your careen is analogous to switching majors in college. It can be done but can also be a set back. If you go from Java to VB.NET it's not impossible (remember the advice from #6, it's just another language), however there are realities once you go down a path that you become familiar with that might be non-existent in other languages. For example if you were a Silverlight developer in 08',09' and moved to be a Java developer, not much of the applied learning would transfer. Sure you have a deeper understanding of rich client web applications but the Silverlight knowledge would not have transferred. If you are looking for longer term success in the 1st 5-10 years of your career, your best bet would be to dig in and become deep at the technology stack you selected and enjoy.


Advice #9: Make a conscious decision on company type. Most of my career has been in the 'Corporate America' atmosphere and I think it has a lot of advantages. To list some: good benefits, larger companies, larger pool of talent to learn from, growth opportunities, job security, and project variety are some of the advantages. I have moved from doing a lot of internal custom development, to working for a public software company. There are other lines of development like government, gaming, hardware and start-ups.  The latter sentence I have no experience with and only a working knowledge through what I read and what I have heard through those I know. I have found that in the government / military work as well in the gaming industry there is large need for low level development in languages like C++. Start-ups are another animal all together. I've heard they pay well, but in return you will probably work a lot of hours, and not afford a great sense of job security. This is because a lot of start-ups are funded by project from various sources. If the project is a failure, funding may stop and people could loose their jobs. If the project is a big hit, the company might get acquired and layoffs occur through duplication of effort by 2 combined companies. However, this environment is typically fast paced and you have the potential to learn a lot. Hopefully if the unfortunate deal arises and you loose your job, you will know you didn't loose the biggest asset which was the byproduct of those projects you worked on and the gained knowledge.


Advice #10: Play the role of grunt and then move on. Don't expect to be writing the next new Xbox game as the lead of your team from day 1 on the job. Odds are you will not work on new development as a junior developer. This is normal and a good thing. You will more than likely inherit either a legacy application to maintain or be placed on a larger team in a supporting role. Either way you will be able to look at existing code (be prepared because it may not have been well written  but this is a part of the growing process) and gain experience in your new work environment. The natural progression for most professionals is the following: get your 1st job, kick a$$ for 3-5 years, learn a lot, and make a maneuver for a new job. Odds are you will make a 10-30% pay increase from job 1 to 2. The problem is job 1 will likely look at you as "John the entry level programmer we got out of college", where as job 2 will look at you as "the experienced mid-level .NET guy with 5 years experience at a large company." I read a book about 10 years ago that spoke to this exact point but for the life of me can't remember the title. I'm not advocating for job hopping if your happy. However be careful not to get stuck in 1 companies or team's culture of a certain way of programming. You might be the ace at job 1 in methodology 'D', but come to find everyone else is doing methods 'A-C' and you are now overpaid for skills that are becoming obsolete. The job hop after 3-5 years is good to get a fresh perspective, new respect, and a new set of challenges. You'll be able to draw on your experiences from job 1, and now learn the new things from job 2. 


Advice 1...n: Never stop learning (hence 1...n). Want to have a great career, enjoy what you do, and be at least somewhat successful? Make sure you never stop learning new things to become a better software engineer. I have a blog post on the challenges of this (see: You Can't Know It All (YCKIA), But Keep Pursuing After It Anyway). I will not delve too deep into this point since I have written so much of its importance in the link mentioned, but I must reiterate how important it is to keep fresh with updated skills. After all there is a reasons software engineers tend to make a decent salary; it's not easy to do what we do. However I think if you get knee deep in it, the career is totally fulfilling and presents something intriguing and interesting every day.

Wrap Up: Well I could add probably another 10 suggestions but this was a brain full to digest I'm sure if you are a new or aspiring software engineer. This isn't the only path or set of circumstances as I mentioned at the beginning, but rather my collections of experience across jobs and conversations with other colleague's experiences. Feel free to comment and add any of your own thoughts as well. Last but not least, good luck in your career and welcome to the world of software engineering.  

2013 Orlando Code Camp Round-up


It's my 4th year attending Orlando Code Camp at the Seminole State College in Sanford Florida. It's a great facility for hosting the event and it now hosted on the newer wing of the campus. As I always mention, the content here is every bit on par with those of the national conference, often drawing some of the same presenters. If you are serious about furthering your knowledge, this 1x per year Saturday event is a must attend. 

FYI... some of the detail within might be a bit like jotted down notes, but I just wanted to get my recollection down per session and some might be in's raw format, just to let you know.

Session 1: Unlocking the Power of Object Oriented C#, Jay Hill



To start off the day I went to an OO C# class as I always enjoy this kind of stuff. I was a tad late from registration to the class, and it's tough to complain about anything volunteer based and free, but the popularity of this event vs. the room capacity for certain session are mismatched for the 2nd straight year. I had to sit Indian style on the floor for the 1st session and I am feeling like a pretzel that needs to untwist... :(

Jay was breaking down and explaining the SOLID principal in OO development  Music to my ears, "Programming to abstractions is key to OO Principals". He talked about Liskov Substitution Principal and it's polymorphic behavior is based on Interfaces. One way to violate this principal is if there is any kind of branching logic on determining concrete types. They should be replaceable.

Next he went into the Single Responsibility Rule and levels of specificity and granularity involved. You want to make sure your classes and Interfaces are not doing too much. Break them apart and use something like the Composite Pattern if needed. With this pattern you can combine (2) interfaces say of IOrder + IOrder to make CompositeOrder.

One small presenter note because I can be an armchair QB on the subject as I have attend lots of training over the years, presenters should balance leveraging snippets along with writing raw code. You don't want to loose the audience while typing variable declarations and basic code. Just use a template or jump to a completed project to get the point across.

The biggest concept of this class was detailing the power of abstractions vs. concretions and how it is unprecedented. There were some in the class that questioned if this was 'overkill' for development. This is a normal reaction to those newer to OO concepts and scalable / testable architectures. I chimed in and stated that this was not overkill and created a highly testable code source that is perfect for unit testing. It also allows for 'unplugging and plugging in' of components much easier than when using techniques of the inverse that cater to tightly coupling code which often has a reduced lifetime and difficulty being understood by follow-up developers. Good session, and good start to the day.

Session 2: ASP.NET WebAPI and SignalR for Data Services, Brian Kassay



Begin by downloading ASP.NET and Web Tools 2012.2 which updates ASP.NET Web Api, OData, SignalR, along with adding some MVC templates. 

One of the coolest features I heard is the ability to paste JSON and have a .NET class created from it. I'm actually already using Web API but I wanted to see if I could fill in some information vertically. For those of you that have not used it, Web API is an ASP.NET product based heavily on MVC (but is more data centric that presentation centric) that offers HTTP RESTful services. Web API is essentially a bunch of NuGet packages, but the template will add in and make the appropriate associations, so no worries. Just use VS.NET 2012 and you will be all set. The Web API template is under MVC -> Web templates. After selecting MVC you will be able to select Web API.

Those of us familiar with Controllers in MVC will feel right at home in Web API. The HTTP verbs are mapped by convention in the controller, so no need for explicit declarations. Making a HTTP POST to a Customer controller, will automatically map to the Post() method without needed to decorate that this is a HTTP POST' method.

I'm actually knee deep in a Web API project now, so a lot of this session on the Web API part is review for me. No knock on the presenter here because he is doing a good job, but I will not regurgitate content that mostly could be found by going to ASP.NET and doing the '101' tutorials on Web API. 

As typical with short session classes, the presenters cannot expand on properly architecting code and are just displaying the use of technology. Do remember if you choose to use Web API, that I would recommend treating the Web API project/layer created to only act as a presentation layer with skinny controllers. I would even advocate for not using any ViewModels or Models in this layer. Abstract that out to a Service layer instead of fattening
up essentially a presentation/UI layer with all the components of an application. Just like in MVC, the Web API layer should be treated as a presentation layer only.

To make OData calls, make sure to uncomment the 'EnableQueryable' in the .config, and add a method attribute [queryable] to allow querying on the method. Now when doing a get and adding ODATA commands like "Stop=2", "$filter=IsDone%20true", etc. and now we can query the data. This is huge because in 2 lines of code, I have the ability to query with OData. You can actually add a parameter of type ODataQueryOptions and be able to parse the Odata commands sent. One thing to note, the entire data set will be returned and then filtered on the client side. This is why it is important to apply the filtering ahead of time on the repository call so that 1TB of data is not returned. I actually need some more clarification on this because there seemed to be some confusion and a question I asked in regards to this didn't seem to be answered how I was expecting to hear it answered.

Now the SignalR content is something I needed to absorb from a '101' perspective. There are templates in ASP.NET for SignalR classes. Once the update package is installed. Web sockets might be the future, but issues with older browsers, incorrectly configured servers, etc. cause issues. SingalR has actually been absorbed by Microsoft and packaged up and available in ASP.NET. Note this is a fork off the GitHub open source version. The advantage of Microsoft's version is its supported by Microsoft and stable. SignalR actually encapsulates several different ways to keep the connection up, web sockets, server sent events, forever frame, and in a last resort effort, long polling. Long polling might be the most brute  but also the most stable.

Funny break... someones GPS spoke aloud during class and stated "You have reached your destination" Little delay there because we are out 2 hours into the day!

Need to get into 'Hub Code' vs 'Persistent Connection Code' if doing anything mildly complex beyond simple strings being returned.

Not a ton of time for deep detail, but if you need something on a web app presentation that needs to have close to real time updating, look to SignalR as the best tool to solve this today.

Session 3: Chalk Talk - Code Style and Standards, Scott Dorman



Next up 'Code Style and Standards' by Scott Dorman, MVP and author of 3 books. I always enjoy gravitating to individuals this seasoned to draw on their experience.

I was one of 2 'return attendees' to this talk as I attended this last year, and since helped implement code standards at 2 different companies.

Readability and understandability are keys to writing code. Who is interpreting the code, a compiler or a human? Which one is key in making the other work well? Humans read code and it behooves us to write to a standard.

This is a tough session to apply a synopsis to because my mind wonders to all of my thoughts on this (which are right in line to Scott's views). I can and need to branch off and just write an entire post on this.

A couple of key observations, code standards must be continually updated. If you have C# code standards, do they include standards and guidelines for things like LINQ or async/await? It is important for the code standards to be a dynamic and living document.

There were conversations on how much commenting to use, how long vs. short the guidelines should be, tolls to help support enforcing coding guidelines  ReSharper, StyleCop, FxCop, CodeAnalysis, MZ-Tools, etc.). Just remember there is no replacement for true code reviews. The tools are like the icing on the cake, but it doesn't enforce how the code was constructed.

If you are thinking about implementing code standards, step 1 is you MUST get management buy in. Without this it will not stand up.

This class offered way too much great dialog back and forth (much of it which I was involved in from my experiences) to remark on here. I'll have to write a post exclusively on this topic in the future.

Session 4: Unit Testing with Fakes and Mocks in VS 2012, Brian Minisi



OK looking forward to the next session which is Fakes and Mocks in VS.NET 2012. Unit testing is something I'm a huge advocate of doing and it's benefits.

He began by discussing the application life cycle and where impediments to quality can occur in that life cycle. Why unit test? Find bugs early, ensure quality of code.

Black testers are QA devs. White is Unit Testing, Gray is a combination of both.

Stubs replace a class with a substitute  Shims are unit tests for code that are not able to be tested in isolation.

Test doubles isolates code under test from its dependencies. It provides state verification rather than behavior verification. Mocks verify behavior verification.

Mocks are similar to stubs. They do state verification but also do behavioral verification. Behavioral verification is "did the method underneath get called, did the properties get set as expected, did the expected number of records get returned." Behavioral verification is something newer to me in unit testing. Your verifying for example a method does what it is supposed to do internally.

Microsoft Fakes will not do behavioral verification at this point. The main thing to understand is that Mocks, Stubs, and Shims are all considered 'Fakes. Mocks have state AND Behavioral verification, and Stubs only have state verification.

Don't call out to the database to do unit tests. The data could change and it does not allow for true unit testing. Use a stub to mimic the data returned from DB.

MS Fakes is cool because the shim and stub generation or non-generation is configurable through configuration. Fakes are entire assemblies that have been faked. The stubs and shims are available on the fakes assembly within the unit tests project.

Interesting that there were comparisons using MS Fakes and make the same test using Moq.

You tell the mock what we are going to stub with (mockinstance).setup(x => x.Find(It.IsAny())).Returns(GetData())

Times.Between(2,4 Range.Inclusive) is testing with Moq that the method is called 2,3,or 4 times. This is an example of behavioral verification.

Shims replace functionality. For example shiming DateTime DateTime.Now, can be shimmed to always return January 15, 2013. Shims have to be within a using (ShimsContext.Create()) context within the shimmed method. Only use shims if you CAN'T use stubs. Shims are a LOT slower than stub. 500 unit tests should happen in less than 1 second. Use shims for static methods.

I know there were a lot of fragmented sentences in this one but there was a ton of good information and a lot of clarity from the standpoint of proper terminology and usage when writing unit tests. If anything, take some of the information and expand your own knowledge on the topic. I will definitely  be adding posts on unit testing and Moq in the near future.

Session 5: Intro to Open Data Protocol (OData), John Wang



OData is a uniform way of structuring data like Atom or JSON. OData is not a Microsoft only format or technology. However in .NET can do OData services with WCF and Web API endpoints. Odata uses standard PUT,GET,POST,DELETE HTTP operations and typically using GET for data querying and retrieval.

The ODATA query options are extensive and are TSQL-esque in nature when thinking how to query data. OData V3 is the current version so the standard has had time to mature. Almost every platform consumes OData protocol. All of this is a part of WCF Data Services 5.0. WCF Data Services templates are under 'Data' in VS.NET. It appears v5.3 is the most current version. Note: You can download the latest version of WCF Data Services from Microsoft and it is required if you are planning to build this out using VS.NET.

LinqPad has some FANTASTIC ability for querying the catalog available through a tree structure (see my post based on this: Use LINQPad to Query an OData Service). The tree structure is available once a valid connection is created in LinqPad.  It's really cool that you can write a LINQ query and it will create the OData GET query for me. This is a great way to learn and reverse engineer the OData commands. You can also press the 'Lambda' button and see the equivalent lambda expression. Actually this is a good tool generically for converting between LINQ queries and Lambda expressions outside of anything OData related. The presenter was hitting the Netflix OData API (http:odata.netflix.com/v2/catalog/)to test as it returns OData format.

Even CodeCamp had OData exposed via odata.orlandocodecamp.com/dataservice.svc/ to allow querying of the presenters and their classes.

The querying capability on the query string is unbelievable  This to me is a front runner for exposing relation data in a RESTful manner returning a common OData format.

Libraries to consume and process OData exist in JavaScript  Java, AJAX, PHP, Objective C, Windows Phone, WCF Data Services, Silverlight, and many more.

When creating a WCF data service you will need to create a data model server side using EF or ADO.NET using IQueryable.

Web API has a LIMITED set of OData support and WCF Data Services has full Odata support so go with WCF if needing full Odata support.

Presenter even did a Powershell example. The point? There is a ton of support to query OData format.

Netflix entire catalog is completely exposed in OData format. Flexibility and power of OData as it is not technology or platform specific is important. Web, Mobile, Windows 8, etc. all can use same format.  He had a single app getting the OData with HTML5 JS/Win8, WP7 all being able to display with no changes.

You can easily configure which entities can be readable through code on the WCF data service side (i.e. 'AllRead'). Create a SQL View in EF model if needing 'canned' function to be returned, so that the client does not always need to supply some sort of complex OData commands to query a source.

Since WCF Data Services runs atop of WCF there should be the potential to wrap in Basic Authentication to siphon the header values (user/pass) early in the WCF call stack, and apply custom authorization rules about who can see what entity. Need to verify this but it should work well. See my post on Basic Authentication in WCF (it's for REST based WCF but implementation should hold the same) for further details 'RESTful Services: Authenticating Clients Using Basic Authentication'.

One cool note about this presentation... I realized the presenter was using a Surface RT to do the presentation, with VS.NET and SQL Server. Must have some decent processing capability to run that software so well. Very cool/

Session 6: Database Design Disasters, Richie Rump (@jorriss)



Next up is Database Dev disasters  The presenter is a tech geek turn PM back to tech guy (as it pays more ;))

Think of your database as your application foundation. Analogous to the foundation to a building. The application might have a shelf life of ~5 years, but the data will live. The more time we spend on our foundation, the better the application can be.

SQL Server's 1st version released by Sybase was 1989. Over 20 years of development in a robust database. He compared it to Alice's (in Wonderland) whole, that goes deeper, deeper, and deeper and you still can't know it all. Developers, don't think you can know it all because even DBAs can't. Leverage your DBAs knowledge and improve that typically adversary relationship.

NoSQL is a hot topic as they are not relational databases. However don't worry it's not going away.

Topic 1: Poor Data Types. Having the incorrect data types can cause issues in the long run including casts and inefficiencies.

char vs varchar: A char will be padded with spaces so a char 10, will pad at the end with spaces. varchar is the ACTUAL length of the data + 2 bytes. Storage in SQL server is not just disk but memory (because everything is loaded into memory in SQL).

nchar vs nvarchar: data strong points are holding UNICODE data. If you are using a phone number, don't use NVARCHAR. He deals with a 16 Terabyte data where everything is NVARCHAR makes a DBA mad. You cannot create an index on a nvarchar or nvarchar (max) and have to do a full table scan for the data which is extremely inefficient.

DONT EVER USE BIGINT (8 bytes vs 4 bytes) unless your table has more than 2 billion records. Remember that storage size is in storage, index,and memory.

No indexes on Foreign Keys (unless used properly). Might slow queries with JOINS. Will have a performance impact on Deletes. He did an example 1st with no foreign keys and just JOINS: logical reads 1226 (number of 8k page reads). Then he added a foreign key and index. The execution plan thus far was the same. It actually preformed better ~750 reads. However it added a Key Lookup to go to disk. Then he got it down to 4 page reads by creating a nonclustered index with an Include(column_name) statement. He coasted right through this so need to research more.

Don't always trust what SQL is suggesting, because often the suggestions are incorrect.

Data is stored in clustered indexes, 'Tables' are metadata representation.

He was using 'DBCC DRPCLEANBUFFERS' between schema updates.

Then he talked about the Entity-Attribute-Value pattern.  It was essentially a 'Value' column that was the value equating to an 'AttributeType' column. For example Birthdate and 1/1/1980, or phone and 800-123-45678. The problem is there is no type checking. Complicated to query. I didn't like this at all and have not employed any type of dynamic columns before. He was not advocating for this just showing challenges with it.

Pivot querying is syntactical sugar and are slow on billion row queries.

GUIDS (as a clustered index) are 16 bytes which is 2x as big as BIGINT which is already a no,no. They also suffer from fragmentation on disk. They are not good candidates for primary keys. Space used 12mb vs 33mb on disk. int 0.5% fragmentation. GUIDS are 99% fragmentation. When you create primary key SQL server automatically makes a clustered index. So yes, using GUIDs as primary key is not good. The answer was to use a sequential GUID. Fragmentation goes down to 0.6%. Size problem still exists but fragmentation is solved. Google 'primary key fragmentation GUID' for more info.

Surrogate keys/no alternate key. Surrogate keys are a good thing and he uses in everything. (NOT NULL IDENTITY(1,1)) simple.  Problem is same record can be inserted 2x. By adding an alternate key (user_id and password) you will not be able to insert the same data 2x.

Document your decisions no matter which decision you make. Wiki, document, ER Studio, Irwin, whatever. Just document your decisions.

Read 'Data Model Resource Book' vol 1-3. Very good resources (manufacturing, healthcare, etc.)

Session 7: Slicing Up The Onion Architecture, Jack Pines (@bidevadventures)



Slicing up the Onion Layer Architecture to wrap up the day. This has been like all of the other years in that I can't believe it is already 4:00 and the day's almost done.

SOLID -> Software development is not a Jenga Game. This is what happens when piling crap on, and then trying to pull something out from the bottom.

He started out by talking about a common 3 layer architecture, and he showed an awesome slide which shows how much spaghetti code can spawn from this. Onion architecture focuses much like DDD on the domain layer which rarely changes in combination with DI which stages flexibility to switch things out. However in a 3 layer architecture, the UI has to know about the business layer, which has to know about the data layer, which in essence means the UI still understands and knows about the data layer. It's tightly coupled and actually it's transitively tightly coupled.

He had some fantastic slides with visuals on his architecture. Here is a link to the slides from his presentation. One showed focus as the domain being the core and everything is a round (onion) layer around the core. I saw the separation of domain services and application services which is something I'm personally interested in. Inner layers define interfaces, outer layers implement them. The most important code, your business models and logic are your core. Only take a dependency in the core.

His goal was to prove this whole IoC DI layering thing is not over architecting but a simple, straight forward, and easy to understand architecture.

Take a look at the 'Templify' product for creating different templates of applications. Can get his templates which I personally would be interested in looking at.

This architecture proves how you can switch out UIs easily. He chose MVC because of its support for IoC containers, but you could use anything. The core domain is the focus.

He took a step by step approach for converting his empty template into the onion architecture. He was highlighting how easy it is to move away from concretions to abstractions. And indeed it is very easy.

His main difference between some of the authors of the onion architecture and his implementation is that they were really opinionated about specific technologies (nHibernate, Castle Windsor, etc.) where as he wanted to simplify things and get folks to focus on the architecture. I like this attitude; no architecture should be focuses on specific technologies.

IoC containers are a great way to get away from concretions which by nature is making code tightly coupled.

He was a fan of BDD over TDD. He did not go too deep into this, but I write this comment just to give a feel for what others are doing in the industry.

He talked about using the strategy pattern (no if or case statements) and allows for true polymorphic behavior decided by the user at runtime (which service: Bing or Google).

I highly recommend to look at the referred materials in the links on his site: http://www.jackpines.info/ 


Orlando Code Camp 2013 Wrap Up!


The amazing thing to me is how quickly a Saturday goes by each time I go to Code Camp. I always feel satisfaction after the day is done because of the ample amount learned, the interactions with peers, and good conversations that are spawned. I want to thank all of the Code Camp volunteers as they do an excellent job year in and year out. I am already looking forward to 2014!

Use LINQPad to Query an OData Service

This is going to be a brief post just to get you going with using the free LINQPad tool to query an OData Service. 

The 1st step is to download LINQPad if you have not already done this from the following link: LINQPad Free Download

You will also need WCF Data Service 5.0 installed if you are planning on actually creating your own WCF Data Services to be built in VS.NET and then running this tool against. You can find that download here: WCF Data Services 5.0 for OData V3

Once LINQPad is installed go ahead and open it up and press the 'Add connection' link button in the top left-hand corner.



Select the 'WCF Data Services' LINQPad Driver and select 'Next':



The easist OData service to connect to is the Netflix data service which is exposed at the following URI: http://odata.netflix.com/Catalog/ Enter this value in the URI and leave all of the other fields as their defaults indicate. There is no authentication to access the public catalog of Netflix. Press 'OK'.



Take a look at the tree structure built displaying the catalogs available from Netflix. This is how we know the connection was successful.



Now we want to create a simple C# LINQ query and see the multiple pieces of functionality we can extract. Right-click on the 'Titles' catalog and select the suggested 'Titles.Where(t => ...)' which will load this expression into the query window. Finish it off by searching for the movie Top Gun as follows:


Titles.Where (t => t.Name == "Top Gun")



Press the 'Execute' button and see the results:



Take a look at the different ways we can view the results. Press the 'Request Log' button to get the following URI with query string parameters which could be used directly in a browser:

http://odata.netflix.com/Catalog/Titles()?$filter=Name eq 'Top Gun'



Had we written a LINQ query instead of a lambda expression, we would be able to press the lambda button to then reverse engineer the lambda expression from the LINQ query we wrote in the window. There is other functionality like viewing the IL as well.

Free eBooks From Microsoft Press

Short and sweet post here for some FREE stuff. Yes it's always nice to be able to get a few books without having to pay anything for them. Check out the following link which offers 10+ free Microsoft Press books that you can download!