June 29, 2009 by Olav Rask
For a project i am working on in my spare time, i needed to stream MP3 audio from a REST service, implemented in WCF. I was supprised at how easy this was. It’s as simple as setting the response content type and returning a stream:
IAudioDemoService.cs method definition:
[OperationContract]
[WebInvoke(
Method = "GET",
UriTemplate = "/AudioStream")]
Stream GetAudioStream();
AudioDemoService.cs method implementation:
public Stream GetAudioStream()
{
WebOperationContext.Current.OutgoingResponse.ContentType = "audio/mpeg";
return new FileStream(@"c:\AudioFile.mp3", FileMode.Open);
}
(actually the content type isn’t strictly nessesary, but it enables a client to identify the information in the stream – a browser for instance might use it to select an appropriate application for processing)
Easy!
Tags: Audio, C#, MP3, REST, Stream, Streaming, WCF
Posted in Uncategorized | Leave a Comment »
June 29, 2009 by Olav Rask
Commenting on my previous post, Udi Dahan brought this talk of his to my attention: http://www.infoq.com/presentations/Making-Roles-Explicit-Udi-Dahan
While I do feel that some of the points I made with regards to persistence are still valid, I did find Udi’s presentation extremely interesting. The example of IValidate<Customer> just feels right. If you have an interest in software architecture, I am sure you will find this interesting.
Tags: Making Roles Explicit, Roles, Software Architecture
Posted in Uncategorized | Leave a Comment »
June 25, 2009 by Olav Rask
Jason Gorman has a nice post on what he finds to be the best UML modeling tool – theres even a link to a free giveaway of 10 pages of special UML modeling paper, that I will highly recommend.
Post is from June 21 2009 and can be found here: http://parlezuml.com/blog/.
Tags: Jason Gorman, Joke, Modeling, Pen and paper, UML
Posted in Uncategorized | Leave a Comment »
June 22, 2009 by Olav Rask
The problem
Diving into Domain Driven Design and trying to take colleagues with me, I find myself returning to the question of persistence. In the case of DDD, Persistence Ignorance more specifically. DDD deals with fetching data through two mechanisms: repositories and traversal. Repositories give access to aggregate roots. From there traversing relations enables navigation to related business entities.
In regards to persistence, the idea of relations bring with it concepts such as “Lazy Loading” and “Eager Fetching”. Should a given relation be loaded in the same shot as its parent or should it be loaded once a client requests the use of it? Because most computers consist of a combination of fast volatile and slow persistent storage, these decisions can have great impact on the performance of an application. A number of very technical frameworks and solution exists only to assist in designing this behavior.
The focus of Domain Driven Design is a domain model, clearly communicating business logic, unpolluted by such technical concerns.
Over a period of time I have come across various solutions to implementing both repository and traversal. I’ve seen several very well thought true solutions – all of which have helped me in understanding more of the persistence aspect. I have yet to come across a solution that feel completely natural, but in the following I will try to shed some light on some of the solutions I have come across and how these could be combined to achieve a yes another implementation.
Read the rest of this entry »
Tags: Domain Driven Design, Domain Driven Development, Eager Fetching, Infrastructure layer, Lazy Loading, Model Driven Design, Persistence, Persistence concerns, Persistence Ignorance, Repository, Unit Of Work
Posted in Uncategorized | 3 Comments »
June 18, 2009 by Olav Rask
Today i had to terminate an application, if certain launch conditions where not met (settings not filled out more specifically). I started out searching for information regarding UIApplication, but it turned out that a simple C call does the job: exit(0);
Tags: exit, exit iphone application, iPhone, iPhone API, iPhone SDK, objc, programming, quit, terminate, terminate iphone application
Posted in Uncategorized | Leave a Comment »
February 17, 2009 by Olav Rask
As a part of the project i am currently working on (seems there is a difference between finished and FINISHED), i had to implement the pretty standard feature of displaying an address in Google Maps. To my suprise it took me quite some time to find the code, so to make things easier for others, i thought i would post it here.
If found a demo app (http://www.appsamuck.com/day3.html) that shows how to use multiple different url types (phone, email, etc.). At a glance it worked fine, but when i tried to open a Danish address with special characters (æ, ø, å), the “address” bar in Maps would just read “null”. It turned out that who ever put together the sample app, used NSASCIIStringEncoding as the format for encoding the spaces in the address – in my example i changed it to NSUTF8StringEncoding. Enjoy:
// Where is Apple in Denmark on the map anyway?
NSString* addressText = @"Nørre Voldgade 11, 1358 København K";
// URL encode the spaces
addressText = [addressText stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
// Combine url
NSString* urlText = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%@", addressText];
// Open url
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:urlText]];
Tags: Google Maps, iPhone, iPhone SDK, Maps, openUrl, Show address in maps, stringByAddingPercentEscapesUsingEncoding
Posted in Uncategorized | 1 Comment »
January 27, 2009 by Olav Rask
So.. after figuring out how to store a contact in the iPhone addressbook, using the AddressBook framework of the iPhone SDK, i realized that storing phonenumbers wasent quite as straight forward as storing fields like first- and lastname.
Phonenumbers are stored in a “multivalue” property. This means that multiple values with different “labels” can be stored for the property “phone” (kABPersonPhoneProperty) of a person.
Anyways – i thought i would throw in the code:
Read the rest of this entry »
Tags: ABMultiValueAddValueAndLabel, ABMutableMultiValueRef, kABHomeLabel, kABPersonPhoneMobileLabel, kABPersonPhoneProperty, phoneNumberMultiValue
Posted in Uncategorized | 3 Comments »
January 18, 2009 by Olav Rask
So i recently started programming for iPhone. As part of the project i’m currently working on, i have to add new entries to the phones address book (contacts). The address book api is not very intuitive, seems to be a straight C api and is poorly documented. It took me a lot of googling to find the solution, so i promissed my self i would post the code once i found it .
Read the rest of this entry »
Tags: ABAddressBook, ABPerson, Add to contacts, Address book, API, Contacts, iPhone, iPhone SDK, SDK
Posted in Uncategorized | 1 Comment »
April 29, 2008 by Olav Rask
I rescently upgraded my HTC-S620 to Windows Mobile 6.1 (Nice new home screen – wuha) and in the process i had to correct the keyboard map to reflect my danish keyboard correctly.
So if you are in the same situation as me, and you need a danish keyboard file, you can download it here: eT9.Excalibur.0409.kmap.txt drop a comment and i will send it to you / re-post it somewhere.
Tags: Danish, Dash, Excalibur, HTC-s620, Keyboard, Keyboard Map, Windows Mobile
Posted in Uncategorized | Leave a Comment »