Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to write re-usable code 1

Status
Not open for further replies.

fergmj

Programmer
Feb 21, 2001
276
US
This business I work for has provided me with business rules around a new commission structure for employees where I work.

I need to implement these rules into an existing application my fellow developers have written. This application is going to get a complete re-write next year so I would love to write something that I can port over into the new application next year.

The application today is in VS 2003 (C#) with a 1.1 framework and the new application will be in C# 2008 with a 3.5 framework.

Do I create a commission class? If so, what are some of this things I should be thinking about and planning for as I go into a design meeting next week?

Thanks
 
The fast answer is yes, you'll create a commission class. However, it's a lot more difficult to answer than that. Without knowing a lot more about what's needed and what's wanted, you can't really say what's going to be needed. As far as what you need to go in to the design meeting, you already have it. The business rules! As you go over the rules, you should start to see logical CLASSifications within them.

Without reviewing the entire set of business rules, the quick answer for almost ever question will be "Sure, you can do that". The trick is that the business rules will provide the insight to say "Sure, you can do that...but it would work BETTER if you do this"

im in ur stakz, overflowin ur heapz!
 
Given the statement is reusable code.....

You should be thinking about creating an abstract class or interface for commissions. You can then create specific concrete classes to deal with the specific implementation(s).

C
 
To clarify my statement.....

The use of an abstract class or interface does not necessarily make the Commission classes reusable. What it does is make the user of the Commission classes reusable as it is now no longer tied to an concrete class but to an abstract idea. By doing this, you can substitute in future concrete Commission classes for the soon to be developed one.

C
 
Agree first on what everyone means by reusable. It is one of those terms that gets thrown around and is almost as meaningless as structured programming and paradigm. It helps if everyone has a common understanding of the terminology. Everyone's background is different so the understanding will be different.

To me, reuse means write once, use many times in many projects without modification.

To some people, it means a template (interface) that you can use on several projects but not necessarily the same code. Sounds more like a plugin/factory idea but there again, agree on your terminology - in some circles, this is classified as reuse.

Problem with reuse (the way I've defined it) is that by the time it gets to project #4, someone will say "it is looking a bit long in the tooth" and they scrap everything and re-invent the wheel.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top