Click here to Skip to main content
15,909,611 members
Home / Discussions / Design and Architecture
   

Design and Architecture

 
GeneralRe: How to use Design Pattern ??? Pin
led mike10-Apr-07 5:53
led mike10-Apr-07 5:53 
GeneralRe: How to use Design Pattern ??? Pin
Pete O'Hanlon10-Apr-07 23:04
mvePete O'Hanlon10-Apr-07 23:04 
AnswerRe: How to use Design Pattern ??? Pin
richardwest16-Apr-07 9:52
richardwest16-Apr-07 9:52 
QuestionSoftware Quality Metrics Pin
Mazdak8-Apr-07 20:20
Mazdak8-Apr-07 20:20 
AnswerRe: Software Quality Metrics Pin
Paul Conrad4-Nov-07 7:12
professionalPaul Conrad4-Nov-07 7:12 
QuestionWho can tell me the difference between Composite Pattern and Iterator Pattern? Pin
xibeifeijian6-Apr-07 22:29
xibeifeijian6-Apr-07 22:29 
AnswerRe: Who can tell me the difference between Composite Pattern and Iterator Pattern? Pin
Ray Kinsella8-Apr-07 5:37
Ray Kinsella8-Apr-07 5:37 
QuestionGot that bad feeling .... Pin
Ray Kinsella5-Apr-07 13:47
Ray Kinsella5-Apr-07 13:47 
Hey all,

I was reviewing some C# code today that really made me wince. Although I didn't like it, I struggled to think of a better solution, so I thought I would throw it open here and learn something.

class ABC
{
	int doSomething(int a, String b, bool c)
	{
		return doSomething(a,b,c,-1);
	}
	int doSomething(int a, String b, bool c, int d)
	{
		return doSomething(a,b,c,-1,-1);
	}
	int doSomething(int a, String b, bool c, int d, int e)
	{
		//do whatever
	}
}


Now examining the code in the last doSomething, I could make plenty of comments, it was appalling, but I kept getting drawn back to the nasty overloaded doSomething. In C++ I would have used defaults instead and had one method instead of three but this wasn't possible in C#.

Under the current circumstances the third doSomething function has ended up with lots of ugly tests like if(d=-1) doDefault() etc, that execute logic that look like it belongs in the parent doSomething. I feel the functionality of the doSomething would better delegated out of the class altogether, into another class that is perhaps instanced each time, setup for each different circumstance and then executed ... the Command pattern.

Any better ideas ?

Regards

Ray

"Je Suis Mort De Rire"
Blogging @ Keratoconus Watch


AnswerRe: Got that bad feeling .... Pin
Colin Angus Mackay7-Apr-07 0:45
Colin Angus Mackay7-Apr-07 0:45 
GeneralRe: Got that bad feeling .... Pin
Ray Kinsella8-Apr-07 5:38
Ray Kinsella8-Apr-07 5:38 
GeneralRe: Got that bad feeling .... Pin
DavidNohejl10-Apr-07 0:28
DavidNohejl10-Apr-07 0:28 
GeneralRe: Got that bad feeling .... Pin
Pete O'Hanlon10-Apr-07 1:09
mvePete O'Hanlon10-Apr-07 1:09 
GeneralRe: Got that bad feeling .... Pin
DavidNohejl10-Apr-07 1:41
DavidNohejl10-Apr-07 1:41 
GeneralRe: Got that bad feeling .... Pin
Colin Angus Mackay10-Apr-07 2:29
Colin Angus Mackay10-Apr-07 2:29 
AnswerRe: Got that bad feeling .... Pin
DavidNohejl10-Apr-07 0:26
DavidNohejl10-Apr-07 0:26 
QuestionDocument templates for software development? Pin
wojti5-Apr-07 3:18
wojti5-Apr-07 3:18 
AnswerRe: Document templates for software development? Pin
Paul Conrad4-Nov-07 7:13
professionalPaul Conrad4-Nov-07 7:13 
QuestionMVC question Pin
akkram5-Apr-07 2:23
akkram5-Apr-07 2:23 
AnswerRe: MVC question Pin
Pete O'Hanlon5-Apr-07 3:39
mvePete O'Hanlon5-Apr-07 3:39 
AnswerRe: MVC question Pin
Code_Doctor16-Apr-07 17:17
Code_Doctor16-Apr-07 17:17 
QuestionMembership Provider and Permissions Pin
Tristan Rhodes4-Apr-07 1:27
Tristan Rhodes4-Apr-07 1:27 
AnswerRe: Membership Provider and Permissions Pin
Pete O'Hanlon4-Apr-07 1:59
mvePete O'Hanlon4-Apr-07 1:59 
GeneralRe: Membership Provider and Permissions Pin
Tristan Rhodes4-Apr-07 2:10
Tristan Rhodes4-Apr-07 2:10 
GeneralRe: Membership Provider and Permissions Pin
Pete O'Hanlon4-Apr-07 2:17
mvePete O'Hanlon4-Apr-07 2:17 
QuestionDeisgn issues with Digital signature solution Pin
abcxyz823-Apr-07 2:14
abcxyz823-Apr-07 2:14 

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.