Friday, December 26, 2008

Holiday reading update

I just had a look at the .NET Stock Trader sample application. Wow, it included some great features such as virtualization of service endpoints, a configuration management system etc. This stuff should considered when I develop my next distributed system.

On another note I have really started digging IoC containers like Castle Windsor. And LINQ to XML. The Entity Framework I am not too excited about and what I've heard about Oslo sounds like something from the MDA era and the reason why it failed.

For ORM-mapping I think my options today are (depending on project and complexity...):

NHibernate
.netTiers
d00dads

Rhino Mocks looks like a great tool too I think I will use it soon.

Monday, December 15, 2008

Powerful methods to consider in every project

IoC
Code Generation
AOP
Generics
GOF Design Patterns

Friday, December 12, 2008

Some nice technologies

i have come across lately

Balsamiq mockups. Awesome tool to create GUI mockups.

T4 code generator. Built into Visual Studio as of VS 2008

Naked objects. Generate GUI from database.

Tuesday, December 09, 2008

Null coalescing operator in C# 2.0 for ASP.NET ViewState property access

instead of

public bool Enabled
{
get
{
if(ViewState["Enabled"] == null)
return false;

return (bool)ViewState["Enabled"];
}
}

we can now write:

public bool Enabled
{
get
{
return (bool)(ViewState["Enabled"] ?? false);
}
}

Cool! But if we are dealing with a complex type i prefer defensive casting, using something like:

public ComplexObject Complex
{
get
{
return ViewState["Complex"] as ComplexObject;
}
}

Stepping it up with power tools

I bought a book called Windows Developer Power Tools and started looking for tools
to apply in a specific project. For this project I came up with the following:

Enterprise Library Block. To apply best practises within loggin etc.

NUnit 2.4.8. To have an automated test suite for some basic behavious such as object CRUD.

MyGeneration and custom templates. For generating manager classes among other things. ORM-code can be generated with dOOdads templates.

Caste Windsor Container. To promote reusability and get rockin things such as swappable business rules using Inversion of Control.

NDoc. To create professionally looking documetation.

CoolCommands. To improve developer productivity in VS.

VSFileFinder. To find files fast inside VS.

FxCop. To write code that uses best practises.

SourceMonitor. To manage code complexity.

NDepend. Find dependencies in your application that can be improved.

NTime. To verify that performance is acceptable for critical parts of the application.

NProf. To find out in which method time is spent.

Reclector.NET. To look into assemblies when documentation sucks.

Dotfuscator. To prevent reverse engineering of code.

Fiddler. To examinate HTTP traffic.

WSCF. To create contract based web services. Don't deal with the stuff VS produces out of the box.

Subversion. Source control.

AnhkSvn. Subversion in VS.

TortoiseSvn. Subversion in explorer.

Other tool not mentioned that I use:

YSlow. To find out how websites can be optimized.

XP IIS admin. To create multiple IIS websites in XP.

SelfSSL. To generate certs on localhost.


Now if I could just get my hands on a suitable AOP framework...

Saturday, December 06, 2008

Improving ASP.NET code

I have an ASP.NET application that suffers from some problems.

We have a page that dynamically loads a lot of different components, and these components needs to access per-request properties of the application, such as user id, product name etc. Today this can be done something like:

string stateValueToGet = string.Empty;

// Coding horror..
// Component a is where stateValueToGet is parsed.
ComponentA compA = this.Parent.Parent as ComponetA;

if(compA != null)
{
stateValueToGet = compA.GetStateValue();
}

// do something with stateValueToGet ...

To begin with this is not good design to have components be dependent on each other like that. If the component should have a dependency it should probably only be to the page.

But alternative way to store these kind of per request values that need to be accessed in many different places during a page request is to use the HttpContext.Items property that allows you to store data as name-value pairs. However we should not access values directly from the Items collection but instead use proper C# helper classes or properties in the page class for that in order to hide validation, formatting etc.

One drawback with this solution is that dependencies among components will not be as clear but we should strive to minimize those anyway.

How to manage per-requst properties should be a core concern of the architecture.

In addition we need to handle session properties if those are used. Since session properties are used in a lot of different places these should be accessed using C# classes rather than properties in pages. An alternative way is to place these is a MasterPage or BasePage but i don't like that idea due to the fact that using this kind of inheritance can restrict reuse of components.

Sunday, November 02, 2008

Idéer

Jag har idag formulerat en målsättning att jag innan jag inom några år ska ha möjlighet att kunna bedriva verksamhet vart som helst i världen med hjälp av laptop och internet. Målet ska inte vara en enkel livsstil som kännetecknas av överflöd av allt som gör livet värt att leva. Behöver inte vara så motsägelsefullt som det låter vågar jag påstå.

Realistiska sätt att nå detta mål kan vara:

• Att jobba med programmering och IT på konsultbasis.

• Investeringar i aktier, värdepapper.

• Hjälpa företagare med råd vad gäller ekonomiska affärer och skatteplanering.

• Skapa internetsidor som generar annonsintäkter som överstiger driftskostnad.

• Ta del av passiva inkomster (räntor, utdelningar, uthyrning av stugan etc.).

Möjliga sätt att nå detta mål skulle kunna vara:

• Trading i aktier och värdepapper (här är det inte bevisat och inte heller statistiskt roligt att jag går plus).

• Spela poker (här är det inte bevisat och inte heller statistiskt roligt att jag går plus). Möjligen kan man tänka sig att jag kan spela in en låg summa pengar per timme med nuvarande kunskaper.

Fördelar med denna livsstil skulle kunna vara:

• Ta del av intryck och erfarenheter från runt om i världen för att utveckla mig som person och entreprenör.

• Bedriva verksamhet från utvecklande ekonomier samtidigt som intäkter generas från mogna ekonomier, vilket teoretiskt möjliggör högre marginaler.

• Slippa binda förmögenhet i fast egendom vilket möjliggör att kunna utnyttja de osunda svängningar som uppstår på de finansiella marknaderna.

Ett exempel på budget.

Jag utgår från att jag skulle klara mig på 12 000 netto per månad utomlands.

För passiva inkomster, säg att uthyrning borde kunna ge en vinst på 1000 SEK efter skatt per månad. Säg sedan att vi har en KF med aktier som kan avkasta 4% om året efter skatt i utdelning. Säg att den delen står för 2000 SEK månad, då är aktierna värde på 450 000.

Då är 9000 kvar att ta in. Detta bör inte vara några problem då det med en timlön på säg låga 300 innebär endast 60 debiterbara timmar per månad.

Ex. på platser att kunna jobba ifrån:

- Berlin.
- Thailand.
- Malaysia.
- Brasilien.
- Argentina.
- Stugan.

Sunday, October 26, 2008

Ny giv

Jag ska lämna fiaskot som stockpickingen resulterat i, på sikt avveckla hålen jag hamnat i och övergå till att placera i indexfonder, och då primärt OMX30. Jag hoppas kunna uppta denna någon gång i framtiden när jag byggt en mer stryktålig portfölj med stabil tillväxt.

Runt nyår borde jag då kunna ha runt 400 att placera. Det är XACTS fonder som jag kommer satsa på primärt, kanske i en KF.

För timingen då pengarna ska in så använder jag två bra indikatorer, dels http://teknisk-analys.blogspot.com samt farsan. Troligen måste företagens vinster bottna innan det är dags. Pengarna ska stötas in i omgångar. Vid tendens till eventuell rekyl kan jag tänka på att placera 100 mer kortsiktigt om indikatorerna är positiva till detta.

Thursday, August 07, 2008

Subversion

Notes about Subversion:

http://subversion.tigris.org/

link where to download Windows version:

http://www.collab.net/downloads/subversion/

Subversion client

Ankhsvn - open source plugin for visual studio.

Getting started

http://ankhsvn.open.collab.net/servlets/ProjectProcess?pageID=3794

Free book:

http://svnbook.red-bean.com

Notes:

A typical repository often holds the files for several projects.

To checkout repository subbtree using the command line:

svn checkout http://svn.example.com/repos/repository_subtree_name

There are numerous client tools, some important are svnlook and synadmin.

See the quick start guide on page 346.
See page 137 i pdf version of book for information on how to create

Among the server options svnserve is the on to look for.

The easiest way is to run the server process as a Windows Service, see page 168.

Sunday, August 03, 2008

"Varje gång jag träffar honom så ligger hans framtid i nuet"

Friday, August 01, 2008

Spring.NET

I decided that that the new Policy Injection Block probably is not for me so I'll be checking out Spring.NET since
I need to take my coding and architecting to the next level using AOP.

I am also going to do something I should have done ages ago, order (and read) a copy of Code Complete. I am aware of
much of the content in the book but still I want to really dig in on it and reflect.

Next week will be my first as Independent Consultant so I am very exciteed!

Friday, May 09, 2008

BizTalk Orchestration and the #error "Errors exist for one or more children."

Sometimes when you work with an orchestration you get #error "Errors exist for one or more children." as the only error. I managed to get this when I had a loop. Looking in the odx file manually I was able to determine which loop and branch of decide the error was in. Then I could see that one of my shapes had the error flag in the designer. It turned out that it was this line of code in an expression shape that did the error:

transform (DeliveryMessage) = tMap(InboundMessage);

Notice the blank space after transform. That's what did it. However, some strange stuff is:

1. I copied the orchestration from another project where this code worked.
2. Once i had compiled the orchestration i added the white space once again and now it worked.

Ok, I am not too impressed with the Orch Designer.

Friday, May 02, 2008

Visdom

Har kommit på en sak vad gäller aktier. Tidigare har jag mest kollat på undervärderade företag som gör bra vinster. Men detta bör vara hitta undervärderade företag som gör bra vinster och vars aktie uppvisar stark trend.

Tuesday, April 29, 2008

Design Patterns – Template method

The idea is to design a method in a superclass that defines the skeleton of an algorithm. Implementation of varying steps in the algorithm is deferred to a subclass. The superclass can implement a default.

An example would be to create a mechanism for caching objects. The logic for how to cache objects remains the same so we create a template method for it. However, the means for how to get the object from storage differs so it is left to the subclass to implement. The logic is something like:

if (IsObjectInCache(anObjectKey))
{
return GetObjectFromCache(anObjectKey);
}
else
{
Object anObject = GetObjectFromStorage(anObjectKey);
SaveObjectInCache(anObjectKey, anObject);
}


The SaveObjectInCache is then overridden in the subclass.

However, for this example this pattern might not be ideal for this situation. Since caching is normally an application wide concern it might be better solved using an AOP technique or somehow implementing it more loosely using in combination with the Decorator pattern.

Another possible approach would be this: Have all business entities implement a single interface that takes their key (in form a Dictionary object created automatically by using reflection) and loads the object representation. Then have a CacheManager implementing the method skeleton.

So remember that the drivers behind this pattern can be created using some other technique than subclassing.

Monday, April 21, 2008

BízTalk ESB and other fun stuff

I am planning to play around some with the following technologies:

Enterprise library Policy Injection Block. I'll check this one out to see if it in conjunction with the other blocks can solve some of the mundane plumbing I regularly perform. Example of things I would like to have declarative / configuration support for is:

1. Validate parameters.
2. Log parameter values in cause of exception in methods.
3 Log execution time in methods.

I need to check what kind of constraints this puts on my classes. Ideally it should work with PONOs and static methods and be as transparent as possible. I am not convinced that this is the case from what I have read but I just implemented an automatic logging of parameter calls including parameter values and it was pretty cool.

ASP.NET MVC. I need to pick up this one really bad. It is a real pain to implement complex flows in e-commerce apps for instance using regular ASP.NET controls if you just code . This is because of the Post Back model I think.

Micosoft ESB. Using this one in a project and I am in need to adapt some of the code to support the setting of an itinerary programmatically from the BRE for instance inside an orchestration. The problem is that we cannot / do not want to set the itinerary information in the SOAP / WCF header since the message is coming in as file to be picked up by the FILE Adapter. Instead we’ll create an orchestration that subscribes to the message once it is in the message box and sets the itinerary programmatically.

There is lots of cool stuff in this package although you find many of the possibilities it opens up and where to apply them quite confusing. I mean, BTS offered a few options in different areas already before this one. For instance should I use a custom orchestration or itineraries if am doing basic processing? If I am using itineraries in combination with receiving messages from an external system how should the itinerary header be set? If it could be set by an ESB Resolver in the pipeline that would be great I think.

It is really cool that the Patterns & Practices distributes the source for the ESB. I like where Microsoft is going with .NET and I don’t think about switching focus to Java anytime soon although I would love to play with stuff like the upcoming EJB (finally starting to deliver huh?) or ServiceMix.

On another note I need to structure my .NET resources and find more community sites that I feel as passionate for as for the outstanding Java site theserverside.com. Currently I usually check out the following:

theserverside.net
codeplex.
BizTalk blogs from Loesgen and others every now and then. I really like the vivid BizTalk community.
NET Rocks podcasts. I usually listen to this stuff when my eyes are tired from coding but my brain still has some to give J
The Architecture Journal.
BizTalk HotRod.
Microsoft Pattern & Practises.

I would also like to check out the new Microsoft stuff around ORM but it can wait some I guess since I am really happy using NetTiers at the moment. Too little time, too much fun J

Thursday, April 17, 2008

Kortspec

Köpte KappAhl för några dagar sedan på 50.25 och sålde av på 51.5. Skulle behållt längre, men aktien var kanske inte så stark som jag förväntade mig. Gjorde dock liten vinst på 550 SEK före skatt.

Sunday, April 13, 2008

Uppdatering

Eniro visar hyfsad styrka trots relativt svag börs vilket bådar gott för framtiden. Håller annars ett öga på Ericsson ned mot 11 kronor. Andra kandidater är KappAhl, PA Resources och RnB.

Wednesday, April 02, 2008

Uppdatering på aktiefronten

Sålde av 4000 Ericsson med liten vinst i förhoppning om att köpa tillbaka billigare senare. Hade snitt på 12.01 och fick 12.22.

Ligger nu med 1000 ENIRO som borde kunna utvecklas fint inför utdelningen förutsatt att börsen int är allt för skakig.

Monday, March 24, 2008

Analys

Tittar på kandidater till nya köp. Tanken är att investera i ytteligare två bolag när tiden är mogen. Ett troligt scenario är att börstrenden kommer driva ned dessa ytterligare.

SAS. Surdegen har tagit otroligt mycket stryk med rekordlågt P/S-tal runt 0.15 och projicerat P/E-tal på 8. Har nyligen brutit stöd på 50 kronor. Det finns inget skäl att rusa in i aktien då den inte ger utdelning. Aktien är knepig då bolaget är politiskt och ej aktieägarvänligt. Dessutom måste stora investeringar i flygplan göras och oljepriset är en negativ faktor. Dock finns det så oerhört mycket negativt diskonterat i denna aktie så det bör finnas en stor uppsida.

Rekommendation: Avvakta och se om kanonläge uppstår. Långsiktigt köpvärd under 47 kronor, straffspark ned mot 40 kronor.

PA Resources. Stora förväntade kassaflöden de närmaste åren vilket ger mycket stor potential i aktien. Trots förväntad stor tillväxt kommande år är projicerad P/E idag endast 6. Produktionsrapporterna från senaste tiden ser inte så bra ut och beror på det höga beroendet till ett enda oljefält. Aktien i fallande trend efter att ha varit uppe i 50 kronor. Är högintressant vid kurs ned mot 40 kronor. Ger ingen utdelning så det är inte bråttom in i aktien.

Rekommendation: Avvakta och se om kanonläge uppstår. Långsiktigt köpvärd under 42 kronor, straffspark ned mot 35 kronor.

KappAhl. Hög direktavkastning och låg P/E men en del belåning om än inte så farligt.

RnB. P/E på 10 plus starkt eget kapital och bra avkastning ger intresse.

Andra kandidater som kan vara intressanta är Kungsleden och Volvo.

Wednesday, March 19, 2008

Buckle up... vilket fiasko

Mina innehav har utvecklats otroligt svagt. Fastän jag har legat utan aktier i 8 dagar av 10 under 2008 så är jag lika mycket back som index, måste vara nåt slags rekord. Både ERIC och ENRO underperformar mot index varje dag, om index faller är fallet typ det dubbla och vid återhämtningar fås endast hälften av index tillbaks. Jag får antagligen se dessa som lågsiktiga innehav då det lär vara kört att få inhämtning under 2008 och kanske även under 2009.

Min entré i aktie-businessen kunde börjat bättre, men det är bara att ta nya tag.