Click here to Skip to main content
15,907,687 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: Database Queries Pin
Wendelius8-Jan-09 5:25
mentorWendelius8-Jan-09 5:25 
GeneralRe: Database Queries Pin
Jon Rista8-Jan-09 10:56
Jon Rista8-Jan-09 10:56 
GeneralRe: Database Queries Pin
Mark Churchill7-Jan-09 13:53
Mark Churchill7-Jan-09 13:53 
QuestionSoftware development Pin
systemexpertise1-Jan-09 18:26
systemexpertise1-Jan-09 18:26 
AnswerRe: Software development Pin
Cosmic Egg10-Jan-09 3:29
Cosmic Egg10-Jan-09 3:29 
QuestionStylesheet in VS2008 Pin
sarang_k30-Dec-08 19:01
sarang_k30-Dec-08 19:01 
AnswerRe: Stylesheet in VS2008 Pin
CodingYoshi4-Jan-09 15:45
CodingYoshi4-Jan-09 15:45 
QuestionException Hierarchy Pin
CodingYoshi29-Dec-08 11:27
CodingYoshi29-Dec-08 11:27 
Lets say I have a class called Person (Encapsulates the business layer functionality) and PersonManager (Encapsulates Data Access Layer). Here are code snippets simplified for clarity:

public class Person
{
public void Save()
{
Personmanager manager = new PersonManager();
manager.Save(this);
}
}

public class PersonManager
{
public void Save(Person p)
{
if (p.IsNew)
Insert(p) // Private method
else
{
if (P.IsOld)
Update(p) // Private Method
}
}
}

During insertion problems can occur so Insert method should deal with it and if it can not then it should throw it to the caller. Ideally, Insert should not reveal its inner working to the caller and should not break encapsulation but let the caller know something exceptional happened. The PersonManager class will also try to deal with it, and if it can not, throw it to the caller (Person) without breaking encapsulation. The Person class will follow the same rule.

My questions are:

1. Why do we append InnerExceptions as they will break encapsulation? For example, if an SqlException occurs and I attach it as inner exception, now the caller knows I am dealing with SQL database and encapsulation is broken! If I do not attach it then caller will not have sufficient enough information.

2. GUI will have a try-cach which calls person.Save() and Person will have a try-catch which calls PersonManager.Save(Person p) and Insert() and Update will also need try-catch blocks. Am I right? Is this nesting too far or is this how things should be done ideally?

3. Every class, and the method within it should try to deal with the exception and try an alternative or retry again. Is there a general rule of thumb how many times it should try and give up? Does it depend on how critical the system is?

Am I the only one who is lost because I have read many sources to obtain these answers? Please provide any useful links or book names.
GeneralRe: Exception Hierarchy Pin
Luc Pattyn29-Dec-08 15:12
sitebuilderLuc Pattyn29-Dec-08 15:12 
GeneralRe: Exception Hierarchy Pin
CodingYoshi30-Dec-08 3:18
CodingYoshi30-Dec-08 3:18 
AnswerRe: Exception Hierarchy Pin
Jon Rista6-Jan-09 8:48
Jon Rista6-Jan-09 8:48 
GeneralRe: Exception Hierarchy Pin
Leftyfarrell6-Jan-09 13:29
Leftyfarrell6-Jan-09 13:29 
GeneralRe: Exception Hierarchy Pin
Jon Rista6-Jan-09 17:31
Jon Rista6-Jan-09 17:31 
GeneralRe: Exception Hierarchy Pin
Curtis Schlak.25-Feb-09 9:02
Curtis Schlak.25-Feb-09 9:02 
AnswerRe: Exception Hierarchy Pin
Curtis Schlak.25-Feb-09 9:20
Curtis Schlak.25-Feb-09 9:20 
QuestionWho can show me the process and method of Scrum? Pin
Tal Rasha's Guardianship18-Dec-08 21:32
Tal Rasha's Guardianship18-Dec-08 21:32 
AnswerRe: Who can show me the process and method of Scrum? Pin
Ashfield18-Dec-08 22:01
Ashfield18-Dec-08 22:01 
GeneralRe: Who can show me the process and method of Scrum? Pin
Tal Rasha's Guardianship22-Dec-08 17:17
Tal Rasha's Guardianship22-Dec-08 17:17 
GeneralRe: Who can show me the process and method of Scrum? Pin
Ashfield26-Dec-08 22:40
Ashfield26-Dec-08 22:40 
QuestionArchitecture that supports Unit Testing - Is there such a thing as Too Many Interfaces? Pin
Leftyfarrell18-Dec-08 4:42
Leftyfarrell18-Dec-08 4:42 
AnswerRe: Architecture that supports Unit Testing - Is there such a thing as Too Many Interfaces? Pin
led mike19-Dec-08 7:40
led mike19-Dec-08 7:40 
QuestionRe: Architecture that supports Unit Testing - Is there such a thing as Too Many Interfaces? Pin
Leftyfarrell19-Dec-08 8:08
Leftyfarrell19-Dec-08 8:08 
AnswerRe: Architecture that supports Unit Testing - Is there such a thing as Too Many Interfaces? Pin
Giorgi Dalakishvili19-Dec-08 8:19
mentorGiorgi Dalakishvili19-Dec-08 8:19 
AnswerRe: Architecture that supports Unit Testing - Is there such a thing as Too Many Interfaces? Pin
Mark Churchill22-Dec-08 18:42
Mark Churchill22-Dec-08 18:42 
AnswerRe: Architecture that supports Unit Testing - Is there such a thing as Too Many Interfaces? Pin
CodingYoshi25-Dec-08 21:03
CodingYoshi25-Dec-08 21:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.