New to CLSA, 1st .NET project

New to CLSA, 1st .NET project

Old forum URL: forums.lhotka.net/forums/t/4288.aspx


Warren posted on Monday, February 04, 2008

Hi All,

I am a developer with almost 20 years programming experience getting ready to take my first plunge with a .NET development project. I have done a few VB 6.0 projects in the past but mostly worked with procedural languages, mainframe, SQL Server and Oracle databases etc. For the past 3 weeks I have been breathing .NET, learning about patterns, reviewing code, reading blogs. One of the things I have been doing is watching a set of web casts by Joe Humell. He briefly discusses frameworks and mentions CSLA. I purchased the CLSA 3.0 e-book last night and am starting to read it today. I understand the architecture that Joe Hummel has been discussing, MVC and the need to separate my UI, business and data layers.

My application will be Windows forms, no internet or web service required, 1 or 2 users, SQL server 2005 database with approximately 30 tables, access will be via stored procedures only. We will use VS 2008. The application is a small financial system with 10 - 15 reports identified. I have a very strong understanding of the business and have wrote the technical specifications document but have left out the UML and class design part. I would be satisfied if I could design a solid 2-tier system that separates the 3 components and is easy to maintain. I know I could get away with using the VS IDE and drop and drag controls and quickly get something going but I want to avoid that and do things the right way.

I understand all I have learned in the last few weeks but am a little overwhelmed with the thought of starting the coding process.

Do think it is a good idea for me to use the CLSA framework in this case and if so is starting with the Using CSLA .NET e-book I just purchased a good place to start.

Thanks for your time.

davido replied on Monday, February 04, 2008

Hi Warren,

You may be better starting with the expert business objects book. The CSLA 3.0 ebook is more of an update than a place to start.

The "expert" book descries the framework as targeted for .NET 2.0 the ebook describes the differences in the framework that targets .NET 3.0. the book is also available in VB.NET.

Hope that helps.

http://www.apress.com/book/view/1590596323

david.wendelken replied on Monday, February 04, 2008

Yes, I do think starting with CSLA is a good way to do it.  It worked very nicely for me and for my team.

No, you cannot just use the 3.0 ebook.  It is a SUPPLEMENT to the printed book.  It discusses changes made since the book was published.   (Rocky will have to chime in on whether you need the 2.1 ebook also - I don't remember whether the 3.0 ebook uses 2.0 or 2.1 as its baseline.)

Like you, I had 20+ years of software development experience when I made the switch to .Net and web applications.

There are a bazillion ways to do something and many of the books/articles do NOT demonstrate sound engineering practices.  In fact, many of them demonstrate VERY BAD practices.

CSLA is a well-engineered solution.  It provides a way to build software in a .Net environment that is top-notch.  Is it perfect?  No.  Is it quality work?  Absolutely.

I will caution you on one thing.  The sample project that comes with CSLA demonstrates several different ways to do things.  As you work your way thru them, recognize that portions of their code exist only to show a different way to do things, not the "one true way" to do things.   Data mapping techniques come to mind as an example of this.  I was puzzled sometimes mapping was done one way and sometimes another.  It was just to show two different ways, not a recommendation to use both in the same program!

 

 

Warren replied on Monday, February 04, 2008

Thanks for the quick reply David. I'll order the book today then.  One thing I have noticed so far is CLSA is all about business objects, the proper architecture of which will allow you to build a presentation layer that focuses on the UI and not the data.  Does the CLSA framework also provide suggestions for designing the UI?

Thanks

Warren

 

 

 

 

 

 

 

 

david.wendelken replied on Monday, February 04, 2008

The sample project illustrates several different ways the same business object library could be used by a UI layer.

The business objects also include a number of methods/properties that make it easy for a UI programmer to do their job.

 

 

JoeFallon1 replied on Monday, February 04, 2008

CSLA has some suggestions for how to interact with the UI. It tries very hard to use DataBinding correctly. Rocky is still fixing small DataBinding bugs even after 4 years. The latest comments on how to bind/unbind correctly should be searched for and then printed out and pasted over your work area. It is extremely important to get it right up front.

There is a sample project that shows how to use BOs in a Winforms app. It is by no means perfect or the ideal solution. Its purpose is to show how to fetch a BO and bind it to a form and interact with it.

One other idea - if you could get someone like David or Andy to help you for a week or so your project could be accelerated by months. I don't know if they consult but if time is an issue you will learn tons of stuff way faster using an experienced CSLA consultant than if you try to overcome all the issues which we have done for 4 years.

e.g.

Code generation

Base Classes

Naming conventions

Templates

etc.

Joe

 

davido replied on Tuesday, February 05, 2008

If you do get guidance on

Code generation

Base Classes

Naming conventions

Templates

etc.

I'd love to hear about it too. Thanks

Warren replied on Tuesday, February 05, 2008

It is very inspiring to have people respond to my first post to quickly.

Last night I watch Rocky speak about the framework on DNRTV and this convinced me to go ahead and order the book. 

I am hoping to get up to speed in 2 or 3 weeks, at least enough to start mapping out my objects and building a base form class.

Thanks for the advice everyone.

 

weebee replied on Tuesday, February 05, 2008

Just some thoughts from a first time user as well.

a small project like this is the perfect example in learning a new framework (less risk, less overhead), challenges on technology will be minimized such as Transport layers, UI etc... and you guys could focus more on what is important (Business rules, business objects and proper implementation of design patterns and architecture).

at first glance CSLA is quite daunting and overwhelming specially if you're used to the ".Net" way of things which maximizes XML and other default .Net objects (DataSets, Data Adapters etc...)

CSLA basically just opens up more options on how to implement things with things like code reusability and code maintenance in mind.

 

 

 

Warren replied on Tuesday, February 05, 2008

Thanks for the encouraging words weebee.

I don't need to necesarily take advantage of .Net 3.0 features.  Getting into WPF at this point seems like another hurdle that i don't need.  I'm not  sure what the best version of CSLA to start with. 

Should I start with the latest and greatest non-beta version even if I don't need the all the features?

 

 

 

 

 

david.wendelken replied on Thursday, February 07, 2008

Warren:

I don't need to necesarily take advantage of .Net 3.0 features.  Getting into WPF at this point seems like another hurdle that i don't need. 

I understand that completely!  The same CSLA business objects will work with WPF later.  Finding help with WPF issues you face will be harder than older UI styles.  Plus, the UI "way to do things" is changing every couple of years and there's no reason to believe it won't continue to change until they finally get it right.  Given that it takes 3 to 4 programming languages just to be sure someone entered in a date or number into a textbox (unlike in 1982 when it just took one language to do the entire program!), I see absolutely NO evidence that "how to build the web UI layer" is anywhere near "the right way to do it". :)

Warren:

I'm not  sure what the best version of CSLA to start with.  Should I start with the latest and greatest non-beta version even if I don't need the all the features?

I would. :)

zinovate replied on Wednesday, March 19, 2008

3.0 the WCF support is awesome. 

WPF has allot of growing to do and the tooling sucks.

rsbaker0 replied on Thursday, February 07, 2008

Warren:

...My application will be Windows forms, no internet or web service required, 1 or 2 users, SQL server 2005 database with approximately 30 tables, access will be via stored procedures only. We will use VS 2008. The application is a small financial system with 10 - 15 reports identified. I have a very strong understanding of the business and have wrote the technical specifications document but have left out the UML and class design part. I would be satisfied if I could design a solid 2-tier system that separates the 3 components and is easy to maintain. I know I could get away with using the VS IDE and drop and drag controls and quickly get something going but I want to avoid that and do things the right way....

Yes, CSLA will work for this, but read the first book on Expert Business Objects.

The beauty of CSLA is that, if you follow the program, the same set of business logic can be deployed in as many tiers as you want, and you can go from a  fat-client 2-tier deployment to 3-tier just by changing a configuration file, and you can add a 4th tier later to support a web or internet interface without having to rewrite or duplicate your business logic.

It takes a bit of getting used to. The main thing that gets me is that objects are being cloned all the time, so if you aren't paying attention, you may have a "stale" or orphaned object that appears to be fine in your UI, but exhibits other odd behavior (won't save, isn't current) etc.

Warren replied on Wednesday, February 27, 2008

Howdy folks,

I have just finised chapter 5 of the Business Object book and feel I have a decent understanding of the framework and how it all ties together. Soon it will be time to roll up the sleeves and start coding.

Today I have been thinking about the use of DTOs and specifically do I need to use them in a 2-tier physical environment where my server-side code is actually running in the client process on the workstation.  My application is a Windows Forms app that even if scaled up to a physical 3-tier app would not become web based.  I think the answer is DTO's are not necesary but feedback would be appreciated.

 Also, I am wondering if I just start with a ORM to build classes from my relation database tables.

Thanks in advance.

 

 

 

 

ajj3085 replied on Wednesday, February 27, 2008

Well it depends.  DTOs provide strongly typed access to data, which has some advantages.  Also, if you're going to use Linq (which I'm liking very much), you pretty much need DTOs although you can generate them in VS.

Warren replied on Tuesday, March 18, 2008

I am getting my feet wet with CSLA code for the first time. I have PTracker working with Winforms (PTWIN) local proxy only. Now I am trying to determine the best way to use the CSLA framework for my authentication model.

I would like to use Windows authentication but want the users to login again with their Windows login and password.   I would like to use my database roles for authorization, not Windows groups.

Assuming this is this possible with CSLA, can someone please provide some advice on the cleanest way to get this done?

As a start I know I will have to change the app.config CslaAuthentication setting: <add key="CslaAuthentication" value="Windows" />   which I have done but this disables the login screen.

I am also going to try my hand at Code Generation and CSLAGen but will keep in mind the disadvantages of using CSLA with data centric business objects.

Thanks in advance.

zinovate replied on Wednesday, March 19, 2008

I would finish the whole book before starting. In the later chapters, he locks it all together.

There are allot of "ah ha" moments in the later chapters.

One advantage you have starting with CSLA, you didn't have to go through the Dataset dillusion that most of us have.
You're starting in the right place and I look forward to hearing about your project as it proceeds.

One side note: in your original post, you mentioned that you were only building a 2 tier app. I hate to break it to you but it is only a couple lines in the config file to make the app 3 tier'd using your existing Windows Forms front end. :)
You gotta love it.

On the ORM question: That's a big one and depends on your philosophy. There are some veeeeeeeeeeery long threads in this forum about them.

If your interested in taking an Object based design, as Rocky describes in the book, I would check out the FREE EBook from InfoQ

http://www.infoq.com/news/2006/12/domain-driven-design

It is a 100 page summary of 2 Domain Driven Design books. It is a good way to wrap your head around the concept that your design should be about behaviour and the data will come :)  

That was hard for me. I have always been a data centric thinker and DDD (Domain Driven Design) and object first thinking has been messing up my head, but in a good way.

Code Gen is a must. I would search this forum for CodeSmith, there is a free version out there. There are good CSLA templates in the CSLAContrib project. My Generation is good as well. I personally use Code Complete but it is a little pricey (More than free).

On the UI Side. If your application is going to grow into a more mature product and you want to build plugable modules and incorporate larger teams, I would check out the Smart Client software factory (SCSF) on CodePlex. There is also a very good SCSF book as well. I would expect to set aside 2 weeks to learn SCSF. Once you do, you will never look back. I have a 30 man team that is using SCSF 100%. It has saved us a ton of time.
Microsoft is working on the Next Generation of the SCSF and that should be out later this year according to MS.... so expect it this time next year...  (Ron if your reading this, you know I love the team)

If you have heavy reporting needs, make sure you check out SqlServer Reporting services 2005.

Good luck.

Warren replied on Thursday, March 20, 2008

Thanks for the very helpful post zinovate.

I am continuing to read the later chapters as suggested.

Thanks for the info on the DDD guide. I read half tonight.  I like the concept of using value objects, new concepts.....  I was wondering if a service is similar to a CSLA Command object?

I found a PDF version here:

I will likely use SQL Server reporting services instead of the Crystal Reports API. I remember reading about the benefits of having the reporting objects close to the data - in this case the database server.  

My backgound is 'data centric',  I started with what I know best and created a 3rd normal form data model.  Luckily, I do understand the business domain thoughly enough to create objects and I do understand the concept of modeling the domain vs. data. I just haven't went through the process of object modeling before.

I was just going to attempt to create some EditableBase,  EditableCollection, ReadOnlyList objects with CLSAGen to see what the outout is like.  CSLAGen appears to have CodeSmith templates so I will review them tomorrow.  

I have done some SS sprocs (Add,Upd,Del,Sel) for what I think are my domain objects based on the ones Rocky shows in chapter 6.  I want to get a small protoype up in 3 weeks to demonstrate the UI and a few domain objects. 

I don't think the application will be changed much once implemented and require plugin modules. I will forgo SCSF for this project now but can revisit it for the next project. If this project goes well I will be able to use CSLA for a bigger mission critial system in the summer/fall.

Thanks again for your feedback.

 

 

 

zinovate replied on Thursday, March 20, 2008

I think your on the right path Commands == Services.

I think that the CodeSmith templates include some stored proc templates so that should help as well.

SCSF would be overkill for sure.

Thanks for the link. The book by Jimmy Nilsson, Applying DDD is pretty good and is in C# if your looking for more on the subject. Eric Evans book is the best I have seen on DDD.

rsbaker0 replied on Thursday, March 20, 2008

Warren:
 

 Also, I am wondering if I just start with a ORM to build classes from my relation database tables.

Actually, this is what I did, although I didn't deliberately set out to do this. I had an application up and running using an ORM as a prototype, and then decided to use CSLA.

I then simply wrote a few new general classes that derive from CSLA business object classes, and changed my top-level ORM-generated classes to derive from those.

The application doesn't know about the ORM, just the CSLA classes and the concrete object classes themselves, so I could swap out the ORM for another DAL at some point down the road.

(Aside, there are lots of Linq fans here, but I think this has significant implications for multiple database support if you plan to support anyone other than Microsoft. An ORM like NHibernate or Wilson ORMapper can handle multiple backends easily)

Copyright (c) Marimer LLC