|
Use the ID Ten-T pattern
led mike
|
|
|
|
|
led mike wrote: Use the ID Ten-T pattern
I really don't know whether to laugh or not.
|
|
|
|
|
Colin Angus Mackay wrote: I really don't know whether to laugh or not.
That remindes me of my reaction to the first 3 to 4 technical forums I visit each morning here at CP, I really don't know whether to cry or not.
led mike
|
|
|
|
|
|
When you learn something, you deeply want to see it in action, in your project and show others that you're using design patterns.
1- Please take some time to read about Gang of Four, Design Patterns Book
2- Read it very very carefully
3- When finished you will see that you can use more than one pattern in a single project!
4- When you are equipped with design patterns, take some time and read anti-patterns.
Dont give up, just read read read, this is real world, not hollywood's "hacker 9 - movie"
One more thing:
"There is no spoon"
-richard
____________________
http://www.swbox.com
|
|
|
|
|
I'm looking for a software which measure Software Quality Metrics of my projects and I'm looking for FREE one which measure C# projects. I couldn't find any FREE one for C# in asp.net. Thanks for any information.
Mazy
"One who dives deep gets the pearls,the burning desire for realization brings the goal nearer." - Babuji
|
|
|
|
|
Software Quality Metrics is pretty broad topic and finding anything free will be tough.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Who can tell me the difference between Composite Pattern and Iterator Pattern?
Thanks!
█▒▒▒▒▒██▒█▒██
█▒█████▒▒▒▒▒█
█▒██████▒█▒██
█▒█████▒▒▒▒▒█
█▒▒▒▒▒██▒█▒██
|
|
|
|
|
|
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)
{
}
}
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 ?
|
|
|
|
|
Ray Kinsella wrote: Any better ideas ?
yes, you can still chain the methods together but in the opposite direction.
In the DoSomething (by the way, that should really be Pascal Cased rather than camel Cased) with the least parameters do everything you can that only needs those parameters. Then with the DoSomething with the extra parameters call the first DoSomething and add the additional functionality that needs the extra parameter. Then for the DoSomething with the most parameters add the extra functionality that requires all parameters then call the middle DoSomething, which in turn will call the first DoSomething.
Of course, it really depends on what you are doing overall. If it is sufficiently complex it may be better to abstract some of the functionality out in to private methods and have each of the DoSomething methods call the approprate private methods. However, that may cost slighly more to maintain as you'd have to duplicate the call to the private methods in upto three places. But, if the overall code is easier to read it might be worth it.
|
|
|
|
|
Yeah!, your right, should be the other way around. It was on the tip of my tongue, it just didn't feel right before ... must be loosing my edge.
Thanks for that.
|
|
|
|
|
Interesting, what you are saying seems to be exact opposite of what I though is how to do default parameter values in C#, what am I missing?
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Colin's recommending a way that gets around having to put ugly kludges in the code, e.g. using -1 to indicate a missing value.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
To me it looks like if you can't find meaningfull default value (and that is different from "using -1 to indicate a missing value") indicates that they do different things and you should probably have two different methods rather then overloads.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Here's a coded example of what I mean:
This is the first example where the methods are chained from most parameters to least parameters. This assumes that the methods with additional parameters are doing more work.
public void DoSomething(int a, int b, int c)
{
}
public void DoSomething(int a, int b, int c, int d)
{
DoSomething(a, b, c);
}
public void DoSomething(int a, int b, int c, int d, int e)
{
DoSomething(a, b, c, d);
}
NOTE: It is sometimes the case where the version with the most parameters is actually going to do all the work, and the other overloads just provide default values into the method that does the work. Think MessageBox.Show (A lot of its overloads just provide default values for the buttons, icon and so on.) However, if the work is incrementally increased with the number of parameters then the code I showed above is likely to be better.
|
|
|
|
|
Ray Kinsella wrote: In C++ I would have used defaults instead
Well, C# does not have default parameters, but prefered way to archive same results is with overloads, just like you are doing. Make one DoSomething with paramers a, b, c, d, e that does it all, and provide overloads DoSomething(a,b,c,d) that just calls DoSomething(a,b,c,d,e) with meaningfull "default" value of e, if possible. And the same with DoSomething(a,b,c), etc... If it is not possible then I don't know what you wanted to do with C++ defaults.
"Throughout human history, we have been dependent on machines to survive. Fate, it seems, is not without a sense of irony. " - Morpheus
"Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
Hello.
I'm looking for document templates that are helpful for software development.
Especially I need two kinds of templates.
- Research about specific software technology problem
(research template)
- Software concept template
Where can I find these and other document templates for software development?
Thanks for help!
Wojtek
|
|
|
|
|
Google around. I had a link somewhere, I wish I could find it
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi, im implementing a simple MVC pattern in my C# application. Ive never used this technique before so I figure things out as I go, looking at code reading articles etc. A thought has come up though.. As I understand it u usually have one controller for each set of related functionality. In that case I will need to instansiate the same controller from different winforms passing along a reference of the view. Im not such an experienced programmer but I can see some problems with this approach. Any suggestions/thoughts how to handle this?
/thanks
|
|
|
|
|
Perhaps I'm missing something in your question, but why would you want to instantiate the controller from different forms? This negates the usefullness of the MVC pattern.
What you really want to do is instantiate your controller in one place and then *pass* that around as you need it. I usually use a Mediator class to handle this. The Mediator is responsible for instantiating the controller, and contains the reference to it. The controller is made available as a property from the Mediator.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Model View controller is a set of patterns, and has been implemented in many ways.
The main idea behind a MVC is you seperate your view (Screens) from the model (Business Objects) through a center controller. Other patterns can be used here to further abstract the connections, but to keep things simple a good way to accomplish this is to first understand that your screens should know nothing of the business objects.
A central controller class is usually constructed to support the "awareness" of the eventing on the view (screens). The controller then wires up to the business objects to do the work.
Eventing, Interfaces and sometimes other design patterns are used for this "wiring" of abstraction between the view of the model.
For instance, I've just completed a project in which that I implemented a MVC. I added an additional layer of abstraction using a Command pattern.
This pattern, when implemented on the Controller and the View, gives a very abstract way of defining actions. Within the view, I constructed CommandAdapters that adapted each of my commands to the controller. The controller also used the commands for communication back to the view.
There is alot of debate in the industry on the best ways to create n-tier applications. I've learned that if an application is going through alot of changes, and new enhancements are readily being introduced. Then it is worth the extra time architecting a sound MVC approach.
However, if the project is simple, doesn't change much, or there isn't enough funding available. Then using agile development techniques is the better bet.
Hope this helps!
~ CodeDoctor ~
|
|
|
|
|
Hi Guys,
I'd like to make a blog / forum web app as research, and i'd like to use the (Sql)MembershipProvider to manage my users, but i'd like to tie Permission information to them.
I had a few ideas, but wondered what the standard was -
1) Add a permission indicator to the Comment field
Thoughts: Cheesy as hell, not particularly scaleable or searchable.
2) Create a seperate database and create both users at the same time.
Thoughts: Seems nice on the surface, but i would be maintaining two databases, one with login credentials, and one with the user and additional data.
3) Extend the existing SQLMembershipProvider database to support permissions, and expand the "User" object to include permission level.
Thoughts: Work, maintainability, and sabotaging something that already works. Plus, i would have to integrate both the DB's above, into a single entity. Doesn't scale well with the a permissions table either.
4) Seperate databases, like option 2, only with a Permissions table.
Thoughts: Heavy work, i'd need to do some more research into permission sets, but I suspect this is probably how things are done at the moment.
Hope you guys can shed some light on this.
Regards
Tristan Rhodes
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
|
Awesome - Didn't even know it existed
Thanks.
Tris
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|