Recently I have found myself looking at our agile process and trying to work out ways of improving things, here are a few thoughts.
Iterations
The idea of iterations seems like a nice thing when you work in an environment that releases completely ad-hoc and your practices don't really support this due to lack of proper testing. But when I look at projects that utilize automated testing and Continuous Integration the prospect of continuous delivery suddenly seems like a nice thing. If my code base is stable and automatically tested then why shouldn't I release at any point? there should never be a check in where the code base doesn't build/work. While I have defiantly argued the case that the business should be able to commit to 2 weeks worth of work without requiring to add additional stories to the iteration. Is it really such a bad thing for the business to be able to change their mind daily to respond quicker to the needs of customers? This seems like a very agile practice, responding to change quickly to give the business the edge of the competition.
Estimation
The developer in me thinks that pretty much all estimation can quite happily be put under the category 'Waste', but I understand that this kind of thing when done properly can be good for the business to estimate how long things are going to take. I guess the main reason I am cynical is I have yet to see it work very well. At the moment I seem to favor planning poker as an estimation method and like the idea of using a T-Shirt Size/Numbered system crossover. The main reason for this being that t-shirt sizes are very easy for people to understand and they are not related to time, I've found that the whole story point can be quite a confusing concept to explain, though the downside of t-shirt sizes over story points is that the relation ship between the sizes can be very unclear (is a medium twice the size of a small.. e.t.c.). So I am thinking of doing a t-shirt size system but with the story point numbers wrote on the cards as well, this should hopefully make is accessible and clear.
Retrospective
I think this is the most valuable thing that agile brings us, the process of Kaizen (Continuous Improvement). While I often struggle with what to do with the items that come up in retrospectives (How to manage/resolve the problems).
Stand-Ups
Stand ups are quite a good way of keeping track of whats going on between the team but I often find that most of what's said is already known by the people who need to know it. I think a stand up can be a useful tool when people lack time or communication but maybe it is not required by co located teams in an open office where anyone they need to speak to is often no more than a 30 second walk away.
Friday, 12 December 2014
Thursday, 30 May 2013
Asp.net Mvc Image Helpers (Part 2)
Image helper with server side image re-size
In this second part we will continue on from part 1 and add a second option to our image controller that enables us to have the server re-size the image before sending it to the client.
First you need to install Image Resizer http://imageresizing.net/ through nuget, (Tools->Manage Nuget Packages), by searching "imageresizer". We will be using this package to re size the images.
Once the image resizer is installed in your mvc project we can add a new method to the Image Controller.
public ActionResult ImageResize(string image, int width, int height)
{
var imagesPath = Server.MapPath("/Images");
var imageLocation = Path.Combine(imagesPath, image);
var settings = new ResizeSettings
{
Format = "jpg",
Mode = FitMode.Stretch,
Width = width,
Height = height,
Scale = ScaleMode.Both
};
var outStream = new MemoryStream();
ImageBuilder.Current.Build(System.IO.File.ReadAllBytes(imageLocation), outStream, settings);
var resizedImage = outStream.ToArray();
return File(resizedImage, "image/jpeg");
}
In this we map the path as before and then re-size the image and pass it in to a memory stream so we can return the image to the client. There are plenty of options for image resizer see this page for more.
Next we need to add an overload to our html helper extension that allows us to specify image dimensions.
public static MvcHtmlString Image(this HtmlHelper helper, string image, string alternate, int width, int height)
{
var urlHelper = new UrlHelper(helper.ViewContext.RequestContext);
var url = urlHelper.Action("ImageResize", "Image", new {image, width, height});
var builder = new TagBuilder("img");
builder.MergeAttribute("src", url);
builder.MergeAttribute("alt", alternate);
return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));
}
As before this uses a URL helper to generate the URL then generates a img tag using a Tag Builder before returning it as a MvcHtmlString.
To use this in razor just type:
@Html.Image("test.jpg", "Example Image", 50, 50)
Links
Source Code
Part 1
Labels:
asp.net,
c#.net,
html helpers,
image resize,
mvc
Wednesday, 29 May 2013
Asp.net Mvc Image Helpers (Part 1)
In this series I will look at adding a few image helpers to the mvc html helper to simplify adding images to a view.
This will find an image that is inside the "/Images" folder and return it as a "image/jpeg".At this point you should be able to draw an image from this controller by adding the following code to a view:
If you need a test image feel free to use this amazing test image!
While this works just fine its a fair amount to write every time you want to draw an image, so to solve this we can create a html helper that just takes the image name and alternate text. something like "@Html.Image("test.jpg", "Alternate text")"
To do this we need to extend the Html helper to include a method for image, so that we can easily create images and not need to worry about calling @Url.Action() each time we want to render an image.
Create a new static class called "HtmlHelperExtensions"
In this class first we create a static method and have the first parameter as "this HtmlHelper helper" to specify that it is an extension to the HtmlHelper class.
next we use a URL Helper to generate the URL for the image controller action without having to specify it. We then format this in to the <img> tag and return it as an MvcHtmlString so it is properly formatted.
At this point you need to either add an @using statement and specify the namespace where HtmlHelperExtensions is or add it to the web.config inside your views folder so that razor knows where to find it without specifying it in every view you want to use it in. To do this open the razor web.config (the one in the views folder).
In the web.config you should see a <namespaces> element with some <add namespace... elements inside it inside of a <system.web.webPages.razor> element. In here we need to add the namespace that the htmlhelperextensions class is inside. For me that is "SimpleImageHelper.HtmlHelpers" so i need to add:
This should enable you to type
in a view and an image will be created, if the image does not display it can be helpful to view the source of the page to try and get a clue as to where the process is going wrong.
In the next part we will look at creating an image helper that will re size the image on the server before sending it to the client.
Source Code
Simple Image Helper & Image Controller
The first helper is just a simple helper that displays an image tag with the source value set to point at a image controller that returns an image. To do this first create a new controller called "ImageController" this will be used to hold all our image related actions.
Add the method:
public ActionResult Image(string image)
{
var imagesPath = Server.MapPath("/Images");
var imageLocation = Path.Combine(imagesPath, image);
return File(imageLocation, "image/jpeg");
}
This will find an image that is inside the "/Images" folder and return it as a "image/jpeg".At this point you should be able to draw an image from this controller by adding the following code to a view:
<img src="@Url.Action("Image", "Image", new {image = "test.jpg"})" alt="Test Image"/>
and as long as you have an image called test.jpg in your images folder it should get rendered. If you need a test image feel free to use this amazing test image!
While this works just fine its a fair amount to write every time you want to draw an image, so to solve this we can create a html helper that just takes the image name and alternate text. something like "@Html.Image("test.jpg", "Alternate text")"
To do this we need to extend the Html helper to include a method for image, so that we can easily create images and not need to worry about calling @Url.Action() each time we want to render an image.
Create a new static class called "HtmlHelperExtensions"
public static class HtmlHelperExtensions
{
public static MvcHtmlString Image(this HtmlHelper helper, string image, string alternative)
{
var urlHelper = new UrlHelper(helper.ViewContext.RequestContext);
var url = urlHelper.Action("Image", "Image", new {image});
var builder = new TagBuilder("img");
builder.MergeAttribute("src", url);
builder.MergeAttribute("alt", alternative);
return MvcHtmlString.Create(builder.ToString(TagRenderMode.SelfClosing));
}
}
In this class first we create a static method and have the first parameter as "this HtmlHelper helper" to specify that it is an extension to the HtmlHelper class.
next we use a URL Helper to generate the URL for the image controller action without having to specify it. We then format this in to the <img> tag and return it as an MvcHtmlString so it is properly formatted.
At this point you need to either add an @using statement and specify the namespace where HtmlHelperExtensions is or add it to the web.config inside your views folder so that razor knows where to find it without specifying it in every view you want to use it in. To do this open the razor web.config (the one in the views folder).
In the web.config you should see a <namespaces> element with some <add namespace... elements inside it inside of a <system.web.webPages.razor> element. In here we need to add the namespace that the htmlhelperextensions class is inside. For me that is "SimpleImageHelper.HtmlHelpers" so i need to add:
<add namespace="SimpleImageHelper.HtmlHelpers"/>
This should enable you to type
@Html.Image("test.jpg", "Example Image")
in a view and an image will be created, if the image does not display it can be helpful to view the source of the page to try and get a clue as to where the process is going wrong.
In the next part we will look at creating an image helper that will re size the image on the server before sending it to the client.
Links:
Source Code
Subscribe to:
Posts (Atom)



