Remember this guy?

Remember this guy?

I loved playing Stratego when I was a kid. Moving those pieces around, trying to guess if a piece was a bomb or a general. Between this and Risk I killed a LOT of time growing up!

Which brings me to my next thought… being a team lead for me was a little like being that annoying guy with the mustache on the cover of the game. It was fun moving the pieces around and trying to come up with a winning strategy. But there was some things I missed. The engineer part of me missed solving problems, which is a big part of development… and I never felt in control enough of what was going on. Taking credit for other people’s work never sat right with me. I hated watching my technical skills rust away as I spent all day in Outlook or Powerpoint. And, when I “moved up” to project management, the problems both got bigger and more unsolvable, because they had more to do with people and less with process and IT itself. The money was great – but I couldn’t say I was really adding value to the company I belonged with. I was moving pieces around on a board, playing games.

I enjoyed my experiments with project management and I’m not ruling it out in the future. But the contrast with my work now, as a developer, and what it was a few months ago is huge. I no longer take problems home with me. Every day is productive and full of fun and challenging new problems. I’m taking books home on the weekend and – best part – during the day I’m working on things I enjoy, using techniques and a tech stack of my choice, keeping my skills sharp. It’s TERRIFIC. And programmers and engineers, I feel, are the salt of the earth. I don’t think I’ve ever enjoyed a project more than I have this one. The best part is – I get maybe one or two emails a day, all work related, and my calendar is meeting-free. Life is good!!!

None of this is to say that project management isn’t valuable – it’s incredibly valuable and can make the difference between a successful project and an expensive failure. And I’ve got a world of respect for the PM’s out there that can bridge the gap effectively between the business and the world of nerds. But, the kind of smoothness and political skills it takes to thrive as a PM, that’s not my world and it just doesn’t play to my strengths.

Anyway, this will likely be my last post on RogueAgile. Eric as some of you know has been increasingly preoccupied with running his own business; I’m refocusing my efforts on development and want the new site to reflect that. If you’re interested in keeping in touch with me, shoot me an email at driftboatdave@gmail.com and I’ll send you my new site name.

Posted in Uncategorized | Comments Off

ASP.NET Ajax Control Toolkit

I’m embarrassed to say, I hadn’t visited the AJAX control toolkit suite for a while… with the advent of MVC and the abolition of Postbacks/session state (or so I thought), I was putting all that stuff in my rear view mirror. But, suffice to say, there are still times when you’re going to be using WebForms.

 

So, here’s some of my favorite controls from this suite – and why:

  • Accordion – panels collapse/expand.
  • Animation – such as for a popup modal window
  • Auto Complete – auto complete text in a textbox
  • Balloon Popup – great for Help on individual controls.
  • Calendar – for any date data entry
  • Cascading Dropdowns – amazing how many bogus examples there are of exactly this functionality on the web that will lead you down the wrong path.
  • ComboBox – think a dropdownlist with some basic extensions, like autocomplete. Not clear here if this really gives that much of an advantage but it does allow data entry into a ddl.
  • DragPanel – for drag and drop controls.
  • FilteredTextBox – to constrain user entry. (Note this isn’t foolproof! Javascript can be disabled client side so don’t trust this for all data entry client-side.)
  • Gravatar – avatars for user entry
  • HoverMenu – hover over a row to display edit/update commands for example
  • HTMLEditorExtender – allows uploading images, rich text entry
  • NoBot – provides captcha-like bot/spam detection and prevention. Watches for number of requests per IP address per unit of time, forces a delay between request/response, or disabling JS in the browser (“most relevant where 100% effectiveness is not required… for low traffic sites.”) Eeeeeesh.

 

And there’s others – MultiHandleSlider (slider controls), NumericUpDown (up/down controls for month, integers), PasswordStrength(tests password strength), Rating (with star displays), ReorderList (drag and drop order of steps), TabContainer for tabs to organize contents – I’m not a fan of this one, should be separate pages to keep code neat).

The whole Webforms/SmartUI pattern – it’s more of an antipattern – is very dated and I’m running against the constraints of the model every day. But there are times when it’s called for… I’ll post on that later. If you are working in that space, I do love using these controls over paid-for heavyweight suites (looking at you, Telerik/infragistics/etc).

Posted in Uncategorized | Comments Off

Wrestling with CSS using Bootstrap – and adding Users and Role Authentication to an existing WebForms project

More wrestling going on here than with a WWE title fight, eh?

The project I’m working on is starting to lean away from Bootstrap. It is a GREAT advantage to use this as a framework – especially in terms of responsive design, and not having to muck around with CSS. http://www.bootstrapthemeroller.com/twitter-bootstrap-themeroller.html to roll your own themes.

I do love using Page Inspector – a new feature in Visual Studio 2013. Here below I can select different parts of the page, and see the CSS its using – a huge advantage in finding out why the dang CSS is being overridden in display!

 

 

Adding Users and Role Authentication to my Project

Now however I want to move on and start adding users and roles to my budding web app. Microsoft’s made some significant changes to its model – and we’re using Owin now as a pattern.

First right click on the project, select Manage NuGet Packages, and make sure that you have Microsoft.ASP.NET Identity provider set up. Below, the green checkmark tells me all is golden. (Oh NuGet, how did we ever survive without you? M-wah!!!)


The following tables are created – all empty initially. There’s creation scripts for this in the Appendix.


 

 

Go into the database provider and seed your table with the following roles:


 

And then fill in the AspNetUserRoles tables with integers that bind together your User and your Role tables.

 

The best shortcut I found was – since the page had been stomped on pretty good and a lot of key references were missing – was creating a new ASP.NET website with webforms – and copying over to your project the Login, Manage, OpenAuthProvider user control, Register.aspx.

 


 

Now reorganize your site so its neatly divided into folders. I like dropping all the webforms I want screened off to unauthorized access in a folder called, wait for it, Forms. (So creative! Somebody buy me a black beret!) In most of these forms you’ll have a web.config fragment like the following:

<?xml
version=1.0?>

<configuration>

 

<system.web>

<authorization>

<deny
users=?/>

</authorization>

</system.web>

 

</configuration>

 

 

Since this project uses both MVC and webforms, I went into the Controllers and opened up each class and set the following:

namespace PerceptiveCS.Controllers

{

[Authorize]


public
class
BillOfMaterialController : Controller

 

 

That [Authorize] attribute is key – it tells me only authorized users should be viewing that site.

 

Next in the Models folder add a class called IdentityModel, and fill it with the code in the Appendix.

 

In Global.asax add the following fragment so we’re not getting such an ugly error message when Unauthorized:


//need to redirect to login page if the user is unauthorized


protected
void Application_EndRequest(Object sender, EventArgs e)

{


if (HttpContext.Current.Response.Status.StartsWith(“401″))

{


HttpContext.Current.Response.ClearContent();

Response.Redirect(“~/Account/Login.aspx”);

}

}

 

Make sure your Site.Master master page has the correct register/login fields like this – with the events added (esp the Unnamed_LoggingOut) – see the sample Site.Master file that ASP.NET creates for an example of this.

 

Make sure you have a Startup.cs class created and registered – again using the default logic as a setup.

 

Last, in your web.config on the root, add the following so people can at least view your default web page – and log in as well:

 

<system.web>

 

<authorization>

<allow
users=*/>

</authorization>

 

 

 

 

 

notes and findings

 

This posting has a great writeup on enabling database migrations with seeding data. It’s not necessary for my purposes – but it’s good to know it’s there.

http://www.codeproject.com/Articles/674760/Code-First-Migration-and-Extending-Identity-Accoun

This article has a great writeup on minifying the pages and code you’ll need to get going with the AspNet.IdentityService class: http://typecastexception.com/post/2013/11/11/Extending-Identity-Accounts-and-Implementing-Role-Based-Authentication-in-ASPNET-MVC-5.aspx-in-ASPNET-MVC-5.aspx

 

 

Appendix – Database Creation Scripts

Run the following script to create these locally on your SQL server:

 

CREATE
TABLE
[dbo].[__MigrationHistory]
(


[MigrationId]
NVARCHAR (150)
NOT
NULL,


[ContextKey]
NVARCHAR (300)
NOT
NULL,


[Model]
VARBINARY (MAX)
NOT
NULL,


[ProductVersion]
NVARCHAR (32)
NOT
NULL,


CONSTRAINT
[PK_dbo.__MigrationHistory]
PRIMARY
KEY
CLUSTERED ([MigrationId]
ASC,
[ContextKey] ASC)

);

 

 

 

 

 

CREATE
TABLE
[dbo].[AspNetRoles]
(


[Id]
NVARCHAR (128)
NOT
NULL,


[Name]
NVARCHAR (MAX)
NOT
NULL,


CONSTRAINT
[PK_dbo.AspNetRoles]
PRIMARY
KEY
CLUSTERED ([Id]
ASC)

);

 

CREATE
TABLE
[dbo].[AspNetUsers]
(


[Id]
NVARCHAR (128)
NOT
NULL,


[UserName]
NVARCHAR (MAX)
NULL,


[PasswordHash]
NVARCHAR (MAX)
NULL,


[SecurityStamp]
NVARCHAR (MAX)
NULL,


[Discriminator]
NVARCHAR (128)
NOT
NULL,


CONSTRAINT
[PK_dbo.AspNetUsers]
PRIMARY
KEY
CLUSTERED ([Id]
ASC)

);

 

(note above could also have our FirstName, etc values.)

 

CREATE
TABLE
[dbo].[AspNetUserRoles]
(


[UserId]
NVARCHAR (128)
NOT
NULL,


[RoleId]
NVARCHAR (128)
NOT
NULL,


CONSTRAINT
[PK_dbo.AspNetUserRoles]
PRIMARY
KEY
CLUSTERED ([UserId]
ASC,
[RoleId] ASC),


CONSTRAINT
[FK_dbo.AspNetUserRoles_dbo.AspNetRoles_RoleId]
FOREIGN
KEY ([RoleId])
REFERENCES [dbo].[AspNetRoles]
([Id])
ON
DELETE
CASCADE,


CONSTRAINT
[FK_dbo.AspNetUserRoles_dbo.AspNetUsers_UserId]
FOREIGN
KEY ([UserId])
REFERENCES [dbo].[AspNetUsers]
([Id])
ON
DELETE
CASCADE

);

 

 

GO

CREATE
NONCLUSTERED
INDEX
[IX_RoleId]


ON
[dbo].[AspNetUserRoles]([RoleId]
ASC);

 

 

GO

CREATE
NONCLUSTERED
INDEX
[IX_UserId]


ON
[dbo].[AspNetUserRoles]([UserId]
ASC);

 

 

 

CREATE
TABLE
[dbo].[AspNetUserLogins]
(


[UserId]
NVARCHAR (128)
NOT
NULL,


[LoginProvider]
NVARCHAR (128)
NOT
NULL,


[ProviderKey]
NVARCHAR (128)
NOT
NULL,


CONSTRAINT
[PK_dbo.AspNetUserLogins]
PRIMARY
KEY
CLUSTERED ([UserId]
ASC,
[LoginProvider] ASC,
[ProviderKey] ASC),


CONSTRAINT
[FK_dbo.AspNetUserLogins_dbo.AspNetUsers_UserId]
FOREIGN
KEY ([UserId])
REFERENCES [dbo].[AspNetUsers]
([Id])
ON
DELETE
CASCADE

);

 

 

GO

CREATE
NONCLUSTERED
INDEX
[IX_UserId]


ON
[dbo].[AspNetUserLogins]([UserId]
ASC);

 

 

 

 

 

 

 

CREATE
TABLE
[dbo].[AspNetUserClaims]
(


[Id]
INT
IDENTITY (1, 1)
NOT
NULL,


[ClaimType]
NVARCHAR (MAX)
NULL,


[ClaimValue]
NVARCHAR (MAX)
NULL,


[User_Id]
NVARCHAR (128)
NOT
NULL,


CONSTRAINT
[PK_dbo.AspNetUserClaims]
PRIMARY
KEY
CLUSTERED ([Id]
ASC),


CONSTRAINT
[FK_dbo.AspNetUserClaims_dbo.AspNetUsers_User_Id]
FOREIGN
KEY ([User_Id])
REFERENCES [dbo].[AspNetUsers]
([Id])
ON
DELETE
CASCADE

);

 

 

GO

CREATE
NONCLUSTERED
INDEX
[IX_User_Id]


ON
[dbo].[AspNetUserClaims]([User_Id]
ASC);

 

 

/Models/IdentityModel.cs

using Microsoft.AspNet.Identity;

using Microsoft.AspNet.Identity.EntityFramework;

using Microsoft.Owin.Security;

using System.Web;

using System;

using PerceptiveCS.Models;

// note – this is required below

using System.ComponentModel.DataAnnotations;

 

namespace PerceptiveCS.Models

{


// You can add User data for the user by adding more properties to your User class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.


public
class
ApplicationUser : IdentityUser

{


//public class ApplicationUser : IdentityUser { public DateTime BirthDate { get; set; } }

[Required]


public
string FirstName { get; set; }

 

[Required]


public
string LastName { get; set; }

 

[Required]


public
string Email { get; set; }

 

}

 


public
class
ApplicationDbContext : IdentityDbContext<ApplicationUser>

{


public ApplicationDbContext()

: base(“DefaultConnection”) //was Entities

{

}

}

 

#region Helpers


public
class
UserManager : UserManager<ApplicationUser>

{


public UserManager()

: base(new
UserStore<ApplicationUser>(new
ApplicationDbContext()))

{

}

}

}

 

namespace PerceptiveCS.Models

{


public
static
class
IdentityHelper

{


// Used for XSRF when linking external logins


public
const
string XsrfKey = “XsrfId”;

 


public
static
void SignIn(UserManager manager, ApplicationUser user, bool isPersistent)

{


IAuthenticationManager authenticationManager = HttpContext.Current.GetOwinContext().Authentication;

authenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);


var identity = manager.CreateIdentity(user, DefaultAuthenticationTypes.ApplicationCookie);

authenticationManager.SignIn(new
AuthenticationProperties() { IsPersistent = isPersistent }, identity);

}

 


public
const
string ProviderNameKey = “providerName”;


public
static
string GetProviderNameFromRequest(HttpRequest request)

{


return request[ProviderNameKey];

}

 


public
static
string GetExternalLoginRedirectUrl(string accountProvider)

{


return
“/Account/RegisterExternalLogin?” + ProviderNameKey + “=” + accountProvider;

}

 


private
static
bool IsLocalUrl(string url)

{


return !string.IsNullOrEmpty(url) && ((url[0] == ‘/’ && (url.Length == 1 || (url[1] != ‘/’ && url[1] != ‘\\’))) || (url.Length > 1 && url[0] == ‘~’ && url[1] == ‘/’));

}

 


public
static
void RedirectToReturnUrl(string returnUrl, HttpResponse response)

{


if (!String.IsNullOrEmpty(returnUrl) && IsLocalUrl(returnUrl))

{

response.Redirect(returnUrl);

}


else

{

response.Redirect(“~/”);

}

}

}

#endregion

}

Posted in Uncategorized | Comments Off

Wrestling around with Web API and the first stumbles with the Repository pattern. And bootstrap theming.

 

Not too long ago I was writing WCF data services using entity framework and OData (and feeling weird about how easy it was to create a REST service when your model is set). I thought I would fool around a little with the Web API pattern – which is the way Microsoft is touting serving up JSON to applications using the following pattern:

 

I’m using the repository pattern, and following these steps:

  1. Create a Entity Framework model with the tables I want to display. Yawn.
  2. Add an interface in Models, call it IProductTypeRepository, with the behaviors I want to see.
  3. Add a model class (ProductModel.cs) that inherits from this interface
  4. Make sure Global.asax has either default api setup or there’s a App_Start\Routeconfig and WebApiConfig class.
  5. Surgery on the ValuesController class.

… AND IT TURNS OUT, I found myself in a dead end pretty quickly. There are three ways to approach Entity Framework –

  • Database-first: You start with a database, and Entity Framework generates the code.
  • Model-first: You start with a visual model, and Entity Framework generates both the database and code.
  • Code-first: You start with code, and Entity Framework generates the database.

Fair warning here – using the repository pattern I mapped out above could end up in a cul-de-sac for you. The Web API seems to work best where you don’t know the shape of the database model – i.e. either model- or code-first. Most of the examples you see online follow either the model- or code-first pattern. There’s a reason for that… EF patterns for database-first are so simple, I’m not sure if the Web API is the right way to go – and I got a series of errors when I tried to auto-generate T4 classes of more than one table (“I’m missing a key”, VS will complain).

Anyway below is a writeup of my travails. The end result is, I’m abandoning this and going with EF with WCF data services. See the MSDN article in the footnote by Julie Lerman – she indicates to use Web API when you’re going code-first and aren’t sure what your final model/db layer will look like, and using WCF Data Services when your db is more established:

If most of what you want to expose is simple Create, Read, Update, Delete (CRUD) without the need for a lot of customization, then a data service will be your best choice. If you’ll need to customize a good deal of the behavior, a Web API makes more sense. I like the way Microsoft Integration MVP Matt Milner put it at a recent gathering: “WCF Data Services is for when you’re starting with the data and model and just want to expose it. Web API is better when you’re starting with the API and want to define what it should expose.”

 

Web API Project – From Scratch

I think the above MIGHT be because we’re using EF6, not EF5. I find it frustrating that WebAPI seems to like Code-first versus Model-first. So, let’s kick over and do this from scratch:

 

Create a new project. Empty, but add core references for MVC and Web API.

 

R click on your Models folder and Add a EF model with your tables. Look at the genereated code. See this? Use PCSEntities as your Entity, and PCSModel as your namespace.

 

R-click on Controllers, select Web API Controller with Actions, using Entity Framework.

 

Check out the shiny new generated code:

 

Now build that sucker. Look at our shiny XML:

 

Let’s turn off XML generation. Add the following:

 

 

 

Build again. Yay, we have liftoff:

 

 

 

Repeat the steps above for Location:

 

 

 

Shiny!

 

 

 

What happens when we query http://localhost:32237/api/Location/3?

 

 

 

Some Notes Here About Bootstrap

 

Bootstrap theming is terrific – and I love the ability to have responsive design that’s truly cross-browser compatible without having to muck around with CSS. To do bootstrap I did this:

  1. Go to http://Bootswatch.com, and download a theme.
  2. Copy the contents of the downloaded CSS file.
  3. In Visual Studio, create a new Style Sheet file named bootstrap-theme.css in the Content folder and paste the downloaded CSS code into it.
  4. Open App_Start/Bundle.config and change bootstrap.css to bootstrap-theme.css.

 

 

Notes and Links

I’m not done yet. I want to do some more research about the Repository pattern and how to do Web API the RIGHT way. I think I need to spend more time thinking about the design pattern and get out of the database-first box.

Next, for the frontend, I want to start thinking about KnockoutJS and the MVVM model:

f

I need to add user authentication and roles – this article contains some great info on hooking up users/roles.

Jason Zander’s blog post – has a nice walkthrough on the Web API: http://blogs.msdn.com/b/jasonz/archive/2012/07/23/my-favorite-features-entity-framework-code-first-and-asp-net-web-api.aspx

Best example I’ve seen yet on Web API – including the otherwise excellent MVC book by Apress – is this post: http://www.dotnetglobe.com/2012/03/crud-operation-using-aspnet-web-api-in.html

See the MSDN article here on Single Page Applications and MVC vs MVVM.

Another article on Web API and how it could be used vs WCF Data Services – http://msdn.microsoft.com/en-us/magazine/dn201742.aspx

 

 

Posted in Uncategorized | Comments Off

More love notes to Visual Studio and the Entity Framework – Scaffolding has come a long way!

 

Been a hectic first two weeks on the job! Seven days in, we have agreement on our first set of entities – and have seeded it with data and some sprocs to generate manufacturing work orders and assembly history. Now comes the fun part – the UI!

Big challenge here – we are under extreme pressure to deliver in a short timeframe a fairly smooth and intuitive UI. Since I work on a manufacturing floor, the design needs to be responsive and work naturally on a tablet and with handheld scanners. And since whatever we produce will almost certainly undergo massive changes, it needs to be lightweight and easy to implement. In terms of design, I’m caught here between two demands – it needs to be throwaway code, yet intuitive and well designed enough to warrant a second version when we get our data layer more complete. What to do?

I’m going to skip some of the steps we followed last week in putting together. Here’s the nitty-gritty on how we scaffolded out the administrative forms to add new records to the workflow template tables (like Process, Step, etc).

 

  1. Make sure your data layer is set up in SQL Server, including all relational ties and identity fields and FK’s. Ensure that you have a SQL server login you can use for application access with limited rights (I usually grant db_reader, db_write role access to the database).
  2. If you haven’t already, install Visual Studio 2013 and create new project. With the new One ASP.Net there’s no separate MVC or Webform project options, thank GAWD. So, just select File, New Project, and select ASP.NET Web Application.
  3. Add a new data model. Right click on the Model folder, and select Add new -> ADO.Net Entity Data Model. Add all the tables you want to connect to.
  4. Right click on Controllers, and select Add new Scaffolded Item. Select the MVC5 Controller with Views, using Entity Framework option.


    NOTE – here I got an error “blah blah blah… Error generating the model, etc.” the big hint is at the end of the error message – “TRY REBUILDING THE PROJECT”! VS is having a hard time understanding the generated code classes from EF and is waiting on you to hit F5. Build the project and you should be golden.

     

    See the screenshot below from my model. I’m going to try to build out a scaffolded Process view, a Location view, and a Step view. The Step view in particular should have dropdowns to Test (which is off the screen) and the StepType lookup table. Let’s rock:


 

Now to scaffold out my actual application layer itself. I just want to add three forms, one for Process, one for Location, and the last one for Step. Don’t be intimidated if you’re coming from the webforms world – think of the Views as being forms, and the Controller folders as just being a handy place to stuff your actions where we used to put in codebehind or inline code.

 
 

  1. Right click on the Controller and select Add -> New Scaffolded Item. Select the MVC 5 Controller with Views using EF option.


 
 

Then fill it in with the name of your entity – like “ProcessController” – and select the model class and the data context class you created with your model earlier:


 
 

 
 

Now check out the view in SolutionExplorer. Hmm, this is interesting. Not only do I get shiny awesome controller scripting – all my business logic in one shiny beautiful place! – but now I see some views appearing as well. Wonder what these do?

 
 


 
 

  1. Lets build it, and enter in my URL – replacing “default.aspx” with “Process” for example. Wow! A nice list view here appears of processes. Clicking on the Edit hyperlink gets me this fancy Razor view:

 
 


Its ugly, no doubt – but I can change that easily using Bootstrap, and it’s responsive design. I can easily hide the modified/create fields in the cshtml views so only the important fields are shown.

 
 

  1. Now go through and add new scaffolded items for Location and Step. However, I see an issue – ProductType isn’t showing up where it should.
  2. Closing out the browser, I open up the entity framework diagram and immediately see the issue – ProductType in my data model is linked to the Step entity – not the Process model as it should be. (The list of locations is fixed – but each ProductType has a different set of processes, each with their own set of steps.) Hmm, how easy will this be to correct?

 
 


 
 

 
 

 
 

For some context, it wasn’t all that long ago – say around 3.5 of Entity Framework – when I would basically have to start over with this kind of massive database change. I remember creating a WCF service where any major entity changes would involve creating a new model – and God forbid if the ID primary key field wasn’t called exactly that, “ID”, and in upper case! Now, with EF4.5, those dark days are gone.

 

  1. I go into SQL Server and change my relationships, blowing away the ProductTypeID field in the Step table, and setting up the link properly from ProductType to Process:

 

 

  1. Now I go back into my trusty IDE and open up the model. I right-click on the diagram and select “Update from Database” option. I don’t have to do anything special here – it knows to refresh any entities currently displaying on the diagram.


 
 

 
 

… And I get this awesome error message.


 
 

 
 

I’ve been down this rodeo before – this means I’ll have to manually go through and remove field references, both on the Controller side, the View side, and in the model codebehind. The agony! Or, since I put so little effort into these views and controllers anyway, maybe I can just – I don’t know – blow them away and repeat steps for both Step and Process. I’m not emotionally invested yet into any of these views, right?

 
 

  1. So, I go into the diagram and delete those two tables. (No, it doesn’t drop them from the underlying data layer!!) Now I right-click on the diagram and select Update from database, and add back my two errant tables:


 
 

 
 

 
 

It builds, and the forms look great!

 
 

In Sum-Up

Anyone in the .NET world is aware, or at least we should be, what a sea change Nhibernate and Ruby on Rails was when they first appeared – and what a challenge they were competitively in terms of speed-to-market. Entity Framework (and in its early forms Dynamic Data sites) may have been late on the gate – and we still have pockets of resistance from developers that perversely seem to enjoy writing all their database connectivity and middle layer logic by hand, line by line (these are probably the same ones that enjoy “hand crafting” html in Notepad!). But there’s really no excuse for not using Entity Framework and the power of being able to quickly develop a frontend with both traditional webforms and model-view-controller (MVC) logic to show your bosses cannot be denied. Add to it responsive design and changeable themes with Bootstrap and I think its safe to say, Visual Studio has caught up with a vengeance.

 
 

  • Powerful and extremely performant websites right now are running entirely on EF. Please, get to know both model-first, code-first, and database-first development – what I used above was database-first, but that’s only one option – and which works best for your project.
  • MVC should be your default choice in writing an application, WebForms a distant second. Put simply, the advantage in code cleanliness, maintainability and testability far outweigh the few days it will take you to learn what the pattern has to offer. Even though WebForms in ASP.NET 4.5 now have URL routing, we still have the potential of a bloated codebehind and an overreliance on an outdated and dangerous Viewstate model. MVC isn’t a fad and it isn’t a cure-all, but I think it’s well worth the investment of time it takes to learn.
Posted in Miscellaneous | Comments Off

Microsoft Is Awesome! … and visual studio 2013 publish is a GEM.

I have a great new gig! At Microsoft! I’m SUPER THRILLED and feel like I’m back in my wheelhouse – application development. Engineers are the salt of the earth!

I had to share something neat with y’all. Of course, you’ve already downloaded Visual Studio 2013 by this point and you’re playing around with this whole cool new “One ASP.NET” thing – or as I prefer to call it How It Should Have Been All Along.

 

One thing I remember from the Bad Old Days was how difficult it was troubleshooting and debugging web applications as they moved from environment to environment. I’m pleased to say, it’s MUCH smoother now.

 

Yesterday I got the schema set up for the backend system, and I wanted to do an early push of what I’d scaffolded in MVC. (This helps us avoid what happened with healthcare.gov recently – where they waited till the last second to actually push out working code and iron out setup/integration/loading issues!) I did what I should do more often – some basic research instead of plunging ahead – and found this great article.

 

I was having issues moving this off of my local dev environment to IIS on a new webserver. So, I followed these steps: 

  1. In SQL Server Management Studio, generate a script of the database.
    1. Select default (all objects) – Types of data to script – Data only. And set Use Database to FALSE.
    2. R-click on the projects, select Properties, and select Package/Publish Web. Set to Release.
    1. Set up IIS on local system so we can mimic what will be on Azure.
      1. Click here for web platform installer – http://www.microsoft.com/web/gallery/install.aspx?appsxml=&appid=IIS7;ASPNET;NETFramework4;WDeploy
      2. Check to make sure 4.5 is installed:

      1. Once you’ve checked – and I did NOT have 4.5 set up by default! – make sure the application pool is .NET 4.0. Now you’re set.
    2. Open up Visual Studio AS AN ADMINISTRATOR and set up your Publish Web profile as below:

    3. Publish it and then open it up. If it works, you know the problem isn’t in your code.
    4. I remote desktopped (using the excellent Remote Desktop Application manager) onto the target box and ran Web Platform Installer, and also checked in Add Windows Features that under Application Development (IIS node) that ASP.NET 3.5, 4.5, etc was enabled.
    5. Back to Visual Studio. In the Publish Web Connection setting – the second one down – I changed the Server to http://[MYSERVERnAME], site name the same – added my user name and password, and the Destination URL http://[MYSERVERNAME]/SiteName. Then in the database connection for my entities (you ARE using EF aren’t you?) I entered in the QA server name, a SQL serverlogin and database. Would it work?

       
       

The answer is, it worked – LIKE A CHARM! Visual Studio makes it especially easy to publish out to Azure, for the well-heeled or well-connected of you. I do plan on setting up Elmah at some point in the future for logging – including this post as my base and the setup steps detailed here. For all I know this was here in 2010/2012 but I do like the way the web platform installer gives me a plain-vanilla, working IIS setup right out of the box when admins partially set up a webserver and leave the rest to us poor harassed devs. Rock on MSFT!!!!

 
 

Posted in Miscellaneous | Comments Off

Retrospectives and Iteration Planning in two slides.

 

 

 

Posted in Uncategorized | Comments Off

ETL from hell – getting past denial

A great article here on diagnosing problems with batch system performance: https://www.simple-talk.com/sql/performance/the-etl-from-hell—diagnosing-batch-system-performance-issues/

Basically it goes like this – when there’s problems with batch processes overlapping or timing out, companies typically try the following:

  1. Can we ‘fix’ this with more hardware? (this is expensive, and a temporary fix)
  2. Can we change the product – for example from SQL to Oracle? (this only work with a redesign. Usually the product isn’t the issue!)
  3. Turnkey solution (expensive and typically doesn’t address the root issue)
  4. Split systems into parts, each on isolated servers (hard to synchronize running jobs across your now-separate systems)

Instead of these knee-jerk reactions, there’s a better way – both strategic and tactical – to fix this:

  • Tactical
    • Gather statistics – how long is a process likely to take?
    • Get a baseline of long-running problem queries
  • Strategic
    • Determine processing time windows
    • Create a task list in Excel – and include internal/external dependencies
    • Monitor the system – and include management in monitoring reports
    • Define threads – tasks in sequence – and processing times
    • Implement batch system control that runs off your table of tasks/dependencies
Comments Off

Sprint Reviews That Work

The purpose of the sprint review is to show customers what it has accomplished over the sprint. Here’s some basic guidelines:

  • It should be informal
  • It should be short. For a two week sprint, 90 minutes – for 4-week sprints, anywhere from 2-4 hours.
  • Use Powerpoint slides versus ‘retrospective notes’. Have a slide for
    • The sprint goal
    • The stories we committed to delivering
    • Stories completed
    • The stories we failed to complete
    • Recap of key decisions made during the sprint (tech, market-driven, etc)
    • Project metrics (code coverage, etc)
  • All of the above should take 10-15 minutes.
    • Demonstration of the completed work (ideally done by stakeholders themselves)
    • Priority review for the next sprint
    • Ask for acceptance on stories during the meeting

So here it is in graphical form:

Posted in Uncategorized | Comments Off

What’s a “Code Dojo”?

Had a great presentation a few weeks ago at AgilePDX on ‘Scaling Practice: Rebooting the Technical Culture’ by Matt Plavcan at Intel. Matt Plavcan is a Technical Practices Coach with the Intel’s Emergent Systems and Coaching team, and is the founder of the Code Dojo and Retreat program at Intel, which uses dedicated practice to hone professional programming skills.

Some interesting statements made by the speaker:

  • Pairing is the only way to get exponential growth.
  • In terms of distractions, you’d think Meetings is #1… it isn’t. Email is the biggest threat, followed by debugging, followed – last – by meetings.
  • Saying “Agile makes you go fast” is a horrible message. The emphasis is on repeatability, execution, stability. Speed is a byproduct of disciplined execution.
  • He hosted a code dojo – starting in October of 2011. Started with 12 people, in a 2 hour session, 1x a month. People donated their time. Pairing, outside of work environments. He didn’t ask management’s permission – you shouldn’t have to ask to improve your skills! Ground rules:
    • No code comes in from outside
    • Everybody pairs
    • No code accepted without a test
    • Focus on how, not what
    • Frequent short sessions
    • Whatever happens in here doesn’t matter in the “real world”.

The last bullet point was very intriguing to me… so I followed up with Matt after the conference on his “8 principles” in guiding a dojo. Here’s what he wrote me back:

The operating principles for the dojo are:

  1. Learning through shared experience
  2. Fast feedback
  3. Failure without consequence

The first rules I wrote were designed to avoid known anti-patterns I’d observed in other practice efforts.  I’m a little less enthusiastic about them now, so I tend to not overstate them unless I’m starting adojo with novices.  The 8 original rules (with my comments on their purpose) are:

  1. Everyone must participate in coding        (avoids inactive partners)
  2. One computing device per group             (for writing code; using the other computer to look up information is perfectly fine)
  3. No one codes alone                                        (forces pairing)
  4. No pre-written code                                      (avoids cut/paste, encourages understanding syntax)
  5. No code accepted without a test              (working code trumps all)
  6. Test first, test early, test often                  (TDD if you can; if not test as small a piece of code as possible, frequently)
  7. Question code, don’t criticize it                  (Referred to as the ‘Jeopardy Rule’.  Questions elicit answers without judgment.  It’s really, really  hard to have an argument in interrogative form.)
  8. Pay Attention: You’re next                          (when we do ‘mob’ practice, only one person in the dojo is writing the code, but the role is rotated frequently. This keeps everyone in the loop.)

This sets the stage for practice, but to be effective, the dojo needs to be “fed” with training, such as TDD or refactoring techniques, so that the group has something they have agreed to train themselves with.

 
 

The interesting part is that, in true scrum fashion, he started with 8 principles – and ended up with 3 easy to follow guidelines. I think the whole concept of a code dojo (and not asking for permission from managers!) very interesting – and applicable where I work.

Posted in Uncategorized | Comments Off