Filed under: Uncategorized | 3 Comments
Tags: alt-net, IOSCD
FluentMigrator Composite Index
Fluentmigrator is a really nice migration tool that allows you to tear your database up and down keeping version, please visit the project page for more info.
Anyway, the other day I had to create a composite index, and I didnt know how, the way to do that is:
Create.Index(“Name_of_the_index_String”).OnTable(“Name_of_the_Table_String”).OnColumn(“Column_Name_string”).Ascending()
.OnColumn(“Other_Column_Name_string”).Ascending();
Looks kinda obvious no? but what threw me off at the time is that I was looking at the possible operations after OnColumn and there was nothign obvious there,
then I looked at the Sql documentation for CREATE INDEX
CREATE [ UNIQUE ] [ CLUSTERED | NONCLUSTERED ] INDEX index_name
ON <object> ( column [ ASC | DESC ] [ ,...n ] )
[ INCLUDE ( column_name [ ,...n ] ) ]
[ WHERE <filter_predicate> ]
[ WITH ( <relational_index_option> [ ,...n ] ) ]
The solution was (kind of) there, you could do more columns after you specify the sorting direction. Perhaps it’s obvious but it took me a while to figure out. It was logical however not obvious.
Also on composite, before I created an index I thought about using composite keys, J.Miller has a post here on why that is not really a good idea ( have a look at the comments in particular). For me, it boils down to:
- Maybe something that has meaning now, wont necessarily have the same meaning in the future
- It’s harder to manage composite keys that it is to manage surrogate keys
There are more reasons for and against surrogate keys, but this was what was suitable to me at the time
Cheers
Filed under: .net, NHibernate | Leave a Comment
Tags: fluentmigrator, NHibernate
I m late with the Ada Lovelace Day article, I had the choice of making it on time but incomplete, or put some time and be late, and I chose the later this time. I really though the person and the topic deserved in depth investigation.
I didnt really know how to aproach the Ada Lovelace Day last year and this year I still dont know now, I think the best homage I can do is learn more about F# in this case.
This post is about Amanda Laucher and about F#. Amanda is the author of F# in Action. A speaker and most importantly a software developer, when you see her talking you can see she really likes what she does, and that fact is pretty inspirational.
I found quite a few of her presentations online
- QCon London 2010 – Pragmatic F# in Action
- QCon London 2009 – Concurrent Programing with F#
- Channel 9 - 2008 Ted Newward and Amanda Laucher on F#
- I m sure there is more but that ll get you going =)
Then I also found some other F# resources
Wikipedia had a pleasant surprise in store for me with a really comprehensive introduction to the language, and also pointed me to a wikibook however when I started typing the code and tryng to run it I ran into problems because the parser looks at line breaks.
Disclaimer: I never done any f# before so anything below could be completely wrong (if so please let me know so I learn
)
In a short time I learnt that
F# is
- Not purely a functional language, some OO aspects and has type inference.
- a strongly typed language
- .Net language
- has Garbage Collection
- does Lazy evaluation ( this is really cool )
- Some sort of Asynchronous workflow ( need to digg deeper on this)
More detail
- Everything is inmutable by default, but there are mutable objects ( apparently the objects that you can get by interoping with, say,a c# dll are mutable but i m not sure)
- lazy evaluation
- Asynchronous Workflows
- You can pass functions as result of function executions, or be the result of functions, and have functions inside functions
- Send parts of parameters into a function
- have a collection of functions that can be started asynchronously (holy smokes!)
After looking around I also found some good videos from Erik Meyer on the topic, hes got a series of them you can have a look here, the series goes through the history of functional programming and principles, very interesting.
I can see a lot of potential on this, I find functional programming a big mind switch and I m sure it will take me a good while to do it properly, however, the goodness of looking at this code comes from the ideas you can take from different aproaches.
One thing that did strike me so far is that i ve seen bad variable names and no unit testing on it at all, on the other hand, the power that you seem to sudenly have is just incredible, tho since the paradigm shift is so big, I found myself stumbling and not being able to do things that i find really simple in c# (like print an array to the console, the difficulty was on realising that the line breaks are significant)
The real life example from the QCon talk from 2009 was a really good way to see the value of the language as real life usage, the QCon talk from 2010 was really good because it dived deep into the language, language usage, etc.
I feel like I ve started learning something that will cahnge the way I code and I m really happy about that.
Filed under: .net | 3 Comments
Tags: ALD, f#
Irish Open Spaces Coding Day II
Hi all:
Just thought I d post here that a group of us in Dublin. Alt.Net are organizing a coding day the 24th of April in UCD, it should be a fun day of hacking some code. One of the really cool things is that James Gregory will be there talking about Fluent Nhibernate.
If this sounds like something you d’like to do you, can register and find out more about it in codingday.org
Cheers
Filed under: Uncategorized | Leave a Comment
I understand the title makes little sense, but this is probably what I would search in a web search engine ( hopefully at the time I ll find my own post) A short, unordered list of things I install when I get a new machine/wipped machine
- An FTP client Filezilla will do
- Firefox + Add on: firebug, noscript, colurful tabs,
- Chrome ( for js intensive stuff it jsut renders faster)
- ieTester ( run multiple ie versions parallely)
- ieDebuger
- Wireshark, comes handy
- Reflector
- Resharper
- Syntax friendly Notepad ( I use Notepad ++ but not mad about it)
- Tortoisesvn or Anksvn
- Tortoise git
- SVN Monitor
- Git ( you ll need it at least to download libraries code)
- foobar2000 music player ( after all you need to block the noise from the outside)
- Sql Server Management Studio , you ll eventually need it and if you have profiler you ll probably need it too
- #Develop is kinda handy too
- I use Evernote, so I would install that, tho not run it often just because I don’t like the desktop client much tbh
- Sumatra PDF (if anyone knows a better one I d appreciate it)
- Visual Studio
- Setup IIS
Filed under: Uncategorized | 4 Comments
DDD South West
So there is another DDD event the 5th of June, and this time is in Bristol, call for speakers is on ( if you want to submit, you can get instructions on how to do so here)
Sessions look interesting so far.
I really enjoyed the last DDD in Reading, Uk.
Filed under: Uncategorized | Leave a Comment
The Art of Unit Testing – Review
A few of us have been reading this book as a part of a book club. Finally I think is time to push a review for this book .
Let me start saying that my expectations for the book were very high, the book club helped because we were really reading it in depth and going over little bits of each chapter.
Bad things about the book
Examples are not great, there are errors on some of them, and (possibly the worse thing of it all) some of the tests dont follow the advice that is given in the book, particularly in naming convention.
If you download the code that accompanies the book, some of the tests (that are supposed to pass) fail.
We sent an email with corrections but never heard back ( not sure if they didnt get it or what), which, to be honest, was a bit disappointing, if this code was on github I would have forked it just to get it fixed, tho I m not sure Is correct to do that if the code is not on github (if anyone knows please let me know).
Again on the code samples, some of the examples scenarios are not really that descriptive, I have to add, that after preparing the talk I gave in DDD, I have to say its really really hard to come up with good sample code, that demonstrates a smell and a solution in a clear way in not a lot of code… so maybe its not a fair criticism, but I really had to mentione it, because you read the sample and really wtf? a bit .
The chapter on Mocking is not great either, Rhino mocks is not used in anger, and I m pretty sure Roy could have gotten someone with loads of experience in Rhino Mocks to look and review (and improve ) the example code.
Good things about the book
I know that after what I said what bad in the book, this will sound fake, but I actually think the book is really good, because I learned loads about unit testing.
It made me think about how to test, What to think about when testing, how to approach writing code with testing in mind.
It basically gave me a lot of basics like, the difference between Unit and integration tests, and that was important, because I could clearly define, I need to tests this (whatever it is you are writing) I understood the differences between different Fakes, as well as the difference between state and behavioural tests.
Along the way, you pick up on test smells, and many tips on what to do and most important, what not to do.
Since I read the book I understand and I have the purpose of writting code ( test code included of course) , that is readable and maintainable. And I want to trust my tests, and thanks to the book, I can now understand why these are important qualities of the code.
The funny thing is, that since then, I actually feel like I really got how to be test driven, because writing code in any different way, simply doesn’t make sense any more.
Conclusion
A really good book if you are interested in unit testing and feel the need to learn how to do it better, like anything you read, take it, use what you can and completely believe in and then, discard the rest; even then you will have about 80% of the book (or more) really valuable.
Reading this book, along with TDD by example by Kent Beck and maybe completing it with xUnit Test Patterns byMeszaros
Filed under: Uncategorized | Leave a Comment
Tags: unit-testing
The other day I was listening to Kent Beck in this podcast where he was talking about, amongst other things, push on green deployment, basically the idea is that once your test suite goes green, you deploy.
When I heard this originally I thought :
1) Think about all possible problems -> not only technical( this component is not compatible with the component just rolled out, etc, etc) but also processes ( and people using them ) this is a real concern, because the pace of change would increase I would guess)
2) What tests? Who wrote them? I would think higher level tests? actually all tests? Possibly the upside of this is that companies that produce quality software will become incredibly popular ( “My software doesn’t brake, we test throughly” could actually be part of the marketing and backed by actual tests, imagine that)
3) The premise for push on green is basically to push Software Development practices up a notch, so that as a developer we can say we are delivering a feature on a particular date and we can do that confidently, How does push on green help us deliver as we promised, would it makes us slower?
Deployment is a painful process, and often neglected topic, as a developer how often do you think about it? And worse, How many times you just don’t know what will happen? Most importantly. How stressed do you get close to going live? (I guess this is the time when we all start thinking about it seriously)
Great, now imagine What if that would happens every hour?
In the beginning it would be scary, but then, the practices need to be polished enough so it becomes something normal, that you are not only used to , but confident about it. After all we all become better at things with practice.
Do i like the idea? Yeah! and Its as scary as it gets
Lets look into it more in depth
So how can this possibly work?
If I was going insane(er?) and really wanted to do this, as a C# developer, what is possible?
Maybe I would start of an continuous open beta or, edge (somehow warning my users of the fact that the code they are using is “fresh out of the oven”) and once I see some stability (perhaps people could vote for it or similar)then I can fully deploy.
But then thats is just my application, lets imagine I produce code that is not public facing, but that , its an API, consumed by many other applications, how would they be aware and react to interface changes? More importantly, would this make software evolution slower by persisting everlasting APIs? or would it induce APIs that are very noisy, hence harder to discover?
I m asking this because: lets forget about the barrier of web or desktop for a minute and focus on dlls, where they live and how we use them and consume them.
If my Operating System vendor/framework provider makes a push do i want my app to get that immediately?
Say I m using an interface something like IEmailSender, that has the methods Send(IEmailTemplate, ISomethingElse) and that is replaced for the better designed IEmailSender.Send(Message) with the Send(Message[]) overload. In that example I agree with the change, I want to use the new code because the contract is better (lets assume we all agree is better ok); however, that would mean changing my application, re testing all those areas where I use IEmailSender and I most likely don’t want that.
I have to add, I would probably want to do an integration test anyway, or should I blindly trust the new IEmailSender implementation because we are all pushing on green now?
So the option here seems to be, create the new contract but maintain the old one around for a while right?, but then your API will have all these Send methods, and that doesnt seem to be going into the better development practices direction
Next I m gonna try heroku in anger and see if I get more ideas from using it, heroku is a service that runs ruby applications that are deployed when you commit.
This is a brain dump on this and would love to hear thoughts from other people, corrections, feedback, etc always welcome
Filed under: Uncategorized | 5 Comments
Tags: deployment, development, push-on-green
Test Class Organization
Hi there
Just though I d share this
this is the way I ve been organizing my test code as of late
public class MyClassTests { public class Given_a_context { [Fact] public void When_somthing_happens_Then_result() { throw new NotImplementedException(); } //............... } public class Given_a_different_context { [Fact] public void When_somthing_happens_Then_result() { throw new NotImplementedException(); } //............... } }I like this because you can still easily find the class name with resharper
you can also separate the contexts you are testing in a more clean way
this works out good for me most of the times, even when you are inheriting
from a base test class.
It also reads well in the Test runner.
Any comments?
Filed under: Uncategorized | 9 Comments
Tags: unit-testing
- I do speak too quick,
- I should talk about legacy code and how to deal with that
Filed under: Uncategorized | 6 Comments
Search
-
You are currently browsing the roundcrisis.Find<Solution>() weblog archives.

