Click here to Skip to main content
15,916,293 members
Home / Discussions / C#
   

C#

 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv12-May-13 10:21
N8tiv12-May-13 10:21 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv12-May-13 10:23
N8tiv12-May-13 10:23 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
dusty_dex12-May-13 10:32
dusty_dex12-May-13 10:32 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv12-May-13 11:08
N8tiv12-May-13 11:08 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv12-May-13 10:40
N8tiv12-May-13 10:40 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
Richard MacCutchan12-May-13 21:09
mveRichard MacCutchan12-May-13 21:09 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv12-May-13 21:40
N8tiv12-May-13 21:40 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
Richard MacCutchan12-May-13 23:16
mveRichard MacCutchan12-May-13 23:16 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
N8tiv13-May-13 2:21
N8tiv13-May-13 2:21 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
Keith Barrow12-May-13 23:38
professionalKeith Barrow12-May-13 23:38 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
Richard MacCutchan12-May-13 23:56
mveRichard MacCutchan12-May-13 23:56 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
Pete O'Hanlon13-May-13 0:36
mvePete O'Hanlon13-May-13 0:36 
GeneralRe: Methods, Parameters, Arguments… Oh my! Pin
Richard MacCutchan13-May-13 0:38
mveRichard MacCutchan13-May-13 0:38 
QuestionJust a simple question Pin
Jesús Frías12-May-13 6:13
Jesús Frías12-May-13 6:13 
AnswerRe: Just a simple question Pin
Abhinav S12-May-13 6:19
Abhinav S12-May-13 6:19 
QuestionRE: Custom Login to a secure Page on an external site. Pin
khali7811-May-13 19:29
khali7811-May-13 19:29 
AnswerRe: RE: Custom Login to a secure Page on an external site. Pin
Richard MacCutchan11-May-13 21:26
mveRichard MacCutchan11-May-13 21:26 
Questionsockets + Cryptography Pin
Member 997361610-May-13 14:07
Member 997361610-May-13 14:07 
SuggestionRe: sockets + Cryptography Pin
AlphaDeltaTheta10-May-13 15:35
AlphaDeltaTheta10-May-13 15:35 
GeneralRe: sockets + Cryptography Pin
Member 997361610-May-13 22:50
Member 997361610-May-13 22:50 
GeneralRe: sockets + Cryptography Pin
AlphaDeltaTheta11-May-13 16:38
AlphaDeltaTheta11-May-13 16:38 
Questionwhats the best practice to save service data? Pin
neodeaths10-May-13 9:18
neodeaths10-May-13 9:18 
AnswerRe: whats the best practice to save service data? Pin
Dave Kreskowiak10-May-13 10:49
mveDave Kreskowiak10-May-13 10:49 
AnswerRe: whats the best practice to save service data? Pin
Eddy Vluggen11-May-13 3:30
professionalEddy Vluggen11-May-13 3:30 
QuestionProperties vs Methods Opinions sought Pin
Keith Barrow10-May-13 4:22
professionalKeith Barrow10-May-13 4:22 
Hi
I've had a suggestion on a very basic bit'o'code and I want people's thoughts on it. The example is a voucher that has been redeemed. We produce a batch code for the voucher e.g. "ABC" and a code, e.e. "1234". The user sees the full remption code "ABC1234".

My code:

C#
public void Foo
{
   public int? Code { get; set; }
   public string BatchCode { get; set; }
   public string RedemptionCode
   {
       get
       {
            if(Code.HasValue)
               return BatchCode + RedemptionCode; 
            return "";
       }
   }
}



Code review suggestion:

C#
public void Foo
{
   public int? Code { get; private set; }
   public string BatchCode { get; private set; }

   public void SetClaimedCode(string batch, int? code) 
   {
     if(code.HasValue)
        throw new AgumentException("...");
     Code = code;
     BatchCode = batch 
   }

   public void GetClaimedCode() 
   {
      return BatchCode + RedemptionCode; 
   }

}


My thinking is Claimed Code is a noun --> poperty. The reviewer thinks that there shouldn't be any processing in a property, as it is doing something it is a method.

Aside from the concat (which you may or may not agree with) and the visibility changes, and, to a certain extent the exception throw what do people think about the property vs method?
“Education is not the piling on of learning, information, data, facts, skills, or abilities - that's training or instruction - but is rather making visible what is hidden as a seed”
“One of the greatest problems of our time is that many are schooled but few are educated”


Sir Thomas More (1478 – 1535)

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.