Archive

Tag Archives: c#

The Iron Foundry Team are big advocates of open source software. We write code across all sorts of languages, just like many of the development shops out there do. Sometimes we’re heavy on the .NET, other times we’re all up in some Java, Ruby on Rails, spooling up a Node.js Application or something else. So keeping with our love of open source and our polyglot nature we’ve created the Thor Project with three distinct apps.

Before jumping into the applications though, a little context for what and where Thor is in the grand scheme of things. We need to roll back to the Cloud Foundry Project to get into that. The Cloud Foundry Project is an open source project built around software for PaaS (Platform as a Service) which can be used to build your own PaaS internally or externally, in a cloud provider or directly on hardware. It’s your choice how, when and where you want to use it. For more context on PaaS check out my previous entry “The Confusions of IaaS, PaaS and SaaS“.

Thor Project

Cocoa for OS-X

Thor Odinson

Thor Odinson, God of Thunder

You know who Thor is right? He’s this mythic Norse God, also known as the God of Thunder. Since we’re all about bringing the hamma we welcomed Thor into our team’s stable of applications. So starting immediately we’ve released Thor into the realms for contributions and fighting the good open source software battle! If you’d like to join the effort, check out the github project and feel free to join us!

Technically, what is the Thor Application? This is a Cocoa Application built for OS-X that is used for managing, deploying and publishing applications to Cloud Foundry enabled and or Iron Foundry extended PaaS Environments.

.NET for Windows 7

The .NET Metro version of the Thor Application is also released via github with a provided installer. We’ve almost taken the same path, except of course for the very different UX and UI queues with Windows 7 and the Metro UX design guidelines.

WinRT for Windows 8

I wasn’t really sure what to call this version. Is it Metro or WinRT or Windows 8 or something else? Anyway, there is a project, it is albeit empty at this point, but it is the project where the Windows 8 version of Thor will go! For now get the Windows 7 version and install it on Windows 8, it won’t have touch interface support and things, but should work just like a regular application on Windows 8.

The Code

To get started with these, generally you’d just clone the repo and do a build, then get started checking out the code. There is one catch, for the OS-X version you’ll want to pull down the sub-modules with the following command.

git clone git@github.com:YourForkHere/Thor.git
git submodule update --init --recursive

Once you do that in XCode just make sure to then select the right project as the starting build project.

…then when the application is launched…

Thor Running in OS-X

Thor Running in OS-X

I’ll have more in the coming days and weeks about Thor & Iron Foundry. For now, check out the blog entry on the Iron Foundry Blog and subscribe there for more information.

It started like this.

string responseValue;

if (null == vcapResponse)
{
    responseValue = message;
}
else
{
    responseValue = vcapResponse.Description;
}

return responseValue;

…and after a few alt+enter hits…

return null == vcapResponse ? message : vcapResponse.Description;

I ended up with that beauty. Oh yeah. :)

…and for today, that’s it. Whew!

If you live in or around the south sound region near Olympia, would like to hear about the AWS Toolkit and SDK for Visual Studio, come and check out the South Sound .NET Users Group on at Olympia Center, 222 Columbia NW, Olympia, Washington.  The meeting will be on January 12th at 7:00pm.

Slides & Links to Code are already available!

Overview:  During this presentation I will provide an overview of what is needed to get started using Visual Studio 2010 with the AWS Toolkit & SDK. We’ll also cover the basic design ideas behind the do’s and don’ts of cloud architecture and development. There will be some hands on coding (if you’d like to bring a laptop to follow along) and we will deploy code (pending a wireless/cat5 connection) into AWS Cloud Services & get EC2 instances up and running live!

The first example is some working code, that determines if a date value is a weekend day and returns true or false based on that.

bool firstSecondNulls = false;
var dayOfWeek = (DateTime) zeros.ElementAtOrDefault(i).BalanceDate;
if (dayOfWeek.DayOfWeek == DayOfWeek.Sunday || dayOfWeek.DayOfWeek == DayOfWeek.Saturday)
    firstSecondNulls = true;
return firstSecondNulls;

This second example also provides the same result, except in a more readable, cleaner, and more efficient way. Matter of fact, I’d say in some circumstances it is exponentially more efficient! Do you see why?

var dayOfWeek = (DateTime) zeros.ElementAtOrDefault(i).BalanceDate;
return dayOfWeek.DayOfWeek == DayOfWeek.Sunday || dayOfWeek.DayOfWeek == DayOfWeek.Saturday;

This is an insanely simple example. But just imagine some of the nightmarish methods and functions, with hundreds of lines of code. Keep in mind, that those nightmares are minimal compared to the Enterprise Scale 1000+ plus line methods! Yes, those exist and they are beyond nightmares but holocausts of thought and design!

So the next time you think “meh, I’ll refactor it later.” just take that extra minute or two and do it now! The pay off, you know full well when you think about it, is massive in the end. Cheers!

I put together a little project on Github, partially because I’ve been making headway learning the intricacies of JavaScript, and partly because I wanted something that would parse a string that represents a time value. So here’s the TDD I went through. In the process I pulled in QUnit and used that as my testing framework for the JavaScript example. I’d love input on either of these, so feel free to gimme some heat, tell me what I’ve done wrong, and especially how I ought to be doing this.  :)

The first thing I did was put together the C# Library. I started two projects, one for the tests and one for the actual library.  In the tests project I added a class file and removed the default using statements and replaced them with the following by way of Nuget:

using NUnit.Framework;
using Shouldly;

After adding these references I jumped right into setting up the test fixture. Since I know I want to have something to parse the hour for military time also I’ve setup two test variables.

[TestFixture]
public class with_static_parsing_of_time
{
    protected string sampleTimeOne = "10:12am";
    protected string sampleTimeTwo = "2:30pm";

The first test I then dived into was to test the hour.

[Test]
public void should_return_a_time_piece_with_correct_hour()
{
    var timePiece = TimePiece.Parse(sampleTimeOne);
    timePiece.Hour.ShouldBe(10);
}

I then fleshed out the object and implemented enough to get this test to pass.

namespace TimeSlicer
{
    public class TimePiece
    {
        public TimePiece(string time)
        {
            ParseTime(time);
        }

        private void ParseTime(string time)
        {
            SetHour(time);
        }

        private void SetHour(string time)
        {
            Hour = Convert.ToInt32(time.Split(Convert.ToChar(":"))[0]);
        }

        public int Hour { get; set; }

I then continued back and forth writing tests and implemented each. For the complete code check out the Github Repository. This example is really simple. I’d love any thoughts on adding to it or what you might think is a better way to test the object.

For the JavaScript I downloaded QUnit. Again I stepped into the testing, which is a whole different ballgame than in C#.

<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen"/>
<script type="text/javascript" src="jquery-1.6.2.js"></script>
<script type="text/javascript" src="qunit/qunit.js"></script>
<script type="text/javascript" src="TimeSlicer/TimePiece.js"></script>
<script type="text/javascript">

var timeValueOne = "1:30am";
var timeValueTwo = "8:15pm";

$(document).ready(function() {

module("Parse hour from value.");

test("Should parse hour from value.", function() {
    TimePiece(timeValueOne);
    equal(TimePiece.Hour(), 1, "The appropriate hour value is returned for AM meridian value.");
});

For the full test file with other JavaScript libraries and CSS check out the code file on github.

…and directly into implementation. With the caveat that I’m extremely unfamiliar with actual psuedo/pretend/faux object creation in JavaScript. In this realm I’m still reading up on best ways to do this.

TimePiece = function(time) {
    TimePiece.Hour = function () {
        return time.toString().split(":")[0];
    }
    return time;
};

I went on from here writing tests and implementing as I did with the C#. The JavaScript was interesting. I’ve also noticed that I get a lot of strings back versus the number values that I’d actually want, thus the addition of the “parseInt” in the final version.

Check out the overall project on Github at: https://github.com/Adron/Time-Slice

Metal Cactus

Just another WordPress.com weblog

ChaniBlog

Code, cooking, and randomness.

plain old objects

the building blocks of software

midnight mystery ride

at midnight, we ride.

Riding on Roadways

Writing on Riding on Roadways

Not Rich Yet

It's going to happen. Gotta find something to do until then.

craftedincarhartt

Carhartt Women's Blog

heydev

For the love of code

Nathan Evans' Nemesis of the Moment

My nemesis of the moment

Open Source Bridge: Presentation Proposals

Snippets, software architecture, lean, agile, management, and leadership bits.

Captured Refractions

A collection of my latest adventures, past reflections and other photos.

for the love of Nike

for the love of Nike

The Cloud Dev

Developing {for/ on/ the} Cloud...

Project Manager in a Cloudy IT World

Thoughts, comments and ideas from experiences as a Project Manager in IT

iBikeuBike

If I can bike... So can you!

MAX FAQs

Portland Light Rail

UX Success

User Experience Design, Agile Development, Lean UX, Start Up

The lost outpost

a weblog by Andy Piper about technology, photography, and life

SaintGimp

Agile development, software craftsmanship, continuous improvement - Eric Lee's blog

Clang and Clamour

pardon the construction noises while we build the internet

Follow

Get every new post delivered to your Inbox.

Join 5,548 other followers

%d bloggers like this: