In an O/RM solution the business logic often ends up in the very queries. Don’t mock them if you want to test business logic.
Some hundred years ago when Microsoft was pushing their first Entity framework and all examples were PresentationLayer<->DataAccessLayer someone asked “When one is using an O/RM; where is the business logic?”
After all this time I have finally found out. In the very queries.
This effects the unit tests.
Because what you often want to test with unit tests is business logic and mock out everything else. The call to the O/RM is often quite simple. Then comes some hefty Linq statement that translates to EF or nHibernate. Then follows some simple handling of the result. The main logic is in the O/RM call.
So when one mocks out the O/RM one mocks out a big part of the logic.
One solution is to not mock out the O/RM but instead mock the data retrieval beneath. I have not figured out how to do this.
Another solution is to do an integration test all the way to the database. My first try at this was messy but worked out. My second try was equally messy but also worked out and has returned the investment many times. My third, and present, try uses helper methods to set up the data and contrary to the earlier tries it doesn’t look messy any more.
This is inspired by my present gig where the QA guy wrote a simple DSL with fluent syntax to set up test data. I have not managed to replicate his library but am, presently, happy with helper methods.
I don’t think the standard type in Visual studio is the best one just because it is what is shipped.
Instead I test different and from 10+ years I have come to the conclusions:
1) Sans serif is better than serif.
2) Fixed width is not important – it is very seldom I need anything aligned by the count of characters.
3) Proportional width packs more characters per cm without losing readability.
Of all the fonts I have tested I still believe Arial is the best compromise.
When I started out I believed that capital letter O looking similar to digit 0 would be a problem but have come to the conclusion that in reality it is not.
Fonts tested: (I have tested way more but just recently decided to write them down and cannot remember all)
Arial // yes
Arial narrow // too dense to be readable on screen
Comics // did not work for programming – too hard to read
Consolas // nope, too stiff
Courier // serif, does not work, too slow to read
Kalinga // presently testing
Leelawade UI // works alright
I have the host OSX for administrative tasks
and then one VM per Windows OS.
I would prefer to have one VM per customer but have not come around to it.
Setting up a new VM does not take that much time but installing Visual studio, Sqlserver, Chocolatey and configuring everything does. When Windows updates 7->8->8.1->10 I create new machine and copy stuff I need as I go; instead of updating the VM. This is my way of continuously cleaning my work space.
The only issue I have run into is multi monitor support that sometimes is a bit shaky to set up but it has stabilised every time. (as I write this my second monitor switches to green every time my screen saver has kicked in and I have to replug it)
I run Parallels which is not gratis and not even cheap. To add insult to injury they make sure to not support newer OSX and Windows versions as they come out. This means that the one time price (presently upgrade is 50€) has to be paid several times, like every other year or so.
I have not compared Parallels to their competitors Fusion and Virtualbox. AFAIK Fusion is about the same in both functionality and price. Virtualbox is free as in F/OSS.
The reason I started with Parallels instead of Virtualbox is twofold:
1) I was new to the host:OSX/vm:Win arena and wanted something someone said worked. (I did not want to buy a fancy pansy mac just to install windows on it)
2) By that time Virtualbox could not handle bootcamp.
My plan was to test to run Windows as a VM and if it wasn’t performant enough switch to bootcamp. Then I learned that to be able to run the vm as bootcamp it has to be configured as bootcamp to start with. I never did and I have never had the need.
(I would love to try to have the dev machine totally remote. Then I could have a phat machine without the fan noise.)
Wireless/WLAN/Wifi did not work when I upgraded my Surface Pro Win8 to Win10.
My resolution was to go to the devices and remove a WLAN driver (Marvell Avastar 350N wireless network controller?) and right after that look for hardware changes in the same window. Unfortunately I did not take any screenshots and promptly forgot the accurate data.
Do you solve the problem one step at a time, slowly ever going forward, but without the final goal?
or do you see the goal and work steadily towards it?
Of course you do both but might be biased.
Below is a readworth article about this.
Den hyggligt korta artikeln delar upp teknisk skuld i flera delar: programmeringsskuld
, designskuld, testskuld och kunskapsskuld. Jag tycker det var lite onödigt komplicerat; men samtidigt upplever jag det gav en möjlighet att diskutera. T.ex. vet jag ett projekt som klarar sig bra på allt utom kunskapsskulden. I och med att uppdelningen gav mig möjlighet att prata om, just, kunskapsskulden utan att blanda in all annan teknisk skuld tyckte jag att jag fick fram det jag ville säga.
Sedan undrar jag om man skall räkna in de andra skulderna i teknisk skuld.
Vidare undrar jag om “skuld” är rätt ord eftersom det är något man, förhoppningsvis, kan amortera bort. En teknisk skuld kommer aldrig försvinna för när man kommer närmare målet ökar man bara sin ambitionsnivå.
Apigee has kindly written a book with simple illuminating examples on how to design a REST API.
It is short, concise and has good examples from the Real World like Google, Netflix and Twitter.
There are several ways to see what queries are used by Nhibernate.
If you are doing serious development I recommend Nhprof. It costs some but it is second to none regarding overview and ease of use. One bug caught and it is paid for. The GUI is a bit clicky but does a good job of providing good S/N ratio.
Sniff the traffic. I have not done this seriously but once wrote an ADO sniffer since there wasn’t any profiler for MsAccess.
There there is tracing the RDB. Possibly gratis or even free, depending on database (I haven’t checked them all, only Microsoft’s one). In my experience it is too noisy to have running during the whole development cycle like one can do with Nhprof.
Then one can use Nhibernate itself to log. Check Nhibernate succinctly, chapter 12, for how to setup Nhibernate with Log4net. If you want to log through another framework the same author wrote an article.
If you haven’t decided whether to use Log4Net, EnterpriseLibrary, nLog, home baked or any of the other logging frameworks – wrap it or abstract it.
Common.Logging is an “ordinary compiled lib”. It is strongly named with its pros and cons.
LibLog on the other hand is just a file (like Dapper). When developing a lib for public use this might be good to keep fewer dependencies.
The author of LibLog mentioned some pros for LibLog (vs Common.Logging) here. It uses dynamic and Tuple so it is Dotnet4+.
Simple Logging Façade is a compile lib, like Common.Logging.
I develop programs. I touch type. I use a keyboard extensively.
I don’t take light on keyboards and don’t understand other keyboard jockeys that just use whatever comes with the machine.
I’d love to make my own keyboard.
Here is a the Geekhack forum for DIY and buy.
I have made my own 1337 keyboard layout that mixes the layout of Us-En (good for programming languages), Swedish (my language of birth) and Azerty (switched numbers/characters in top row).
But until then I keep track of existing. Both ergonomic for extensive use and portable for mobile use.
Atreus. DIY or order. Ergonomic. Open source. Looks wireless. Looks awesome for typing and hacking. Me want.
Ergodox. Does still not exist. It’s a hacker project so it will probably be F/OSS.
Keyboardio home page. is open source and ergonomic. A bit ugly but triggers my want-hormones. It also has a wooden surface and and an Arduino to run it all. Kickstarted.
Ultimate hacking keyboard. Split. Crowdsourced.
Waytools Textblade. For mobile use. Blue tooth. Qwerty layout but not totally touch type. From about 100€. Might work.
Id love to get my hands on one to test and review.