Click here to Skip to main content
15,887,027 members
Home / Discussions / C#
   

C#

 
GeneralRe: Ellipse Pin
Lamrin17-Oct-10 15:46
Lamrin17-Oct-10 15:46 
GeneralRe: Ellipse Pin
WebMaster18-Oct-10 5:16
WebMaster18-Oct-10 5:16 
GeneralRe: Ellipse Pin
WebMaster20-Oct-10 8:21
WebMaster20-Oct-10 8:21 
GeneralRe: Ellipse Pin
Lamrin23-Oct-10 6:24
Lamrin23-Oct-10 6:24 
GeneralRe: Ellipse Pin
WebMaster24-Oct-10 8:10
WebMaster24-Oct-10 8:10 
GeneralRe: Ellipse Pin
Lamrin25-Oct-10 5:15
Lamrin25-Oct-10 5:15 
GeneralRe: Ellipse Pin
WebMaster25-Oct-10 9:27
WebMaster25-Oct-10 9:27 
QuestionOOB design - class fields Pin
Dell.Simmons15-Oct-10 13:41
Dell.Simmons15-Oct-10 13:41 
I'm a hobbyist learning slowly about C# & OOD & N-Tier. I was looking at a couple of how-tos on the web today. Both had the business layer talking to the data layer like this example-
 public class BusinessLayer
    {

        public int Method1(string firstName, string lastName)
        {
            DataLayer dataLayer = new DataLayer();
            return dataLayer.DoSomething(firstName, lastName);
        }

        public int Method2(int personID, string firstName, string lastName, int age)
        {
            DataLayer dataLayer = new DataLayer();
            return dataLayer.DoSomethingElse(personID, firstName, lastName, age);
        }
}


I would have coded it like this -
 public class BusinessLayer
    {
        private DataLayer dataLayer = new DataLayer();
       
        public int Method1(string firstName, string lastName)
        {  
            return dataLayer.DoSomething(firstName, lastName);
        }

        public int Method2(int personID, string firstName, string lastName, int age)
        {
            return dataLayer.DoSomethingElse(personID, firstName, lastName, age);
        }
}

Assuming my way is wrong, why is their way correct? Is it an encapsulation principle that I don't understand correctly or something else? Thanks.
AnswerRe: OOB design - class fields Pin
ricmil4215-Oct-10 14:29
ricmil4215-Oct-10 14:29 
GeneralRe: OOB design - class fields Pin
Dell.Simmons15-Oct-10 14:34
Dell.Simmons15-Oct-10 14:34 
AnswerRe: OOB design - class fields Pin
Abhinav S15-Oct-10 22:25
Abhinav S15-Oct-10 22:25 
AnswerRe: OOB design - class fields Pin
Keith Barrow16-Oct-10 5:40
professionalKeith Barrow16-Oct-10 5:40 
AnswerRe: OOB design - class fields Pin
Nish Nishant16-Oct-10 6:27
sitebuilderNish Nishant16-Oct-10 6:27 
AnswerRe: OOB design - class fields Pin
Paul Michalik17-Oct-10 0:45
Paul Michalik17-Oct-10 0:45 
QuestionRead the 'raw' FileVersion and ProductVersion values from a file's version resource. Pin
Blake Miller15-Oct-10 13:02
Blake Miller15-Oct-10 13:02 
QuestionApplication Settings "Save Location" Pin
I Believe In GOD15-Oct-10 10:30
I Believe In GOD15-Oct-10 10:30 
AnswerRe: Application Settings "Save Location" Pin
Ian Shlasko15-Oct-10 10:34
Ian Shlasko15-Oct-10 10:34 
GeneralRe: Application Settings "Save Location" Pin
I Believe In GOD15-Oct-10 10:46
I Believe In GOD15-Oct-10 10:46 
GeneralRe: Application Settings "Save Location" Pin
AspDotNetDev15-Oct-10 12:29
protectorAspDotNetDev15-Oct-10 12:29 
QuestionHow to create a user control with parameters as tags Pin
kuul1315-Oct-10 10:17
kuul1315-Oct-10 10:17 
AnswerRe: How to create a user control with parameters as tags Pin
Not Active15-Oct-10 11:47
mentorNot Active15-Oct-10 11:47 
QuestionAsp.net Website Pin
MKC00215-Oct-10 2:59
MKC00215-Oct-10 2:59 
AnswerRe: Asp.net Website Pin
OriginalGriff15-Oct-10 3:05
mveOriginalGriff15-Oct-10 3:05 
AnswerRe: Asp.net Website [modified] Pin
Abhinav S15-Oct-10 3:22
Abhinav S15-Oct-10 3:22 
GeneralRe: Asp.net Website Pin
J4amieC15-Oct-10 4:42
J4amieC15-Oct-10 4:42 

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.