Are there any worthy CSLA alternatives available? - c#

My company is interested in porting a large business application to .NET. We plan on developing a desktop version and a silverlight version. I mostly researched the CSLA framework (got rocky's book, halfway through already) and found it a bit over-engineered, the data layer side didn't seem so polished either.
Is there any other frameworks that claim to do what CSLA is doing? I'm not talking about ORM tools (e.g L2S, EF, NHibernate.) I'm interested in a framework that supports business rules, easy n-tier architecture, objects are domain driven and not database driven, security on the business objects etc...
I know I can find small frameworks that will do some of the work required (Enterprise Application Block comes to mind) but I'm looking for one that has everything included.

I would be interested in hearing more about why you think CSLA is over-engineered. I have found it to be very feature rich but most of the features just implement standard .NET framework interfaces and so all the plumbing comes free and you definately have to use it.
Your requirements seem to be a great fit for CSLA. Other frameworks (such as ORMs) contain validation/business rules but the major issue is that you are (in most cases) stuck with your data schema. This leads to objects that are not friendly for UI development and force you to know the intricacies of your database.

Here's a good blog post (archived version) courtesy of "Adam on the Net" discussing and comparing the following:
Castle Project
Spring.NET
Enterprise Library
CSLA

If I were you I would either pick Spring.NET or just start building your own framework around ASP.NET MVC and Fluent NHibernate. Then slowly add your own building blocks as and when you need them. Enterprise library blocks are good but heavy according to me and have lot of things that you may not really need.

Related

In .NET, is a data-centric architectural approach still the default? If not, what has replaced it?

When last involved in .NET, Microsoft advocated an architectural approach where one programmed against a representation of the database in code - datasets, datatables etc. This suited their auto-generated code by tools based approach. They never advocated a rich object domain model as the basis for your architecture.
Has this position changed? Is a rich domain model architectural approach now advocated or supported by Microsoft, especially as a result of introducing Entity Framework, or is a data-centric approach still advocated?
Entity Framework is now the recommended data access solution as opposed to ADO.NET. F# has type providers and allows designing domain specific languages. This embraces information rich programming.
Now .NET Core is moving away from tooling and auto-generated approaches. It is cross-platform, agile and focused on what open source communities doing for years.
To summarize, .NET is now not revolving around database and tools.
Judging by this MSDN "Patterns and Practices" series book from 2012, they have been recommending a rich domain model approach for quite a while.
Not that this is an exclusive recommendation - Microsoft basically moved to a less opinionated, right-tool-for-the-right-job speech about pretty much everything they provide, and the data-centric tools are still there. Regardless, it would be suicidal of them to lag behind everyone else and still recommend a data first, code-generation based only approach these days.
[Edit]
You should note that CQRS and/or Event Sourcing are not exclusive of a rich domain model, quite the opposite. CQRS commands trigger rich domain logic in entities, which then emit (rich) domain events. It's precisely what the book describes. Don't be fooled by the title.

Sharp Architecture alternative

I am looking Sharp Architecture alternative which use Entity Framework code first as ORM. Is there any mature project like Sharp Architecture with EF code first ?
Architecture is a blueprint. Once you see Sharp Architecture you should be able to simply think about it and change it to work with EF. If you are not able to do that you probably don't have enough skills with required APIs - that is th first thing you have to change before start dealing with architecture. No architecture will save you from understanding APIs and without understanding them you cannot do a good architecture correctly using features of your APIs.
Architecture should be driven by needs of your application. The approach where you want to bend needs of your application to fulfill some architecture blueprint is terrible wrong. First you have to define what should your architecture solve for you and after that you can ask if there is any blueprint already doing it (and nothing more).
Most of articles and sample architectures are just pushing a lot of patterns without actual need for them. Number of patterns and layers don't make a good architecture. In most cases it just makes the system overachitected and hard to maintain. These samples are mostly for explaining how to implement some patterns.
Bad news there is no exact replacement, Good news its easy to create something your own like I did.
I have been using S#arp for a long time and it is a good Architecture, I developed lots of applications with it but it looks like there is no more movement with that open source project so late last year I decided to move on an recreate something similar using the same principles but with Entity Framework.
Key components such as NHibernate, NHibernate.Validator and Castle Windsor was replaced to use Entity Framework, LINQ to Entites, System.ComponentModel.DataAnnotations and Autofac respectively. The layers remained the same like the Domain, Presentation, Task, Framework and Infrastructure.
On how I created it please have a look at this post on its detailed explanation.
http://www.macaalay.com/2015/10/20/creating-a-solid-architectural-foundation-from-scratch-is-not-really-that-hard/
I also created a code generator which I called Effinator, which generated CRUD operations and basic UI from your database design

NHibernate (or other worth recommendation ORM), real life example?

I'd like to learn database applications in C# and I'm about to select some framework. I heard many recommendations of NHibernate, however I haven't decided yet.
Anyway, I'd like to know if there's any real-life example (with sources) of NHibernate in C#, to learn best practices etc.? I know all of them are probably covered in the docs, but working example helps a lot understanding the proper development pattern.
Check out Ayende#Rahien, there's a lot of blog entries on NHibernate there. Another good source is NHibernate Forge. To get you started this would be especially helpful: NHibernate Getting Started Guide. Finally here you can find a downloadable working example of a NHibernate project based on the Northwind database.
The open source project S#arp Architecture is so far the best example I'm aware of for NHibernate:
S#arp Architecture
Even if it feels sometimes a little bit overdesigned, it follows best practices in implementing NHibernate in a multi-tier architecture.
I personally learned a lot about ORMs and good loosely coupled architecture going through
the code of the project.
Another worthwhile article about NHibernate can be found on CodeProject:
NHibernate Best Practices
Real life example: Orchard uses NHibernate, Fluent NHibernate and Linq To NHibernate for data access. It is an opensource CMS build by Microsofties. Source code is available at CodePlex.
NHibernate is a very solid ORM which allows you to create POCO classes, keeping your domain model very clean and allowing easier testability.
Entity Framework is improving rapidly. The UI tools in EF4 are okay for small applications but it is difficult to manage that kind of development with version control, rapidly changing DB schema etc. With EF4 Code First approach (in CTP stage at the moment) EF4 will will be much more attractive.
I have used LLBLGen in past with great success.
For beginners, Webmatrix can get you started very quickly. Check Rob Connery's video on how to use it with testing framework here
As others have said, NHibernate is a solid framework to work with. It's quite mature and has a lot of features that let you control exactly what will happen to your date.
That said if you're just starting out with database programming you may also want to consider LinqToSql. It's not nearly as powerful as NHibernate, and it has been more or less EOLed. However, what you give up in power you gain in simplicity. It will allow you to get a basic database application up and running probably within minutes and allow you to experiment as you first learn. Despite the simplicity of getting your first app up and running it's still powerful enough to be used to build something like Stack Overflow.
Some good Linq to Sql beginner resources:
NerdDinner
ScottGu's series: Using LINQ to SQL (link is to part 9 because that has links to 1 through 8 at the top). Although this one doesn't have an application download (best I can tell) it basically walks you through building an app.
If you have your heart set on learning NHibernate, you can also start with the NerdDinner tutorial linked above and take a look at Ayende's writeup on porting it to NHibernate as well as a series on mapping NerdDinner with NHibernate. There's also a series of articles on using NHibernate in a WPF application (most other tutorials focus on web apps).
Resources:
Ayende's Reviewing NerdDinner and Reviewing NerdDinner: The Select N+1 pitfall
NerdDinner with Fluent NHibernate Part 1 - The domain model
NHibernate and WPF (again, links to part 4 that has link to parts 1 - 3).
One thing I can't emphasize enough is once you get past the initial "cool...I can talk to the DB" phase, grab a trial license for an appropriate profiler (list of profilers at the top) for your platform. It will let you see what exactly your ORM is sending to the DB. It can be very valuable for learning how what you're doing gets translated into SQL as well as troubleshooting bugs you run into.
Regardless of which path you choose you should also take a look at Data Access Practices Using Microsoft .Net: A Nerdly Comparison and Data Development GPS: Guidance for Choosing the Right Data Access Technology for Your Application Today. Although those only cover Microsoft technologies, it'll give you a high level overview of what's available out there and when it may and may not be appropriate for your projects (in the future).
Take a look at NHibernate addins project http://code.google.com/p/unhaddins/
Though this is not real life production example, the sample applications there are pretty close to real life applications | scenarios. The examples there are written by well known and respected programmers and they show some serious OOP and design patterns skills. This is definitely not for beginners.

Composite Application Block - Is there a suitable replacement available?

I have two very large WinForm applications built on the now dead Composite Application Block ("CAB") from Microsoft Patterns & Practices. I was an earlier adopter and jumped in first to embrace and use CAB. Well, now that it's truly dead I'm starting to think more and more about the future and what framework I can migrate to.
What I like about CAB:
* Structure, structure, structure - I lose focus easily and tend to suffer from "analysis paralysis". CAB introduces a "way to do things" and that keeps me on track and developing the application instead of worrying "how to wire up events, or what the best IoC is, etc.
* Actually... I think that's about all that I really like about CAB ;0)
I have seen articles about "build your own CAB" but I'm not interested in that. I'd really like to jump ship to a similar framework that is solid and actively supported. My web searches have not turned up anything that seems to serve the same needs as the CAB did. Maybe it's that everyone DOES build their own and that's why there isn't another framework out there.
If you have some guidance or advice I'd really like to hear it.
You can check out the
Smart Client Software Factory
OR the
Web Client Software Factory
I am not sure about specific features / patterns that are targeted by especially the SCSF v/s the CAB but i have been using WCSF for a while now and it definitely provides the structure that you like about CAB.
I believe these two do constitute the prescribed guidance from P&P and are definitely being updated.
I would suggest you porting your app into WPF - PRISM. I wish they had a PRISM way for Winforms too, but sadly they dont. We had two of our last enterprise level applications migrated using SCSF, now we have switched over to PRISM for the obvious reason. It does include initial learning curve, i knew wat WPF was and had my Helloworld app done with few extras. but now since we had to switch to PRISM WPF, i am having the steep learning on both! Good luck!

Provider model in .net

When the .net 2.0 framework first came out, the provider model was all the rage. 2.0 even shipped with a bunch of default providers (Membership, sitemap, role). Since the release of 2.0, the hype has died down, and whilst I still use providers day to day, it seems to get far less press.
I was wondering if this is because people are using something other than providers and they've been superseded, or is it simply because the take up wasn't as big as other IoC methods?
It actually hasn't died down. DI is still big. There are many DI frameworks out there to choose from. Yes, it's not hard-baked into every part framework like it should absolutely be, but its still a very good practice to follow. For instance, I was using the P&P's custom application blocks to do DI. Until they ditched it for Unity. Now I'm using unity.
A lightweight DI framework is a good idea for any large extensible application.
I think that as these tools become more standard within .NET the hype around them becomes less, but their use does not. Certainly the Membership and role providers are very important to our new application that we are developing and will save us significant amounts of code.
Microsoft Patterns and Practices is the birthplace of tools like the Enterprise Library, which is heavily involved with the provider patterns (particularly with membership) in regards to the Security Applicaiton block and the model appears to be used throughout the blocks.

Categories

Resources