What does Agile in a workplace mean to you?

I was asked this question recently at a meetup? It took me by surprise, i waffled and somehow manage to get my points across.
But as i sit down here this evening, i decide to note down what i think Agile in a workplace means.

Requirements-Plan-Design-Develop-Release-Monitor

I believe
Agile means working in cross-functional team

Having daily catch-up with all team members to discuss what you are doing
and how things are going.

Working in short iterations.

Developers are empowered to estimate the work and have an input on what they
want to work on according to the priorities.

Having a unified backlog, prioritized by someone responsible for the product
(the product owner)

And Developers participate in testing the application.

Advertisements

Using CKEditor with NET MVC Razor

At work, we have a project coming up that requires content to be constructed by the user. For content entry, we will implement a WYSIWYG editor to give users a familiar set of tools to interact with. There are a plethora of WYSIWYG editors available on the web our chosen one is CKEditor
The CKEditor offers a rich tool set that can be tailored to meet the requirements for content entry. CKEditor comes with well written documentation on a well put together website which is a huge selling point.

Getting Started

To get started, and throw in a quick plug, I am going to use the default .NET MVC web project template to give us a head start. All you have to do is create the default project in visual studio. We have our project, the next step is to download the CKEditor. The current version at the time of writing is 4.7. Once downloaded, unzip the contents (should be a single directory called “ckeditor”) and copy to the root directory in the website.

Implementation

Lets just get the CKEditor loaded on a page in the website. Firstly the JS files for CKEditor need to be included on the web page, include the required JS files into the master page (or just onto the web page the ckeditor is required on) of the project for the moment as shown below.

<script src="ckeditor/ckeditor.js"></script>
<script src="ckeditor/adapters/jquery.js"></script>

ckeditor.js is the main JS file that holds all the code that makes up the CKEditor. I always utilise the JQuery framework to assist with JS coding on a website as it just makes things a lot easier. So in order to get the CKEditor working with JQuery the jquery.js adapter is required. In order to get the editor working, some JS is required in order to convert a DOM element into the CKEditor. You can use a div, p or textarea, I recommend using a textarea because the textarea is a reasonable fallback when the browser doesn’t have JS enabled.

<textarea id="my-textarea"></textarea>

Above is the textarea I have added to the web page so it can be converted into a ckeditor. I never use inline JS, so I have added the code below to the main external JS file (js/mylibs/boilerplate.js). The code is basically saying when the document had loaded, convert the specified selector into a ckeditor. If the selector doesn’t match any elements in the DOM, then nothing happens.

$(function () {
    $('#my-textarea').ckeditor();
});

Provided you have everything in place correctly, you should see something resembling the screenshot below. The textarea has been converted into a CKEditor offering a rich set of content formatting tools. Super!

installation

Sending Content to the Server

So we have our CKEditor on the page, next step is to send the content added by the user to the server so it can be stored or whatever needs to be done with it. With the .NET MVC framework, a process known as model binding is used to send data from the client to a method in a controller on the server. Model binding will take the form values or query string values and try to set those values on the properties of an object instance (the view model), that object is then passed to a method on a controller.

Lets create a view model that will hold the content that is created by the user via the ckeditor.

namespace CKEditorExample.ViewModels.Content
{
    public class ContentViewModel
    {
        public string Text { get; set; }
    }
}

The Text property will have the user content set on it automatically by MVC 3 before it is passed into a controller method. Next step is to modify the razor view page that shows the ckeditor to tell MVC to bind the textarea to the view model that we just created. Razor provides lots of useful helper methods, particular to do with setting up HTML form elements for model binding. The code for the razor view for the content submission is shown below.

@model CKEditorExample.ViewModels.Content.ContentViewModel

@{
    ViewBag.Title = "Content Entry";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Content Input</h2>

<form method="post" action="/Content/Submit">
@Html.TextAreaFor(x => x.Text)

<p><input type="submit" value="Submit" /></p>
</form>

At the top on the view the model is declared, so now the textarea can be binded to a property on our model. As you can see we are using the razor Html.TextAreaFor to bind a textarea to the Text property on our view model, so when the form is submitted the value in the textarea at the time of submission should be set on the Text property. You may notice that the form is being submitted to /Content/Submit, I have created another razor view / controller method to handle the form submission and display a web page showing the content from the ckeditor that was sent to the server. The ContentController has two methods now, Index which returns a view that displays the form, and Submit that takes care of the form submission.

using System;
using System.Web.Mvc;
using CKEditorExample.ViewModels.Content;

namespace CKEditorExample.Controllers
{
    public class ContentController : Controller
    {
        [HttpGet]
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        [ValidateInput(false)]
        public ActionResult Submit(ContentViewModel model)
        {
            ViewBag.Text = model.Text;
            return View();
        }
    }
}

Above the Submit method shown in the controller above are a couple of attributes. HttpPost stipulates that only POST requests are accepted. The second attribute ValidateInput is telling MVC not to validate the user input, without this when submitting the form you will see the error message shown below.

[HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client…” exception is thrown because there is HTML being sent to the server. The [ValidateInput(false)] attribute will prevent this error happening, however we are opening ourselves up to a security vulnerability. So, to handle this you can encode the HTML before it is saved a database, or run checks on the content to ensure there isn’t any malicious HTML, such as script tags for JS code blocks. This will allow all our properties on the model to have HTML passed to the server, if your not keen for that you can add [AllowHtml] above the property that is permitted to accept HTML, thus removing the need for the [ValidateInput(false)] attribute.

So submitting the form in the state as shown below.

content_submission

Will result in the web page shown below.

content_submitted

As you can see the HTML that is created by the CKEditor has been sent to the server and is now displayed in the response. This demonstrates creating a CKEditor and sending the content entered by a user to the server.

Shiftless…

There is one thing about me i’m not a dreamer. i can say i’m an achiever if that makes sense.
I love challenges, and i love them more if they are attainable. I admire people that like or pose challenges as well.

Now when i say i like people that pose challenges i am not referring to human relationship challenges. i tend to stay away from those type of challenges.

An old friend of mine once described as a goat-head. She was remarking the fact that i never give up and quite stubborn in the face of challenges.

She said it as an insult, i received it as a compliment. I guess that’s because i’ve already made that realisation about myself, challenged it and end up falling in love with it.
Self-analyses have made me realise that this is what keeps me going in life.

You know, i believe

Where there is desire
There is going be a flame
Where there is a flame
Someone’s bound to get burned
But just because it burns
Doesn’t mean you’re gonna die
So you’ve gotta get up and  try and  try and try…..

Now, that might come across as “trying the same thing over and over again with the expectation of a different result”. NO, that’s not my way.
I believe life is a lesson, i believe everyday and every moment on this earth is meant to teach us something. it can be something beautiful, enjoyable or painful.
Every attempt at a challenge should be treated as a lesson.

i know some people that dont believe in this way of life. people that will try things once or twice and give up.
i dont despise these people, i quite admire them in a way. I believe everyone is different and i respect that.
They dont know my journey, they might never understand the life of someone that is not born with a special talent, look or charisma.

people like me have to work very hard for what we have. We have to study every day to ensure we get that first class honours result.
We have to train 5 times a week to ensure we win that race. We have to go out with a couple of women to learn not to confess your whole heart on the first date.(even though it’s the truth). Such is life i guess but you know one thing. There is no
greater feeling like winning something that you worked hard for. Even if you are not the best, you know you are better and knowledgeable person than
who you were before you take on the challenge.

glass of water

A psychologist walked around a room while teaching stress management to an audience. As she raised a glass of water, everyone expected they’d be asked the “half empty or half full” question. Instead, with a smile on her face, she inquired: “How heavy is this glass of water?”

Answers called out ranged from 100 ml. to 300 ml.

She replied, “The absolute weight doesn’t matter. It depends on how long I hold it. If I hold it for a minute, it’s not a problem. If I hold it for an hour, I’ll have an ache in my arm. If I hold it for a day, my arm will feel numb and paralyzed. In each case, the weight of the glass doesn’t change, but the longer I hold it, the heavier it becomes.” She continued, “The stresses and worries in life are like that glass of water. Think about them for a while and nothing happens. Think about them a bit longer and they begin to hurt. And if you think about them all day long, you will feel paralyzed – incapable of doing anything.”

It’s important to remember to let go of your stresses. As early in the evening as you can, put all your burdens down. Don’t carry them through the evening and into the night. Remember to put the glass down!

smart guy

One of my mates father was in the pub with us one night, near closing time he said he was going to order a chinese from the restaurant across the road from the pub. Instead of going in to order, he phoned them and asked them to deliver it to his house. He then went across the road and waited by the delivery drivers car so he could get a free lift home with him. worked too, what a crafty smart-guy.

Image

Quote

Your life

The best day of your life is the one on which you decide your life is your own. No apologies or excuses. No one to lean on, rely on, or blame. The gift is yours – it is an amazing journey – and you alone are responsible for the quality of it. This is the day your life really begins. ~Bob Moawad