Blog Stats
  • Posts - 99
  • Articles - 5
  • Comments - 236
  • Trackbacks - 105

 

Repository vs ActiveRecord

Warning this post is not well formulated but has some useful random information :)

There has been alot of talk lately about people refactorring from the repository pattern to the Active Record pattern. For instance Sam Gentile brings it up here

How prevalent is this movement? I personally prefer the repository pattern over ActiveRecord for quite a few reasons.

  1.  My db objects and domain objects rarely match up.
  2.  I often use polymorphism on my repositories (especially for testing).
  3.  I can write a generic repository (reusing code for general methods such as Delete or FetchByQuery)
  4.  I can allow repository injection by the domain host.
  5. A Repository shows explicitly a decision to make the object an aggregate root 
  6. I use alot of AOP and its nice being able to place aspects on my repositories, this could not be done with active record's static methods
  7. ActiveRecord seems to defeat the entire concept of DDD, ActiveRecord promotes a database centric model

skeleton example of generic repository

public class Repository {
    public virtual List FetchByQuery(QueryObject _Query) {
    }
    public virtual void Save(T _Object) {
    }
    public virtual void Delete(T _Object) {
    }
}

I guess the big question in choosing which way to go is whether or not your object creations varies for a given object. If you only ever have a single repository then perhaps you are probably better off with the static accessors. Personally I prefer the seperation (and the code saving).


Unit Testing

The very concept of a repository is that it gives the impression of an in memory database. This works perfectly for unit testing as I can just use a repository that actually holds all of its data in memory for testing purposes! I can in fact even make a generic based one that can operate on my query objects using reflections.

also .. some interesting links I happenned accross:

http://www.xprogramming.com/xpmag/jatSustainablePace.htm 
http://www.joelonsoftware.com/items/2006/04/11.html
http://media.spikedhumor.com//805/zoomquilt.swf very dali'esque

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# sharegyan:-share market tips

Gravatar Hi,

Your blog is nice and informative. We would like to share few information’s with users.
At this point of time Indian Stock Market
is looking bullish in short term still its in bearish mood in medium term. Nifty good till 4700 and
this target will be achieved very soon. We can see some profit booking from these levels. Nifty major support is 3650 and major resistance is 5200 in months ahead.
Investors should grab fundamentally strong shares at every fall. There are lot many shares available at throw away prices at this point of time.



For any doubt please feel free to ask us.


Thanks

Regards

SHARETIPSINFO TEAM


8/26/2008 1:39 AM | sharegyan.gyan

# re: Repository vs ActiveRecord

Gravatar I have just checked this blog and I have found this to be very informative and useful. This blog must be very helpful to its visitors.

Stock market is a volatile market. Where people invest with the intention of making money but many traders and investors end up as a looser. Must be wondering what makes one trader a winner in the stock market and another one as a looser in the market.

In Indian stock market many people have many doubts but they don’t want to clear them by consulting professionals nor they want to raise there questions where other traders and investors can help them out. But now many portals are coming up with QNA sections where investors and traders can exchange there views about stock and stock market. Indeed it’s a great help for everyone who are related to stock market.

Stock Trading India 7/17/2009 6:38 AM | India Stock Tips

# re: Repository vs ActiveRecord

Gravatar Excellent post and wonderful blog, I really like this type of interesting articles keep it up.

Stock market of India is volatile and all those who speculate in market are loosing everyday. Please remember stock market is not for speculation purpose. If one feel investing in stock market is gamble then its better to think again.

One should always note that if they want to invest money they should do proper research be it fundamental research or technical research. Just think how come you can invest
your money without any convincing reason for the same?



Thanks! For sharing …….


Option Tips

9/21/2010 3:56 AM | Option Tips

# re: Repository vs ActiveRecord

Gravatar I think the big advantage of the repository, is its inherent testability. The unit test are easy to write when you use a repository interface with dependency injection. It's inherent goodness, does not however translate into popularity. In a googlefight, Active Record beats Repository hands down. Clearly the battle for testable architecture has not yet been won. 10/26/2010 5:59 AM | Free Mcx Tips Trial

# re: Repository vs ActiveRecord

Gravatar Why don't you delete the robospam comments? 11/10/2010 2:21 AM | Mikael

# NSE and BSE tips – Sharetipsinfo

Gravatar Hi,
Seems like it’s a nice blog. So let us also add something useful in it. Trading in volatile market can be very fruitful also if we follow technical levels closely. It’s a common saying that stock market can change fortune in either way. But now the question is how to earn money from the Indian stock market.

Traders are advised to strictly follow technical analyses and investors can follow fundamental analysis. Many analysts say it’s not wise to follow technical and fundamental analysis together. But we say what the problem is if one does so? As more knowledge will add up things will not have any negative impact.

Regards
. Sharetipsinfo Team





12/4/2010 1:09 AM | sharetipsinfo

# re: Repository vs ActiveRecord

Gravatar Highly accurate stock market tips covering NSE and BSE by sms and yahoo messenger.
12/6/2010 9:33 PM | sharetipsinfo

# Hello

Gravatar Hi thank you for an perceptive post, I actually found your blog by searching on Goole for something else nearly related, in any case before i ramble on too much i would just like to state how much I enjoyed your post, I have bookmarked your site and also taken your RSS feed, Once Again thank you very much for the blog post keep up the good work. 12/13/2010 2:24 AM | Sureshot Tips

# re: Repository vs ActiveRecord

Gravatar Hi , Very good information you are providing at here . Thanks for your knowledege , it vreally helps me a lot.
Regards
Anjali 12/18/2010 5:05 AM | forex

# re: Repository vs ActiveRecord

Gravatar Hey,
Nice and useful blog. It’s a fact that in India NSE and BSE are most popular and very volatile stock exchanges with many listed shares in it. Again its true no matter how volatile Share market is still investors can mint good profit.

Now the question is how one can earn money via share market trading?

Answer to this is quite simple. We all know share market have many listed stocks and it’s a fact that everyday we have top gainers and top losers in stock market. If our stock timing and stock selection is right we can earn decent profit from stock market.


So again new question is How to select and time stocks?


No matter how good trader or investor you are still one has to rely on market research. Only technical and fundamental research helps, speculation is not worth and no one can earn regular profit by speculations.



Regards
SHARETIPSINFO TEAM

12/28/2010 1:29 AM | sharetipsinfo

# re: Repository vs ActiveRecord

Gravatar This blog is quite nice and informative, it is a pleasure to post a comment on this useful blog. Really E-learning Stock Market Tutorial

stretches our education budget further with more training for the same time and effort.
Want to know more about unit testing.
1/6/2011 12:41 AM | globalfinanceschool

# Bse and Nse tips – Buzzingstreet

Gravatar Nice post. Its always better to think before investing money in stock market. Investment should be done in share market but with the aim to increase our funds so speculation should not be the mode of investment. Investors should know why they are investing money in any stock.
Regards
2/18/2011 12:39 AM | buzzingstreet

# re: Repository vs ActiveRecord

Gravatar Please delete the comment spam (including this post)!

Thanks,

Art
3/8/2011 12:50 PM | Art

# re: Repository vs ActiveRecord

Gravatar Stock market India is volatile and all those who speculate in market are loosing everyday. Please remember stock market is not for speculation purpose. If one feel investing in stock market is gamble then its better to think again.

One should always note that if they want to invest money they should do proper research be it fundamental research or technical research. Just think how come you can invest
your money without any convincing reason for the same?

Indian stock market is one of the most happening and emerging market. Major Indian stock exchanges are BSE and NSE and both are of world class standards.

So grab good stocks and invest that’s the bottom line.

We hope to see you in major profits.

Regards

Stock Tips
4/19/2011 9:03 PM | stock tips

# re: Repository vs ActiveRecord

Gravatar I appreciate your post. I also wrote that SMS advertising provides a cost effective method of targeting promotions to specific customer profiles. You might want to remind customers of specific events or promotions, but for whatever reasons, SMS allows you to pass information directly to the right customer at very affordable prices and fast delivery.
Stock Tips
5/3/2011 7:12 AM | stock tips

# Nifty Intraday Calls

Gravatar Thanks so much for this! I haven't been this moved by a blog for a long time! You’ve got it, whatever that means in blogging. Anyway, You are definitely someone that has something to say that people need to hear. Keep up the good work. Keep on inspiring the people!
regards:
http://sonictrades.com/intraday-stock-tips/ 6/20/2011 5:27 AM | commodityfever

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

 

 

Copyright © Greg Young