I was reading the book "Expert C# 2005 Business Objects".
The book describes various base classes to be inherited by various classes to solve real-world problems.
But the book does not provide examples of all those classes.
Can anyone give me all of those examples (with reason) to better understand CSLA?
For example, Which real-world objects are to be considered as Read-only Root Objects (Student/Product/Order, etc.)? And Why?
The ProjectTracker sample (which can be downloaded on the CSLA downloads page) has examples of all the main sterotypes used in the CSLA books.
Chapter 6 in the book (Object Orientated Application Design) gives an overview of the design process of business objects & Chapter 8 (Business Object Implementation) gives the actual implementation of the Project Tracker objects.
In terms of your specific query - I haven't often used "Read-only root" objects. However, I often use "Read-only list root" objects though. An example would be: I have a list called ProductInfoList, which has a read-only child ProductInfo. This would be returned to the user either in a ListBox, or from a search result, etc.
Hope this helps!
I would also recommend checking out our CSLA 3.8 templates. I had this same dilemma when I was learning CSLA. He does provide sample snippets of what each BO Type should look like but I don't find this very helpful to visualize. You could take a look at our templates and run the quick start against one of your databases that you are familiar with and modify the different BO Types per table to get a better understanding of how CSLA works.
Here you can find what you need:
http://www.lhotka.net/cslanet/download.aspx (see Framework, test, samples)
But before that take a look at this article:
The CSLA Framework; what is in it for me?
Related
I don't understand why in Object Oriented development people are using some ObjectMapper class. Could you explain me what is the purpose of this kind of class? I'm also looking for documentation about it. I found a lot of information explaining how to create it but nothing about how and why to use it. Do you know where I can find a good article, blog on this (in C# if possible).
A sub-question to be sure to understand. Are ObjectMapper something used in C++?
Thank you.
Object to Object mapping is not a programming language related question.
There are plenty of useful scenarios when Object to Object mapping comes in handy.
One common scenario is when you have designed your business object model and developed your business services that deal with those objects, within your domain application layer. Now, what if you want to expose your data to any UI and/or clients? You obviously do not want to expose business objects. Here comes the mapping! You might transform your business objects to DTO’s if you’re dealing with web services. You might transform them to ViewModels if the consuming UI is an MVC application…
Hope this helps!
ObjectMapper
This mapper (or, data binder, or codec) provides functionality for converting between Java objects (instances of JDK provided core classes, beans), and matching JSON constructs. It will use instances of JsonParser and JsonGenerator for implementing actual reading/writing of JSON.
As far as I know, the ObjectMapper class is not related to C++. Indeed, it is something related to Java. Hope it helps. In either case, you can refer to below link for your knowledge,
http://www.massapi.com/class/ob/ObjectMapper.html
As #Hiren Pandya points out, ObjectMapper is a java class that helps in the serialization and deserialization of java objects to and from json.
In general, this is helpful when you have matching json properties (and structure) and you don't want to write all of that mapping code yourself.
Object mappers as a pattern (even more general) can be useful in many scenarios. Anytime you have two representations (classes) that are logically part of the same concept, you may want to copy data from one to the other.
I hope this helps, however, as I write it sounds pretty general. Maybe if you give a specific case where you feel it might be needed it would be easier to address.
I am looking at the DDD Sample for .net provided by DDD sample at Codeplex and trying to understand how the various layers work with DDD.
With the sample, I can see when a new Cargo is created the aggregate root Cargo is stored via the repository in the BookingService.BookNewCargo() call. However, when I assign a new route or change a destination (AssignCargoToRoute() or ChangeDestination() calls in BookingService) I expected a CargoRepository.Store() to be called as well.
Code sample using Nhibernate which I have not used before.
What am I missing?
In other words, how is the aggregate getting persisted if Store() is not called?
JD
hm, i've seen a number of switch statements in the domain, seems like there are a few core terms missing in the domain. at first glance a number of areas seem to have quite a bit of ceremony, but hey, it's just a first impression.
udi dahan's domain events pattern has been used here, there is an event handler "cargo has been assigned to route" which seems to store the object in question. watch out for usages of the domainevents class in combination with the proper event class, i hope that will tell you what triggers the store.
Here is a sample application I wrote:
http://clientdatasystem.codeplex.com/SourceControl/list/changesets
And here is my accompanying blog:
http://lucidcoding.blogspot.com/2011/10/enterprise-software-architecture-how-to.html
As you may note in my blog, I don't describe it as DDD, but as following the Domain Model pattern. It is simpler than the Cargo application, and may suit your needs better. I follow the pattern of create and save, and also update and and save that you were expecting. I'm not saying my sample is better than Eric Evans's (I wouldn't dare!) but the Cargo Application is not completely a basic, stripped down version.
In my asp.net mvc 2 application I have the following specifications:
I have to make a POS system that extensively use JQuery (so I'm not interested in patterns in this part) and generate sales and sales reports classified in periods of time so in my model.
Also I need to generate orders to products providers.
I have entities such as sales, products, sales reports, purchase orders and products providers.
I will use Entity Framework, linq2Sql, automapper and viewmodels to pass information to aspx pages.
My problem with patterns is that I understand the examples over the internet but I hardly can imagine applying to my model.
Do you think in any common pattern which can be applied to this scenario? Maybe some "similar" example using any pattern?
On the other hand, is it a good practice to write the linq2sql sentences within the models classes?
For example, is it right to do the following to get the list of sales within Models/Sales.cs ?
public List<Sales> GetSales(DateTime Date1, DateTime Date2){
var sales = from item in data.Sales
where ((item.Date> Date1) && (item.Date< Date2)) &
select item;
//Rest of code
.......
}
Thanks in advance!
My problem with patterns is that I understand the examples over the internet but I hardly can imagine applying to my model
Trying to fit low-level design patterns to a high-level concept like you have described simply won't work. In order to even start writing low-level software, you have to have these high-level concerns ironed out:
your entire domain model (not code)
your required business scenarios
your IT topology to support your app
which pieces of software you need to write
how each piece of software interacts with other pieces
Once that is well established, you can start working on things like your high-level architecture for your individual application, the corresponding classes that will be required to implement your business requirements and interactions, and the collaborations those classes will have with each other.
Low-level design patterns really apply to this final piece - collaborations between individual classes, or families of classes.
Of course, you can always try the bottom-up approach and start writing code before your design is solidified. But you're only going to be able to apply patterns once you already know which classes you'll be using, and how they need to interact.
In other words, I'd have to look at your code to tell you which low-level design patterns you should be using.
The details of your description show that you are already using higher-level patterns:
Asp.net mvc 2
Entity Framework
linq2Sql
automapper
viewmodels
Each of these components has a host of patterns naturally built into them. ORM, iterators and MVC are all design patterns, for example.
is it a good practice to write the linq2sql sentences within the models classes
If you only take your examples from common practice, then you probably would avoid it. People seem to like plain-old-objects in multi-tiered applications for some reason.
However, some experts consider this extremely common practice of having code-less domain (model) objects to be an Anti-Pattern: See http://en.wikipedia.org/wiki/Anemic_Domain_Model and http://www.martinfowler.com/bliki/AnemicDomainModel.html
can we create our own platform/objects and interact it with CSLA.NET, is this possible or not? Can somebody out there who has more experience in CSLA.NET can help or advice. Thank you
The real question here is: Your platform/objects will need CSLA?
First you need know what is csla and how you can use it?
CSLA is a framework to develop business objects, the framework provide a easy way to implement your business and validation rules, providing authorization checker in the object life cycle.
Csla implements a proxy (dataportal) to use your objects from web and windows application without any change. The csla objects can be easily bind to controls full functionality of error check. The nice work done in csla let you split your application follow a MDA and let for example the data access work to linq to sql.
So you must search in the functionality that you expect have your plataform/objects, if your object not will work with the business logic (very rare but posible), you could let that work to csla, if your object will do it doest not have any sense duplicate the functionality.
For more information about csla you can go to the owner web site at: http://www.lhotka.net/cslanet/Info.aspx.
Background
We have our own Business Object Architecture, a much lighter (...and loosely based on, but does'nt actually use...) version of the "CSLA" business object framework with similar usage, validation, inclusive DAL etc. All code is generated (stored procs and Business Objects are creaed using CodeSmith)
The Business Objects are quite rich with regards features to Get Objects, Lists with filter sort parameters to return Objects and Generic Lists.
This architecture may not subscribe to one particular or popular architecture and purism, but its works well for us and has reduced a lot of manual coding.
The one thing we find a lot, especially when integrating with other systems (3rd party, Flash or Silverlight etc) is the requirement for contextualised "Basic Objects" or Data Containers that can be easily serialized and supplied across webservices etc for a specific purpose.
Looking around SO and the web, the Term DTO comes up a lot. We have created these Basic objects within a Dto namespace, these objects are basic objects that represent basic or specific versions of Business Objects but have no features except Constructors that accept either a DataRow or Business Object to populate the "Dto" object.
Questions:
1) Is calling this a "DTO" object correct?
2) Rather than having constructors to provide the data and set the object properties, should this population code be in a different class, some kind of "Helper Class"
Any comments on terminology and naming conventions for what I am trying to do?
Thanks
1) Yes.
2) I see no big problem, allthough you kind of limit the use of the DTO. But again I see no big problem with it. There is a mapping framework you could use to do this for you which you can find here http://www.lostechies.com/blogs/jimmy%5Fbogard/archive/2009/01/22/automapper-the-object-object-mapper.aspx