Click here to Skip to main content
15,905,875 members
Home / Discussions / C#
   

C#

 
GeneralRe: Community Project Pin
OriginalGriff5-Dec-14 8:12
mveOriginalGriff5-Dec-14 8:12 
QuestionProblems adding an .NET 3.5 dll to a .NET 2.0 application Pin
Stephen Holdorf5-Dec-14 7:20
Stephen Holdorf5-Dec-14 7:20 
AnswerRe: Problems adding an .NET 3.5 dll to a .NET 2.0 application Pin
OriginalGriff5-Dec-14 8:09
mveOriginalGriff5-Dec-14 8:09 
GeneralRe: Problems adding an .NET 3.5 dll to a .NET 2.0 application Pin
Stephen Holdorf5-Dec-14 9:13
Stephen Holdorf5-Dec-14 9:13 
GeneralRe: Problems adding an .NET 3.5 dll to a .NET 2.0 application Pin
OriginalGriff5-Dec-14 21:39
mveOriginalGriff5-Dec-14 21:39 
QuestionWindows Service Interface Pin
milo-xml5-Dec-14 3:45
professionalmilo-xml5-Dec-14 3:45 
GeneralRe: Windows Service Interface Pin
PIEBALDconsult5-Dec-14 3:54
mvePIEBALDconsult5-Dec-14 3:54 
GeneralRe: Windows Service Interface Pin
milo-xml8-Dec-14 2:12
professionalmilo-xml8-Dec-14 2:12 
Questiongeneral query related to C# Pin
Member 112872604-Dec-14 13:33
Member 112872604-Dec-14 13:33 
AnswerRe: general query related to C# Pin
syed shanu4-Dec-14 14:14
professionalsyed shanu4-Dec-14 14:14 
GeneralRe: general query related to C# Pin
Member 112872604-Dec-14 14:29
Member 112872604-Dec-14 14:29 
GeneralRe: general query related to C# Pin
syed shanu4-Dec-14 14:45
professionalsyed shanu4-Dec-14 14:45 
AnswerRe: general query related to C# Pin
BillWoodruff4-Dec-14 18:46
professionalBillWoodruff4-Dec-14 18:46 
AnswerRe: general query related to C# Pin
V.4-Dec-14 20:03
professionalV.4-Dec-14 20:03 
GeneralRe: general query related to C# Pin
den2k885-Dec-14 0:35
professionalden2k885-Dec-14 0:35 
GeneralRe: general query related to C# Pin
Member 112872605-Dec-14 2:44
Member 112872605-Dec-14 2:44 
GeneralRe: general query related to C# Pin
V.5-Dec-14 2:46
professionalV.5-Dec-14 2:46 
GeneralRe: general query related to C# Pin
Member 112872605-Dec-14 3:02
Member 112872605-Dec-14 3:02 
GeneralRe: general query related to C# Pin
Member 112872605-Dec-14 3:39
Member 112872605-Dec-14 3:39 
GeneralRe: general query related to C# Pin
V.5-Dec-14 4:36
professionalV.5-Dec-14 4:36 
QuestionQuestions about refactoring switch statement to Strategy Pattern in C# Pin
Member 97402194-Dec-14 11:48
Member 97402194-Dec-14 11:48 
AnswerRe: Questions about refactoring switch statement to Strategy Pattern in C# Pin
SledgeHammer014-Dec-14 12:24
SledgeHammer014-Dec-14 12:24 
1) you don't new up the strategies on start, you new them up when they are requested

2) its not really necessary to cache the strategy objects unless they are expensive to create (new'ing up a class with an empty constructor is very cheap)

3) at the bottom of a strategy pattern is a switch

4) you are doing too much in the switch, all the switch should do is return the instance and the switch should be "internal". I.e., you'd have a static strategy factory class that has a static GetStrategy(someEnum) and returns the ICalculationMethod object. So your caller just needs to do StrategyFactory.GetStrategy(someEnum); The GetStrategy() method is going to have the switch.

5) your suggested use case is a trivial case and probably strategy is overkill for simple calculations... a more realstic scenario might be FedEx vs UPS shipping for example. Your strategy class will have methods for calculating the shipping, tracking, interacting with FedEx or UPS web service, etc. So it'll be much more then just a single method.

If your strategies are all 5 to 10 lines, I'd say strategy is overkill.
GeneralRe: Questions about refactoring switch statement to Strategy Pattern in C# Pin
BillWoodruff4-Dec-14 18:36
professionalBillWoodruff4-Dec-14 18:36 
GeneralRe: Questions about refactoring switch statement to Strategy Pattern in C# Pin
Matt T Heffron5-Dec-14 6:51
professionalMatt T Heffron5-Dec-14 6:51 
Questionpostback issue with dynamically created datetimepicker Pin
Dhyanga4-Dec-14 4:58
Dhyanga4-Dec-14 4:58 

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.