locked
CSLA or Entity Framework first? RRS feed

  • Question

  • I'm learning about architecture and am at the point that I recognize it's value in creating more maintainable and flexible code.  I'm currently reading the VB Business Objects book by Lhotka.  But i'm also interested in learning about the entity framework and some designs that might best suit it, such as MVC which I think uses services. 

    What I like about EF is that a lot of code is auto generated and it has designer support, but I haven't done much with it beyond a very simple example so I dont know how much more has to be generated when I start addressing the business layer. On the other hand, I have not gotten a single CLSA code generator to work for me with MySQL, and I dont like the idea of having to hand code a lot of tedious code.  I've read the CLSA is not a data access component where EF is more of a data access component and the two can actually complement each other.

    I want to learn one first and then learn the other.  So where should I begin?  If I start with entity framework I have the plus of it being built into visual studio 2008 and the code generation working seamlessly; however, it's not really an architecture (?).  I would appreciate your thoughts on this.  Thank you.
    • Edited by c_manboy Wednesday, August 19, 2009 2:22 AM
    Tuesday, August 18, 2009 8:16 PM

All replies

  • Hi,
    I don't think it really matters which you learn first.

    Both framework aim to provide rapid development by taking care of some aspect of the plumbing required in any information-oriented software solution. CSLA promotes the concept of having business objects that can manage their own state, thus releasing the developer from having to think about state management. EF is more targeted to data access tasks. as you mentioned, they can both complement each other, but can also stand on their own.

    One of the main benefits you'll probably have from learning each / either is a better understanding how to achieve state management, communications (e.g. how to move entities between layers) and data access, and to accomplish that it doesn't really matter which one you choose as the first to learn.


    on a slightly different note, i'd also recommend looking into the NHibernate project which, in my opinion, provides a more compelling offering than both CLSA and EF for most enterprise-level projects.

    Good luck! :)

    Fernando Felman
    Solution Architect
    Unique World
    My blog

    If your question was answered, please don't forget to mark it.

    Tuesday, August 18, 2009 11:49 PM
  • As I look at EF, though, it seems pretty easy to dig into it to create an app, assuming I dont worry too much about layering, etc.  That way I can start creating and refactor as I learn how to separate things.  It doesn't appear that CSLA will allow me to quickly start programming with it and learn as I develop.

    When I looked at NHibernate recently I was primarily looking at code generators and since I couldnt get any generator to create any code, I stopped looking.



    Wednesday, August 19, 2009 2:30 AM
  •  
    As I look at EF, though, it seems pretty easy to dig into it to create an app, assuming I dont worry too much about layering, etc.  That way I can start creating and refactor as I learn how to separate things.  It doesn't appear that CSLA will allow me to quickly start programming with it and learn as I develop.
    I think that both has the same "complexity magnitude", but if you feel you'll be better off starting with EF, then that's probably the way to go.


    When I looked at NHibernate recently I was primarily looking at code generators and since I couldnt get any generator to create any code, I stopped looking.
    Ahh, so you're after a code-generation solution? No worries, mate! :)
    David Hayden put quite a considerable effort back in 08 and provides this excellent summary of options available for code generation and O/R mappers: http://davidhayden.com/blog/dave/category/15.aspx?Show=All .

    BTW, if you want to benefit from both NHibernate and the Active Record pattern (used by CSLA), you might find the Castle ActiveRecord project (which is part of the impressive Castle project ) quite interesting. And yes, you can code-generate it by using e.g. Code Smith .


    Fernando Felman
    Solution Architect
    Unique World
    My blog

    If your question was answered, please don't forget to mark it so.

    Wednesday, August 19, 2009 4:29 AM
  • Interesting question.

    You're talking about learning architecture, and then proceeding to discuss technologies?

    For me, the way an architect can differntiate themselves from a developer is that they already are aware of the technologies, and have that higher understanding of design patterns, best practices, and an ability to troubleshoot problems, and resolve them.

    Onto your question, I personally think EF is for lazy coders - it's a sweeping statement, I know, but you can write similar code in a stored procedure, and get the same result.  The downside to EF is technology bleed - You need to use context objects here there and everywhere.  In my mind that isn't acceptible, as it leaves the architecture tightly coupled to an implementation.  Yes, it is possible to abstract the context object away from the other layer, but then EF doesn't work out of the box, and is then actually harder work than it is worth.
    There's another point I have - why would ou ever want to use a technology that does not offer you full control over it?  What if you wanted to performance tune something from the EF?  Not easily done - it's hidden from you because it is easier that way.  It's easier that way because you're lazy.  Designing for lazy coders isn't the way to go in my opinion.

    I haven't really felt the need to get into CSLA, but from what I hear, and the small amount that I have read about it, it offers a lot more flexibility than the EF currently does, at least for applications that need to scale.

    If you're keen on learning both technologies, then it really won't matter which order you go in.  I think I'd read a little on both, and see if after a short amount of time, you still think them appropriate for your endeavours, then you will also have an idea which sounds more interesting to you.  My thought is that to learn architecture, CSLA would be the best one to go for.  For reasons stated above, you really need to know what you'd use any LINQ based technology for, and also the pros and cons of using them.  Ease of use shouldn't be a consideration at all, nor should 'coolness'.  There are plenty of technologies out there that will offer flexibility and performance, scalability and extensibility, which should be more of interest to you as an architect.

    I hope this helps!

    Martin.

    MCSD, MCTS, MCPD. Please mark my post as helpful if you find the information good!
    Sunday, August 23, 2009 9:35 PM
  • Thanks for the feedback.  Part of the problem for me is that I'm no architect.  I've created some simple, very basic applications for the company I work for, and only do it as time allows.  Lucky for me (or not so lucky, depending on your point of view) they have become dependent on some of these apps and I find myself in a pickle when I go back to the source and try to add a new feature or fix a bug they discovered.  Trying to read my code and understand my logic is confusing and scary.

    I am hoping to learn something about creating better code and all my research has led me to this.  I understand why a purist might say that EF is a lazy way to go, but as I see it you usually wont get burned by being familiar with microsoft methods (Is EF an architecture, technology, or design?).  And for a non professional like me, simplicity is good.

    However, I really enjoy creating software and learning better methods for doing so.  For this reason I want to explore some of the professional methods of architecting (designing?) my code and see how far I can go with it.

    I've been reading the CSLA book and it's sort of sinking in.  What I dont like about EF is that it seems to be an easy way to do a 2 tier system, which may be good for most of what I'm doing.  But when I start learning more about asp.net I may want to add a web ui to a couple of apps and I might benefit from a 3 or 5 tier design.  My big problem is that I don't want to get 2/3 of the way thorugh the CSLA book and come up on some challenges that will take a lot of time to learn.
    Saturday, August 29, 2009 5:51 AM
  • Hey Martin.

    If you don't use some ORM then what are you binding to in your code?

    I'm a big fan of stored procedures but not so much of strongly typed datasets.

    Friday, December 3, 2010 9:43 AM
  • It's been a while since I posted this and want to provide an update.  I ended up learning CSLA and found it fairly straightforward, for the most part.  I then moved on to implement the MVVM pattern that Rocky describes and found that, too, to be very good

    Tuesday, May 3, 2011 4:22 AM