|
The only book to really recommand is THE book on DDD. Its called "Domain Driven Design: Tackling Complexity in the Heart of Software", by Eric Evans. Its an awesome book, first on my list of recomendations for aspiring architects and curious programmers.
http://www.amazon.com/Domain-Driven-Design-Tackling-Complexity-Software/dp/0321125215
The concept is really not that hard...the general idea is that software is intended to directly model business processes and meet business needs. Evans introduces the concept of using a conceptual model of the business and its entities as the central piece of a software project, and which is in turn used to create the 'domain'. The domain is a direct implementation of the concepts in the model, and contains some other facilities such as factories and repositories to support technical needs. A lot of the individual concepts and patterns are familiar...its the whole thing together that really makes a true difference. Some of the key things Evans advocates are full isolation of the domain from persistance logic, which gives it fludity making it more adaptable to the constant requirements changes that occurr on a daily basis (something most programmers have come to hate). The intriguing thing about DDD is that it takes that factor of constantly changing requirements and just factors it into the design and development process in a way that actually works...in (significant) part because of the strict separation of concerns between domain and persistance logic.
|
|
|
|
|
Great I will check the book out.
One question though: Rockford Lhotka's approach also separates the domain from the persistence logic, no? Do you mean tracking states of the object Dirty, Deleted, New and Save(), Delete() should not be within the domain and be placed in persistence logic?
|
|
|
|
|
Yes, I mean all of the persistance related stuff, his undo/redo stuff, etc. on his objects, which includes Dirty, Deleted, New, Save(), Delete(). Those are what we call "persistance concerns"...they represent a certain set of functionality and state that has nothing to do with the business, and everything to do with managing updates of data in a database. That blends the concerns of your business classes, which violates the principals of Single Responsibility (SR) and Separation of Concerns (SoC). These two principals are critical to creating maintainable software...software that has cohesive, properly-coupled components without reducing the isolation of specific kinds of functionality.
CSLA creates an object model that is really convenient to use as a developer...having implemented it myself once, I liked the ability to save a business object just by calling .Save(). But I learned some really hard lessons on that project, especially the lesson about SR and SoC. Despite having used CodeSmith heavily on that project, the maintainability of such a coupled and blended architecture is atrocious. Even if you just have a .Save() method on a business entity that calls out to DAL classes that actually implement the operation...that business entity (and quite probably a specialized entity-specific collection class) are still tightly coupled to the DAL, and when the DAL changes, so do all the objects that rely on it. The problem is only compounded by cross-sampling behavior between related entities...such as having Customer also save its Orders when you call its .Save() method...take that a few degrees farther and you can probably see the nitemare for yourself.
By following DDD patterns and principals, you keep the vast bulk of your classes loosly coupled, and aggregate the bulk of "orchestration" logic...logic that blends all those various concerns together to implement a process...into services. Such an architecture is much easier to change, as there is one, and only one, location to go to in response to changes in your DAL, entities, or support types (i.e. factories).
Single Responsibility[^]
Separation of Concerns[^]
|
|
|
|
|
Found this[^] - you have to register (painless and free) but then you can download it.
Might be worth a look?
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Thanks but I already went and got the book. Lets see what it provides and hopefully will be what Jon stated.
|
|
|
|
|
Hi there, I may as well chuck something in here, as I love design...
It's difficult to decide what to go with sometimes. I mean, there are so many methodologies and one developer will claim this way is better, another will claim that way, etc. etc.
It sounds to me like you have a relatively uncomplicated problem with not a huge amount of workflow and service requirements (please correct me if I'm wrong). It sounds like you might be implementing a reasonably straight-foreword windows app or web site. WINDOWS or WEB - two completely different technologies here!! Stateful and stateless. Nobody can truely answer you query without understanding more about your problem. However, I've implemented Active Record when business logic isn't too complex (you won't require the dreaded ORM's you speak of) and it has been very successful for me. I have also mixed some Active Record patterns with unrelational Domain Patterns as business complexity has increased - this has also worked.
I read the other answers
Don't confuse DTO's with Business Objects. DTO's just hold data(fields) and don't implement behavior, but Business objects do implement behavior and usually have a method to persist itself, by implementing a Save method, and calling through to a data layer/tier.
Developers like to give advise but do your own research and when you've decided your route - implement it properly, that's my advise. I'm going on a bit aren't I I've recently created a couple of blogs and I've already written an article about the Active Record Pattern[^] (I've turned it in to a Domain Record Pattern) and I'm going to be writing a lot more about design. It's interesting to see what kind of questions people are asking. I hope you get chance to look at my blog - and please comment!!!
Here's a recommended read for you. Microsoft .NET: Architecting Applications for the Enterprise[^] and it's not too heavy either.
The article I've posted on dotnet-notepad are just notes (the blog is literally a notepad of ideas). My in-depth articles are going on csCoffee[^]
Pen and Paper before Visual Studio. Hope I've been helpful.
|
|
|
|
|
I a noob, just to get that clear. Here is what i wanna accomplish.
I retrieve a user id via a connection string, i want to used that id to call a stored procedure that then bring back the user's fname, last, add etc in my labels, do any of you have any example or guide on how to do this, guys i really need help and thanks in advance.
Ferron
|
|
|
|
|
So you have "in your hand" a user ID and you want to be able to send it down to a stored proc to lazy-load[i.e. "load on demand"] the user's data?
There are several things that could be done, but the solution to this problem can be very rudimentary or quite complex. It is important to know what the kernel of your code-base looks like in order to cater a solution to your specific app.
What have you tried so far? What isn't working?
"I need build Skynet. Plz send code"
|
|
|
|
|
well i know how to create the query string. Just need to know how to create the stored procedure and place the data in the necessary labels
Ferron
|
|
|
|
|
do you know where i could get a good guide or can you point me to a online tutorial that can do this, thanks guys
Ferron
|
|
|
|
|
Here is one way, but there are many:
public class User
{
private string _firstName;
private string _lastName;
private string _id; // or int not sure what type yours is
public void Load(string id)
{
UserManager manager = new UserManager();
manager.Retrieve(this);
}
// properties and other methods
}
public class UserManager()
{
public void Retrieve(User userToRetrieve)
{
SqlCommand cmd = new SqlCommand();
cmd.Text = "SELECT FirstName, LastName FROM UserTable WHERE UserID = '" + id + "'";
// Here use an adapter and fill a DataTable
// If the DataTable has rows then assing the proper columns to the userToRetrieve object
// If no rows then throw an exception to advise no User was found with the given id.
}
}
You UI code can be something like this:
User aUser = new User();
string id = "123";
try
{
aUser.Load(id);
this.LabelID.Text = aUser.ID;
this.LabelFirstName.Text = aUser.FirstName;
this.LabelLastName.Text = aUser.LastName;
}
catch(SomeException ex)
{
MessageBox.Show(ex.Message);
}
If you still can not do it then buy a book on C#. Please note this code might have errors but it is just to give you an idea.
|
|
|
|
|
Hi Guys; Anyone have an idea how to retrieve the string value of an object's property?
For instance, assume an object instance of type "Inspection" named _inspection, which has a property called "Region" of an unassuming type.
Any idea how to get the string value "Region" from
this._inspection.Region
(more information than is necessary...I'm trying to build type-safety into the column names of a GridView)
"I need build Skynet. Plz send code"
|
|
|
|
|
Have a look at this : [^]
A dogged, arrogant belief in self and the childlike idealism that comes with not knowing my limits. This is my greatest blessing, my priceless attribute.
|
|
|
|
|
...I was actually hoping that there was a solution that didn't involve reflection. I mentioned that in my original post, but edited it out to keep the suggestions open.
I mean, you can get the string representation of an enum with the following:
[Enum].GetName(typeof([LIB].Enumerations.InspectionStatusType), Me._inspection.Status)
(and that is in the mscorlib.)
Isn't there any way to retrieve the string evaluation of an object's property without reflection yet?
"I need build Skynet. Plz send code"
|
|
|
|
|
Enum.GetName uses reflection internally. Reflection IS the retrieval of code metadata...which includes the name of a property. Thats the entire purpose of reflection...
|
|
|
|
|
Jon Rista wrote: Enum.GetName uses reflection internally
ah, good to know. Thanks
"I need build Skynet. Plz send code"
|
|
|
|
|
i will tell the requirement in detail.
i have spooled some record in one datatable, in score.cs class.
i have to print that report in other windows form name report.cs(which is a windows form where i kept my crystal report viewer)
now i want to access my datatable in the score.cs.
for this i have to inherit those things.
like public partial class report:score,
instead of public partial class report:form,
but if i do so i m getting error that my form is not showing,as form is a class we cannot remove that.
can you please guide me how to access my datatable??
|
|
|
|
|
Well this site is an excellent database in itself of some very useful articles pertaining to connecting to databases programmatically, give CodeProject a search or two
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
Hello Fellow Coders;
I'm still struggling with some of the concepts of the treeview in C#. I found this code whick works great. I am trying to figure out how to assign values to the nodes that get added such as the name, text,tag, imageindex, tooltip etc.
This sample is using the TreeNodeCollection can I assign the above properties using this collection??
Here is the code....
TreeNode AddNode(TreeNodeCollection Parent, string text)
{
foreach (TreeNode node in Parent)
{
if (node.Text == text)
return node;
}
return Parent.Add(text);
}
void InsertNodes(TreeNodeCollection treeviewNodes, List<string> _nodes)
{
if (_nodes.Count == 0)
return; //Recursive exit
TreeNode TempNode = AddNode(treeviewNodes, _nodes[0]);
_nodes.RemoveAt(0);
InsertNodes(TempNode.Nodes, _nodes); //Recursive calling
}
private void button1_Click(object sender, EventArgs e)
{
List<string> NODES = new List<string>(); //Save nodes
string[] strArr = textBox1.Text.Split('\\');
foreach (string str in strArr)
NODES.Add(str);
InsertNodes(treeView1.Nodes, NODES);
}
Thanks In Advance
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Please use pre tags for code blocks. It makes the reading easier.
The first method return the node added so you can use it's properties on the calling side:
...
TreeNode addedNode = AddNode(MyTreeView.Nodes, "New node text");
addedNode.Tag = "XYZ";
addedNode.ImageIndex = 123;
...
Or if you want, add a variable inside the method and assign the properties you want in the method:
TreeNode AddNode(TreeNodeCollection Parent, string text)
{
TreeNode temporaryNode;
foreach (TreeNode node in Parent)
{
if (node.Text == text)
return node;
}
temporaryNode = Parent.Add(text);
temporaryNode.Tag = "XYZ";
temporaryNode.ImageIndex = 123;
...
return temporaryNode;
}
The same idea goes with the other method.
In all cases you may have to add parameters to the methods or extra logic how you decide what tag, imageindex etc is set.
This is quite basics, so I think you should get a good book concerning C# programming.
|
|
|
|
|
Thanks for this answer...I will try it out.
I have read
Visual C#.Net by Williams MS Press
And currently reading
Programming Visual C# 2008 by Marshall MS Press
Can you recommend a book??
Thanks
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
|
Thanks;
I had tried your suggestion before asking the questions but in looking at your reply realized that I was doing it in the wrong place.
Here is what worked..
TreeNode AddNode(TreeNodeCollection Parent, string text)
{
TreeNode temporaryNode;
foreach (TreeNode node in Parent)
{
if (node.Text == text)
{
return node;
}
}
temporaryNode = Parent.Add(text);
temporaryNode.Name = text;
temporaryNode.Text = text;
temporaryNode.Tag = "XYZ";
temporaryNode.ToolTipText = "XYZ";
temporaryNode.ImageIndex = 123;
temporaryNode.SelectedImageIndex = 123;
return temporaryNode;
//
return Parent.Add(text);
}
Thanks Again
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|
|
Glad if it helped
|
|
|
|
|
As a followup for anyone reading this. This part of the above code has unexpected results.....
temporaryNode = Parent.Add(text);
temporaryNode.Name = text;
temporaryNode.Text = text;
temporaryNode.Tag = "XYZ";
temporaryNode.ToolTipText = "XYZ";
temporaryNode.ImageIndex = 123;
temporaryNode.SelectedImageIndex = 123;
return temporaryNode;
But on the whole if you are looking for a recursive way to add tree nodes the orginally posted code works great. It's just not full featured.
Rafone
Statistics are like bikini's...
What they reveal is astonishing ...
But what they hide is vital ...
|
|
|
|